Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expense ratio for ETFs .info returns None #244

Closed
aditya08 opened this issue Apr 6, 2020 · 1 comment
Closed

Expense ratio for ETFs .info returns None #244

aditya08 opened this issue Apr 6, 2020 · 1 comment

Comments

@aditya08
Copy link

aditya08 commented Apr 6, 2020

'annualReportExpenseRatio' is working fine for mutual funds but not for ETFs.

Python 3.7.3 [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import yfinance as yf
>>> vti = yf.Ticker('VTI')
>>> vti.info['annualReportExpenseRatio']
>>> print(vti.info['annualReportExpenseRatio']) 
None
>>> vtsax = yf.Ticker('VTSAX')
>>> vtsax.info['annualReportExpenseRatio']
0.0004
ycc1107 added a commit to ycc1107/yfinance that referenced this issue Apr 8, 2020
read fundProfile and populate to info
@ycc1107
Copy link

ycc1107 commented Apr 8, 2020

The issue code did not go to the fundProfile to find annualReportExpenseRatio.

johnnymo87 pushed a commit to johnnymo87/yfinance that referenced this issue Jan 17, 2021
read fundProfile and populate to info
johnnymo87 added a commit to johnnymo87/yfinance that referenced this issue Jan 17, 2021
As reported in issue ranaroussi#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.

```py
>>> 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.
johnnymo87 added a commit to johnnymo87/yfinance that referenced this issue Feb 5, 2021
As reported in issue ranaroussi#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.

```py
>>> 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.
johnnymo87 added a commit to johnnymo87/yfinance that referenced this issue Mar 14, 2021
As reported in issue ranaroussi#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.

```py
>>> 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants