I am unable to place both Target Limit & StopLoss Limit order for Banknifty Call Option

Hi Team,

I am trying to implement OCO scenario using uplink API. But I am unable to do the same. Here is the payloads.

POSITION PAYLOAD: (NO ISSUES)
{‘quantity’: 15, ‘product’: ‘D’, ‘validity’: ‘DAY’, ‘price’: 545.9, ‘tag’: ‘NSE_FO|47974|2024-08-27 12:57:00|BUY_LIMIT’, ‘instrument_token’: ‘NSE_FO|47974’, ‘order_type’: ‘LIMIT’, ‘transaction_type’: ‘BUY’, ‘disclosed_quantity’: 0, ‘trigger_price’: 546.0, ‘is_amo’: False}

TARGET PAYLOAD:
{‘quantity’: 15, ‘product’: ‘D’, ‘validity’: ‘DAY’, ‘price’: 555.9, ‘tag’: ‘PARENT_ORDER_ID|SELL_LIMIT’, ‘instrument_token’: ‘NSE_FO|47974’, ‘order_type’: ‘LIMIT’, ‘transaction_type’: ‘SELL’, ‘disclosed_quantity’: 0, ‘trigger_price’: 555.0, ‘is_amo’: False}

STOPLOSS PAYLOAD:
{‘quantity’: 15, ‘product’: ‘D’, ‘validity’: ‘DAY’, ‘price’: 535.0, ‘tag’: ‘PARENT_ORDER_ID|SELL_LIMIT’, ‘instrument_token’: ‘NSE_FO|47974’, ‘order_type’: ‘SL’, ‘transaction_type’: ‘SELL’, ‘disclosed_quantity’: 0, ‘trigger_price’: 539.0, ‘is_amo’: False}

I am getting this error RMS:Margin Exceeds,Required:115191.73, Availab

How to solve this issue.

Thanks & Regards
R C Vamsi

Any one interested to reply?

I am not sure whats wrong with this payload. Even Upstox Pro is not placing orders for SL-LIMIT.

Are you guys busy looking into this?

Thanks
Vamsi

@vardhan36397, if you’re looking to implement an OCO (One Cancels the Other) scenario, please follow these steps:

  1. Start by ensuring that your limit buy order is executed first. If you place all three orders simultaneously, there’s a possibility that the sell order might be executed before the buy order if the current market price reaches the target order’s price.
  2. Once your buy order is executed, place two sell orders: one with the target payload and the other with the stoploss payload. If one of these sell orders is executed, you should promptly cancel the remaining open sell order using the Cancel Order API.

Note: The margin required for the two sell orders will be the same as the margin needed to place a single sell order without an existing buy position.

For real-time updates, you can monitor order statuses via the order update Websocket. Additionally, you can refer to the SDK streamer functions for ease of use:

I hope this helps with your implementation.

Thank you.