I tried to pull data on a stock symbol using the Yahoo finance python module. I checked the other questions that are on a similar topic and most of them say to try to run the program during market hours, but that does not help.
This is my code:
import yfinance as yf
yf.download('QQQ', '2020-01-01', dt.datetime.now().strftime('%Y-%m-%d'))
This is the error:
No data found for this date range, symbol may be delisted
But clearly the symbol exists:
I can't reproduce the issue on 0.2.18
(latest) :
[*********************100%***********************] 1 of 1 completed
Open High Low Close Adj Close Volume
Date
2020-01-02 214.399994 216.160004 213.979996 216.160004 212.012711 30969400
2020-01-03 213.300003 215.470001 213.279999 214.179993 210.070663 27518900
2020-01-06 212.500000 215.589996 212.240005 215.559998 211.424179 21655300
... ... ... ... ... ... ...
2023-05-08 322.420013 324.040009 321.320007 323.690002 323.690002 36465800
2023-05-09 322.000000 322.880005 321.320007 321.640015 321.640015 31768800
2023-05-10 324.119995 326.010010 321.600006 325.140015 325.140015 60368600
[845 rows x 6 columns]
You may just need to pip install --upgrade yfinance
. Or, use this (as per GH1268) :
import pandas as pd;yf.download('QQQ', '2020-01-01', pd.Timestamp.now())