Can we have stoploss and Target order open at the same time? Do we need extra margin for this? Can’t use bracket order because it only supports limit/market order currently for the entry leg. Will enter using trigger order and then place the stoploss and target orders.
Hello @Ritesh_Srivastava
You can use Forever Order for this, to have Stoploss and Targer Order both, via OCO. The order stays on Dhan side, so there is no margin blocked until the order is triggered.
Thanks @Hardik , can you please share an example payload for triggering OCO orders using api.
Forever order is only for holding stock. If we want same day stop loss and target after buying in delivery.
Are you using Python Library or the REST API endpoints itself?
@Mudabbir_Hasnain yes, it is true for equity. For F&O, it can be placed on the same day.
Using the python library.
forever = dhan.place_forever(
security_id=1333,
exchange_segment=dhan.NSE,
transaction_type=dhan.SELL,
product_type=dhan.CNC,
order_type=dhan.LIMIT,
quantity=10,
price=1000,
trigger_price=1050,
order_flag="OCO",
validity="DAY",
price1=1200,
trigger_price1=1250,
quantity1=10
)
Hi @Hardik in case of Product Type “CNC” can the validity be “DAY” for options?
How to place normal orders for options not intraday through api? When I am trying dhanhq.CNC it’s using delivery orders
@Hardik : can you please look into my query.
Hi @Hardik
Could you please help with the below requirement in pyhton?
I need to place order at market price with StopLoss & Profit in %.
Hello @Ritesh_Srivastava @Rahul_Singh4
You can use MARGIN as product type for this.
Stop Loss and Profit will be input at value only, since the API takes input in that way. You can keep the percentage calculation at your end.
OrderPlacement = dhan.place_order(
transaction_type=dhan.BUY,
exchange_segment=‘MCX_COMM’,
product_type=dhan.BO,
order_type=dhan.LIMIT,
validity=‘DAY’,
security_id=security_id,
quantity=quantity,
disclosed_quantity=0,
price=53.0,
# trigger_price=bo_stop_loss_Value,
bo_profit_value=bo_profit_value,
bo_stop_loss_Value=bo_stop_loss_Value,
after_market_order=False
)
I am using the above code to place a bracket order for MCX Crude Oil, but it throws the below error.
{‘status’: ‘failure’, ‘remarks’: {‘error_code’: ‘DH-906’, ‘error_type’: ‘Order_Error’, ‘error_message’: ‘Bracket Order Not Enabled For Script’}, ‘data’: {‘errorType’: ‘Order_Error’, ‘errorCode’: ‘DH-906’, ‘errorMessage’: ‘Bracket Order Not Enabled For Script’}}
Order_Type I tried with dhan.MARKET as well as dhan.LIMIT but same issue
Could you please help me on the above code to place BO for MCX_CrudeOil
Hello @SARAT_AMBATI
Welcome to MadeForTrade community!
Glad to know you are exploring Dhan APIs. Right now, we do not provide BO orders for MCX. This is why you are not able to place the same and getting the rejection.