Codebase Update: New Features Added in Dhan_TradeHull

We’ve made several improvements to the Dhan_TradeHull codebase, and here’s a quick overview of what’s new:

  1. Long-term historical data
    You can now pull multi-year data easily using:
data = tsl.get_long_term_historical_data(
    tradingsymbol="NIFTY",
    exchange="NSE",
    timeframe="5",
    from_date="2022-01-01",
    to_date="2025-12-03"
)
  1. Sector-wise historical data (Intraday)
    This helps when analysing broader market sectors.
data = tsl.get_historical_data("NIFTY 100", "NSE", timeframe="1", sector="YES")

data = tsl.get_long_term_historical_data(
    tradingsymbol="NIFTY 100",
    exchange="NSE",
    timeframe="5",
    from_date="2022-01-01",
    to_date="2025-12-03",
    sector="YES"
)
  1. Expired options data
    You can now fetch historical option data even after expiry.
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"
)
  1. Market depth data for multiple instruments
    Useful when you need full-depth snapshots for different symbols.
symbol_list = [
    ("RELIANCE", "NSE"),
    ("NIFTY 09 DEC 26000 CALL", "NFO"),
    ("NIFTY 09 DEC 25500 PUT", "NFO")]

depth_data = tsl.full_market_depth_data(symbol_list)

for key, depth_client in depth_data.items():
    bid_df, ask_df = tsl.get_market_depth_df(depth_client)
  1. Fetching historical Data for 90 days
    The tsl.get_historical_data() function is now updated to return candle data for the past 90 days.

  2. Strike selection issue fixed
    Strikes for symbols now resolve correctly without mismatch.

To use all these updates:

• Install the required dhanhq version

pip install dhanhq==2.1.0

• Upgrade to the latest Dhan-Tradehull

pip install --upgrade Dhan-Tradehull

• Confirm the version is 3.1.2

pip show dhanhq

You can check the full documentation here:
https://pypi.org/project/Dhan-Tradehull/

2 Likes