yfinance icon indicating copy to clipboard operation
yfinance copied to clipboard

[Potential bug] make symbol uppercase

Open xareelee opened this issue 1 year ago • 1 comments

EDIT: after I review my code again, I found I downloaded those tickers synchrously in a for-loop, so I alter my description.


yfinance version: 0.2.17

I got a KeyError when downloading a ticker FPLpB (note that there is a lowercase in the symbol). I got this symbol from polygon.io API, and I tried to download the history data by yfinance.

df = yf.download("FPLpB")
File {path_to_project}/yfinance/multi.py:163 in download(...)
    161 if len(tickers) == 1:
    162     ticker = tickers[0]
--> 163     return shared._DFS[shared._ISINS.get(ticker, ticker)]
    165 try:
    166     data = _pd.concat(shared._DFS.values(), axis=1, sort=True,
    167                       keys=shared._DFS.keys())

KeyError: 'FPLPB'

Obviously, shared._ISINS.get(ticker, ticker) in line 163 is FPLPB and my ticker is FPLpB.

I tried to download the ticker FPLpB alone again, and the error did not show up. I don't know why.

In multi.py#L142:

# This changes the symbol as the key.
shared._DFS[ticker.upper()] = data

I'm not sure whether the symbol should always be capitalized or just be the original one.

xareelee avatar Apr 10 '23 22:04 xareelee

I got it running the first time, but there's no data for the symbol.

yf.download("FPLpB")
[*********************100%***********************]  1 of 1 completed

1 Failed download:
- FPLPB: No timezone found, symbol may be delisted
Out[2]: 
Empty DataFrame
Columns: [Open, High, Low, Close, Adj Close, Volume]
Index: []

I'm using version 0.2.18

KevinYew97 avatar Apr 26 '23 15:04 KevinYew97

FPLpB doesn't exist on Yahoo

ValueRaider avatar Mar 16 '24 11:03 ValueRaider