AlpacaPy DataStream¶
- class src.boatwright.Data.OHLCV.Live.AlpacaPyDataStream.AlpacaPyDataStream(symbols, granularity, api_key=None, api_secret=None, crypto=False, debug=False, verbose=False)¶
A DataStream is an interface to an external websocket client for streaming live candle data, and converting the received data to be compatible with boatwright.
- Parameters:
symbols (str) – string, or list of strings of symbols to subscribe websocket client to
granularity (str) – desired data resolution i.e. “1-min”
api_key (str) – if broker_name is None will use this api_key
api_secret (str) – if broker_name is None will use this secret_key
crypto (bool) – boolean toggle to indicate if subscribing to crypto data, or stock data
verbose (bool) – boolean toggle to print extra information to terminal
debug (bool) – boolean toggle to print debugging information to terminal
- async handle_msg(msg)¶
converts message collected from a websocket subscription to boatwright compatible format
- Parameters:
msg – message received from websocket
- async run(queue)¶
launch datastream
- Parameters:
queue (Queue) – asyncio.Queue or dictionary of {“symbol”:asyncio.Queue, …}