(#244) Fix .info['annualReportExpenseRatio'] for ETFs
As reported in issue #244, there is a bug with querying for an ETF's
expense ratio. For mutual funds, this value is found in
.info['annualReportExpenseRatio'], but for ETFs it is not.
>>> import yfinance as yf
>>> print(yf.Ticker('VTSAX').info['annualReportExpenseRatio'])
0.0004
>>> print(yf.Ticker('VTI').info['annualReportExpenseRatio'])
None
The github user @ycc1107 commented on the issue, identifying the root
cause, which is that for some reason this value is only available inside
the 'fundProfile' key of the data dictionary, a key that is only
present when querying mutual funds and ETFs.
The 'fundProfile' key leads to a dictionary with a
'feesExpensesInvestment' key, which leads to a dictionary with an
'annualReportExpenseRatio' key, which has the value we need.
The github user @ycc1107 opened a PR to fix this issue, but I'm
concerned that it changes too much, as it recursively merges the
entirety of the 'fundProfile' dictionary into the .info dictionary.
So I'm proposing an alternative fix here that attempts to write only
.info['annualReportExpenseRatio'] and nothing else.
MR closed without any changes. Dont think it is to hard to update it as it only requires 4/5 added lines of code and constitues important info for ETFs
I'm going through old issues/PRs, and see this was closed when looks to me like should have been merged. But codebase has changed a lot since - can someone create a fresh new PR?