Kotak-Neo / kotak-neo-api

113 stars 103 forks source link

client.subscribe custom on_message callback #110

Closed crypt0inf0 closed 8 months ago

crypt0inf0 commented 9 months ago

How to use custom on_message on neo_api_client.subscribe

live_data = {}

def on_feed(message):
    global live_data
    try:
        print(f"message : {message}")
        for i in message:
            live_data[i['ts']] = i['ltp']
    except Exception as e:
        print(f"Error {e}")

inst_tokens = [{"instrument_token": "65373", "exchange_segment": "nse_fo"}]

def stream():
    c.subscribe(instrument_tokens=inst_tokens, on_message=on_feed)

Thread(target=stream).start()

@Kotak-Neo Can you add this functionality?

crypt0inf0 commented 9 months ago

i use https://github.com/Kotak-Neo/kotak-neo-api/pull/63

Kotak-Neo commented 8 months ago

We are soon releasing a new version which will contain the same. Will keep you guys posted :)

Hari3115 commented 3 months ago

@Kotak-Neo When is the new version coming up? the callback function is not working for anyone trying it lately