Historical Data More then 100 days

Shaileshkumar
Hello everyone...
I am facing issues while I am trying to retrieve data over 100days for intraday (5min).
why it is not allowing to read historical data over 100 days?

is there any way to read more than 100days data using single code ?
  • Shaileshkumar
    I am getting error while downloading nifty and bank nifty Data as
    "error in dowloading NIFTY", could you advise on how to resolve it >
  • SRIJAN
    Paste your code where you fetch historical data.
  • rakeshr
    "error in dowloading NIFTY"
    There is no error/exception as such from Historical data API. You need to paste here the complete error message along with the requested input params.
  • Shaileshkumar


    def get_hist_data(name, segment, delta, interval, continuous, oi):
    to_date = datetime.datetime.now().date()
    from_date = to_date - datetime.timedelta(days = delta)
    zrd_name = segment + ":" + name
    instrument_token = kite.ltp([zrd_name])[zrd_name]['instrument_token']
    data = kite.historical_data(instrument_token, from_date, to_date, interval, continuous= continuous, oi= oi)
    #data = kite.historical_data(instrument_token, from_date,'6-1-2021', interval, continuous= continuous, oi= oi)
    df = pd.DataFrame(data)
    return df


    watchlist = ["AARTIIND","ABBOTINDIA","ABFRL","ACC","ADANIENT","ADANIPORTS","ALKEM","AMARAJABAT","AMBUJACEM","APLLTD","APOLLOHOSP","APOLLOTYRE","ASHOKLEY","ASIANPAINT","ASTRAL","ATUL","AUBANK","AUROPHARMA","AXISBANK","BAJAJAUTO","BAJAJFINSV","BAJFINANCE","BALKRISIND","BANDHANBNK","BANKBARODA","BANKNIFTY","BATAINDIA","BEL","BERGEPAINT","BHARATFORG","BHARTIARTL","BHEL","BIOCON","BOSCHLTD","BPCL","BRITANNIA","BSOFT","CADILAHC","CANBK","CANFINHOME","CHAMBLFERT","CHOLAFIN","CIPLA","COALINDIA","COFORGE","COLPAL","CONCOR","COROMANDEL","CROMPTON","CUB","CUMMINSIND","DABUR","DALBHARAT","DEEPAKNTR","DELTACORP","DIVISLAB","DIXON","DLF","DRREDDY","EICHERMOT","ESCORTS","EXIDEIND","FEDERALBNK","FINNIFTY","FSL","GAIL","GLENMARK","GMRINFRA","GODREJCP","GODREJPROP","GRANULES","GRASIM","GSPL","GUJGASLTD","HAL","HAVELLS","HCLTECH","HDFC","HDFCAMC","HDFCBANK","HDFCLIFE","HEROMOTOCO","HINDALCO","HINDPETRO","HINDUNILVR","IBULHSGFIN","ICICIBANK","ICICIGI","ICICIPRULI","IDEA","IDFCFIRSTB","IEX","IGL","INDHOTEL","INDIACEM","INDIAMART","INDIGO","INDUSINDBK","INDUSTOWER","INFY","IOC","IPCALAB","IRCTC","ITC","JINDALSTEL","JKCEMENT","JSWSTEEL","JUBLFOOD","KOTAKBANK","L&TFH","LALPATHLAB","LAURUSLABS","LICHSGFIN","LT","LTI","LTTS","LUPIN","M&M","M&MFIN","MANAPPURAM","MARICO","MARUTI","MCDOWELL-N","MCX","METROPOLIS","MFSL","MGL","MINDTREE","MOTHERSUMI","MPHASIS","MRF","MUTHOOTFIN","NAM-INDIA","NATIONALUM","NAUKRI","NAVINFLUOR","NESTLEIND","NIFTY","NMDC","NTPC","OBEROIRLTY","OFSS","ONGC","PAGEIND","PEL","PERSISTENT","PETRONET","PFC","PFIZER","PIDILITIND","PIIND","PNB","POLYCAB","POWERGRID","PVR","RAMCOCEM","RBLBANK","RECLTD","RELIANCE","SAIL","SBICARD","SBILIFE","SBIN","SHREECEM","SIEMENS","SRF","SRTRANSFIN","STAR","SUNPHARMA","SUNTV","SYNGENE","TATACHEM","TATACONSUM","TATAMOTORS","TATAPOWER","TATASTEEL","TCS","TECHM","TITAN","TORNTPHARM","TORNTPOWER","TRENT","TVSMOTOR","UBL","ULTRACEMCO","UPL","VEDL","VOLTAS","WHIRLPOOL","WIPRO","ZEEL"]
    for name in watchlist:

    try:
    df = get_hist_data(name = name, segment = 'NSE', delta = 30 , interval = 'minute' , continuous = False, oi = False)
    except Exception as e:
    print(f"error in dowloading {name}")
    continue


    path = r'D:\Kite_Connect_API\historical_data\newdata' + "\\" + name + '.csv'
    df.to_csv(path)
    print(f"{name} {watchlist.index(name) + 1} scripts downloaded from {len(watchlist)} scripts")
  • SRIJAN
    You are trying to get historical data for a item "NIFTY" in your watchlist. Which is invalid,the correct symbol is "NIFTY 50".
  • Shaileshkumar
    what about bank nifty ?
  • SRIJAN
    SRIJAN edited January 2022
    You can get trading symbols for every instrument from the instruments dump.
Sign In or Register to comment.