A complete guide to Algorithmic Trading for Beginners🚀

Check if python is added to path variable. Else take google mata help

1 Like

Hello @Hardik

Yes, python is installed in the system. Also, I did all the steps as mentioned in the video. Added the PATH as well.

Hello @Kelvin

As @optionstrader mentioned, you need to add Python to Path variable. You can uninstall this version of Python, reinstall it and while reinstalling, make sure to tick “add to path” box.

Thank you @Hardik & @optionstrader. Its’ working now.

1 Like

where we can install websocket ?

Hello @killerjayesh

Welcome to Dhan Community!

If you are coding in Python, you can refer to DhanHQ official python client - here. Else, you can refer to detailed documentation (here) to get started.

1 Like

NameError: name ‘dhanhq’ is not defined this error is showing

Where is the code? There are no codes in the description. It is said in the video that the file is provided. Where is it ? I need caller_function.py ?

Hello @killerjayesh

Make sure that the library is installed first in your environment (you can find code for the same in the GitHub ReadMe itself). After that, you can start with using the code./

@mahadevan
Welcome to Dhan Community!

You can find the required code from caller_function here: GitHub - dhan-oss/DhanHQ-py: The official Python client for communicating with the Dhan API.

caller_function.py is just name of file referenced in the video.

1 Like

The entire playlist is now live! We’ve embedded all the links in the main thread for everyone’s reference. This is just the beginning, and we see a growing community of API trading enthusiasts joining us. I encourage everyone to participate in the conversations, and sharing their invaluable knowledge.

sir continue this series

Dear Sir , I am getting the following error from starting itself. Can you assist me to solve the issue>
from dhanhq import dhanhq
File “C:\Users\sabir\AppData\Local\Programs\Python\Python312\Lib\site-packages\dhanhq_init_.py”, line 2, in
from dhanhq.marketfeed import DhanFeed
File “C:\Users\sabir\AppData\Local\Programs\Python\Python312\Lib\site-packages\dhanhq\marketfeed.py”, line 9, in
import websockets
ModuleNotFoundError: No module named ‘websockets’

Thanks. I installed websockets. Its working now. :star_struck:

where can I find the functions.py code? In the video it was mentioned that it will be provided here in the community or under comments sections.

It will be great if you can attach the file and pin it to this thread.

Thanks

I’m trying to practice the code provided under “Introducing Dhan Websockets for Super Traders | Real-Time Market Updates | Historical Data | Dhan”

While am trying to write the same code as provided by sir, am getting name error. As am still learning Python, not sure what is different for sir Vs my code. Please help rectify this error.

def historical_data(dhan, symbol, exchange_segment, instrument_type, from_date, to_date):
>     equity_historical_data = dhan.historical_daily_data(
>         symbol= symbol,
>         exchange_segment= exchange_segment,
>         instrument_type=instrument_type,
>         expiry_code=0,
>         from_date=from_date,
>         to_date=to_date
>     )
> 
> 
> df = pd.DataFrame(equity_historical_data['data'])
> df['start_Time'] = df['start_Time'] + 315569260
> df['symbol'] = symbol
> print(df)
> 
> symbol_list = ['TCS', 'HDFCBANK', 'ITC', 'WIPRO']
> 
> for symbol in symbol_list :
>     exchange_segment='NSE_EQ',
>     instrument_type='EQUITY',
>     from_date='2024-02-22',
>     to_date='2024-02-22'
>     historical_data(dhan, symbol, exchange_segment, instrument_type, from_date, to_date)

Traceback (most recent call last):
File “c:\Users\admin\Documents\Dhan API\historical_data.py”, line 20, in
df = pd.DataFrame(equity_historical_data[‘data’])
^^^^^^^^^^^^^^^^^^^^^^
NameError: name ‘equity_historical_data’ is not defined

Hi Rahul, Im getting this error on my first program. pls help

{‘status’: ‘failure’, ‘remarks’: {‘error_code’: ‘RS-9005’, ‘message’: ‘The token was expected to have 3 parts, but got 1.’}, ‘data’: ‘’}

@Hardik @RahulDeshpande
Good days Sirs,
Can you pls provide with the python code for combined take profit and combined stoploss for straddle strategy as its not mentioned in Episode 10 (Build Algo trading strategy).

Thank & Regards.

i am also getting same error.did your problem solved>

Facing this issue
n312/python.exe e:/Personal/Sample/stat_API.py
{‘status’: ‘failure’, ‘remarks’: {‘error_code’: ‘RS-9005’, ‘message’: ‘The token was expected to have 3 parts, but got 1.’}, ‘data’: ‘’}

Hello @LearnTrading

Welcome to Dhan Community!

@abrsetti @Deeksha_Goyal
The error that you are getting basically comes up when the access token being passed on API is incorrect. The most frequently occuring issue that we have seen from user end is this, wherein they are defining access token variable but instead passing "access_token" as a string inside function.

Kindly take a look and if not, then send code snippet here so that someone from community can help you out here.