Advanced Algo Trading 2026 | Codes | Youtube

Hi @deva ,

We don’t have any dump available for download at the moment.

Dear Sir,

How to get expired option data for specific nifty option strike for the given date with 1 min time frame.

Hello sir, how to get the code for Direction option selling algo?

HI @Mihir_Shah ,

We need to follow both steps to get expired options data

Refer this link it gives consolidated data -

Refer this link it gives strike wise data -

Hi @prashantjawale21 ,

We are still working on it . We will update you soon .

Hi @Tradehull_Imran - Can you figure out a way to add websocket (Marketfeed) in Tradehull library? It will be helpful for quick scalping algos.

Thanks.

Hi @Sadha ,

Websocket was already integrated in codebase.

Refer this video for the code reference -

code files : https://drive.google.com/file/d/1OD_t105oPVS5VnLxKv9k6Hp4Fj-uPqrM/view

1 Like

Hello Sir,

With your given guidance I was able to fetch the expired option data explained in the youtube video.

I am working on options backtesting using Tradehull and need some knowledge about historical options data.


My requirement

For any given trading day, I want:

  • 1-minute option data

  • For ATM / OTM strikes

  • For the nearest or next weekly expiry contract

    I was able to download the data and then manipulate them to make data based on the strike selection.


My confusion (2 scenarios)

Scenario 1 (Expiry Day)

Example: 27 Jan 2026 (Tuesday - expiry day)

If I use:
get_expired_option_data(...)

:backhand_index_pointing_right: Will it return data for:

  • 27 Jan 2026 expiry (same day)? :check_mark:
    OR something else?

Scenario 2 (Non-expiry Day)

Example: 29 Jan 2026 (Thursday)

:backhand_index_pointing_right: I want data for:

  • Next expiry (03 Feb 2026)

:backhand_index_pointing_right: Does it return:

  • Previous expiry (27 Jan)?

  • OR next expiry (03 Feb)?

Hi @Mihir_Shah ,

In this function, for the given from_date and end_date, it will return expiry dates within that range—monthly expiries if monthly is selected, or weekly expiries if weekly is selected.

Refer the below codes -

Fetch Expired Option Chart Data

Retrieve minute-wise OHLC, Volume, IV, OI, Spot, and Strike data for expired option contracts (index options only, as supported by DHAN).Get Expired Option Data

  • tsl.get_expired_option_data(tradingsymbol: str,exchange: str,interval: int,expiry_flag: str,expiry_code: int,strike: str = “ATM”,option_type: str = “CALL”,required_data: list = None,from_date: str = “”,to_date: str = “”)
  • Arguments:
    • tradingsymbol (str): The symbol for which historical expired option data is required
      (e.g., "NIFTY", "BANKNIFTY", "RELIANCE").
    • exchange (str): Exchange of the underlying
      Allowed: "NSE", "BSE"
    • interval (int): Candle interval in minutes
      Allowed: 1, 5, 15, 25, 60.
    • expiry_flag (str): The expiry type
      • "MONTH" for monthly contracts
      • "WEEK" for weekly contracts
    • expiry_code (int): Expiry sequence number
      • 1 → Near expiry
      • 2 → Next expiry
      • 3 → Far expiry
    • strike (str): Strike selection mode
      Examples: "ATM", "ATM+3", "ATM-3".
    • option_type (str): "CALL" or "PUT".
    • required_data (list, optional): Which fields to fetch
      Default: ["open","high","low","close","volume","iv","oi","spot","strike"]
    • from_date (str): Start date in YYYY-MM-DD format.
    • to_date (str): End date in YYYY-MM-DD format.
  • Sample Code:

data = tsl.get_expired_option_data(tradingsymbol=“RELIANCE”,exchange=“NSE”,interval=1,expiry_flag=“MONTH”,expiry_code=1,strike=“ATM”,option_type=“CALL”,from_date=“2024-10-10”,to_date=“2024-11-10”)

Hello Sir,

Thanks for the guidance I am able to fetch the expired options data now.

The output is only having datetime,open,high,low,close,volume,iv,oi,spot,strike

How to add expiry date in the output, without the expiry date it is not possible to backtest alogo and manipulate data also on which basis we can save the records that can be used for further

Please Guide.
Thanks

data = tsl.get_historical_data(tradingsymbol=‘NIFTY’, exchange=‘INDEX’, timeframe=“DAY”)

Exception in Getting OHLC data as dhanhq.convert_to_date_time() missing 1 required positional argument: ‘epoch’

can you help ?

Seems like Dhan-Tradehull 3.2.2 is broken