Maybe you know how to fix this based on your question? I went by the documentation (beginner here) and used the example to pull for 2 days of data (current/or close and previous day close). If I change this to get_bars, it breaks.
I think @Dan_Whitnable_Alpaca mentioned at some point that, with get_barset(), the bars are calculated backwards (or starting with the most recent one). This is why you can simply put barset = api.get_barset(ticker, ‘day’, limit=2) and get the last 2 days.
For some reason, despite being newer (and supposedly better), get_bars() doesn’t do this. Instead, the bars are calculated forwards, which means you need to specify the start time.
Thank you so much Maxks90! This works wonderfully. I was able to quickly test to make sure I could run and then merged back into my main program. The rest of the code works great as access by index of bars and bars
Appreciate greatly the time and attention you provided to ensure that I build the right foundation with Alpaca.
@Dan_Whitnable_Alpaca, would it be possible to get this functionality added to get_bars()? I imagine most people would want to get the most recent bars by default, so this would make things a lot easier. Those who want to get bars from a specific date range can simply use the start and end parameters.