Hi @Tradehull_Imran ,
Awaiting for the response…
Hi @Akshay_Bawane ,
Tagging @Dhan for the same.
Hi @Vasili_Prasad ,
On high level, currently i do not think such option is available.
Hi @Vasili_Prasad ,
Tty to get the more days data from dhan api,
Run the below code in cmd
pip show Dhan-TradeHull
Go to Location of the file and make the changes in Dhan_Tradehull file get_start_date() function.
start_date = df.iloc[-2]['timestamp']
# change -2 to -10
start_date = df.iloc[-10]['timestamp']
Once changes has done confirm you are getting the index data for more number of days and retry.
Very Good Afternoon Sir
I have searched the file ‘Dhan_Tradehull’
I could not get result for ‘start_date’
There is ‘Start_time’
For Your Information and further guidance sir.
VBR Prasad
@Tradehull I want to scan the Sensex options to get suitable CALL, PUT levels in Sensex based on my strategy, but I am not been able to get intraday data of Sensex Options. What changes should I made to the code in order to get proper data. @Tradehull_Imran sir Could you help me on this ?
My Code is:-
watchlist = ['SENSEX']
trade_info = {'Direction': 'Buy', 'Level': 80100}
traded_watchlist = []
while True:
live_pnl = tsl.get_live_pnl()
current_time = datetime.datetime.now().time()
if current_time < datetime.time(9, 15):
print("Market is not open yet")
time.sleep(5)
continue
for option in watchlist:
time.sleep(0.2)
print(f"Processing: {option}")
chart_5 = tsl.get_intraday_data(
tradingsymbol=option, exchange='BSE', timeframe=5)
complete_chart_5 = chart_5.iloc[-1]
pdb.set_trace()
Error is as follows:-
Hi Aarush
- use tsl.get_historical_data instead of tsl.get_intraday_data
- for “SENSEX” exchange should be exchange=“INDEX”
Hi @Qaisar , Thanks for your reply, but I want to retrieve the Intraday Data of Sensex, which is not possible with .get_historical_data(). Is there any other method to get intraday data for the same.
plz tell me to check whether excel file is updating or not do we need to subscribe to data api because data api which are free are only for order placement and using mtm pl etc and to fetch live data or historical data we need to subscribe data api. am i correct sir. plz reply
@Hardik
I am still waiting for response on this. Can you please guide me how can I calculate margin requirement using programing for option strategies.
Mainly for sold options when implementing vertical spreads or delta neutral.
Please guide me at earliest as possible.
Thanks!
Getting this error code during trying to get historical and intra day data. Please help
previous_hist_data = tsl.get_historical_data(‘ACC’,‘NSE’,20)
DataFrame constructor not properly called!
Traceback (most recent call last):
File “C:\Users\com\AppData\Local\Programs\Python\Python38\lib\cmd.py”, line 214, in onecmd
func = getattr(self, ‘do_’ + cmd)
AttributeError: ‘Pdb’ object has no attribute ‘do_previous_hist_data’
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “D:\Dhan\3. Session3 - Codebase\3. Session3 - Codebase\Dhan codebase\Dhan_Tradehull.py”, line 222, in get_historical_data
df = pd.DataFrame(ohlc[‘data’])
File “C:\Users\com\AppData\Local\Programs\Python\Python38\lib\site-packages\pandas\core\frame.py”, line 817, in init
raise ValueError(“DataFrame constructor not properly called!”)
ValueError: DataFrame constructor not properly called!
(Pdb++) intraday_hist_data = tsl.get_intraday_data(‘ACC’,‘NSE’,1)
intraday_minute_data() missing 2 required positional arguments: ‘from_date’ and ‘to_date’
Traceback (most recent call last):
File “C:\Users\com\AppData\Local\Programs\Python\Python38\lib\cmd.py”, line 214, in onecmd
func = getattr(self, ‘do_’ + cmd)
AttributeError: ‘Pdb’ object has no attribute ‘do_intraday_hist_data’
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “D:\Dhan\3. Session3 - Codebase\3. Session3 - Codebase\Dhan codebase\Dhan_Tradehull.py”, line 253, in get_intraday_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’
(Pdb++) intraday_hist_data
(Pdb++)
Hi @Aarush_Choubey ,
You can fetch historical data and slice data for today. Refer the below code.
data = tsl.get_historical_data('TCS', 'NSE', '1')
today_data = data[pd.to_datetime(data['timestamp']).dt.date == pd.Timestamp.today().date()]
Hi @mangesh_utane ,
Yes you need to subscribe to Data API’s. Follow below steps to Subscribe for Data API:
- Go to Profile Section
- Select “Dhan HQ Trading API”
- Switch to Data API tab
- Click Subscribe
- Revoke the access token and try
Once you have active subscription you will be able to fetch historical and live data.
Hi @kanhaji ,
Yes you need to subscribe to data api to fetch live data or historical data.
Hi @SITA_RAM ,
- Open Command Prompt: Press Win, type cmd, and press Enter.
- Install Dhan-Tradehull: Run
pip install Dhan-Tradehull - Confirm the installation by running
pip show Dhan-Tradehull
Thank you once again @Tradehull_Imran sir.




