Continuing the discussion from Option chain is not fetching:
Hello @Tradehull_Imran sir,
I am getting an error in the code below. When I run it with a single or individual stock code, it works correctly. However, when I run the code with a watchlist, it gives me an error for every second name.
Please help me to fix this error.
Code:
import pdb
from Dhan_Tradehull import Tradehull
import pandas as pd
client_code = “-”
token_id = “-”
tsl = Tradehull(client_code,token_id)
watchlist = [‘UNIONBANK’, ‘VEDL’, ‘WIPRO’]
for names in watchlist:
atm, optchain = tsl.get_option_chain(Underlying=names, exchange=“NFO”, expiry=0, num_strikes=10)
print(f"\n{names}\n next\n")
Error Message:
PS E:\API_APP> & C:/Users/prite/AppData/Local/Programs/Python/Python38/python.exe “e:/API_APP/striks finding.py”
Codebase Version 3
-----Logged into Dhan-----
reading existing file all_instrument 2025-04-07.csv
Got the instrument file
WIPRO
next
PS E:\API_APP> & C:/Users/prite/AppData/Local/Programs/Python/Python38/python.exe “e:/API_APP/striks finding.py”
Codebase Version 3
-----Logged into Dhan-----
reading existing file all_instrument 2025-04-07.csv
Got the instrument file
WIPRO
next
Getting Error at Option Chain as {‘status’: ‘failure’, ‘remarks’: {‘error_code’: None, ‘error_type’: None, ‘error_message’: None}, ‘data’: {‘data’: {‘805’: ‘Too many requests. Further requests may result in the user being blocked.’}, ‘status’: ‘failed’}}
Traceback (most recent call last):
File “e:/API_APP/striks finding.py”, line 20, in
atm, optchain = tsl.get_option_chain(Underlying=names, exchange=“NFO”, expiry=0, num_strikes=10)
TypeError: cannot unpack non-iterable NoneType object
PS E:\API_APP> & C:/Users/prite/AppData/Local/Programs/Python/Python38/python.exe “e:/API_APP/striks finding.py”
Codebase Version 3
-----Logged into Dhan-----
reading existing file all_instrument 2025-04-07.csv
Got the instrument file
VEDL
next
PS E:\API_APP> & C:/Users/prite/AppData/Local/Programs/Python/Python38/python.exe “e:/API_APP/striks finding.py”
Codebase Version 3
-----Logged into Dhan-----
reading existing file all_instrument 2025-04-07.csv
Got the instrument file
VEDL
next
Getting Error at Option Chain as {‘status’: ‘failure’, ‘remarks’: {‘error_code’: None, ‘error_type’: None, ‘error_message’: None}, ‘data’: {‘data’: {‘805’: ‘Too many requests. Further requests may result in the user being blocked.’}, ‘status’: ‘failed’}}
Traceback (most recent call last):
File “e:/API_APP/striks finding.py”, line 20, in
atm, optchain = tsl.get_option_chain(Underlying=names, exchange=“NFO”, expiry=0, num_strikes=10)
TypeError: cannot unpack non-iterable NoneType object
PS E:\API_APP> & C:/Users/prite/AppData/Local/Programs/Python/Python38/python.exe “e:/API_APP/striks finding.py”
Codebase Version 3
-----Logged into Dhan-----
reading existing file all_instrument 2025-04-07.csv
Got the instrument file
UNIONBANK
next
PS E:\API_APP> & C:/Users/prite/AppData/Local/Programs/Python/Python38/python.exe “e:/API_APP/striks finding.py”
Codebase Version 3
-----Logged into Dhan-----
reading existing file all_instrument 2025-04-07.csv
Got the instrument file
UNIONBANK
next
Getting Error at Option Chain as {‘status’: ‘failure’, ‘remarks’: {‘error_code’: None, ‘error_type’: None, ‘error_message’: None}, ‘data’: {‘data’: {‘805’: ‘Too many requests. Further requests may result in the user being blocked.’}, ‘status’: ‘failed’}}
Traceback (most recent call last):
File “e:/API_APP/striks finding.py”, line 14, in
atm, optchain = tsl.get_option_chain(Underlying=names, exchange=“NFO”, expiry=0, num_strikes=10)
TypeError: cannot unpack non-iterable NoneType objectPreformatted text