Python RunTime error

When I use this code I get the next error:
(RuntimeError: asyncio.run() cannot be called from a running event loop)
“”"
import alpaca_trade_api as tradeapi

API_KEY= ’ ’
API_SECRET_KEY= ’ ’
API_ACCOUNT_URL= ‘https://paper-api.alpaca.markets

async def bar_callback(t):
print(‘trade’,t)

def main():
stream = tradeapi.Stream(key_id=API_KEY,base_url=API_ACCOUNT_URL, secret_key=API_SECRET_KEY,data_feed=‘iex’)
stream.subscribe_trades(bar_callback,‘AAPL’)
stream.run()

data = main()
“”"
I would appreciate any help on how to solve it, thanks.

This sounds like you’re using alpaca_trade_api incorrectly. I’d suggest asking in the support channel for that package, as they will likely be able to help you better than we can here.

I already did it three days ago but still haven’t got any response that’s why I’ve post it here