alpaca-trade-api-python icon indicating copy to clipboard operation
alpaca-trade-api-python copied to clipboard

get_crypto_bars method not returning correct number of bars

Open Slickky210 opened this issue 2 years ago • 2 comments

return self.api.get_crypto_bars( symbol=self.symbol, timeframe=alpaca_trade_api.TimeFrame.Minute, start=(datetime.datetime.now(tz=datetime.timezone.utc) - datetime.timedelta(minutes=60)).isoformat(), )

The length is 141, but should be 60.

Slickky210 avatar May 05 '22 14:05 Slickky210

Hey @Slickky210, This can be a common occurrence for crypto when you get back multiple bars for the same minute, but from multiple exchanges. If you check the x field on the bars you should see that they're different for where the minutes are the same.

If you need to limit it to only one exchange there is an exchanges param on get_crypto_bars.

Does the issue still present if you specify only one exchange?

drew887 avatar May 05 '22 14:05 drew887

Also in the future please use the issue templates we have

drew887 avatar May 05 '22 14:05 drew887