I'm trying to start simple here just so I can get the hang of this stuff. I understand the premise of asyncio but its so confusing trying to use it with ccxt. Is there any recommended resources besides the asyncio documentation that someone can forward me to?
import time
import ccxt.async_support as ccxt
import configpro
exchange = ccxt.coinbasepro({
'apiKey': configpro.apiKey,
'secret':configpro.secret,
'password': configpro.password,
'enableRateLimit': True})
async def test():
async with exchange as session:
print(await session.fetch_ticker('BTC/USD'))
async def main():
print(f"started at {time.strftime('%X')}")
await test()
print(f"finished at {time.strftime('%X')}")
asyncio.run(main())
And my error:
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x000001ED6BE8EDC0>
Traceback (most recent call last):
File "C:\Users\micha\AppData\Local\Programs\Python\Python39\lib\asyncio\proactor_events.py", line 116, in __del__
self.close()
File "C:\Users\micha\AppData\Local\Programs\Python\Python39\lib\asyncio\proactor_events.py", line 108, in close
self._loop.call_soon(self._call_connection_lost, None)
File "C:\Users\micha\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 746, in call_soon
self._check_closed()
File "C:\Users\micha\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 510, in _check_closed
raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed