subscribing in on_order_update

y_sravan
Hi All,

all the example code shows subscribing in on_connect function.
I want to subscribe when the order is successfully placed.

so, I'm subscribing/unsubscribing in on_order_update callback function.

like this
def on_order_update(ws, data):
token = []
token.append(data['instrument_token'])
ws.subscribe(token)
ws.set_mode(kws.MODE_FULL, token)
this is not getting me any error, not I'm getting on_tick

what am I missing?
can we subscribe in on_order_update?
also how to subscribe to Futures symbol?

PS: tick data only working for Equity.
any help is appreciated
Tagged:
  • rakeshr
    @y_sravan
    can we subscribe in on_order_update?
    Yes, you can subscribe in on_order_update.

    Your python code for subscribing token in on_order_update method is correct.
    Are you assigning all the callbacks properly? Can you paste complete Websocket code here.
    also how to subscribe to Futures symbol?
    You can subscribe to any trading instrument for Websocket streaming using it's instrument_token.Get complete trading instrument_token list here.
  • y_sravan
    y_sravan edited October 31
    @rakeshr thanks for the response and for link to token list

    I'm assigning these callbacks
    kws.on_ticks = on_ticks
    kws.on_close = on_close
    kws.on_error = on_error
    kws.on_connect = on_connect
    kws.on_reconnect = on_reconnect
    kws.on_noreconnect = on_noreconnect
    kws.on_order_update = on_order_update
  • rakeshr
    @y_sravan
    As instrument subscription is done in on_order_update,then what operations are you performing in on_connect method?
  • y_sravan
    y_sravan edited October 31
    @rakeshr
    not doing anything in on_connect.
    we have is_connected() method to check if it is connected in any method
  • sujith
    You just need to assign a callback to on_order_update for listening to order updates. There is no need to subscribe or do anything.
    I would suggest just comment all the logic and keep only connect logic and add a print statement in on_order_update callback. Place an order which will eventually get rejected and you should see an order update.
  • y_sravan
    @sujith
    I'm getting order_update callback.
    problem is when I subscribe to the futures token data['instrument_token'], I'm not getting on_tick callback
    it's working for equity though.
    subscribe logic is same for both
  • sujith
    Are you sending num or String?
  • y_sravan
    @sujith
    I'm sending number only data['instrument_token']
  • sujith
    Can you print the json you are sending and paste it here?
  • y_sravan
    thanks @sujith and @rakeshr for response
    I could able to get it working
    some mismatch in my code

    we can close this thread
This discussion has been closed.