Also how to get monthy and weekly candle live and historical data ?
Hey @Harry
If you are talking about adding stocks based on indices, that is something which is not available right now. Usually users do have their own logic to screen stocks and then subscribe to the data for the same.
yes. I;m on the latest version.
Its failing while getting LTP in ATM_Strike_Selection
ERROR: Exception at calling ltp as {‘status’: ‘failure’, ‘remarks’: {‘error_code’: None, ‘error_type’: None, ‘error_message’: None}, ‘data’: ‘’}
____________________________________________________
FYI… If I run the prog locally, Its working
(Pdb) self.tsl.ATM_Strike_Selection(instrument[“underlying”], 0)
(‘SENSEX 08 JAN 85000 CALL’, ‘SENSEX 08 JAN 85000 PUT’, 85000)
However, Its failing on AWS server. Not sure, what’s the issue. ![]()
@Dhan @Hardik @RahulDeshpande @Pratham_Gada @Shrutika_Poojari
Hi @Harry ,
You can call data of ‘day’ timeframe and resample the data to monthly or weekly data. Refer the below sample code-
def monthly_resample_data(self,df):
'''
this function will return monthly resample data.
resample is the process to combine
'''
try:
logic = {'open':'first','high':'max','low':'min','close':'last','volume':'sum'}
df = df.set_index(df['date'])
resample_data = df.resample('M').agg(logic)
return resample_data
except Exception as e:
print(e)
traceback.print_exc()
def weekly_resample_data(self,df):
try:
"""
this function may have some some ambuiguity in data
"""
logic = {'open':'first','high':'max','low':'min','close':'last','volume':'sum'}
df = df.set_index('date')
df = df.resample('W-FRI', origin= "start").agg(logic)
df = df[df.isna().any(axis=1) == False]
df
return df
except Exception as e:
print(e)
traceback.print_exc()
any update?
@Tradehull_Imran @Hardik
-
Upgrade pip
python -m pip install --upgrade pip -
Install Dhanhq 2.1.0
pip install dhanhq==2.1.0 -
Then install Dhan-Tradehull
pip install Dhan-Tradehull==3.1.2
Let me know if it works.
Usually the program shall work on server as well, without any issues.
Can you share server error screenshot, and some more details to check on it.
Also check if ClientID on server is correct.
@Tradehull_Imran Thank you sir it works.
But there was a minor issue with python version
your installation bat file was ready for 3.0.8 and I am using 3.13.5
@Tradehull_Imran sir I want to trade in MCX with overnight position.
But “NRML” & “CNC” order is not executed only works with “MIS”.
How can I solve it ?
What will be the “trade_type” for overnight postion / cash & carry order in MCX ?
2026-01-13 09:58:22 | PUT for SENSEX JAN FUT bot.py:445
2026-01-13 09:58:22,249 INFO: PUT for SENSEX JAN FUT
2026-01-13 09:58:23,195 ERROR: Exception at calling ltp as {‘status’: ‘failure’, ‘remarks’: {‘error_code’: None, ‘error_type’: None, ‘error_message’: None}, ‘data’: ‘’}
Traceback (most recent call last):
File “/home/ubuntu/zerobot/venv/lib/python3.10/site-packages/Dhan_Tradehull/Dhan_Tradehull.py”, line 247, in get_ltp_data
raise Exception(data)
Exception: {‘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 got in ce_pe_option_df ‘SENSEX’
2026-01-13 09:58:23 | Strike result: (None, None, 0) bot.py:448
2026-01-13 09:58:23,224 INFO: Strike result: (None, None, 0)
2026-01-13 09:58:23 | Invalid strike returned for SENSEX PUT: None bot.py:458
2026-01-13 09:58:23,225 ERROR: Invalid strike returned for SENSEX PUT: None
@Tradehull_Imran @Dhan @Hardik
FYI… I have added static IP and generating the token using TOTP via headless browser in AWS cloud
and also, its working once in a while.
2026-01-13 09:33:49 | Strike result: (‘SENSEX 14 JAN 83700 CALL’, bot.py:448
‘SENSEX 14 JAN 83700 PUT’, 83700)
![]()
Its a serious issue that needs immediate attention from @Dhan
Dear Sir
From today morning I am getting error in ce_name, pe_name, ce_strike, pe_strike = tsl.OTM_Strike_Selection(‘SENSEX’, 0, OTM_count=1) or ce_name, pe_name, strike = tsl.ATM_Strike_Selection(‘SENSEX’, 0).
I am using Dhanhq 2.1.0 and Dhan-Tradehull 3.1.2.
ERROR:exception got in ce_pe_option_df Unable to find the ATM strike for the SENSEX
Screenshot attached
Kindly solve the issue.
thank you!
I’m facing an issue with placing CNC orders through the Dhan API, despite it being listed as a valid product_type option in the official DhanHQ API documentation.
- The
dhan_hq.pylibrary includes CNC as a product type option - API calls with
product_type="CNC"are failing/not executing properly
I apologize for reporting this issue, but would appreciate if the team could investigate whether there’s a backend restriction or if I’m missing something in the implementation. This is affecting my ability to place delivery-based orders(MCX) programmatically.
I have also shared some screenshot at my earlier post
@RahulDeshpande @Hardik @PravinJ @Tradehull_Imran
Hi @DEBJYOTI_GHOSE
yes your analysis is correct, we are also checking same issue.
we will update soon on this one.
-
Can you confirm if you have check ClientID if its correct. (Sometimes this issue can arise due to wrong clientid)
-
Also is this issue intermittent, or has the Ltp call not worked at all on aws.
-
Can you just run a basic test and see which api calls are working and which are not.. Ideally if some calls are working then the LTP call shall also work,
use this code to place order NRML MCX orders
orderid = tsl.order_placement(tradingsymbol='GOLDPETAL JAN FUT', exchange='MCX', quantity=1, price=0, trigger_price=0,order_type='MARKET', transaction_type='BUY', trade_type='margin')
@Tradehull_Imran thank you sir, it works properly
Delete the ‘Dependencies’ folder and then check , it worked for me. I think sensex expiry has changed from 15/01/2026 to 14/01/2026 today, this might be the reason. Deleting the folder or “all_instrument 2026-01-13.csv” file should solve the issue.






