yfinance icon indicating copy to clipboard operation
yfinance copied to clipboard

Get intraday historical data

Open hpdeandrade opened this issue 5 years ago • 2 comments

Dear everyone,

When running the pdr.get_data_yahoo function I'm having issues with the start and end parameters.

It works fine when I use the YYYY-MM-DD format, however I want to get intraday data such as the below.

pdr.get_data_yahoo("TSLA", interval="1m", start="2020-10-01", end="2020-11-10") -> this does work. pdr.get_data_yahoo("TSLA", interval="1m", start="2020-10-01 11:00", end="2020-11-10 15:00") -> this does not work.

Error I get is the following: ValueError: unconverted data remains: 11:00

Is there any workaround to solve this problem? Many thanks in advance.

hpdeandrade avatar Nov 11 '20 19:11 hpdeandrade

I get the following response when I run your code:

1 Failed download:
- TSLA: 1m data not available for startTime=1601506800 and endTime=1604966400. Only 7 days worth of 1m granularity data are allowed to be fetched per request.

However, when I run the following:

df = pdr.get_data_yahoo("TSLA", interval="1m", start="2020-11-09", end="2020-11-11")

I get a data point for every minute the market was open, starting from 9:30 on 2020-11-09 to 15:59 on 2020-11-10 (776 rows). I think the quickest way forward for you here is to take the returned df and apply a filter between 11:00 and 15:00.

Hope this helps!

jamesprinc3 avatar Nov 16 '20 19:11 jamesprinc3

Wrong repository, pdr is pandas data reader.

ValueRaider avatar Mar 12 '24 22:03 ValueRaider