@Tradehull_Imran Sir,
exception got in ce_pe_option_df ‘<’ not supported between instances of ‘int’ and ‘str’
while running the code
atm_ce_name, atm_pe_name, strike = tsl.ATM_Strike_Selection(nifty_FnO_stocks, “30-01-2025”)
Hi @Arun_Rawat
use below code
CE_symbol_name, PE_symbol_name, strike_price = tsl.ATM_Strike_Selection(Underlying='ACC', Expiry=0)
- Expiry (int): The expiry to select.
- 0 - Current week/month (depending on expiry type)
- 1 - Next week/month (depending on expiry type)
- and so on for subsequent weeks/months.
Also, do post all queries on this thread: Learn Algo Trading with Python | Codes | Youtube Series
This helps me keep track of questions and ensures other traders benefit as well, as they might be facing similar issues.
Ok, Sir I’ll check and update you.
Regards,
Arun
this works. Thanks Imran
Tried everything as given in Youtube & given here. It’s not working.
ce_strike, pe_strike, strike = tsl.ATM_Strike_Selection(Underlying = ‘NIFTY’, Expiry = 0 )
Above give following error
Codebase Version 2.8 : Solved - Strike Selection Issue
-----Logged into Dhan-----
reading existing file all_instrument 2025-04-10.csv
Got the instrument file
exception got in ce_pe_option_df ‘NIFTY’
CE_symbol_name, PE_symbol_name, strike_price = tsl.ATM_Strike_Selection(Underlying=‘ACC’, Expiry=0)
Above statement gives same following error
Codebase Version 2.8 : Solved - Strike Selection Issue
-----Logged into Dhan-----
reading existing file all_instrument 2025-04-10.csv
Got the instrument file
exception got in ce_pe_option_df ‘ACC’
–Return–
[0] > ←[33;01mg:\pythonsam\sam_v2_get_historical_data.py←[00m(←[36;01m46←[00m)()->None
Q1) Will it works when Market is Closed.
Q2) Please share link where all above funtions used Syntax with Parameters can be checked. Tried finding it on Github but failed.
Also do you have any documentation, where we know, that following thing works only when market is open and following when it works when closed.
cause when market is open we don’t get time to check everything.
Thanks in advance.
This is the Code:
import pdb
import time
import datetime
import traceback
from Dhan_Tradehull import Tradehull
import pandas as pd
from pprint import pprint
import talib
client_code = “”
token_id = “”
tsl = Tradehull(client_code,token_id)
pdb.set_trace()
chart = tsl.get_historical_data(tradingsymbol = “NIFTY”, exchange=“INDEX”, timeframe=“5”)
ce_name, pe_name, strike = tsl.ATM_Strike_Selection(Underlying=‘NIFTY’, Expiry=0)
ce_name, pe_name, ce_OTM_price, pe_OTM_price = tsl.OTM_Strike_Selection(Underlying=‘NIFTY’, Expiry=0, OTM_count=3)
ce_name, pe_name, ce_ITM_price, pe_ITM_price = tsl.ITM_Strike_Selection(Underlying=‘NIFTY’, Expiry=0, ITM_count=5)
Getting this error.
Codebase Version 3
-----Logged into Dhan-----
reading existing file all_instrument 2025-04-20.csv
Got the instrument file
[0] > d:\stocks\06_1st live algo\1st live algo\how to use updated codebase.py(17)()
→ chart = tsl.get_historical_data(tradingsymbol = “NIFTY”, exchange=“INDEX”, timeframe=“5”)
(Pdb++) ce_name, pe_name, strike = tsl.ATM_Strike_Selection(Underlying=‘NIFTY’, Expiry=0)
Exception at getting Expiry list as {‘status’: ‘failure’, ‘remarks’: ‘Expecting value: line 1 column 1 (char 0)’, ‘data’: ‘’}
Unable to find the correct Expiry for NIFTY
*** TypeError: cannot unpack non-iterable NoneType object
(Pdb++)
Please guide. Thank you.
The code seems to be right, do try running the code during market open days.