ValueError: unknown channel A.TSLA (you may need to specify the right data_stream)

Program was running Friday. This morning I am getting above error.
I changed keys but this did not help. Also changed symbol and ran old copy of code that was working. No luck on either.

Here id the offending code:
def start_trading(self):

    conn = tradeapi.StreamConn(self.key_id, self.secret_key, self.base_url)

    @conn.on(r'A$', [self.symbol])                                                    



Any Ideas???

Did you figure out the issue?

There was a change in SDK that now defaults to alpaca data stream unless you specify data_stream parameter to the initializer, and alpaca data stream does not support A channel. That is what the error message means but apparently it is still not clear.

We are also updating the example code we posted in the past to avoid this confusion.

Ah, same issue here, and I posted a question under programming. How do I specify data_stream parameter to the initializer, Hitoshi, would you please give an example? Thanks!

Do we have any updates on the example code to resolve the above issue?

Any updates on this ?

Hi Hitoshi,
My program stopped working yesterday. It gives this error “RuntimeError: This event loop is already running”
I removed all of my code and just left code from examples on the Alpaca site. It still gives the same error message.
Here is the code: It gives error on the line. Please please please. Tell me what is wrong? Thank you…Thomas

!pip install alpaca-trade-api
import alpaca_trade_api as tradeapi
class MartingaleTrader(object):
def init(self):
self.key_id = “PKCD5QCAHON7FRU6VIPQ”
self.secret_key = “yjb83YL4Mzp43o891BkoMr1KgixgxDi60webIaSL”
self.base_url = “
self.data_url = ‘
self.api = tradeapi.REST(self.key_id, self.secret_key, self.base_url)
self.trade_number = 0
self.symbol = ‘TSLA’
def start_trading(self):
conn = tradeapi.StreamConn(self.key_id, self.secret_key, base_url=self.base_url, data_url=self.data_url, data_stream=‘polygon’ if USE_POLYGON else ‘alpacadatav1’)
@conn.on(r’A$’, [self.symbol])
async def handle_agg(conn, channel, data):
self.trade_number = self.traden_number + 1
if USE_POLYGON:[f’A.{self.symbol}’, ‘trade_updates’])
else:[f’alpacadatav1/T.{self.symbol}’, ‘trade_updates’])
if name == ‘main’:
trader = MartingaleTrader()