How to get trading symbol in the websocket data instead of instrument_token

Dileep
Hi,
In Kite web socket i am getting the data like "[{'tradable': True, 'mode': 'quote', 'instrument_token': 3906305, 'last_price': 4.2, 'last_quantity': 5, 'average_price': 4.18, 'volume': 94090500, 'buy_quantity': 0, 'sell_quantity': 768765, 'ohlc': {'open': 4.65, 'high': 4.7, 'low': 3.95, 'close': 4.55}, 'change': -7.6923076923076845}, "

In the above instead of "instrument_token" can i get trading symbol?
  • Dileep
    @sujith can you please guide me
  • rakeshr
    @Dileep
    In the above instead of "instrument_token" can i get trading symbol?
    No, trading symbol field is not present in websocket response.
  • ridhi_karan
    import requests
    url = "https://api.kite.trade/instruments"
    row = str(requests.get(url).content, 'utf-8').split("\r\n")
    head = row[0].split(",")
    data = [cell.split(",") for cell in row[1:-1]]
    instrument_token = "738561" #reliance

    # here tick contains market data from websocket connection
    for i in data:
    if tick["instrument_token"] == instrument_token :
    print (i[head.index("tradingsymbol")])

    However searching though ~ 60k rows on every tick is not very efficient, therefore i store the tradingsymbol in a list, before connecting to websocket.
  • Dileep
    Dileep edited June 2019
    Thanks @ridhi_karan ,
    @rakeshr, @sujith by using websocket response can i get market depth in "Buy" side and "Sell" side? Previously there was 'depth.buy', 'depth.sell' columns was there. No is it removed?
  • Imran
    hii @Dileep

    Use full mode to get market depth
    ws.set_mode(ws.MODE_FULL,subscribe)
  • Dileep
    Thanks @Imran sir..
This discussion has been closed.