Market cap for all the nse token

Hsadikot
Hi,

Is there any way to download market quote information for NSE stocks using zerodha. I have referred the documentation here:

https://kite.trade/docs/connect/v3/market-quotes/

But I am not able to find the same for the python client:

https://kite.trade/docs/pykiteconnect/v3/#kiteconnect.KiteConnect

  • sujith
    You can use this API.
  • Hsadikot
    @sujith

    I tried the quotes api and PFA the code:





    from kiteconnect import KiteConnect
    import os


    cwd = os.chdir("C:\\Users\\Administrator\\Desktop\\Zerodha")

    #generate trading session
    access_token = open("access_token.txt",'r').read()
    key_secret = open("api_key.txt",'r').read().split()
    kite = KiteConnect(api_key=key_secret[0])
    kite.set_access_token(access_token)

    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']# Fetch quote details
    for instrument in kite.instruments():
    quote = kite.quote("NSE:x")



    The issue being that after running the code it gives me an empty quote dictionary as shown:



  • sujith
    sujith edited December 2020
    You can run pykiteconnect with debug logs on and check what exactly you are sending.
    If you don't understand then please post the complete stack trace here by removing the app tokens, we will check and get back to you.
  • Hsadikot
    Can you guide me on how to do that?

    I read the discussion here: https://kite.trade/forum/discussion/7225/enable-logging

    This does not cater to my needs as i am using a python client
  • Hsadikot
    @sujith,

    As suggested I tried to run the pykiteconnect with debug logs as shown:


    from kiteconnect import KiteConnect
    import os
    import logging
    cwd = os.chdir("C:\\Users\\Administrator\\Desktop\\Zerodha")

    #generate trading session
    access_token = open("access_token.txt",'r').read()
    key_secret = open("api_key.txt",'r').read().split()
    kite = KiteConnect(api_key=key_secret[0])
    kite.set_access_token(access_token)
    logging.basicConfig(level=logging.DEBUG)

    #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']# Fetch quote details

    try:
    #quote = kite.quote("NSE:TATACHEM")
    quote = kite.quote("NSE:x")

    logging.info("Order placed. ID is: {}".format(quote))
    except Exception as e:
    logging.info("Order placement failed: {}".format(e))




    The issue is as shown in screenshot it does not print any logs the code runs without error giving a blank dictionary.


    If I run for singular element like this:

    quote = kite.quote("NSE:INFY")




    It gives me a dictionary giving the quotes of INFY as shown:



  • rakeshr
    quote = kite.quote("NSE:x")
    If you want to fetch quote for a list of instruments, you just need to send a list of instruments with their respective exchange. You don't have to double mention exchange "NSE:x" here. It should be:
    x=['NSE:ARVIND', 'NSE:CIPLA', 'NSE:TATAPOWER', 
    'NSE:HEROMOTOCO', 'NSE:ZEEL', 'NSE:LT', 'NSE:BEL', 'NSE:COALINDIA', 'NSE:SPARC', ....]
    quoteData=kite.quote(x)
  • Hsadikot
    @rakeshr

    Thanks, This solves the issue but how to run the pykiteconnect with debug logs?

    I tried to run as shown above but it does not yield the logs
  • sujith
    sujith edited December 2020
    @Hsadikot,
    You can check out pykiteconnect docs here to know more.
Sign In or Register to comment.