alpacahq / alpaca-py

The Official Python SDK for Alpaca API
https://alpaca.markets/sdks/python/getting_started.html
Apache License 2.0
537 stars 134 forks source link

fix: Fix TradeUpdate model for validation error #372

Closed hiohiohio closed 10 months ago

hiohiohio commented 10 months ago

fixes https://github.com/alpacahq/alpaca-py/issues/371

Context:

Changes:

How to check:

# to reproduce an error
# ! pip install alpaca-py
# to confirm this PR's change
! pip install git+https://github.com/hiohiohio/alpaca-py.git@fix-trade-update-model

api_key=<YOUR API KEY>
secret_key=<YOUR SECRET>
paper = True

# required for asyncio in google colab
import nest_asyncio
nest_asyncio.apply()

from alpaca.trading.stream import TradingStream

cli = TradingStream(api_key, secret_key, paper=paper)

async def msg_handler(msg) -> None:
    print(msg)

cli.subscribe_trade_updates(msg_handler)
cli.run()