Thanks Mallory for your input, I really appreciate the level of support here.
I will follow the wildcard subscription method, and unsubscribe any unwanted symbols.
I have more questions w.r.t. Intraday Bars.
In my testing of intraday bars, I am encountering missing bars for stocks with trading activity for the minute. I would like to understand the rules in the creation of intraday bars.
My questions are:
1 - What are the base conditions to generate an intraday bar?
a- I assume if there is no trade activity, there will be no intraday bar sent.
b- If there was trade activity, an intraday bar will be sent.
2 - I am performing a test on intraday one minute bars, and bars that I expect to see are not showing up in the streaming API, please provide guidance on how I can resolve this. I am verifying the market activity by using the ThinkorSwim app.
3- I tried unsubscribing to a list of symbols, and I Key error on the unsubscribed symbol.
I cannot unsubscribe to unwanted bars, when I tried to unsubscribe I get the following traceback
Traceback (most recent call last):
File “/home/htom/.local/share/JetBrains/Toolbox/apps/PyCharm-C/ch-0/202.7660.27/plugins/python-ce/helpers/pydev/pydevd.py”, line 1448, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
File “/home/htom/.local/share/JetBrains/Toolbox/apps/PyCharm-C/ch-0/202.7660.27/plugins/python-ce/helpers/pydev/_pydev_imps/_pydev_execfile.py”, line 18, in execfile
exec(compile(contents+"\n", file, ‘exec’), glob, loc)
File “/home/htom/PycharmProjects/DEV1POInjector/minuteMinder.py”, line 282, in
File “/home/htom/PycharmProjects/DEV1POInjector/venv/lib/python3.8/site-packages/alpaca_trade_api/stream.py”, line 420, in unsubscribe_bars
File “/home/htom/PycharmProjects/DEV1POInjector/venv/lib/python3.8/site-packages/alpaca_trade_api/stream.py”, line 177, in unsubscribe_bars
2021-06-14 12:33:14,158 INFO subscribed to trades: , quotes:  and bars: [’’]
KeyError: ‘LITE’ <--------------------- error encountered.
I arrange the code to use a thread safe data-structure. I selected Queue to be the thread-safe data structure.
in my code I have
from queue import Queue
unwanted_symbol = Queue() // unwanted_symbols is a global
async def on_bar_message(message):
if my_s not in my_symbols:
unwanted_symbol.put(my_s) // on bar received, add to unwanted symbol if symbol is unwanted
main event loop
if name == ‘main’:
symbol = unwanted_symbol.get() # get symbol from unwanted queue
conn.unsubscribe_bars(symbol) # unsubscribe to bar.
It appears I cannot unsubscribed correctly, when I perform a wildcard subscription:
Please advise on the proper mechanism to unsubscribe.