yes, now its working fine.
@Tradehull_Imran, Why am I getting the error below in the running market? What is the solution to this?
Hi @Kanha_Meher ,
Do send the whole code with complete screenshot of the error.
let us know what tool are you using to for below chart…
not able to find it in https://stocksrin.com/
Hi @Nagi_Reddy_Vanga ,
In Sublime,
- select all code by Ctrl + A
- go to the bottom-right corner and click on “Tab Size.” Then select “Convert Indentation to Tabs,” save the file
- re-run it.
Imran sir, thank you very much for your help. I did as you mentioned, now it is showing the following error.
https://www.icharts.in/ it was this by mistake copied different site
Hi, @Tradehull_Imran. Maine super trend 1hr cross strategy banayi chat GPT see help lekr. after market hours ise run kiya to output show horha hai. kya ye sahi show kar rha hai
2. Question - Dhan Terminal per order failed, excuted, pending kuch bhi nhi aaya. wo kab aaega jab mene ise run kiya tha reliance already supertrend green ho chuka tha…
3 Question- Data api- Trading api aur historical api dono me se konsa use krna hai… abtk to main Trading api se sab karha hu… historical kab use karna hai…
Code me kuch update karna hai to bataeye. video 5 pr hu me
Thank you
# pip install --upgrade dhanhq
import pdb
import datetime
import traceback
from Dhan_Tradehull_V2 import Tradehull
import pandas as pd
from pprint import pprint
import talib
import pandas_ta as pta
import pandas_ta as ta
import time
# ---------------for dhan login ----------------
client_code = "1102956290"
token_id = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJkaGFuIiwicGFydG5lcklkIjoiIiwiZXhwIjoxNzM5MjY4MjU1LCJ0b2tlbkNvbnN1bWVyVHlwZSI6IlNFTEYiLCJ3ZWJob29rVXJsIjoiIiwiZGhhbkNsaWVudElkIjoiMTEwMjk1NTI5MCJ9.HUlnkT4mah-Cr6Z4J-qXAWFOsr6Bf3bHDayZ7smxU8_Q2AVZM1JF_YDV9ZouBVwgZ9yLO7NhhvQVwuUo6VO2xg"
tsl = Tradehull(client_code, token_id)
# Define the stock symbol and timeframe
stock_symbol = "RELIANCE" # Replace with the desired stock symbol
timeframe = "60"
while True:
try:
stock_chart = tsl.get_historical_data(
tradingsymbol=stock_symbol, exchange="NSE", timeframe=timeframe)
# Check if stock_chart is not None
if stock_chart is None:
print(f"Error: Failed to retrieve data for {stock_symbol}")
continue # Skip to the next iteration of the loop
# Calculate Supertrend
indi = ta.supertrend(stock_chart['high'], stock_chart['low'], stock_chart['close'], 10, 3)
stock_chart = pd.concat([stock_chart, indi], axis=1, join='inner')
# Get the latest candle
latest_candle = stock_chart.iloc[-1]
# Check for Buy Entry Condition: Close price above Supertrend
buy_signal = latest_candle['close'] > latest_candle['SUPERT_10_3.0']
# Check for Exit Condition: Close price below Supertrend
exit_signal = latest_candle['close'] < latest_candle['SUPERT_10_3.0']
print(f"Stock: {stock_symbol}")
print(f"Buy Signal: {buy_signal}")
print(f"Exit Signal: {exit_signal}")
print("-----------------------------------")
# **Important:**
# 1. Implement order placement logic here based on buy_signal and exit_signal.
# 2. Handle order execution and position management.
# 3. Consider adding risk management rules (e.g., stop-loss).
except Exception as e:
print(f"Error: {e}")
traceback.print_exc()
# Introduce a delay to avoid excessive API calls
time.sleep(60)
Output
Microsoft Windows [Version 10.0.22631.4602]
(c) Microsoft Corporation. All rights reserved.
C:\Dhan 2.0\1. Api Upgrade>py "1. Easy way to get LTP.py"
Codebase Version 2.4 : Solved - Option Chain
-----Logged into Dhan-----
reading existing file all_instrument 2025-01-17.csv
Got the instrument file
Stock: RELIANCE
Buy Signal: True
Exit Signal: False
-----------------------------------
Stock: RELIANCE
Buy Signal: True
Exit Signal: False
-----------------------------------
Stock: RELIANCE
Buy Signal: True
Exit Signal: False
-----------------------------------
Stock: RELIANCE
Buy Signal: True
Exit Signal: False
-----------------------------------
Stock: RELIANCE
Buy Signal: True
Exit Signal: False
-----------------------------------
Stock: RELIANCE
Buy Signal: True
Exit Signal: False
-----------------------------------
Stock: RELIANCE
Buy Signal: True
Exit Signal: False
-----------------------------------
Stock: RELIANCE
Buy Signal: True
Exit Signal: False
-----------------------------------
Stock: RELIANCE
Buy Signal: True
Exit Signal: False
-----------------------------------
Stock: RELIANCE
Buy Signal: True
Exit Signal: False
-----------------------------------
Hello @Tradehull_Imran , thanks for the informative video series. I am not able to get the intraday day. The code is as follows:
while True:
for stock_name in watchlist:
chart = tsl.get_intraday_data(stock_name,'NSE',1)
chart['rsi'] = talib.RSI(chart['close'], timeperiod=14)
The error is as follows:
D:\Dhan lecture content\6. Session6- 1st Live Algo\01. Working files>py “Dhan_codebase usage.py”
Codebase Version 2.6 : Solved - Pnl Issue
-----Logged into Dhan-----
reading existing file all_instrument 2025-01-18.csv
Got the instrument file
{‘status’: ‘failure’, ‘remarks’: {‘error_code’: ‘DH-907’, ‘error_type’: ‘Data_Error’, ‘error_message’: ‘System is unable to fetch data due to incorrect parameters or no data present’}, ‘data’: {‘errorType’: ‘Data_Error’, ‘errorCode’: ‘DH-907’, ‘errorMessage’: ‘System is unable to fetch data due to incorrect parameters or no data present’}}
Traceback (most recent call last):
File “D:\Dhan lecture content\6. Session6- 1st Live Algo\01. Working files\Dhan_Tradehull_V2.py”, line 563, in get_intraday_data
raise Exception(ohlc)
Exception: {‘status’: ‘failure’, ‘remarks’: {‘error_code’: ‘DH-907’, ‘error_type’: ‘Data_Error’, ‘error_message’: ‘System is unable to fetch data due to incorrect parameters or no data present’}, ‘data’: {‘errorType’: ‘Data_Error’, ‘errorCode’: ‘DH-907’, ‘errorMessage’: ‘System is unable to fetch data due to incorrect parameters or no data present’}}
Traceback (most recent call last):
File “Dhan_codebase usage.py”, line 23, in
chart[‘rsi’] = talib.RSI(chart[‘close’], timeperiod=14)
TypeError: ‘NoneType’ object is not subscriptable
I read on some of the posts within this topic with this kind of error and you suggested to use historical data instead of intraday data. I am getting another error in that case. The code is as follows:
while True:
for stock_name in watchlist:
chart = tsl.get_historical_data(stock_name,'NSE',1)
chart['rsi'] = talib.RSI(chart['close'], timeperiod=14)
The error is as follows:
D:\Dhan lecture content\6. Session6- 1st Live Algo\01. Working files>py “Dhan_codebase usage.py”
Codebase Version 2.6 : Solved - Pnl Issue
-----Logged into Dhan-----
reading existing file all_instrument 2025-01-18.csv
Got the instrument file
Exception in Getting OHLC data as ‘int’ object has no attribute ‘upper’
Traceback (most recent call last):
File “Dhan_codebase usage.py”, line 23, in
chart[‘rsi’] = talib.RSI(chart[‘close’], timeperiod=14)
TypeError: ‘NoneType’ object is not subscriptable
I am currently using Dhan_Tradehull_V2.py.
Please suggest a solution on this. I am on 8th Video as of now.
During the 6th Video of 1st live algo, it worked very well without giving any error using Dhan_Tradehull_V2. Now the same exact code is giving me the above mentioned errors.
Please help.
hi, @Tradehull_Imran
-
dhan code base ka version update kar diya hai lekin video 6 me abhi bhi purana tradehull se hi import horha hai aur file bhi video 6 me purani hai.
-
To yaha per import me change karna hoga aur file manager me bhi trade hull 2 file upload krke change krna hoga ??
Hi @Tradehull_Imran Sir,
Why we are not able to use 3min timeframe & when it will available for us.
bhai pehle to access token delete karo
okay. Thanx
Thanks
okay
@Tradehull_Imran sir , have u tried now?
Hi, am having issue installing certificate on mac book, are there different steps for installing on python. was trying to execute the session 3 file under codebase, created separate test file to check also, still there is issue.
This BOT Is Picking New File From Dhan
<urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)>
None
Traceback (most recent call last):
File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py”, line 1348, in do_open
h.request(req.get_method(), req.selector, req.data, headers,
File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py”, line 1282, in request
self._send_request(method, url, body, headers, encode_chunked)
File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py”, line 1328, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py”, line 1277, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py”, line 1037, in _send_output
self.send(msg)
File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py”, line 975, in send
self.connect()
File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py”, line 1454, in connect
self.sock = self._context.wrap_socket(self.sock,
File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ssl.py”, line 513, in wrap_socket
return self.sslsocket_class._create(
File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ssl.py”, line 1071, in _create
self.do_handshake()
File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ssl.py”, line 1342, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “/Users/sandeepsharma/PythonProjects/Dhan/3. Session3 - Codebase/Dhan codebase/Dhan_Tradehull.py”, line 85, in get_login
self.instrument_df = self.get_instrument_file()
File “/Users/sandeepsharma/PythonProjects/Dhan/3. Session3 - Codebase/Dhan codebase/Dhan_Tradehull.py”, line 116, in get_instrument_file
instrument_df = pd.read_csv(“https://images.dhan.co/api-data/api-scrip-master.csv”, low_memory=False)
File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pandas/io/parsers/readers.py”, line 1026, in read_csv
return _read(filepath_or_buffer, kwds)
File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pandas/io/parsers/readers.py”, line 620, in _read
parser = TextFileReader(filepath_or_buffer, **kwds)
File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pandas/io/parsers/readers.py”, line 1620, in init
self._engine = self._make_engine(f, self.engine)
File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pandas/io/parsers/readers.py”, line 1880, in _make_engine
self.handles = get_handle(
File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pandas/io/common.py”, line 728, in get_handle
ioargs = _get_filepath_or_buffer(
File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pandas/io/common.py”, line 384, in _get_filepath_or_buffer
with urlopen(req_info) as req:
File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pandas/io/common.py”, line 289, in urlopen
return urllib.request.urlopen(*args, **kwargs)
File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py”, line 216, in urlopen
return opener.open(url, data, timeout)
File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py”, line 519, in open
response = self._open(req, data)
File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py”, line 536, in _open
result = self._call_chain(self.handle_open, protocol, protocol +
File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py”, line 496, in _call_chain
result = func(*args)
File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py”, line 1391, in https_open
return self.do_open(http.client.HTTPSConnection, req,
File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py”, line 1351, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)>
tried installing cert…whl file also, still not luck @Tradehull_Imran @RahulDeshpande