I want to use Websockets Kocoin SDK to get data https://github.com/Kucoin/kucoin-python-sdk
I want to get the current price of all currencies. For this, I used the topic /market/snapshot:USDS in the await ws_client.subscribe() line
I want to have the current price of each currency pair in a list or dictionary every second using this SDK and this topic.
I would be grateful if someone could help me
The changes I made for my needs
symbol_price=[]
async def main():
async def deal_msg(msg):
if msg['topic'] == '/market/snapshot:USDS':
#print(msg["data"])
symbol_price.append(msg['data']['data']['lastTradedPrice'])
client = WsToken()
ws_client = await KucoinWsClient.create(None, client, deal_msg, private=False)
await ws_client.subscribe('/market/snapshot:USDS')
while True:
await asyncio.sleep(1)
if __name__ == "__main__":
loop = asyncio.get_event_loop()
loop.run_until_complete(main())