Traceback (most recent call last):
File “/Users/parveenchugh/python/Dhan_Tradehull.py”, line 222, in get_historical_data
df = pd.DataFrame(ohlc[‘data’])
File “/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/pandas/core/frame.py”, line 887, in init
raise ValueError(“DataFrame constructor not properly called!”)
ValueError: DataFrame constructor not properly called!
How did you resolve this Issue?
I am facing the same
Hi @Nikhil_Shenoy @parveen_chugh
As of now there are no issues in historical data
do use the latest codebase : Dhan_Tradehull_V2.py - Google Drive
Also, do post all queries on this thread: Learn Algo Trading with Python | Codes | Youtube Series
This helps me keep track of questions and ensures other traders benefit as well, as they might be facing similar issues.
Getting Error in tsl.get_intraday_data…
ERROR
File “C:\Users\shahs\Downloads\Python\6. Session6- 1st Live Algo\1st live Algo\Dhan_Tradehull.py”, line 253, in get_in
traday_data ohlc = self.Dhan.intraday_minute_data(str(security_id),exchangeSegment,instrument_type)
TypeError: intraday_minute_data() missing 2 required positional arguments: ‘from_date’ and ‘to_date’
CODE ENTERED
watchlist = [‘ACC’, ‘BHEL’, ‘PEL’, ‘TCS’, ‘TITAN’, ‘INFY’]
traded_wathclist =
for stock_name in watchlist:
chart=tsl.get_intraday_data(stock_name, 'NSE', '1')
print(stock_name)
pdb.set_trace()
I TRIED A LOT…
Hi @Sunny_Shah
tsl.get_intraday_data was a old method to get historical data… it gives data only for today, which makes problem if we want to create indicators on it.
Dhanhq was upgraded and now we can use get_historical_data which gives data for last 5 working days.
Retrieve historical or intraday data:
Get Historical Data
- tsl.get_historical_data(tradingsymbol: str, exchange: str, timeframe: str, debug: str = “NO”)
- Arguments:
- tradingsymbol (str): The trading symbol for the instrument you want to fetch data for (e.g., ‘NIFTY’, ‘ACC’).
- exchange (str): The exchange where the instrument is traded (e.g., ‘NSE’, ‘INDEX’).
- timeframe (str): The timeframe for the data. It can be:
- ‘1’ for 1-minute candles
- ‘5’ for 5-minute candles
- ‘15’ for 15-minute candles
- ‘25’ for 25-minute candles
- ‘60’ for 60-minute candles
- ‘DAY’ for daily candles
- debug (optional, str): Set to “YES” to enable detailed API response logging. Default is “NO”.
- Sample Code:
- Arguments:
data = tsl.get_historical_data(tradingsymbol='NIFTY', exchange='INDEX', timeframe="DAY")
data = tsl.get_historical_data(tradingsymbol='ACC', exchange='NSE', timeframe="1")