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)