Edit 2021-10-25
To clear my answer. Question was:
i wanna set specific date and time intervals. thanks
All you need is in the code documentation.
So start and end could be date or _datetime
start: str
Download start date string (YYYY-MM-DD) or _datetime.
Default is 1900-01-01
Example code:
Note: something wrong with timezones, i've tryed to pass correcth timezone with start and end but lib didn't handle it correctly and I was finish with convert it manually)
import pandas as pd
import yfinance as yf
import pendulum
pd.options.display.max_rows=10 # To decrease printouts
start = pendulum.parse('2021-10-18 09:30').add(hours=7) # My tz is UTC+03:00, original TZ UTC-04:00. So adds to my local time 7 hours
end = pendulum.parse('2021-10-18 10:30').add(hours=7) # Same
print(start)
print(yf.download(tickers="GC=F", interval="1m", start=start, end=end))
Result and you can pass whatever datetime ranges you want:
2021-10-18T16:30:00+00:00
[*********************100%***********************] 1 of 1 completed
Open High Low Close \
Datetime
2021-10-18 09:30:00-04:00 1770.099976 1770.099976 1767.400024 1767.800049
2021-10-18 09:31:00-04:00 1767.900024 1769.099976 1767.800049 1768.500000
2021-10-18 09:32:00-04:00 1768.599976 1769.300049 1768.199951 1769.199951
2021-10-18 09:33:00-04:00 1769.300049 1770.199951 1768.900024 1769.099976
2021-10-18 09:34:00-04:00 1769.199951 1769.300049 1767.599976 1767.800049
... ... ... ... ...
2021-10-18 10:25:00-04:00 1769.900024 1770.400024 1769.800049 1770.300049
2021-10-18 10:26:00-04:00 1770.300049 1770.500000 1769.900024 1769.900024
2021-10-18 10:27:00-04:00 1769.800049 1769.800049 1769.099976 1769.400024
2021-10-18 10:28:00-04:00 1769.400024 1770.400024 1769.400024 1770.199951
2021-10-18 10:29:00-04:00 1770.300049 1771.000000 1769.900024 1770.099976
Adj Close Volume
Datetime
2021-10-18 09:30:00-04:00 1767.800049 0
2021-10-18 09:31:00-04:00 1768.500000 459
2021-10-18 09:32:00-04:00 1769.199951 428
2021-10-18 09:33:00-04:00 1769.099976 750
2021-10-18 09:34:00-04:00 1767.800049 549
... ... ...
2021-10-18 10:25:00-04:00 1770.300049 134
2021-10-18 10:26:00-04:00 1769.900024 147
2021-10-18 10:27:00-04:00 1769.400024 349
2021-10-18 10:28:00-04:00 1770.199951 258
2021-10-18 10:29:00-04:00 1770.099976 382
[60 rows x 6 columns]
PS: with start and end you do not have limitation to the last 7 days, but still have limit to the last 30 days:
1 Failed download:
- GC=F: 1m data not available for startTime=1631980800 and endTime=1631998800. The requested range must be within the last 30 days.
Original
this lib has a lack of documentation. But this is python and as result it some kind of self-documented.
Read definition of download function here
https://github.com/ranaroussi/yfinance/blob/6654a41a8d5c0c9e869a9b9acb3e143786c765c7/yfinance/multi.py#L32
PS this function have start= and end= params that I hope help you