Hi , I’m linking up to to the historical feed using the SDK,
but when requesting historical data via some simple code [as per the SDK], the timestamps look random. I’m not using anything pytz-related within the code arguments - i would expect to return a vanilla timeseries df. Any ideas what could be the issue here?
def fetch_historical_bars(self):
self.client = StockHistoricalDataClient(api_key=alpaca_api_key, secret_key=alpaca_secret)
request_params = StockBarsRequest(
symbol_or_symbols=self.symbols,
timeframe=self.resolution,
start=self.start,
end=self.end)
bars = self.client.get_stock_bars(request_params=request_params)
bars_df = bars.df
bars_df = bars_df.reset_index()
bars_df.drop('symbol', axis=1, inplace=True)
return bars_df
alpaca = AlpacaMarketDataSource([‘TQQQ’],
TimeFrame(amount=5, unit=TimeFrame.Minute),
start=dt.datetime(2022, 1, 1),
end=dt.datetime.today(), live=False)
bars = alpaca.fetch_historical_bars()
running pprint.pprint(bars[‘timestamp’][:10]) …
Returns:
0 2022-01-03 08:30:00+00:00
1 2022-01-03 09:21:00+00:00
2 2022-01-03 10:12:00+00:00
3 2022-01-03 11:03:00+00:00
4 2022-01-03 11:54:00+00:00
5 2022-01-03 12:45:00+00:00
6 2022-01-03 13:36:00+00:00
7 2022-01-03 14:27:00+00:00
8 2022-01-03 15:18:00+00:00
9 2022-01-03 16:09:00+00:00
I’ve checked the full dataframe for busier market hours and the timestamp issue is identical.