Hi @Tradehull_Imran, as per limit order request, trigger price should be blank and price should be filled with target price. i hope this will work tomorrow.
Please check once… rest all my problems has been solved and algo is working fine. Thanks for your guidance
Hi sir,
Thanks for the quick reply.
I apply as you said. But there is a big difference in the values i’m getting and the actual indicator.
Can you please tell me how to fix this. And may i ask you is there any way to apply the Dhan OI indicator on chart in python.
@Tradehull_Imran sir
When I updated my file I am getting above things
PS C:\Users\Subhajit Panja\Documents\Algorithim_HQ> & "c:/Users/Subhajit Panja/Documents/Algorithim_HQ/.venv/Scripts/python.exe" "c:/Users/Subhajit Panja/Documents/Algorithim_HQ/Api Upgrade/0. How to use upgraded files.py"
-----Logged into Dhan-----
This BOT Is Picking New File From Dhan
Got the instrument file
NIFTY 07 NOV 24000 CALL
NIFTY 07 NOV 24000 PUT
single positional indexer is out-of-bounds
Traceback (most recent call last):
File "c:\Users\Subhajit Panja\Documents\Algorithim_HQ\Api Upgrade\Dhan_Tradehull_V2.py", line 244, in get_historical_data
security_id = self.instrument_df[((self.instrument_df['SEM_TRADING_SYMBOL']==tradingsymbol)|(self.instrument_df['SEM_CUSTOM_SYMBOL']==tradingsymbol))&(self.instrument_df['SEM_EXM_EXCH_ID']==instrument_exchange[exchange])].iloc[-1]['SEM_SMST_SECURITY_ID']
File "C:\Users\Subhajit Panja\AppData\Local\Programs\Python\Python38\lib\site-packages\pandas\core\indexing.py", line 1103, in __getitem__
return self._getitem_axis(maybe_callable, axis=axis)
File "C:\Users\Subhajit Panja\AppData\Local\Programs\Python\Python38\lib\site-packages\pandas\core\indexing.py", line 1656, in _getitem_axis
self._validate_integer(key, axis)
File "C:\Users\Subhajit Panja\AppData\Local\Programs\Python\Python38\lib\site-packages\pandas\core\indexing.py", line 1589, in _validate_integer
raise IndexError("single positional indexer is out-of-bounds")
IndexError: single positional indexer is out-of-bounds
Traceback (most recent call last):
File "c:/Users/Subhajit Panja/Documents/Algorithim_HQ/Api Upgrade/0. How to use upgraded files.py", line 25, in <module>
options_chart['ema_30'] = talib.EMA(options_chart['close'], timeperiod=30)
TypeError: 'NoneType' object is not subscriptable
PS C:\Users\Subhajit Panja\Documents\Algorithim_HQ>
working perfectly @Tradehull_Imran sir I got my mistake
this is because of below code
NIFTY 7 NOV 24000 CALL
but @Tradehull_Imran Sir could not find below file anywhere
all_instrument 2024-11-14.csv
-----Logged into Dhan-----
reading existing file all_instrument 2024-11-14.csv
Got the instrument file
NIFTY 23532.7
BANKNIFTY 50179.55
CRUDEOIL 5789
CRUDEOIL 15 NOV 5950 CALL 6
CRUDEOIL 15 NOV 5950 PUT 165
RELIANCE 1267.6
NIFTY 14 NOV 24000 CALL 0.05
NIFTY 14 NOV 24000 PUT 467.05
Hi
@Tradehull_Imran
I want to import index and future data in strategy
How do I get LTP
Can you explain or give me a code for
If Nifty is positive/negative in daily timeframe and
Its close candle rsi is <40 or >60
Its close in 1H timeframe is above/below SMA
Thank you
Hi Imran, I am having issue in websocket excel file. I have changed only option expiry date in the script name and then run the code , LTP received is showing in the CMD prompt but it is not updating in the excel. Please find the attached screenshot for your reference and help me with this. …
HI @Tradehull_Imran ,
I am facing below error while running the script
reading existing file all_instrument 2024-11-15.csv
Got the instrument file
SILVER DEC FUT
GOLD APR FUT
SILVERM APR FUT
ALUMINI DEC FUT
COPPER DEC FUT
SILVERMIC APR FUT
GOLDM DEC FUT
CRUDEOIL APR FUT
If using all scalar values, you must pass an index
Traceback (most recent call last):
File “C:\Automation\AlgoTrading2024\livealgodhan\Dhan_Tradehull_V2.py”, line 259, in get_historical_data
df = pd.DataFrame(ohlc[‘data’])
File “C:\Users\asus\AppData\Local\Programs\Python\Python38\lib\site-packages\pandas\core\frame.py”, line 709, in init
mgr = dict_to_mgr(data, index, columns, dtype=dtype, copy=copy, typ=manager)
File “C:\Users\asus\AppData\Local\Programs\Python\Python38\lib\site-packages\pandas\core\internals\construction.py”, line 481, in dict_to_mgr
return arrays_to_mgr(arrays, columns, index, dtype=dtype, typ=typ, consolidate=copy)
File “C:\Users\asus\AppData\Local\Programs\Python\Python38\lib\site-packages\pandas\core\internals\construction.py”, line 115, in arrays_to_mgr
index = _extract_index(arrays)
File “C:\Users\asus\AppData\Local\Programs\Python\Python38\lib\site-packages\pandas\core\internals\construction.py”, line 645, in _extract_index
raise ValueError(“If using all scalar values, you must pass an index”)
ValueError: If using all scalar values, you must pass an index
If using all scalar values, you must pass an index
Traceback (most recent call last):
File “C:\Automation\AlgoTrading2024\livealgodhan\Dhan_Tradehull_V2.py”, line 259, in get_historical_data
df = pd.DataFrame(ohlc[‘data’])
File “C:\Users\asus\AppData\Local\Programs\Python\Python38\lib\site-packages\pandas\core\frame.py”, line 709, in init
mgr = dict_to_mgr(data, index, columns, dtype=dtype, copy=copy, typ=manager)
File “C:\Users\asus\AppData\Local\Programs\Python\Python38\lib\site-packages\pandas\core\internals\construction.py”, line 481, in dict_to_mgr
return arrays_to_mgr(arrays, columns, index, dtype=dtype, typ=typ, consolidate=copy)
File “C:\Users\asus\AppData\Local\Programs\Python\Python38\lib\site-packages\pandas\core\internals\construction.py”, line 115, in arrays_to_mgr
index = _extract_index(arrays)
File “C:\Users\asus\AppData\Local\Programs\Python\Python38\lib\site-packages\pandas\core\internals\construction.py”, line 645, in _extract_index
raise ValueError(“If using all scalar values, you must pass an index”)
ValueError: If using all scalar values, you must pass an index
hi, sir…
what is the code for exiting the trade after 5 mins from the executed trade.
For example. on 5 mins candle,
lets say 10 am candle open price , i place a buy order and
on same candle close price , i should exit that trade with the help of coding.
Please guide me, sir…
Hi @thakurmhn
Rate limits are required for the api.
you may try increasing sleep time and manage the historical data exceptions using try except
Example :
for stock_name in watchlist:
time.sleep(1)
print(stock_name)
chart_1 = tsl.get_historical_data(tradingsymbol = stock_name,exchange = 'NSE',timeframe="1")
chart_5 = tsl.get_historical_data(tradingsymbol = stock_name,exchange = 'NSE',timeframe="5") # this call has been updated to get_historical_data call,
if (chart_1 is None) or (chart_5 is None) :
continue
if (chart_1.empty) or (chart_5.empty):
continue
# Conditions that are on 1 minute timeframe
chart_1['rsi'] = talib.RSI(chart_1['close'], timeperiod=14) #pandas
cc_1 = chart_1.iloc[-2] #pandas completed candle of 1 min timeframe
uptrend = cc_1['rsi'] > 50
downtrend = cc_1['rsi'] < 49
Also use this updated Dhan_Tradehull_V2 file
-
Do send Supertrend data-frames you have received (upload alteast last 50 candles to excel and share drive link)
-
As of now dhanhq does not support OI data in Historical data, however you can call OI data on tick level
Live Market Feed - DhanHQ Ver 2.0 / API Document
So now the data is working fine.
For the instrument file most-probably it may be a observation issue, without instrument file many of codebase function would not work.
So @Tradehull_Imran Sir
what do you suggests in this scenario …
should I try again in live market to generate proper excel file ?
Hi @Subhajitpanja
Yes
Hi @rahulcse56
Yes its the same as you would do in order panel
Code is just a exact equivalent of it.
Hi @rohit2312
The ltp data is received, Do send watchlist screenshot,
Now we don’t need WebSocket process to fetch LTP, there is now a simpler method in Dhan_Tradehull_V2
we will deprecate WebSocket in near future for Dhan_Tradehull_V2
sir can u help me make code for order management. like once order executed , put sl and trail at certain point (if in profit of 20point modify sl to ctc) ,and the target hit of certain point like 40 exit position through market or limit order @Tradehull_Imran
Sir do you have any course for Algo Trading where I can learn Personally from you. @Tradehull_Imran
Hi Sir,
I am executing Dhan_webshocket.py and LTP is not getting updates.
xlsx is opening and getting after nothing is getting update on that.
C:\Dhan\3. Session3 - Codebase\3. Session3 - Codebase\Dhan codebase>py Dhan_websocket.py
Reading existing file all_instrument 2024-11-16.csv
Watchlist changed. Reconnecting the feed…
Disconnected from WebSocket feed.
Authorizing…
Authorization successful!
Hi @RahulDeshpande , @Tradehull_Imran
Please reply
as per link of video given in this channel i have updated pip dhanhq and update the version of dhanhq to 2.0.0
Can you provide required files for upgraded dhanhq which is in latest video
I am trying to make my algo
But there is something wrong and something missing
I have also subscribed data api
I have tried both version old and new but in both of them have same errors
I have tried with both token id - Trading API and Data API
But error remain same
1 Dhan_websocket me price update nahi ho raha as per old version
2 Meri create ki gayi file main available balance show kar raha hai but aage error aa rahi hai jo main niche de raha hun
So which file should I need to uninstall and reinstall
C:\Algo Practice\2nd live Algo>py “RSI ALGO 5min.py”
-----Logged into Dhan-----
reading existing file all_instrument 2024-11-16.csv
Got the instrument file
If using all scalar values, you must pass an index
Traceback (most recent call last):
File “C:\Algo Practice\2nd live Algo\Dhan_Tradehull_V2.py”, line 316, in get_intraday_data
df = pd.DataFrame(ohlc[‘data’])
File “C:\Users\kalpe\AppData\Local\Programs\Python\Python38\lib\site-packages\pandas\core\frame.py”, line 709, in init
mgr = dict_to_mgr(data, index, columns, dtype=dtype, copy=copy, typ=manager)
File “C:\Users\kalpe\AppData\Local\Programs\Python\Python38\lib\site-packages\pandas\core\internals\construction.py”, line 481, in dict_to_mgr
return arrays_to_mgr(arrays, columns, index, dtype=dtype, typ=typ, consolidate=copy)
File “C:\Users\kalpe\AppData\Local\Programs\Python\Python38\lib\site-packages\pandas\core\internals\construction.py”, line 115, in arrays_to_mgr
index = _extract_index(arrays)
File “C:\Users\kalpe\AppData\Local\Programs\Python\Python38\lib\site-packages\pandas\core\internals\construction.py”, line 645, in _extract_index
raise ValueError(“If using all scalar values, you must pass an index”)
ValueError: If using all scalar values, you must pass an index
{‘status’: ‘failure’, ‘remarks’: {‘error_code’: ‘DH-906’, ‘error_type’: ‘Order_Error’, ‘error_message’: ‘Invalid Token’}, ‘data’: {‘errorType’: ‘Order_Error’, ‘errorCode’: ‘DH-906’, ‘errorMessage’: ‘Invalid Token’}}
Error at Gettting balance as ‘availabelBalance’
MOTHERSON
{‘status’: ‘failure’, ‘remarks’: {‘error_code’: ‘DH-906’, ‘error_type’: ‘Order_Error’, ‘error_message’: ‘Invalid Token’}, ‘data’: {‘errorType’: ‘Order_Error’, ‘errorCode’: ‘DH-906’, ‘errorMessage’: ‘Invalid Token’}}
Traceback (most recent call last):
File “RSI ALGO 5min.py”, line 55, in
chart_1[‘rsi’] = talib.RSI(chart_1[‘close’], timeperiod=14)
TypeError: ‘NoneType’ object is not subscriptable
3 Muje RSI, MA aur supertrend ki jarurat hai uske liye maine try kiya lekin kuch problem ho raha hai niche diya hai uska formula sahi hai?
chart_15[‘real’] = talib.MA(chart_15(‘real’), timeperiod=20, matype=0)
cc_low_great_ma = cc_15[‘ma’]<candle_low
cc_high_low_ma = cc_15[‘ma’]>candle_high
4 Muje sare INDEX and NFO dono ki watchlist lana hai aur daily main vo kitna + / - hai vo values bhi lani hai so uske liye formula chahiye
So can you please help me for that
Waiting for reply
Thank you