The problem is that main()
does not wait for other tasks to finish, so we need to tell it to wait for them. For example using asyncio.gather()
:
import asyncio
from binance.client import AsyncClient
async def get_data(client):
res = await client.get_klines(symbol='BTCUSDT', interval='15m', limit=99)
print(res)
async def main():
client = await AsyncClient.create()
await asyncio.gather(
get_data(client=client)
)
asyncio.run(main())