Historical data endpoint not consistent in end time interpretation

Take this request:

https://data.alpaca.markets/v2/stocks/AESI/bars?feed=SIP&start=2023-03-22T20:00:00.000000Z&end=2023-03-23T14:00:00.000000Z&limit=10000&timeframe=1Hour&adjustment=raw

                     t     o     h     l     c    v   n      vw
1 2023-03-22T20:00:00Z 16.41 16.41 16.41 16.41 4505   1 16.4100
2 2023-03-23T13:00:00Z 16.47 16.49 16.43 16.46 1540 254 16.4812

But

https://data.alpaca.markets/v2/stocks/AESI/bars?feed=SIP&start=2023-03-22T20:00:00.000000Z&end=2023-03-23T13:00:01.000000Z&limit=10000&timeframe=1Hour&adjustment=raw

                     t     o     h     l     c    v n    vw
1 2023-03-22T20:00:00Z 16.41 16.41 16.41 16.41 4505 1 16.41

I have deliberately added 1 extra second to make sure the interval contains 2023-03-23T13:00:00Z.

While this stock A will yield correctly:

https://data.alpaca.markets/v2/stocks/A/bars?feed=SIP&start=2023-03-27T20:00:00.000000Z&end=2023-03-28T14:00:00.000000Z&limit=10000&timeframe=1Hour&adjustment=raw

                     t       o        h        l      c      v   n       vw
1 2023-03-27T20:00:00Z 133.070 133.0700 133.0700 133.07 261975  53 133.0700
2 2023-03-28T13:00:00Z 132.540 133.2800 132.0108 132.71  54605 862 132.7068
3 2023-03-28T14:00:00Z 132.655 132.7126 132.6550 132.71   2978  57 132.6908

Note that it doesn’t yield correctly if 2023-03-28T13:00:00.000000Z is specified in the URL request (??).

While for AESI you have to add an hour to get the 14h time:

https://data.alpaca.markets/v2/stocks/AESI/bars?feed=SIP&start=2023-03-27T20:00:00.000000Z&end=2023-03-28T15:00:00.000000Z&limit=10000&timeframe=1Hour&adjustment=raw

                     t      o     h     l     c     v   n       vw
1 2023-03-27T20:00:00Z 16.520 16.52 16.52 16.52  5162   2 16.52000
2 2023-03-28T13:00:00Z 16.650 16.72 16.40 16.43 15324 336 16.52139
3 2023-03-28T14:00:00Z 16.475 16.60 16.25 16.60 64497 282 16.52268

So for stock A the end time is interpreted as in the request URL in some cases (not all!), while for stock AESI the end time is always (?) offset with 1 hour?

I haven’t looked into the consistency of the bars… Maybe best :face_with_head_bandage: