Hello friends,
I am trading for close to 3 years . I do manual intraday trading only in stocks
Now , I would like to automate my stategy in F&O stocks . I have a ready python code for my strategy
But I dont know how to backtest my strategy in DHAN and execute my strategy
Can someone help me on this . I am struggling to find this for a long time . Thanks in advance
A simple suggestion. If you already have the strategy and want to backtest, have an AI convert it to a pinescript and you can easily backtest in Tradingview. Once you have the results but want to see the python script running then add a dry run and do a Forward test i.e. let it run for 2 weeks which only logs the data of entry and exit. Even to do forward test, you will need to purchase the Data apis at 499/month. Alternatively you can check Tradehull series on Youtube.
1 Like
Hi @Bala2026 ,
We understand that you already have your Python strategy ready and are now looking to backtest and automate it.
Please note that Dhan does not provide a built-in backtesting engine. However, you can achieve backtesting by using the historical data APIs and running your strategy logic on top of that data.
Using Dhan APIs, you can:
• Fetch historical data for active contracts
• Fetch historical data for expired options as well
You can refer to the following documentation for implementation:
https://dhanhq.co/docs/v2/historical-data/
https://dhanhq.co/docs/v2/expired-options-data/