asyncio

namanviz
Hello
The below code snippet is from an example from git.
*******************************************************************************************************************
def on_ticks(ws, ticks):
logging.info("Ticks: {}".format(ticks))


def on_connect(ws, response):
ws.subscribe([13613826])

ws.set_mode(ws.MODE_FULL, [13613826])

def on_close(ws, code, reason):

ws.stop()

# Assign the callbacks.
kws.on_ticks = on_ticks
kws.on_connect = on_connect
kws.on_close = on_close

# Infinite loop on the main thread. Nothing after this will run.
# You have to use the pre-defined callbacks to manage subscriptions.
kws.connect()

*******************************************************************************************************************


Can anyone advise on how to use asyncio for assigning callback 'kws.on_connect = on_connect'

Basically I am looking for something like this
async with kite_trade_socket(client_id, api_id, etc....) as ws:
***here I perform other async calls, and probably do not disturb the main thread****

I have tried few things but they don't seem to work
Thank you and Happy Diwali.
Sign In or Register to comment.