Learn Algo Trading with Python | Codes | Youtube Series

Hi @Raju2 ,

In our latest codebase, the num_strikes parameter is not available for use.
You can retrieve the option chain using the following code:

option_chain = tsl.get_option_chain(Underlying="NIFTY", exchange="INDEX", expiry=0)

We will be adding num_strikes in further versions. You can use the below code if you wish to do it manually:

num_strikes = 10
strike_step = 50
CE_symbol_name, PE_symbol_name, atm_strike = tsl.ATM_Strike_Selection(Underlying='NIFTY', Expiry=0)
oc_df = tsl.get_option_chain(Underlying="NIFTY", exchange="INDEX", expiry=0)
df = oc_df[(oc_df['Strike Price'] >= str(atm_strike - num_strikes * strike_step)) & (oc_df['Strike Price'] <= str(atm_strike + num_strikes * strike_step))].sort_values(by='Strike Price').reset_index(drop=True)

Hey My question has nothing to do with VIX. @Tradehull_Imran Can you please look into it?


@Tradehull_Imran

Hi @Rajashekhar_Rangappa ,

There seems no issue with the data, do check the below screenshot attached.

Hi @Hardik ,

We are still unable to get LTP for India Vix, do look into this:

Hi @Ganesh_Surwase

Better then VS code or Sublime Text, is cursor… try it…
also its AI enabled

See : https://www.cursor.com/

1 Like

Hi @Er_Sanjay ,

See solution link :rocket: Learn Algo Trading with Python | Codes | Youtube Series - #1266 by Tradehull_Imran

Hello @Tradehull_Imran

You can try with IDX_I and 21 as security ID. Let me know if this is still not available.

post deleted as I got the answer myself, I corrected it… thanks Imran sir for your answer in earlier post… helped me to find the answer

1 Like

Hey @Subhajitpanja ,

If you have the link for code files, pls shre them too…

Thank in advance :slight_smile:

@Tradehull_Imran
I am not able to get OHLC data today which was getting till yesterday as below

  1. Exception in Getting OHLC data as Check the Tradingsymbol or Exchange.
import sys
import winsound

import dhan_user_functions
from Dhan_Tradehull_V2 import Tradehull
from datetime import datetime,timedelta
import time
import math
import requests
import pandas as pd
import threading
import datetime as dt
import talib
import logging

# Set up logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')

logging.info(f"Now logging to Dhan Account.")
client_code = open("dhan_client_id.txt",'r').read()     #'clientID'
token_id    = open("dhan_access_token.txt",'r').read()              #'accessToken'
tsl         = Tradehull(client_code,token_id)
logging.info(f"Successfully logged in to Dhan Account.")


name = "NIFTY"
chart = tsl.get_historical_data(tradingsymbol=name, exchange='INDEX', timeframe='5')
print("chart is \n", chart)

"C:\Program Files\Python310\python.exe" C:\Users\amitb\Desktop\Python\dump.py 
Codebase Version 2.8 : Solved - Strike Selection Issue
2025-02-19 15:13:02,944 - INFO - Now logging to Dhan Account.
2025-02-19 15:13:02,945 - INFO - Dhan.py  started system
2025-02-19 15:13:02,945 - INFO - STARTED THE PROGRAM
-----Logged into Dhan-----
reading existing file all_instrument 2025-02-19.csv
Got the instrument file
2025-02-19 15:13:03,116 - ERROR - Error at getting start date as single positional indexer is out-of-bounds
Traceback (most recent call last):
  File "C:\Users\amitb\Desktop\Python\Dhan_Tradehull_V2.py", line 431, in get_start_date
    security_id 	= instrument_df[((instrument_df['SEM_TRADING_SYMBOL']==tradingsymbol)|(instrument_df['SEM_CUSTOM_SYMBOL']==tradingsymbol))&(instrument_df['SEM_EXM_EXCH_ID']==instrument_exchange[exchange])].iloc[-1]['SEM_SMST_SECURITY_ID']
  File "C:\Users\amitb\AppData\Roaming\Python\Python310\site-packages\pandas\core\indexing.py", line 1191, in __getitem__
    return self._getitem_axis(maybe_callable, axis=axis)
  File "C:\Users\amitb\AppData\Roaming\Python\Python310\site-packages\pandas\core\indexing.py", line 1752, in _getitem_axis
    self._validate_integer(key, axis)
  File "C:\Users\amitb\AppData\Roaming\Python\Python310\site-packages\pandas\core\indexing.py", line 1685, in _validate_integer
    raise IndexError("single positional indexer is out-of-bounds")
IndexError: single positional indexer is out-of-bounds
2025-02-19 15:13:03,121 - INFO - Successfully logged in to Dhan Account.
Exception in Getting OHLC data as Check the Tradingsymbol or Exchange
chart is 
 None
2025-02-19 15:13:03,138 - ERROR - Exception in Getting OHLC data as Check the Tradingsymbol or Exchange
Traceback (most recent call last):
  File "C:\Users\amitb\Desktop\Python\Dhan_Tradehull_V2.py", line 476, in get_historical_data
    raise Exception("Check the Tradingsymbol or Exchange")
Exception: Check the Tradingsymbol or Exchange

Process finished with exit code 0

@RahulDeshpande @Tradehull_Imran sir please help with code

Hi @Dev_Goswami ,

Hi
Do update codebase on your system

  • 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

Guide to use the updated codebase:
Video reference : https://www.youtube.com/watch?v=P9iPYShakbA

1 Like

Hi @Tradehull_Imran sir,

A video on ORB with Dhan API with ATM options buying on break out or break Down… pls…

Have nice day
Regards

1 Like

Very Good Morning.
Thank you very much for Imran Ali Sir & Other related Support team in intiating to Provide the Advaced Algo Series. We request you to kindly provide the Support Sublime Text Files along with Each of these Series Videos sir.
Thanka a Lot.
VBR Prasad

1 Like

sir, I want to use CM_williams_Vix_fix indicator. How can I ?

Kudos for the great advice on CURSOR, an advanced AI-powered IDE.

I find it incredibly helpful in writing, enhancing, and debugging algo codes.

1 Like

Hi @Tradehull_Imran,
Thanks for starting the Algo series 2.
One request - Is it possible to add “CE LTP change” and “PE LTP Change” also in the get_option_chain function?
Thanks

Hi @Hardik ,

Thanks it is working now.