1 Hour Barchart Data

I am receiving the following error when trying to access hourly chart information in python. I have referenced the “Missing hourly data” forum post and a couple of other sites that use an hour timeframe.

I tried the following reference code from the forum post above to see if it was just my code, but I get the following error.

Error:
“alpaca_trade_api.rest.APIError: your subscription does not permit querying data from the past 15 minutes”

Code Test:

symbol = 'SPY'
start_date = '2021-01-01'
end_date = '2021-05-25'

bars = api.get_bars(symbol, TimeFrame.Hour, start=start_date, end=end_date, adjustment='raw').df
bars.index = bars.index.tz_convert('America/New_York')

# Add a day column and count the number of hour bars per day.
bars['day'] = bars.index.date
hour_bars_per_day = bars.groupby('day').close.count()

# Display the bars
display(bars)

# Display the count per day
display(hour_bars_per_day)

# Display those days where the count is less than 16
display('days with less than 16 hour bars: ', hour_bars_per_day[hour_bars_per_day < 16])

Does this mean, hourly bar chart data is not available on the free subscription?? Or does the market need to be open for the timeframe to work?

Thank you

This part of the documentation: " This URL is the same for both subscription plans but users with Free subscription will receive an error when trying to access data that is too recent." Is my guess. I have a paid plan, so I can’t test it. I’m interested to see what answer you get from anyone else.

1 Like

Thanks for the feedback!
What’s strange though is that you can call get_barchart with a minute timeframe and it’s fine. But if you ask for “hour” bar chart data it’s too recent? Some of the GitHub repo examples use the hour timeframe as well. I’m on Tokyo time, so I feel like maybe it’s something to do with the market needing to be open? Hopefully, we hear back from the Alpaca team soon

Bringing this back to the top of the thread? Anyone have a get_barchart example of how to return hour bar data without getting the listed error? My algo is based on that timeframe.