Python api get_bars limitations?

Question: I’m using alpaca api to return bars. When I try to pass in a date string with a time as the start time for the returning the bars, it generates an error. So it looks like you can only collect bars or an entire day, is that right? So the best way to handle this is to pull back data for the entire day and then keep only what you want to work with? Is there an API-centric way I can do this? Sorry if this is the wrong place.

When I try to pass in a date string with a time as the start time for the returning the bars, it generates an error.

This suggest that you provide the start time in a wrong format. It should be in RFC 3339. Here’s a working example:

api.get_bars("AAPL", start="2022-07-01T16:15:00Z", timeframe="1Min", limit=5)

Thanks, that worked. The default isoformat() call for python datetime doesn’t include the zulu so you’ve got to add it yourself, in case anybody else comes across this.

1 Like