Not able to fetch correct ITM data

Dear @Tradehull_Imran @Hardik

From the last 1 week I am facing the problem of fetching LTP and strike price data for NIFTY for current expiry.

I want to trade in 1st ITM of Nifty of current expiry but everytime it is fetching data for FINNIFTY…

the python script and screenshot of output is attached for your refernece. Please help.

"import time
import datetime
from Dhan_Tradehull import Tradehull
import pandas as pd
import talib
from rich.live import Live
from rich.table import Table
from rich.console import Console, Group
import os

Initialize Tradehull object

client_code = “”
token_id = “”
tsl = Tradehull(client_code, token_id)

Fetch historical data for NIFTY (Last 5 Candles) - 15 min timeframe

historical_data = tsl.get_historical_data(tradingsymbol=“NIFTY”, exchange=“INDEX”, timeframe=“15”)

Print the last 5 candles

if not historical_data.empty:
print(“Last 5 Candles for NIFTY:”)
print(historical_data.tail(5))
else:
print(“No historical data retrieved.”)

Get first ITM strike of NIFTY

ce_name, pe_name, ce_strike, pe_strike = tsl.ITM_Strike_Selection(Underlying=“NIFTY”, Expiry=0, ITM_count=1)

Fetch LTP of the first ITM CE & PE

ltp_data = tsl.get_ltp_data(names=[ce_name, pe_name])

Print ITM CE & PE with their LTP

print(f"ITM CE: {ce_name} | LTP: {ltp_data.get(ce_name, ‘N/A’)}“)
print(f"ITM PE: {pe_name} | LTP: {ltp_data.get(pe_name, ‘N/A’)}”)

Define order details

lot_size = 75 # NIFTY lot size
order_quantity = 2 * lot_size # 2 lots = 150 quantity

Place Market Order for ITM CE (Call)

ce_order_id = tsl.order_placement(
tradingsymbol=ce_name,
exchange=“NFO”,
quantity=order_quantity,
price=0, # Market order
trigger_price=0,
order_type=“MARKET”,
transaction_type=“BUY”,
trade_type=“MIS”
)
print(f"ITM CE Order Placed | Order ID: {ce_order_id}")

Place Market Order for ITM PE (Put)

pe_order_id = tsl.order_placement(
tradingsymbol=pe_name,
exchange=“NFO”,
quantity=order_quantity,
price=0, # Market order
trigger_price=0,
order_type=“MARKET”,
transaction_type=“BUY”,
trade_type=“MIS”
)
print(f"ITM PE Order Placed | Order ID: {pe_order_id}")
"

Hi @The_Rexx ,

We will look into this issue.

still no update from your side.
please guide what to do in this matter

Hi @The_Rexx ,

We have updated our codebase,Use the below code to update the codebase:
pip install --upgrade Dhan-Tradehull

Refer the below pypi link for more details:
https://pypi.org/project/Dhan-Tradehull/

@Tradehull_Imran thanks . Already updated the same and it’s running fine now.

1 Like