How to receive Order Updates over websoket in Javascript ?

WY4269
HI,

Lets say I placed 2 options order using kite connect 3 javascript api, for which in return I get 2 order IDs (let them me x and y), now in order to make sure this order gets executed, I need to be able to get it's updates, Could you give me an example code of api call using the order IDs x and y?
  • WY4269
    I want to be able to receive the updates over websocket, in kite connect js I have this Ticker function:
    ----------------------------------------------------------------------------------------------
    var KiteTicker = require("kiteconnect").KiteTicker;
    var ticker = new KiteTicker({
    api_key: "api_key",
    access_token: "access_token"
    });

    ticker.connect();
    ticker.on("ticks", onTicks);
    ticker.on("connect", subscribe);

    function onTicks(ticks) {
    console.log("Ticks", ticks);
    }

    function subscribe() {
    var items = [738561];
    ticker.subscribe(items);
    ticker.setMode(ticker.modeFull, items);
    }
    ----------------------------------------------------------------------------------------------

    So do I have to subscribe using order id? or what, how can I get updates for my new placed orders here? also how long will the updates come?
  • sujith
    You need to set on order update callback as mentioned here.

    You will keep getting order updates until your connection is open.
  • WY4269
    so i just need to add "order-update" listener to ticker object? and I'll receive updates one order at a time or grouped?
  • sujith
    You can know more here.
Sign In or Register to comment.