Structure of websocket response is inconsistent.

anujs
this structure is given here :

https://kite.trade/docs/pykiteconnect/v4/#kiteconnect.KiteTicker.__init__

[{
'instrument_token': 53490439,
'mode': 'full',
'volume': 12510,
'last_price': 4084.0,
'average_price': 4086.55,
'last_quantity': 1,
'buy_quantity': 2356
'sell_quantity': 2440,
'change': 0.46740467404674046,
'last_trade_time': datetime.datetime(2018, 1, 15, 13, 16, 54),
'timestamp': datetime.datetime(2018, 1, 15, 13, 16, 56),
'oi': 21845,
'oi_day_low': 0,
'oi_day_high': 0,
'ohlc': {
'high': 4093.0,
'close': 4065.0,
'open': 4088.0,
'low': 4080.0
},
'tradable': True,
'depth': {
'sell': [{
'price': 4085.0,
'orders': 1048576,
'quantity': 43
}, {
'price': 4086.0,
'orders': 2752512,
'quantity': 134
}, {
'price': 4087.0,
'orders': 1703936,
'quantity': 133
}, {
'price': 4088.0,
'orders': 1376256,
'quantity': 70
}, {
'price': 4089.0,
'orders': 1048576,
'quantity': 46
}],
'buy': [{
'price': 4084.0,
'orders': 589824,
'quantity': 53
}, {
'price': 4083.0,
'orders': 1245184,
'quantity': 145
}, {
'price': 4082.0,
'orders': 1114112,
'quantity': 63
}, {
'price': 4081.0,
'orders': 1835008,
'quantity': 69
}, {
'price': 4080.0,
'orders': 2752512,
'quantity': 89
}]
}
},
...,
...]


https://kite.trade/docs/connect/v3/websocket/#quote-packet-structure

But in this url quote structure of websocket respose is given different.

which is correct ?
  • rakeshr
    https://kite.trade/docs/connect/v3/websocket/#quote-packet-structure
    But in this url quote structure of websocket respose is given different.
    The quote packet structure mentions the exchange broadcasted binary packet message structure.
    When receiving WebSocket responses from the Python library or any other client, the data structure is typically in the form of dictionaries or lists. These data structures are generated from the binary message mentioned above, and they may include additional fields that are useful to users (such as mode, tradable, etc.). As per your specific use case, you can iterate through the ticks and extract the required fields accordingly. You can refer to the Python example provided here for further guidance.
  • anujs
    does that means kite api will return same response structure regardless we fetch data for index or stock ?
  • sujith
    The structure will be same, it is just that you won't have depth data on the index data.
  • anujs
    ok, thanks both of you.
Sign In or Register to comment.