Open SingularityMan opened 1 year ago
I have noticed the same thing.
You should try stocks.get_stock_historicals('TQQQ', interval='5minute', span='day', bounds='extended')
This, for some reason, only works with a span=day. However, this seems to be a restriction set by the API: https://github.com/jmfernandes/robin_stocks/blob/3e3d74e65e672fb4b31217b9b5e78353d5713eec/robin_stocks/robinhood/stocks.py#L560C8-L560C8
If you do this manually:
from robin_stocks.robinhood.helper import get_output, request_get
from robin_stocks.robinhood.urls import historicals_url
url = historicals_url()
payload = {'symbols': ','.join(['TQQQ']),
'interval': '5minute',
'span': 'week',
'bounds': 'extended'}
data = request_get(url, 'results', payload)
data[0]['historicals']
It will return history for extended hours for span="day"
and span="week"
. Longer than that doesnt work.
So perhaps the restriction in the API should be updated?
I think the API may need to be updated. I ran a modified version of your code:
url = historicals_url()
payload = {'symbols': ','.join(['TQQQ']),
'interval': '5minute',
'span': 'week',
'bounds': 'extended'}
data = request_get(url, 'results', payload)
for day in data[0]['historicals']:
print(day)
if day['begins_at'] == '2023-07-30T18:00:00Z':
print('Begins at: ', day['begins_at'])
print('Close price: ', day['close_price'])
And it returned dates between 07/28/2023 - 08/01/2023 but it does not show 07/30/2023 (Sunday)
So In terms of stock historicals we're sitting ducks until the API is updated.
Alright here we are!
from robin_stocks.robinhood.urls import historicals_url
url = historicals_url()
payload = {'symbols': ','.join(['TQQQ']),
'interval': '5minute',
'span': 'week',
'bounds': '24_7'}
data = request_get(url, 'results', payload)
But the price over the weekend is static:
{'begins_at': '2023-07-30T00:00:00Z', 'open_price': '45.379900', 'close_price': '45.379900', 'high_price': '45.379900', 'low_price': '45.379900', 'volume': 0, 'session': 'post', 'interpolated': True}
{'begins_at': '2023-07-30T00:10:00Z', 'open_price': '45.379900', 'close_price': '45.379900', 'high_price': '45.379900', 'low_price': '45.379900', 'volume': 0, 'session': 'post', 'interpolated': True}
Some help would be appreciated!
My code includes some historicals, which were implemented before the 24/7 introduction. I believe bounds = 'regular' was returning Mon/Friday prices on regular stocks; but to make it work with crypto and pull weekend prices I had to code bounds as = '24_7'. Haven't check but maybe that's your answer ??
Not really - dont mean to be fastidious but this should be something easily recoverable from the API. Especially for stocks that trade 24/7.
Perhaps @jmfernandes can chime in here?
Something that i noticed is that interpolated=true
for prices that are fetched over the weekend. Could there be a solution to this?
I have tried to set interpolated=False
in the payload
but it doesnt make a difference
robin_stocks doesn't seem to be getting stock historicals from Sunday. It can only go back to Friday. I tried this with this code:
And the final timestamp for historical_data prints this out for TQQQ and SQQQ:
This means Sunday is not being registered as a trading day in the API. I also tried this:
Is there something I'm missing here? maybe I got the timedeltas wrong?