DhanHQ trading API historical_daily_data()

I am trying to get historical data with code

expity = 0

eqtHistoricalData = dhan.historical_daily_data(‘TCS’,‘NSE_EQ’,‘EQUITY’,‘2022-01-08’,‘2022-02-08’,expity) #self, security_id, exchange_segment, instrument_type, from_date, to_date, expiry_code=0
print(eqtHistoricalData)

And I’m getting the error as:

{‘status’: ‘failure’, ‘remarks’: {‘error_code’: ‘DH-905’, ‘error_type’: ‘Input_Exception’, ‘error_message’: ‘Missing required fields, bad values for parameters etc.’}, ‘data’: {‘errorType’: ‘Input_Exception’, ‘errorCode’: ‘DH-905’, ‘errorMessage’: ‘Missing required fields, bad values for parameters etc.’}}

Hello @guru9143

If you check the code, it requires security_ID instead of symbol name, which has been updated in V2.0.0. Make sure that the same parameter is passed for you to successfully fetch the data.

Dear Hardik,
First I was trying to automate using the code show in youtube video of your Dhan platform. But now I am using the code posted on github “GitHub - dhan-oss/DhanHQ-py: The official Python client for communicating with the Dhan API.” and now when I run the script orders.py I am getting error can you plz guide for this

Hello @guru9143

Can you share the python code snippet that you are running here?

Hey Hardik,

Thanks for asking! I’ve actually managed to get the code working on my own now. I’ve implemented the necessary changes, and it’s up and running.

I’m interested in building a basic automated trading strategy to get a better grasp of how DhanHQ V2 operates. Could you recommend a simple example—like a moving average crossover or similar—just to understand the flow of integrating data retrieval, strategy logic, and executing trades? This would help me feel confident in developing my own strategies later.

Any insights on implementing this or structuring the flow with DhanHQ V2 would be hugely appreciated.
Thanks again!

I m also getting the same error