Hi @RahulDeshpande ,@Tredhull_Imran
Please check the below issue. I have update dhanhq to 2.0.1
i am running below code and getting the error. subscribed data api.
call_list = ["NIFTY 21 NOV 24000 CALL", "NIFTY 21 NOV 24000 PUT"]
while True:
current_time = datetime.datetime.now().time()
ltp_data = tsl.get_ltp_data(names = call_list)
print(ltp_data)
ce_ltp = ltp_data['NIFTY 21 NOV 24000 CALL']
pe_ltp = ltp_data['NIFTY 21 NOV 24000 PUT']
atm_combined_premium = ce_ltp + pe_ltp
print(current_time, atm_combined_premium)
time.sleep(5)
Error:
C:\python3.8\python.exe "C:/Dhan/8. Session8- 2nd Live Algo/8. Session 8 Dhan_Tradehull_V2/1.2 combined premium.py"
-----Logged into Dhan-----
reading existing file all_instrument 2024-11-17.csv
Got the instrument file
Traceback (most recent call last):
File "C:/Dhan/8. Session8- 2nd Live Algo/8. Session 8 Dhan_Tradehull_V2/1.2 combined premium.py", line 33, in <module>
ce_ltp = ltp_data['NIFTY 21 NOV 24000 CALL']
KeyError: 'NIFTY 21 NOV 24000 CALL'
{}
Please help me sir.
type or paste code here
Hi
@Tradehull_Imran
Data API subscribe kiya hai fir bhi error aa raha hai. Balance aa raha hai
Jab tak error solve nahi hota tab tak aage kuch nahi kar pa rahe hai
Request to you ki Data API fir se subscribe kar na pade us se pahele folowing error solve kado
available_balance 261211.84
MOTHERSON
If using all scalar values, you must pass an index
Traceback (most recent call last):
File “C:\Algo Practice\Api Upgrade\Dhan_Tradehull_V2.py”, line 298, 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
[0] > c:\algo practice\api upgrade\new setup.py(39)()
→ for stock_name in watchlist:
Request you to solve error as soon as possible
To hum aage ke liye badh sake aur strategy ke liye kam kar sake
Thank you
for me the error still remain even after downgrading to dhanhq 1.3.3
Hi Imran,
Please find the attached watchlist screenshot. It is still, LTP is not updating in this
hi @Kalpeshh_Patel
You can use your code during market hours… perhaps API is not sending you the data that’s why you are receiving this error.
Hi @Tradehull_Imran ,
I am doing with the video you have shared but not getting LTP in this.
Please find the attached screenshot for your reference.
Hi @Abhinav_Patil
It seems you are working with python 3.1.3, do use python-3.8.0
Since Twisted-20.3.0-cp38-cp38-win_amd64.whl is for 3.8 version specifically, that is why you are facing “not supported on platform”
Hi @Himansshu_Joshi
Trailing is added in upcoming todo videos.
Hi @Minakshi_Kuila
Dhan_websocket is a hard method to fetch LTP.
now we can fetch LTP easily using Dhan_Tradehull_V2.py
See : Learn Algo Trading with Python | Codes | Youtube Series - #631 by Tradehull_Imran
Hi @Kalpeshh_Patel
{‘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’}}
This is the main error, and due to this we are not able to get historical data.
check if you token is correct, not expired and it has active subscription for historical data
Hi @Minakshi_Kuila
Apply point no 2
Hi @Kalpeshh_Patel
The token value seems to be incorrect, Do try the code in tomorrows market, and let me know if working
If its still stuck I will send you a updated file for Historical data
Hi @ddeogharkar
Can you confirm if the data is received for
SILVER DEC FUT
GOLD APR FUT
SILVERM APR FUT
ALUMINI DEC FUT
COPPER DEC FUT
SILVERMIC APR FUT
GOLDM DEC FUT
and it failed only for
CRUDEOIL APR FUT
If it has failed only for CRUDEOIL APR FUT, then apply point 4 from below link
Hi
Thanks
But during the market times also shows error
Hi @Kalpeshh_Patel
You may check the token issue.
If it works you will get data even in off market hours.
Hi
Which token should I use
Trading API or Data API
Although I tried with both API but not work