Getting 15-minute and 20-minute intervals when request 5-minute interval data

from alpaca_trade_api.rest import REST, TimeFrame, TimeFrameUnit
api = REST()

api.get_bars(symbols=["BAC", "C"], TimeFrame(5, TimeFrameUnit.Minute), "2021-01-01", "2022-01-01", adjustment='raw').df

Please take a look team

Ah, that’s not 15m or 20m intervals, those are gaps! That’s expected when no trades happen during that interval. Take a look at 2021-01-04 10:20:00+00:00 to 10:35:00+00:00 in your second picture: that’s saying that between 10:25 and 10:35 UTC (10 minutes) there were no trades.

This is very common on stocks pre- or post-market. Those timestamps are UTC, but BAC trades in -05:00 at that time of year, so that’s like 5:35am or so in America/New_York timezone.

Also, look at trade_count and volume: those are very low numbers, which is also a sign that not a lot of trades are happening premarket.