hello sir, here it is
https://www.youtube.com/watch?v=5qw8GLFxu98
hello sir, here it is
https://www.youtube.com/watch?v=5qw8GLFxu98
Hi @siddhesh22
yes the observation is correct, however the conditions were created it was not used in entry descisions.
Hi @vinothsaravanan ,
Refer this code for the LTP -
ltp = tsl.get_ltp_data('NIFTY 12 MAY 24400 CALL')
If still error occurs , share your code to verify it .
@vinothsaravanan
Also mostly I think the code for calling LTP would be correct .. but as error tells.. the data was empty
[ERROR] NIFTY: LTP data empty for NIFTY 12 MAY 24400 CALL — skipping.
so mostly I think we did not get data, because the rate limits were hit.
Here to solve it, we can retry the ltp call, if it fails.
example
try:
quote_data = tsl.get_quote_data(names=['NIFTY 12 MAY 24400 CALL'])['NIFTY 12 MAY 24400 CALL']
except Exception as e:
time.sleep(1)
quote_data = tsl.get_quote_data(names=['NIFTY 12 MAY 24400 CALL'])['NIFTY 12 MAY 24400 CALL']
Hi @Tradehull_Imran sir,
Please refer below my code.
CE_symbol_name, PE_symbol_name, strike = tsl.ATM_Strike_Selection(Underlying=name, Expiry=0)
if not CE_symbol_name:
print(f"[ERROR] {name}: Invalid symbol returned from OTM selection — skipping.")
continue
lot_size = tsl.get_lot_size(tradingsymbol=CE_symbol_name)
data = tsl.get_ltp_data(names=[CE_symbol_name])
if not data:
print(f"[ERROR] {name}: LTP data empty for {CE_symbol_name} — skipping.")
continue
ltp = data.get(CE_symbol_name)
ltp = list(data.values())[0]
margin_required = ltp * lot_size
fund_required = available_balance >= margin_required
The ta-lib issue is solved.
Do use this updated installation files link
Also since python version was also upgraded, so do remove python 3.8.0 and its launcher from control panel.. and then redo the installation for the link.
Let me know if installation works out for you.
@vinothsaravanan
The code is good.
If you wish to retry if the ltp was not received, use below code
try:
data = tsl.get_ltp_data(names=[CE_symbol_name])
except Exception as e:
print(e)
time.sleep(1)
try:
data = tsl.get_ltp_data(names=[CE_symbol_name])
ltp = data.get(CE_symbol_name)
except Exception as e:
continue
also also do use print(e).. this way we will be also able to see the actual error.
Hi @Tradehull_Imran sir,
Again getting the same error .
-----SUCCESSFULLY LOGGED INTO DHAN-----
Exception at calling ltp as {‘status’: ‘failure’, ‘remarks’: {‘error_code’: None, ‘error_type’: None, ‘error_message’: None}, ‘data’: ‘’}
Exception at calling ltp as {‘status’: ‘failure’, ‘remarks’: {‘error_code’: None, ‘error_type’: None, ‘error_message’: None}, ‘data’: ‘’}
Exception at calling ltp as {‘status’: ‘failure’, ‘remarks’: {‘error_code’: None, ‘error_type’: None, ‘error_message’: None}, ‘data’: ‘’}
Exception at calling ltp as {‘status’: ‘failure’, ‘remarks’: {‘error_code’: None, ‘error_type’: None, ‘error_message’: None}, ‘data’: ‘’}
Hi @vinothsaravanan
We did not get any data from the api
This may happen sometimes when the market is over.
try to reset the token, and run again.
Hi @Tradehull_Imran sir,
I resetted the totp, Still issue is repeating. I am facing this error during market hours also.
Okey.. We will check on the api call.
Hi @Tradehull_Imran sir,
When you print individually, it can fetch the data. Error occurs when this code runs
(Pdb++) CE_symbol_name, PE_symbol_name, strike = tsl.ATM_Strike_Selection(Underlying=‘NIFTY’, Expiry=0)
(Pdb++)
(Pdb++) CE_symbol_name
‘NIFTY 12 MAY 24350 CALL’
(Pdb++) data = tsl.get_ltp_data(names=[CE_symbol_name])
(Pdb++) data
{‘NIFTY 12 MAY 24350 CALL’: 180.9}
(Pdb++) ltp = data.get(CE_symbol_name)
(Pdb++) ltp
180.9
(Pdb++) lot_size = tsl.get_lot_size(tradingsymbol=CE_symbol_name)
(Pdb++) lot_size
65
(Pdb++) margin_required = ltp * lot_size
(Pdb++) margin_required
11758.5
Can you send a screenshot of the screen.. Run it in normal run mode.. Let error come. And send the complete screenshot
C:\Users\Administrator\Desktop\2. Session2 - Installation>py “newce.py”
Codebase Version 2.7 : Solved - Option Chain Issue
Codebase Version 3.2.0
-----Trying to login using (PIN + TOTP)-----
reading existing file all_instrument 2026-05-07.csv
Already logged in for today, so reusing the token
-----SUCCESSFULLY LOGGED INTO DHAN-----
starting while Loop
Scanning NIFTY at 23:33:44.779788
[DEBUG] First rows of NIFTY data:
open high low close volume timestamp open_interest
4364 24398.50 24423.35 24317.70 24318.25 20440391.0 2026-05-07 09:15:00+05:30 0.0
4365 24318.25 24337.05 24300.70 24335.35 9577300.0 2026-05-07 09:20:00+05:30 0.0
4366 24334.90 24346.75 24312.20 24334.15 8385678.0 2026-05-07 09:25:00+05:30 0.0
4367 24334.80 24367.95 24320.15 24356.70 7324435.0 2026-05-07 09:30:00+05:30 0.0
4368 24356.15 24372.55 24346.90 24354.15 6043728.0 2026-05-07 09:35:00+05:30 0.0
Exception at calling ltp as {‘status’: ‘failure’, ‘remarks’: {‘error_code’: None, ‘error_type’: None, ‘error_message’: None}, ‘data’: ‘’}
[ERROR] NIFTY: LTP data empty for NIFTY 12 MAY 24350 CALL — skipping.
starting while Loop
Scanning NIFTY at 23:33:49.545195
[DEBUG] First rows of NIFTY data:
open high low close volume timestamp open_interest
4364 24398.50 24423.35 24317.70 24318.25 20440391.0 2026-05-07 09:15:00+05:30 0.0
4365 24318.25 24337.05 24300.70 24335.35 9577300.0 2026-05-07 09:20:00+05:30 0.0
4366 24334.90 24346.75 24312.20 24334.15 8385678.0 2026-05-07 09:25:00+05:30 0.0
4367 24334.80 24367.95 24320.15 24356.70 7324435.0 2026-05-07 09:30:00+05:30 0.0
4368 24356.15 24372.55 24346.90 24354.15 6043728.0 2026-05-07 09:35:00+05:30 0.0
Exception at calling ltp as {‘status’: ‘failure’, ‘remarks’: {‘error_code’: None, ‘error_type’: None, ‘error_message’: None}, ‘data’: ‘’}
[ERROR] NIFTY: LTP data empty for NIFTY 12 MAY 24350 CALL — skipping.
starting while Loop
Scanning NIFTY at 23:33:54.298391
[DEBUG] First rows of NIFTY data:
open high low close volume timestamp open_interest
4364 24398.50 24423.35 24317.70 24318.25 20440391.0 2026-05-07 09:15:00+05:30 0.0
4365 24318.25 24337.05 24300.70 24335.35 9577300.0 2026-05-07 09:20:00+05:30 0.0
4366 24334.90 24346.75 24312.20 24334.15 8385678.0 2026-05-07 09:25:00+05:30 0.0
4367 24334.80 24367.95 24320.15 24356.70 7324435.0 2026-05-07 09:30:00+05:30 0.0
4368 24356.15 24372.55 24346.90 24354.15 6043728.0 2026-05-07 09:35:00+05:30 0.0
Exception at calling ltp as {‘status’: ‘failure’, ‘remarks’: {‘error_code’: None, ‘error_type’: None, ‘error_message’: None}, ‘data’: ‘’}
[ERROR] NIFTY: LTP data empty for NIFTY 12 MAY 24350 CALL — skipping.
starting while Loop
Scanning NIFTY at 23:33:59.032367
[DEBUG] First rows of NIFTY data:
open high low close volume timestamp open_interest
4364 24398.50 24423.35 24317.70 24318.25 20440391.0 2026-05-07 09:15:00+05:30 0.0
4365 24318.25 24337.05 24300.70 24335.35 9577300.0 2026-05-07 09:20:00+05:30 0.0
4366 24334.90 24346.75 24312.20 24334.15 8385678.0 2026-05-07 09:25:00+05:30 0.0
4367 24334.80 24367.95 24320.15 24356.70 7324435.0 2026-05-07 09:30:00+05:30 0.0
4368 24356.15 24372.55 24346.90 24354.15 6043728.0 2026-05-07 09:35:00+05:30 0.0
Exception at calling ltp as {‘status’: ‘failure’, ‘remarks’: {‘error_code’: None, ‘error_type’: None, ‘error_message’: None}, ‘data’: ‘’}
[ERROR] NIFTY: LTP data empty for NIFTY 12 MAY 24350 CALL — skipping.
starting while Loop
Scanning NIFTY at 23:34:03.890267
[DEBUG] First rows of NIFTY data:
open high low close volume timestamp open_interest
4364 24398.50 24423.35 24317.70 24318.25 20440391.0 2026-05-07 09:15:00+05:30 0.0
4365 24318.25 24337.05 24300.70 24335.35 9577300.0 2026-05-07 09:20:00+05:30 0.0
4366 24334.90 24346.75 24312.20 24334.15 8385678.0 2026-05-07 09:25:00+05:30 0.0
4367 24334.80 24367.95 24320.15 24356.70 7324435.0 2026-05-07 09:30:00+05:30 0.0
4368 24356.15 24372.55 24346.90 24354.15 6043728.0 2026-05-07 09:35:00+05:30 0.0
Exception at calling ltp as {‘status’: ‘failure’, ‘remarks’: {‘error_code’: None, ‘error_type’: None, ‘error_message’: None}, ‘data’: ‘’}
[ERROR] NIFTY: LTP data empty for NIFTY 12 MAY 24350 CALL — skipping.
starting while Loop
Scanning NIFTY at 23:34:08.606998
[DEBUG] First rows of NIFTY data:
open high low close volume timestamp open_interest
4364 24398.50 24423.35 24317.70 24318.25 20440391.0 2026-05-07 09:15:00+05:30 0.0
4365 24318.25 24337.05 24300.70 24335.35 9577300.0 2026-05-07 09:20:00+05:30 0.0
4366 24334.90 24346.75 24312.20 24334.15 8385678.0 2026-05-07 09:25:00+05:30 0.0
4367 24334.80 24367.95 24320.15 24356.70 7324435.0 2026-05-07 09:30:00+05:30 0.0
4368 24356.15 24372.55 24346.90 24354.15 6043728.0 2026-05-07 09:35:00+05:30 0.0
Exception at calling ltp as {‘status’: ‘failure’, ‘remarks’: {‘error_code’: None, ‘error_type’: None, ‘error_message’: None}, ‘data’: ‘’}
[ERROR] NIFTY: LTP data empty for NIFTY 12 MAY 24350 CALL — skipping.
starting while Loop
Scanning NIFTY at 23:34:13.408562
[DEBUG] First rows of NIFTY data:
open high low close volume timestamp open_interest
4364 24398.50 24423.35 24317.70 24318.25 20440391.0 2026-05-07 09:15:00+05:30 0.0
4365 24318.25 24337.05 24300.70 24335.35 9577300.0 2026-05-07 09:20:00+05:30 0.0
4366 24334.90 24346.75 24312.20 24334.15 8385678.0 2026-05-07 09:25:00+05:30 0.0
4367 24334.80 24367.95 24320.15 24356.70 7324435.0 2026-05-07 09:30:00+05:30 0.0
4368 24356.15 24372.55 24346.90 24354.15 6043728.0 2026-05-07 09:35:00+05:30 0.0
Exception at calling ltp as {‘status’: ‘failure’, ‘remarks’: {‘error_code’: None, ‘error_type’: None, ‘error_message’: None}, ‘data’: ‘’}
[ERROR] NIFTY: LTP data empty for NIFTY 12 MAY 24350 CALL — skipping.
starting while Loop
Scanning NIFTY at 23:34:18.300353
[DEBUG] First rows of NIFTY data:
open high low close volume timestamp open_interest
4364 24398.50 24423.35 24317.70 24318.25 20440391.0 2026-05-07 09:15:00+05:30 0.0
4365 24318.25 24337.05 24300.70 24335.35 9577300.0 2026-05-07 09:20:00+05:30 0.0
4366 24334.90 24346.75 24312.20 24334.15 8385678.0 2026-05-07 09:25:00+05:30 0.0
4367 24334.80 24367.95 24320.15 24356.70 7324435.0 2026-05-07 09:30:00+05:30 0.0
4368 24356.15 24372.55 24346.90 24354.15 6043728.0 2026-05-07 09:35:00+05:30 0.0
Exception at calling ltp as {‘status’: ‘failure’, ‘remarks’: {‘error_code’: None, ‘error_type’: None, ‘error_message’: None}, ‘data’: ‘’}
[ERROR] NIFTY: LTP data empty for NIFTY 12 MAY 24350 CALL — skipping.
starting while Loop
Can you send the complete code.. And supported files as well..
Do remove your credentials and and confedential info.
Were you able to get ltp data even a single time. or is the issue intermittent.
If we did not get ltp even a single time it may be a codebase version issue. as in code the version is at 3.2.0.
a. Do upgrade the version in this case to 3.3.0
pip install Dhan-Tradehull==3.3.0
b. Also we now don’t need Dhan_Tradehull_V2, so you can remove its import
If the issue is intermitten, so in this case we can just apply except and continue. Code will not break when data is not, and will run fine when data comes fine.
We ran the code files on our end and it ltp seems to be working fine
Hi @Tradehull_Imran Sir,
I have just started watching videos of algos and started working on it. I am a totally beginner in coding and facing attached issue. Please help!
Thanks
Code seems to be correct. can you share the complete code as well. (Do remove credentials)
Also try calling ltp data for a stock.. and see if we can get it
The issue was in token,
below we got data after above 3 steps
Hello @Tradehull_Imran Sir,
I am executing Order_testing.py. I have replaced Client Id and Token with my ID and Token (newly created). Even I have set my DigitalOcean IP in Dhan. I am getting below error:
(venv) root@ubuntu-s-1vcpu-1gb-blr1:~/Desktop/Intsallation Dhan Algo# python3 Order_testing.py
Codebase Version 3.3.0
Attempting authentication using ACCESS TOKEN.
System is fetching the latest instrument file from Dhan
Killed