@Tradehull_Imran sir I am getting below error
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-----
reading existing file all_instrument 2024-11-18.csv
Got the instrument file
NIFTY 23450.15
BANKNIFTY 50348.1
CRUDEOIL 5655
CRUDEOIL 16 DEC 5950 CALL 115.4
CRUDEOIL 16 DEC 5950 PUT 322
RELIANCE 1255.8
NIFTY 28 NOV 24000 CALL 46.05
NIFTY 28 NOV 24000 PUT 531.2
If using all scalar values, you must pass an index
Traceback (most recent call last):
File "c:\Users\Subhajit Panja\Documents\Algorithim_HQ\Api Upgrade\Dhan_Tradehull_V2.py", line 259, in get_historical_data
df = pd.DataFrame(ohlc['data'])
File "C:\Users\Subhajit Panja\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\Subhajit Panja\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\Subhajit Panja\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\Subhajit Panja\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:\Users\Subhajit Panja\Documents\Algorithim_HQ\Api Upgrade\Dhan_Tradehull_V2.py", line 259, in get_historical_data
df = pd.DataFrame(ohlc['data'])
File "C:\Users\Subhajit Panja\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\Subhajit Panja\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\Subhajit Panja\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\Subhajit Panja\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
Traceback (most recent call last):
File "c:/Users/Subhajit Panja/Documents/Algorithim_HQ/Api Upgrade/0. How to use upgraded files.py", line 39, in <module>
options_chart['ema_30'] = talib.EMA(options_chart['close'], timeperiod=30)
TypeError: 'NoneType' object is not subscriptable
here is my file below
# pip install --upgrade dhanhq
import pdb
import time
import datetime
import traceback
from Dhan_Tradehull_V2 import Tradehull
import pandas as pd
from pprint import pprint
import talib
# ---------------for dhan login ----------------
client_code =
token_id =
tsl = Tradehull(client_code,token_id)
ltp_data = tsl.get_ltp_data(names = [
'BANKNIFTY',
'NIFTY' ,
'CRUDEOIL',
'RELIANCE',
'NIFTY 28 NOV 24000 CALL',
'NIFTY 28 NOV 24000 PUT',
'CRUDEOIL 16 DEC 5950 CALL',
'CRUDEOIL 16 DEC 5950 PUT'
])
for script_name,ltp in ltp_data.items():
print(script_name, ltp)
data = tsl.get_historical_data(tradingsymbol = 'BANKNIFTY',exchange = 'INDEX',timeframe="DAY")
data = tsl.get_historical_data(tradingsymbol = 'ACC' ,exchange = 'NSE' ,timeframe="15")
options_chart = tsl.get_historical_data(tradingsymbol = 'NIFTY 28 NOV 24000 CALL' ,exchange = 'NFO' ,timeframe="15")
options_chart['ema_30'] = talib.EMA(options_chart['close'], timeperiod=30)
data = tsl.get_historical_data(tradingsymbol = 'CRUDEOIL DEC FUT' ,exchange = 'MCX' ,timeframe="15")
data = tsl.get_historical_data(tradingsymbol = 'CRUDEOIL 16 DEC 5950 CALL' ,exchange = 'MCX' ,timeframe="15")
print (data)
ce_strike, pe_strike, strike = tsl.ATM_Strike_Selection(Underlying ='CRUDEOIL',Expiry ='16-12-2024')
ce_strike, pe_strike, ce_OTM_price, pe_OTM_price = tsl.OTM_Strike_Selection(Underlying ='CRUDEOIL',Expiry ='16-12-2024',OTM_count=5)
ce_strike, pe_strike, ce_ITM_price, pe_ITM_price = tsl.ITM_Strike_Selection(Underlying = 'CRUDEOIL',Expiry = '16-12-2024',ITM_count=1)
@Tradehull_Imran Sir I think problem is still same for me
excel file name still old date I have tried with other file also