Code for trading symbol?

from Dhan_Tradehull import Tradehull
import pdb
import pandas as pd

client_id = “1104458389”
access_token = “…”
tsl = Tradehull(client_id, access_token)

available_balance = tsl.get_balance()
print("Your available balance is = " , available_balance)

#option chain
atm, option_chain = tsl.get_option_chain(Underlying=“NIFTY”, exchange=“INDEX”, expiry=0, num_strikes=20)

import pandas as pd

df = pd.DataFrame(option_chain)

df_clean = df[[
‘CE OI’,‘CE Volume’,‘CE LTP’,
‘Strike Price’,
‘PE LTP’,‘PE Volume’,‘PE OI’
]]

print(“\n===== NIFTY OPTION CHAIN =====\n”)
print(df_clean.to_string(index=False))

3. Ltp based strike Selection

required_strike = option_chain.loc[option_chain[‘CE LTP’] <= 100, ‘Strike Price’].iloc[0]

#Required strike
print("\nRequired_strike = " , required_strike)

> output in CMD

Codebase Version 3
-----Logged into Dhan-----
This BOT Is Picking New File From Dhan
Got the instrument file
Your available balance is = 253.19

===== NIFTY OPTION CHAIN =====

CE OI CE Volume CE LTP Strike Price PE LTP PE Volume PE OI
88920 301925 1074.50 23500.0 88.90 75542675 5757895
1235 3510 1018.50 23550.0 95.10 16966755 617760
13650 40300 972.40 23600.0 100.90 26584090 1856725
2470 5265 929.70 23650.0 106.95 18241535 827320
50570 115895 899.90 23700.0 112.40 25370735 2141685
3835 9425 853.75 23750.0 120.25 12679875 607815
61750 271505 813.00 23800.0 128.00 34925475 2763475
24310 90480 768.70 23850.0 136.25 17804865 661635
39325 235495 732.90 23900.0 144.25 29524690 1417910
24310 184405 686.65 23950.0 153.50 14804465 521560
419965 5142605 649.00 24000.0 164.25 111355920 6273930
44785 422175 609.30 24050.0 173.80 20105735 583245
72995 1925625 572.00 24100.0 185.20 43790110 2411695
47450 1243905 534.90 24150.0 196.85 20222605 863785
241800 9263540 498.45 24200.0 210.00 56835350 2605265
128310 4928365 463.15 24250.0 225.00 31389605 916955
744835 40423695 428.40 24300.0 239.70 109081245 3587415
554840 45460935 394.00 24350.0 256.00 93465840 1877785
1704625 128518065 360.40 24400.0 272.55 164662290 4095065
799370 58863675 330.00 24450.0 292.50 55042780 1414400
3152630 115132615 299.25 24500.0 312.00 91557180 4050475
917670 42533205 271.10 24550.0 332.70 24373895 712725
1681355 74140170 243.25 24600.0 355.75 31568225 1661400
725855 32215560 217.85 24650.0 379.75 6695260 502190
1724255 54220855 193.65 24700.0 405.75 12499825 1294670
530595 33966725 171.75 24750.0 432.80 3638180 324090
2114775 71994130 150.95 24800.0 459.45 9129055 1222845
669110 32674785 130.95 24850.0 492.00 2704845 350675
2073435 61484995 114.05 24900.0 522.05 4878380 1009580
732875 32890390 99.00 24950.0 557.85 931970 183950
6335940 133128320 84.95 25000.0 593.25 6809790 2009670
726245 28694120 72.80 25050.0 632.45 288795 94445
2701725 46332325 62.20 25100.0 672.35 798720 430365
834080 24067810 53.55 25150.0 711.85 189345 68900
3029520 57138250 45.00 25200.0 756.15 793130 580905
914030 23135970 38.75 25250.0 800.00 83330 82680
2544620 45714500 32.90 25300.0 837.65 558740 458835
971035 21295105 28.20 25350.0 886.55 166270 78845
2666235 39414310 23.95 25400.0 933.95 373750 520520
1230255 20089550 20.00 25450.0 986.10 108290 122590
5551520 61007895 17.70 25500.0 1028.15 535730 1264510

Required_strike = 24950.0

MY QUESTION

I GOT REQUIRED STRIKE, KINDKY TELL ME HOW TO GENETARE TRADING SYMBOL, SO THAT I CAN PLACE ORDER

@Dr_Nazim_Khan

# trading_symbol = “NIFTY 21 NOV 24400 CALL”
trading_symbol = f"{Underlying} {expiry} {required_strike} {option_type}"

Docs - GitHub - TradeHull/Dhan-Tradehull: This repository contains the codebase for DhanHQ. · GitHub

thank you so much…also give me a code format for super order at market for option buying

limit - order_id = tsl.place_super_order(tradingsymbol=“NIFTY10MAR24950CE”,exchange=“NSE”,transaction_type=“BUY”,quantity=65,order_type=“LIMIT”,trade_type=“MIS”,price=25,target_price=27,stop_loss_price=24,trailing_jump=0.2)

market - ???
buy- market
stoploss - 1 rupee
I want that whenever I take a market order trade, my stop-loss should automatically be placed 1 rupee below the entry price.

order_id = tsl.place_super_order(
    tradingsymbol="NIFTY10MAR24950CE",
    exchange="NFO",              # Note: Use 'NFO' for F&O segments
    transaction_type="BUY",
    quantity=65,
    order_type="MARKET",         # Order type set to MARKET
    trade_type="MIS",
    price=0,                     
    target_price=27,             
    stop_loss_price=24,          
    trailing_jump=0.2
)

Reference - Dhan-Tradehull/Dhan_Tradehull.py at main · TradeHull/Dhan-Tradehull · GitHub

buy- market
stoploss - 1 rupee
I want that whenever I take a market order trade, my stop-loss should automatically be placed 1 rupee below the entry price.

This is not possible because entry price can only be determined after the order if FILLED when using MARKET order type. Can only be achieved using custom algo code.

Step 1: Place Super order as mentioned in the previous comment.

Step 2: Get the entry price at which the order is FILLED.

Step 3: Modify the SL leg of the Super order with a new price as per entry price.

ERROR WHILE PLACING SUPER ORDER, KINDLY GIVE SOLUTION

AttributeError: ‘Tradehull’ object has no attribute ‘place_super_order’

@Dr_Nazim_Khan SDK docs here. SDK code here. Make sure you have latest versions of packages. Read here.