# Real time data stream for after market

**URL:** <https://forum.alpaca.markets/t/real-time-data-stream-for-after-market/12190>\
**Category:** Alpaca Market Data\
**Created:** [April 13, 2023, 9:09pm UTC](https://forum.alpaca.markets/t/real-time-data-stream-for-after-market/12190 "2023-04-13T21:09:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bomin\_Zhang](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/bomin_zhang/32/5275_2.png) [@Bomin\_Zhang](https://forum.alpaca.markets/u/Bomin_Zhang)\
**Post date:** [April 13, 2023, 9:09pm UTC](https://forum.alpaca.markets/t/real-time-data-stream-for-after-market/12190/1 "2023-04-13T21:09:37Z")

</div>

I’m using the following code the receive real time data stream using alpaca-py library.  
But after and pre market data seems to be unavailable.  
Is it the case that premium subscription will provide pre and after market data? or is this just a limitation of their real time datasource?

raw\_data = True  
async def bar\_handler(bar):  
print(bar)  
mapped\_bar = {  
BAR\_MAPPING[key]: val for key, val in bar.items() if key in BAR\_MAPPING  
}  
print(mapped\_bar)

stream = StockDataStream(api\_key = API\_KEY, secret\_key = SECRET\_KEY, raw\_data=raw\_data, feed=DataFeed.IEX)  
# stream = CryptoDataStream(api\_key = API\_KEY, secret\_key = SECRET\_KEY)

```
stream.subscribe_bars(bar_handler, "BABA")

```

---

<div class="post-metadata">

**Author:** ![maciejg](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/maciejg/32/647_2.png) [@maciejg](https://forum.alpaca.markets/u/maciejg)\
**Post date:** [April 19, 2023, 7:42pm UTC](https://forum.alpaca.markets/t/real-time-data-stream-for-after-market/12190/2 "2023-04-19T19:42:05Z")

</div>

DataFeed.IEX my be your problem, I believe only SIP will provide extended hours.
