Quote for multiple symbols

ayyaz
in one of your promotion email it was said that i can fetch quote for 50 stocks in a go .. , i quickly purchased for same reason ,
now i am getting exception continuously ..

this is how i called it.
kite.quote("NSE",x)

x is list printed below ..
i searched it in forum , i dint find solution for the same , instead websockets where suggested without proper example in terms of fetching 50 symbol quote simultaneously .

e=Exception fetching quote
X=['NSE:IZMO', 'NSE:TATASTEEL', 'NSE:EICHERMOT', 'NSE:POWERGRID', 'NSE:HAVELLS', 'NSE:BLUESTARCO', 'NSE:SBIN', 'NSE:UPL', 'NSE:IOC', 'NSE:AMBUJACEM', 'NSE:HDFC', 'NSE:ULTRACEMCO', 'NSE:INFRATEL', 'NSE:CENTURYPLY', 'NSE:KOTAKBANK', 'NSE:SUNPHARMA', 'NSE:BPCL', 'NSE:WIPRO', 'NSE:EXIDEIND', 'NSE:BHARTIARTL', 'NSE:RCOM', 'NSE:TCS', 'NSE:ADANITRANS', 'NSE:ASIANPAINT', 'NSE:BAJAJFINSV', 'NSE:ONGC', 'NSE:ICICIBANK', 'NSE:MARUTI', 'NSE:BAJAJAUTO', 'NSE:PCJEWELLER', 'NSE:IBULHSGFIN', 'NSE:AXISBANK', 'NSE:BATAINDIA', 'NSE:HCLTECH', 'NSE:INFY', 'NSE:GSFC', 'NSE:NTPC', 'NSE:TECHM', 'NSE:ESCORTS', 'NSE:DRREDDY', 'NSE:IDEA', 'NSE:HINDUNILVR', 'NSE:TATAMOTORS', 'NSE:M%26M', 'NSE:BOSCHLTD', 'NSE:ASHOKLEY', 'NSE:ADANIPOWER', 'NSE:SUZLON', 'NSE:IGL', 'NSE:HDFCBANK']


e=Gateway is busy

X=['NSE:ARVIND', 'NSE:CIPLA', 'NSE:TATAPOWER', 'NSE:HEROMOTOCO', 'NSE:ZEEL', 'NSE:LT', 'NSE:BEL', 'NSE:COALINDIA', 'NSE:SPARC', 'NSE:ADANIPORTS', 'NSE:GAIL', 'NSE:INDUSINDBK', 'NSE:MOTHERSUMI', 'NSE:TITAN', 'NSE:HINDALCO', 'NSE:LUPIN', 'NSE:YESBANK', 'NSE:RELIANCE', 'NSE:ITC', 'NSE:AUROPHARMA', 'NSE:HINDPETRO']

e=Exception fetching quote


please provide solution , in case if you r suggesting websocket , please provide an example of same to fetch quote price for 50 symbols

in case if am using wrong API let me know how can i get current buy price for symbol , and how to fetch the same for 50 symbols simultenously .

2. Is there any limit on number of queries i make i might want to query this per second . is not possible let me know how duration can be kept in between two queries .

3. i also tried historical data (minute) get ended up with same exception it will be great if u provide an example . is it possible to club this information as well? where i can fetch per minute histroy for multiple symbols
4. also about placing order buy and sell how much time it takes to execute buy and sell in case if i am doing very fast trade using my algo , can be assured that all my orders will be executing at the same time
  • sujith
    Hi,
    You can try using Kite Connect 3.
    In one query, you can get the quote for up to 500 instruments.
    If you are already using Kite Connect 3 then you can enable debugging and check logs.

    You can check out Kite Ticker(websockets) usage example in the readme of the pykiteconnect repository.

    All the Kite Connect API calls are limited to 3 requests per second.

    You don't seem to have an active Historical data subscription. You can go to developers console and subscribe to the same.
  • ayyaz
    git clone https://github.com/zerodhatech/pykiteconnect/tree/kite3
    Cloning into 'kite3'...
    fatal: repository 'https://github.com/zerodhatech/pykiteconnect/tree/kite3/' not found


    why dont you paste the example here itself , isnt it simple
  • ayyaz
    i have active historical data subscription and its expiring without using only because nowhere straightway example is mentioned , i dont understand why u dont paste examples here and save our time? instead of making us search all over
  • sujith
    Hi @ayyaz,
    You can check out historical_data method here and read documentation for more information.
  • ayyaz
    please provide any working program , instead of giving information in bits and pieces,
  • ayyaz
    it gives errors like .
    ERROR:kiteconnect.ticker:WebSocket connection lost: [Failure instance: Traceback (failure with no frames): : Connection was aborted locally, using.
    ].
    ERROR:kiteconnect.ticker:WebSocket connection lost: [Failure instance: Traceback (failure with no frames): : Connection was aborted locally, using.
  • ayyaz
    kws = KiteTicker(currentAcctTrader.apikey, currentAcctTrader.acess_token)

    def on_ticks(ws, ticks):
    # Callback to receive ticks.
    logging.debug("Ticks: {}".format(ticks))

    def on_connect(ws, response):
    # Callback on successful connect.
    # Subscribe to a list of instrument_tokens (RELIANCE and ACC here).
    ws.subscribe([738561, 5633])

    # Set RELIANCE to tick in `full` mode.
    ws.set_mode(ws.MODE_FULL, [738561])

    # Assign the callbacks.
    kws.on_ticks = on_ticks
    kws.on_connect = on_connect
  • ayyaz
    ERROR:kiteconnect.ticker:WebSocket connection lost: [Failure instance: Traceback (failure with no frames): : Connection was aborted locally, using.
    ].
    ERROR:kiteconnect.ticker:WebSocket connection lost: [Failure instance: Traceback (failure with no frames): : Connection was aborted locally, using.

    please solve this problem , specifically instead of giving random solution
  • vvijay
    @ayyaz
    I have coded the equivalent in python as follows. This is working fine.

    api_key='myapikey'
    atoken='session_auth token'
    tkn='token '+api_key+":"+atoken
    #use a comma separated list for instrument, or single as below
    inst='NFO:BANKNIFTY18JAN26000PE'
    #or
    # inst=['NFO:BANKNIFTY18JAN26000PE','NFO:BANKNIFTY18JAN26000CE']

    headers ={
    'X-Kite-Version': '3',
    'Authorization': tkn,
    }

    params = (
    ('i', [ inst]), )


    response = requests.get('https://api.kite.trade/quote', headers=headers, params=params)

    qo=response.json()
  • vvijay
    Another option is kite.ltp(['exchange:instrument','exchange:instrument2']
  • ayyaz
    This is pull request , but i need push one , which will be more precise i think push is over webSockets , i am not able to see precise working example for websocket tick by tick for any 50 instruments . by the way why instrument name is crafted like this NFO:BANKNIFTY18JAN26000PE how can i formulate it generically in case if want LUPIN, SUNPHARMA , etc.. 50 instruments i will would like to pass these symbols to get the current trade (sell ) values tick by tick .

    I request Zerodha to give quick answer which is precise in such a way that i can consume it directly ..
  • ayyaz
    in websockets to get tick by tick we are required to pass some token which is related instrument like 738561 for ACC 5633 for RELIANCE
  • ayyaz
    please let me know how to i get these token for rest of the symbol
  • sujith
    @ayyaz,
    You can get all the instrument tokens in the instrument csv dump. For more information, check out documentation.
  • Devang_b
    @ayyaz would like to know if you found a solution for your query? I am looking for something similar, would be a great help if you could guide on the same.
  • Devang_b
    Devang_b edited July 2022
    @sujith Would love to hear from you too, if there's any update on this
  • sujith
    @Devang_b, You can read the documentation linked above.
Sign In or Register to comment.