Python Order placement for buying Banknifty Option

lets say I want to place order with stop-loss of 40 points, from python code for

49300 PE BANKNIFTY for 30-01-2025 expiry, how to do this ?

There is no clear example documented for algo based option buying

Hi @Zen_Yoga

reference video for order placement : https://youtu.be/9KicRvYFLlU?si=Qj5gqIH57atC4_XW&t=177

1 Like

Okay here is the basic simple steps to place option buying order through Python.

  1. Download this files.
    https://images.dhan.co/api-data/api-scrip-master.csv

  2. Lets say this is your contract details BANKNIFTY 30 JAN 48200 CALL then search the csv file with exact string format (with your values)…

  3. We will find security id there for BANKNIFTY 30 JAN 48200 CALL if you take a look at link given by @Tradehull_Imran you will find code to automate this process.

  4. Using that id we can write our python code for placing market order like this…

 placedOrder = dhan.place_order(
    security_id="39475", # security id we found in csv file
    exchange_segment= dhan.NSE_FNO,
    transaction_type=dhan.BUY, 
    quantity=15, #  15 means 1 lot**
    order_type=dhan.MARKET, 
    product_type=dhan.INTRA, 
    price=0)
print(placedOrder)

please go through the link given by @Tradehull_Imran to understand everything in great details.

1 Like