I am trying to figure out how to modify the subscribed stocks in my stream. The following seems to stop the event loop rather than just remove AAPL but continue the loop as I would expect. I want the quote_data_handler function to conditionally update the list of symbols in the stream. Can anyone provide a simple example that would start the stream showing SPY and AAPL then remove AAPL and continue the event loop?
async def quote_data_handler(data):
print(data)
wss_client.unsubscribe_quotes("AAPL")
wss_client = StockDataStream(api_key, secret_key)
wss_client.subscribe_quotes(quote_data_handler, "SPY", "AAPL")
wss_client.run()