ltp endpoint working slowly

pratiks
    fut_symbol_list = df['tradingsymbol'].tolist()
'''
['AARTIIND21SEPFUT', 'ABFRL21SEPFUT', 'ACC21SEPFUT', 'ADANIENT21SEPFUT', 'ADANIPORTS21SEPFUT', 'ALKEM21SEPFUT', 'AMARAJABAT21SEPFUT', 'AMBUJACEM21SEPFUT', 'APLLTD21SEPFUT', 'APOLLOHOSP21SEPFUT', 'APOLLOTYRE21SEPFUT', 'ASHOKLEY21SEPFUT', 'ASIANPAINT21SEPFUT',
'ASTRAL21SEPFUT', 'AUBANK21SEPFUT', 'AUROPHARMA21SEPFUT', 'AXISBANK21SEPFUT', 'BAJAJ-AUTO21SEPFUT', 'BAJAJFINSV21SEPFUT', 'BAJFINANCE21SEPFUT', 'BALKRISIND21SEPFUT', 'BANDHANBNK21SEPFUT', 'BANKBARODA21SEPFUT', 'BATAINDIA21SEPFUT', 'BEL21SEPFUT', 'BERGEPAINT21SEPFUT', 'BHARATFORG21SEPFUT', 'BHARTIARTL21SEPFUT', 'BHEL21SEPFUT', 'BIOCON21SEPFUT', 'BOSCHLTD21SEPFUT', 'BPCL21SEPFUT', 'BRITANNIA21SEPFUT', 'CADILAHC21SEPFUT', 'CANBK21SEPFUT', 'CANFINHOME21SEPFUT', 'CHOLAFIN21SEPFUT', 'CIPLA21SEPFUT', 'COALINDIA21SEPFUT', 'COFORGE21SEPFUT', 'COLPAL21SEPFUT', 'CONCOR21SEPFUT', 'COROMANDEL21SEPFUT', 'CUB21SEPFUT', 'CUMMINSIND21SEPFUT', 'DABUR21SEPFUT', 'DEEPAKNTR21SEPFUT', 'DIVISLAB21SEPFUT', 'DIXON21SEPFUT', 'DLF21SEPFUT', 'DRREDDY21SEPFUT', 'EICHERMOT21SEPFUT', 'ESCORTS21SEPFUT', 'EXIDEIND21SEPFUT', 'FEDERALBNK21SEPFUT', 'GAIL21SEPFUT', 'GLENMARK21SEPFUT', 'GMRINFRA21SEPFUT', 'GODREJCP21SEPFUT', 'GODREJPROP21SEPFUT', 'GRANULES21SEPFUT', 'GRASIM21SEPFUT', 'GUJGASLTD21SEPFUT', 'HAL21SEPFUT', 'HAVELLS21SEPFUT', 'HCLTECH21SEPFUT', 'HDFC21SEPFUT', 'HDFCAMC21SEPFUT', 'HDFCBANK21SEPFUT', 'HDFCLIFE21SEPFUT',
'HEROMOTOCO21SEPFUT', 'HINDALCO21SEPFUT', 'HINDPETRO21SEPFUT', 'HINDUNILVR21SEPFUT', 'IBULHSGFIN21SEPFUT', 'ICICIBANK21SEPFUT', 'ICICIGI21SEPFUT', 'ICICIPRULI21SEPFUT', 'IDEA21SEPFUT',
'IDFCFIRSTB21SEPFUT', 'IEX21SEPFUT',
'IGL21SEPFUT', 'INDHOTEL21SEPFUT', 'INDIAMART21SEPFUT', 'INDIGO21SEPFUT',
'INDUSINDBK21SEPFUT', 'INDUSTOWER21SEPFUT', 'INFY21SEPFUT', 'IOC21SEPFUT', 'IPCALAB21SEPFUT', 'IRCTC21SEPFUT',
'ITC21SEPFUT', 'JINDALSTEL21SEPFUT',
'JSWSTEEL21SEPFUT', 'JUBLFOOD21SEPFUT', 'KOTAKBANK21SEPFUT', 'L&TFH21SEPFUT', 'LALPATHLAB21SEPFUT', 'LICHSGFIN21SEPFUT', 'LT21SEPFUT', 'LTI21SEPFUT', 'LTTS21SEPFUT', 'LUPIN21SEPFUT', 'M&M21SEPFUT', 'M&MFIN21SEPFUT', 'MANAPPURAM21SEPFUT', 'MARICO21SEPFUT', 'MARUTI21SEPFUT', 'MCDOWELL-N21SEPFUT',
'MCX21SEPFUT', 'METROPOLIS21SEPFUT',
'MFSL21SEPFUT', 'MGL21SEPFUT', 'MINDTREE21SEPFUT', 'MOTHERSUMI21SEPFUT', 'MPHASIS21SEPFUT', 'MRF21SEPFUT', 'MUTHOOTFIN21SEPFUT', 'MUTHOOTFIN30SEP2128OCT21FUT', 'NAM-INDIA21SEPFUT', 'NATIONALUM21SEPFUT', 'NAUKRI21SEPFUT', 'NAVINFLUOR21SEPFUT', 'NESTLEIND21SEPFUT', 'NMDC21SEPFUT', 'NTPC21SEPFUT',
'OFSS21SEPFUT', 'ONGC21SEPFUT', 'PAGEIND21SEPFUT', 'PEL21SEPFUT', 'PETRONET21SEPFUT', 'PFC21SEPFUT', 'PFIZER21SEPFUT', 'PIDILITIND21SEPFUT', 'PIIND21SEPFUT', 'PNB21SEPFUT', 'POLYCAB21SEPFUT', 'POWERGRID21SEPFUT', 'PVR21SEPFUT', 'RAMCOCEM21SEPFUT', 'RBLBANK21SEPFUT', 'RECLTD21SEPFUT', 'RELIANCE21SEPFUT', 'SAIL21SEPFUT', 'SBILIFE21SEPFUT', 'SBIN21SEPFUT', 'SHREECEM21SEPFUT', 'SIEMENS21SEPFUT', 'SRF21SEPFUT', 'SRTRANSFIN21SEPFUT', 'STAR21SEPFUT', 'SUNPHARMA21SEPFUT', 'SUNTV21SEPFUT', 'SYNGENE21SEPFUT', 'TATACHEM21SEPFUT', 'TATACONSUM21SEPFUT', 'TATAMOTORS21SEPFUT', 'TATAPOWER21SEPFUT', 'TATASTEEL21SEPFUT', 'TCS21SEPFUT', 'TECHM21SEPFUT', 'TITAN21SEPFUT', 'TORNTPHARM21SEPFUT', 'TORNTPOWER21SEPFUT', 'TRENT21SEPFUT', 'TVSMOTOR21SEPFUT', 'UBL21SEPFUT', 'ULTRACEMCO21SEPFUT', 'UPL21SEPFUT', 'VEDL21SEPFUT', 'VOLTAS21SEPFUT', 'WIPRO21SEPFUT', 'ZEEL21SEPFUT']
'''
# print(fut_symbol_list)
future_string = f"https://api.kite.trade/quote/ltp?api_key={api_key}&access_token={access_token}&"
for symbol in fut_symbol_list:
temp = symbol.replace("&", "%26")
symbol = temp
future_string = future_string + "i=NFO:" + symbol + "&"
future_string = future_string[:-1]
r = requests.get(future_string)
data = (r.json())
dic = data['data']

normally this code takes hardly 1 second to run, but today it is taking 21 seconds.
this happens once or twice every week,

why sometimes api work slowly?
Tagged:
Sign In or Register to comment.