Stop Limit Buying in Index Options - Cover Order

The following is a code for Buying nifty 50 PUT option (NIFTY 02 MAY 21450 PUT) which will be triggered at 5.8 and executed at 5.9.
Is Cover order possible with Stop Limit Buying Orders?
How would you modify the following code so that buy order executes at 5.9 and simultaneously a stop loss is set at 5.4 that triggers at 5.5.

from dhanhq import dhanhq
import pandas as pd

client_id = “123456”
access_token = “MyaccessCode”
dhan = dhanhq(client_id,access_token)

price1 = 5.9
trigger_price1 = price1 - 0.1

#Place a buy order in NFO
def place_Buy():
option_id = dhan.place_order(
transaction_type=dhan.BUY,
exchange_segment=dhan.NSE_FNO,
product_type=dhan.CNC,
order_type=dhan.SL,
security_id=40989,
quantity=50,
disclosed_quantity=0,
price=price1,
trigger_price=trigger_price1,
after_market_order=False,
bo_profit_value=0,
bo_stop_loss_Value=0,
drv_expiry_date=None,
drv_options_type=None,
drv_strike_price=None
)
return option_id

op_id = place_Buy()
print(op_id)

Hello @Dev

On Cover Orders, as you know there are two legs - Main Order entry leg and Stop Loss leg.

  1. Main Order - Can be Limit or Market
  2. Stop Loss - Will be Market Order with a trigger; trigger is active once the main order is executed.

On the code, you can refer below:

#Place a buy order in NFO
def place_Buy():
option_id = dhan.place_order(
transaction_type=dhan.BUY,
exchange_segment=dhan.NSE_FNO,
product_type=dhan.CO,
order_type=dhan.LIMIT,
security_id=40989,
quantity=50,
disclosed_quantity=0,
price=price1,
trigger_price=trigger_price1,
after_market_order=False,
)

Above will place CO order, where main order leg is Limit Order with limit price - price1. Along with this, SL will be created with trigger price as trigger_price1.