Thank you, @RahulDeshpande, and your entire team for your support! We also want to acknowledge @Dhan for going above and beyond to help us—your efforts mean a lot
Hello @Tradehull_Imran Sir, How we can get more months OHLC data for stocks to backtest our algo, please make a video on it or suggest any source from where we can get data affordably to test our algos. Regards
Hi Sir @Tradehull_Imran
please help me in getting live oi data sir
What i have to send inplace of request code
(for request code 17 , i’m getting quote data but not getting oi data)
Sir, What is the input format to get oi data live
(i’m reading entire Dhanfeed Code from 2,3 days continoulsy , still not able to understand sir)
from dhanhq import marketfeed
sub_instruments = [(marketfeed.NSE, “1333”, 17)]
version = “v2” # Mention Version and set to latest version ‘v2’
try:
data = marketfeed.DhanFeed(client_id, access_token, sub_instruments, version)
while True:
data.run_forever()
response = data.get_data()
print(response)
self.cancel_order(entry_order_id) will cancel order if its pending in orderbook (in which case it has not been executed and its pending and not in positionbook)
Yes, we can cancel the stop-limit order when LTP drops below the last updated trigger price. Additionally, we need to immediately send a market order in the reverse transaction type to square off the position. This ensures that the position is exited effectively, simulating a stop-loss market order.
Also note we can only cancel pending orders…
for orders that have been executed… we need to send reverse transaction type order
@Tradehull_Imran How can I retrieve historical data for a specific day in a 5-minute time frame? According to your video, it seems that only 2-3 days of 5-minute data can be fetched. My algorithm requires 5-minute interval data for backtesting, but I don’t have enough data. How should I proceed in this case? Also, why is Dhan charging for historical data access?
Hi Sir,
I need live option chain data for stocks through web socket.
For example: TCS (only for stocks not for indexes)
i need option data(for both ce and pe) @ ATM, 2OTM & 2ITM strikes data.
"
Code…
instruments = [(marketfeed.NSE, “1333”, 17)]
version = “v2”
try:
data = marketfeed.DhanFeed(client_id, access_token, instruments, version)
while True:
data.run_forever()
response = data.get_data()
print(response)
except Exception as e:
print(e)
data.disconnect()
"
Here i’m getting Quote Data bcz of Request Code 17 But In API clearly metioned that(Whenever you subscribe to Quote Data, you also receive Open Interest (OI) data packets which is important for Derivative Contracts.)
I’m not getting oi data sir. Do i need to change input structure. Or else anything need to change.
please help me in getting live oi data for all my stocks sir. I need live oi from 9 to 3 for all my stock options.
PS C:\Users\owner\OneDrive\Business\Algo Trading\Dhan\live-trading-project> & C:/Users/owner/AppData/Local/Programs/Python/Python38/python.exe "c:/Users/owner/OneDrive/Business/Algo Trading/Dhan/live-trading-project/src/backtesting_v4_live_tr.py"
Codebase Version 3
2025-02-14 17:33:18,424 - Dhan.py started system
2025-02-14 17:33:18,424 - STARTED THE PROGRAM
-----Logged into Dhan-----
reading existing file all_instrument 2025-02-14.csv
Got the instrument file
2025-02-14 17:33:26,878 - Error processing GMRINFRA: No expiry date found for GMRINFRA
Traceback (most recent call last):
File "C:\Users\owner\AppData\Local\Programs\Python\Python38\lib\site-packages\Dhan_Tradehull\Dhan_Tradehull.py", line 128, in correct_step_df_creation
raise ValueError(f"No expiry date found for {name}")
ValueError: No expiry date found for GMRINFRA
-----Logged into Dhan-----
reading existing file all_instrument 2025-02-14.csv
Got the instrument file
2025-02-14 17:33:39,445 - [ERROR] Dhan API Login Failed
[ERROR] Dhan API Login Failed
2025-02-14 17:33:39,445 - [ERROR] Strategy stopped due to API authentication failure.
[ERROR] Strategy stopped due to API authentication failure.
PS C:\Users\owner\OneDrive\Business\Algo Trading\Dhan\live-trading-project>