Search code examples
pythonalpaca

How do I get data through my alpaca datastream?


I am trying to get live stock data through my Alpaca API, however, when I run my script, nothing happens at all. Here is the script.

from alpaca.data.live import StockDataStream

async def quote_handler(quote):
    print(quote)

stream = StockDataStream("<key>", "<secret>")
stream.subscribe_quotes(quote_handler, "TSLA")
stream.run()

Solution

  • First, you should not give away your keys, it's called secret key...

    Second, if there is no stream, maybe you try to get data when the market is closed