Understanding Subscription to instrument data

When i go through documentation "subscribe " to a instrument is confusing me.
This is my requirement, start of day i would have decided what instruments to trade and i will be trading only those instruments for entire calendar day.
I understood that i can subscribe to live streaming data of market -> which means that once i subscribe to start of the day i will be relayed data from your server and i can fire orders based on that data.

I want to react (firing buy/sell) when it reaches my pre determined price based on market(live) and historic data(my backend).Considering i found a scrip to be selling in low price and purchased it around 10AM in the morning, now i read the instrument data around 10:05 AM and found that LTP has increased more than what i purchased and i want to sell it .IN this scenario should i keep requesting data from kite server for this scrip or this is where "Subscription" comes into picture ?

So if i am subscribed to that instrument data i will be relayed live until i close my subscription ?
if i have understood correct -what is the number of instruments i can be subscribed to ? :blush:
  • sujith
    The Kite Ticker keeps publishing ticks for the instrument that a client has subscribed to. A user will keep receiving ticks until unsubscribe is called or the connection is closed.
    A user can subscribe for up to 3000 instruments with one API connection.
  • ZI4453
    me(Client API)->Kite Server
    Start client -> Subscribe to individual instrument data->Read individual instrument data->fire orders->close client(ending subcription) by EOD.

    So this websocket is only data streaming and nothing related to firing orders, is my understanding correct ?
  • sujith
    yes, all other API calls are http requests.
  • ZI4453
    @sujith- will there be any restriction on reading Orders/Account balance status ? If my understanding is correct
    i will have to keep reading order's and fund balance status
    to go for next order.
  • Imran
    hii @ZI4453
    yes, the margins can be read by kiteconnect.
    have a look to this link : https://kite.trade/docs/pykiteconnect/v3/#kiteconnect.KiteConnect.margins
  • ZI4453
    @Imran _ my Querry was not about reading margin data... I am dealing only with CNC ,

    Client->Websocket->Read Market data->Refresh Rate( Live stream )
    Client->Fire order based on data from websocket
    Client->Http->Read my Account data(Orders,Fund status).Since this is Http data i will have to keep reading to understand my Order's/Account information. I am trying to if any rate limit is set to Read my Account standing on your OMS.

    Now- Since websocket is subscribed data for upto 3000 instruments per API, i am clear in that part and no doubt in that.

    Or- lets say a scrip has been sold and fund is back to my account ? will i get any response or something like that or do i need to keep reading Order status from API ?

    ->Place buy/Sell order->order placement(Success/Fail)->If order success placed->how will i know that order has gone through i.e buy/Sell translation has happened for a script?

    i am looking to understand how read OMS data of my orders placed and their transaction status from exchange, for that instance.this is to fire further orders for the day.
  • sujith
    You can listen to order status using postbacks API or postbacks via websockets.
  • ZI4453
    ZI4453 edited July 2019
    @sujith - You are awesome...Thats what exactly i was asking/searching for ...

    from your documentation redirect(https://kite.trade/docs/connect/v3/postbacks/)
    1.the status says "complete" does this mean its bough or sold status ?
    2.There is also "exchange ID" which mean it has reached SE but does that guarantee trasnaction(buy/Sell),
    I am trying to understand order cycle
    Fire orders->Z server(order_id) ->Exchange server(exchange_order_id):
    ->Client API->
    -postback Websocket->Read order status (confirm exchange_order_id is not null):

    how to know from postback data that actual "transaction->Buy/Sell" has happened ?

    Also from that link see "status_message" is empty.. Please share more sample payload for each possibilities in Order cycle.
  • sujith
    Once an order is placed, it goes through various systems in the backend before it reaches exchange. It includes mainly Kite trade, RMS, OMS. While it moves from one system to another there is a status change recorded and it can be checked by fetching the order history.
    An executed order status can be COMPLETE, CANCELLED, REJECTED and a pending order can have many intermediate statuses but commonly you will see OPEN, TRIGGER PENDING.
    AMO has a different set of statuses. You can check all these by just placing an order. Even it can be placed after market hours just to check the order history.

    The field status message is used to see the order rejection reason or order modify failure reason.

    A limit order can be in the OPEN status but may also have been filled partially which can be checked by using the pending quantity field in the order.

    If you see COMPLETE, CANCELLED, REJECTED status for an order then it means the order is executed. For limit orders, you need to also check the pending quantity field when the status is OPEN for partial fill scenario.
  • ZI4453
    @sujith , i am confused..
    ->Client(place CNC order-1 Qty)->Check order placed in exchange->wait for transaction to complete.

    thats what i want to know, API fires order(only 1 Qty of CNC), it is sent o Zerodha, after processing it places order to Exchange. Now once order is placed in exchange we will waiting for the order's transaction to be honored by exchange which is "trade".

    Now - for Live data we have websocket and order is fired through API.Once order is placed as you mentioned we have Postback WebSocket to track order's transaction status..
    I am trying to get that postback sample Payload for trade which was honoured by exchange.
  • sujith
    Ok, basically you need to check if the status is COMPLETE, CANCELLED or REJECTED. In the postback response if you see any of these statuses in the status field then it means the order is executed.
  • ZI4453
    No able to get you.. let me check myself once i get API ... Please close this thread
This discussion has been closed.