Im subscribed tot the $50 a month account and I am pulling aggregate minute bars, but it seems like a lot of the bars have major delays, sometimes hours old. Here is a small sample of the time difference for different tickers. Anyone know if this is currently being worked on? I need 16 bars at a time for my algorithm to work.
Aggregate data bars are only calculated and posted if there are eligible trades within that bar. No trades no bars. For a number of thinly traded stocks (such as KBSF in the screenshot) many minutes can pass before an eligible trade occurs and therefore no new bar is generated.
If you are using python, the resample method can be used to ‘fill in’ those missing bars. Something like this
# Get minute bars and then resample
minute_bars = api.get_bars('KBSF', TimeFrame.Minute, '2021-04-28', '2021-04-28', adjustment='raw').df
minute_bars_resampled = minute_bars.resample('1T').last()
# Forward fill the prices but fill any empty volume bars with 0
minute_bars_resampled.volume.fillna(0, inplace=True)
minute_bars_resampled.fillna(method='ffill', inplace=True)
# Convert to market timezone and display just the last 16 bars during market hours
minute_bars_resampled.index = minute_bars_resampled.index.tz_convert('America/New_York')
minute_bars_resampled.between_time('9:30', '16:00').tail(16)
The result looks like this
4 Likes
Thank you so much! Thats exactly what will fix my app.