# Streaming trade data has gaps

**URL:** <https://forum.alpaca.markets/t/streaming-trade-data-has-gaps/6046>\
**Category:** Alpaca Market Data\
**Created:** [June 24, 2021, 6:51pm UTC](https://forum.alpaca.markets/t/streaming-trade-data-has-gaps/6046 "2021-06-24T18:51:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![natan](https://avatars.discourse-cdn.com/v4/letter/n/b38774/32.png) [@natan](https://forum.alpaca.markets/u/natan)\
**Post date:** [June 24, 2021, 6:51pm UTC](https://forum.alpaca.markets/t/streaming-trade-data-has-gaps/6046/1 "2021-06-24T18:51:06Z")

</div>

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:

1. Is there a streaming API that gives you real-time trades and guarantees delivery of all trades?
2. What is the minimum look-back period for getting historical trade data?

Example program with trade times:

```auto
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

```

---

<div class="post-metadata">

**Author:** ![Dan\_Whitnable\_Alpaca](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/dan_whitnable_alpaca/32/1658_2.png) [@Dan\_Whitnable\_Alpaca](https://forum.alpaca.markets/u/Dan_Whitnable_Alpaca)\
**Post date:** [June 24, 2021, 9:34pm UTC](https://forum.alpaca.markets/t/streaming-trade-data-has-gaps/6046/2 "2021-06-24T21:34:33Z")

</div>

@natan The `wss://stream.data.alpaca.markets/v2/sip` streaming endpoint delivers real time trades consolidated across all markets. There is roughly a 20ms latency plus whatever network latency between Alpaca and the client, but all trades are included.

The reason you are seeing ‘gaps’ is because the endpoint is `wss://stream.data.alpaca.markets/v2/iex`. That only streams trades which occurred on the IEX exchange which typically only accounts for about 2% of the total market. You will need a subscription to the Alpaca ‘Unlimited’ data plan, but change the streaming connection to `wss://stream.data.alpaca.markets/v2/sip` and you will see all trades without the ‘gaps’.

There’s more information about the difference in [the documentation](https://alpaca.markets/docs/api-documentation/api-v2/market-data/alpaca-data-api-v2/real-time/).

---

<div class="post-metadata">

**Author:** ![natan](https://avatars.discourse-cdn.com/v4/letter/n/b38774/32.png) [@natan](https://forum.alpaca.markets/u/natan)\
**Post date:** [June 24, 2021, 10:04pm UTC](https://forum.alpaca.markets/t/streaming-trade-data-has-gaps/6046/3 "2021-06-24T22:04:43Z")

</div>

Thanks for the quick response Dan. I’m a neophyte when it comes to the different exchanges and what data they provide. Makes sense!

---

<div class="post-metadata">

**Author:** ![Julio\_Spinelli](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/julio_spinelli/32/6081_2.png) [@Julio\_Spinelli](https://forum.alpaca.markets/u/Julio_Spinelli)\
**Post date:** [May 2, 2024, 6:42pm UTC](https://forum.alpaca.markets/t/streaming-trade-data-has-gaps/6046/4 "2024-05-02T18:42:06Z")

</div>

I don’t find the option in my web interface for only getting the unlimited subscription. The only option I find is the 99 per month option for the trader-plus plan. Is that correct? I am only starting to develop the real time interface for implementing signal detection that I have developed with historical data. Do I need to get the unlimited plan through the trader plus? or is there any other way to test the real time analysis program using delayed quotes? The data rate I am getting now is on the average 1 quote every 4.75 seconds. Thanks for any guidance or help, Julio
