I’m trying to just get a basic example working with Streamconn
from alpaca_trade_api import StreamConn
from alpaca_trade_api.common import URL
import config
import logging
logging.basicConfig(format='%(asctime)s %(message)s', level=logging.INFO)
conn = StreamConn(
config.API_KEY,
config.SECRET_KEY,
base_url=URL('https://paper-api.alpaca.markets'),
data_url=URL('https://data.alpaca.markets'),
#data_stream='alpacadatav1'
)
@conn.on(r'^AM\..+$')
async def on_minute_bars(conn, channel, bar):
print('bars', bar)
quote_count = 0 # don't print too much quotes
@conn.on(r'Q\..+', ['AAPL'])
async def on_quotes(conn, channel, quote):
global quote_count
if quote_count % 10 == 0:
print('bars', quote)
quote_count += 1
@conn.on(r'T\..+', ['AAPL'])
async def on_trades(conn, channel, trade):
print('trade', trade)
conn.run(['trade_updates', 'AM.AAPL'])
When I run it, I get this:
2020-10-07 18:44:43,025 connected to: wss://paper-api.alpaca.markets/stream
2020-10-07 18:44:43,227 connected to: wss://data.alpaca.markets/stream
and that’s it, nothing else. What am I doing wrong, I’m sure it’s something stupid.