When I subscribe to a ticker’s real-time trades, I get second gaps in the data. I’m using the alpaca python v2 streaming api (alpaca-trade-api 1.2.1) and python3.9.5 on macos 10.15. I was expecting to get all trades but it seems it just does a sampling that’s somewhat random. I tried using the historical data API to fetch all trades from the last minute, but even with a look-back time of 3 minutes, I get a 422 Unprocessable Entity error on the request. Two questions:
- Is there a streaming API that gives you real-time trades and guarantees delivery of all trades?
- What is the minimum look-back period for getting historical trade data?
Example program with trade times:
INFO:alpaca_trade_api.stream:started data stream
INFO:alpaca_trade_api.stream:connected to: wss://stream.data.alpaca.markets/v2/iex
INFO:alpaca_trade_api.stream:subscribed to trades: ['AAPL'], quotes: [] and bars: []
trade_time:2021-06-24 18:37:40.069432+00:00, current_time:2021-06-24 18:37:40.702806+00:00
trade_time:2021-06-24 18:37:44.091103+00:00, current_time:2021-06-24 18:37:44.918916+00:00
trade_time:2021-06-24 18:37:44.093297+00:00, current_time:2021-06-24 18:37:44.941262+00:00
trade_time:2021-06-24 18:37:45.000567+00:00, current_time:2021-06-24 18:37:45.013751+00:00
trade_time:2021-06-24 18:37:45.002291+00:00, current_time:2021-06-24 18:37:45.031236+00:00
trade_time:2021-06-24 18:37:45.012025+00:00, current_time:2021-06-24 18:37:45.127809+00:00
trade_time:2021-06-24 18:37:45.016740+00:00, current_time:2021-06-24 18:37:45.175280+00:00
trade_time:2021-06-24 18:37:45.022448+00:00, current_time:2021-06-24 18:37:45.231731+00:00
trade_time:2021-06-24 18:38:05.040133+00:00, current_time:2021-06-24 18:38:05.408625+00:00
trade_time:2021-06-24 18:38:05.094710+00:00, current_time:2021-06-24 18:38:06.068356+00:00
trade_time:2021-06-24 18:38:09.009501+00:00, current_time:2021-06-24 18:38:09.103607+00:00
trade_time:2021-06-24 18:38:12.002677+00:00, current_time:2021-06-24 18:38:12.037967+00:00