Tradehull live prices

for sym in [“TRENT”, “RELIANCE”, “BANKNIFTY”, “SENSEX”]:

print(sym)

print(tsl.get_ltp_data(names=\[sym\]))

Problems is sometimes i am getting exception .
TRENT
{‘TRENT’: 3270.8}
RELIANCE
Exception at calling ltp as {‘status’: ‘failure’, ‘remarks’: {‘error_code’: None, ‘error_type’: None, ‘error_message’: None}, ‘data’: ‘’}
{}
BANKNIFTY
{‘BANKNIFTY’: 57779.85}
SENSEX
Exception at calling ltp as {‘status’: ‘failure’, ‘remarks’: {‘error_code’: None, ‘error_type’: None, ‘error_message’: None}, ‘data’: ‘’}
{}

Live Prices: {‘NIFTY’: 23966.5, ‘SENSEX’: 76762.75, ‘CRUDEOIL’: 6603.0, ‘TRENT’: 3271.0}

sometimes I will get correct .

Hi @Gopal_Reddy

The error tells we have received no data from the api. This can happen if we call for ltp more than once in 1 second. since we will be breaching then rate limit for the api
try to use sleep of 1 second.

Also on a sidenote, we can call multiple scripts ltp in one go

example

watchlist   = ["ONGC", "HINDALCO", "SBIN", "RELIANCE", "MAXHEALTH", "SUNPHARMA", "COALINDIA", "EICHERMOT", "ULTRACEMCO", "ETERNAL", "CIPLA", "TATASTEEL", "JSWSTEEL", "INDIGO", "DRREDDY", "TATACONSUM", "HDFCLIFE", "GRASIM", "AXISBANK", "ITC", "M&M", "NTPC", "KOTAKBANK", "WIPRO", "MARUTI", "JIOFIN", "LT", "APOLLOHOSP", "BEL", "BAJAJ-AUTO", "BHARTIARTL", "POWERGRID", "ADANIENT", "SHRIRAMFIN", "BAJAJFINSV", "TRENT", "TMPV", "TECHM", "TCS", "ASIANPAINT", "NESTLEIND", "ICICIBANK", "BAJFINANCE", "ADANIPORTS", "HDFCBANK", "HINDUNILVR", "SBILIFE", "HCLTECH", "TITAN", "INFY"]
quote       = tsl.get_ltp_data(names=watchlist)

Maintainer of the sdk needs to improve error handling, it’s really hard to debug what is the root of the issue.

Exception at calling ltp as {‘status’: ‘failure’, ‘remarks’: {‘error_code’: None, ‘error_type’: None, ‘error_message’: None}, ‘data’: ‘’}

Hi @Hemant_Kumar ,

Refer the code -

client_code = ""
tsl = Tradehull(client_code, mode="pin_totp", pin="", totp_secret="")
ltp_list = ["TRENT", "RELIANCE", "BANKNIFTY", "SENSEX"]
ltp_data = tsl.get_ltp_data(ltp_list)
print(ltp_data)

Output -

Screenshot 2026-06-30 100901

Yeah Thank You sir.

1 Like