API to square off NIFTY Options in Intraday

Hi @Pradeep_Jaiswar

I need to square-off Nifty Option positions using API.
As of now, I place a sell order for Nifty options to square off, but this requires about 10x margin.

Example:

Step 1: Order API: BUY Order 1 lot of CE NIFTY-08AUG23-2500 @Market
Step 2: Order API: SL Order 1 lot of CE NIFTY-08AUG23-2500 @{some-stop-loss-price}
Step 3: Order API: SELL Order 1 lot of CE NIFTY-08AUG23-2500 @Target-Price

My step3 typically fails due to lack of margin :slight_smile:

So, Is there a way to do ‘square-off’ instead of selling options using API?

@Amit_Kumar_Sharma Acknowledged. We are working on a similar approach to enable exiting all positions or specific order numbers through a single API. I will provide more details as soon as possible.

1 Like

Thanks @Pradeep_Jaiswar . Till this API is developed, I believe there are two ways to exit NIFTY options positions :

  1. Manually : using square off button from UI
  2. Manually: using GTT SELL order with target and SL set.
  3. API: using SELL OPTIONS order (which will require ~10x margin).

I am sticking to #2 for now.

Could you please confirm if my analysis is correct?

Yes, @Amit_Kumar_Sharma 2 is a better option in this case.

Hi @Pradeep_Jaiswar
Circling back on this one. Requesting you to please get this taken up on priority, as I am sure I am not the only one impacted. There must be many more API users, who are facing this challenge.

The absence of a options square off API is stopping me dead in the tracks from automating my intraday NIFTY CE & PE trades. I can not place SELL orders for CE and PE bought during day trade. If at least a GTT API can be provided for placing static target and SL, it will meet the requirements.

Example:

  1. I buy NIFTY 25000 CE 12-SEP-2024, 1075 qty @ 94.4. Margin required = INR 1.01 lakh
  2. Target price = 100 (6%)
  3. Target price met
  4. To SELL NIFTY 25000 CE 12-SEP-2024, 1075 qty @ 100, I will need a margin of about INR 28 lakhs!!!

Which means to make 6% on 1 lakh, I need to keep 28 lakhs in my wallet :frowning:

Such margin requirement are not there when squaring off in UI using square off button or GTT orders.

PFA attached screenshots of margin requirements from Upstox margin calculator for your reference.

Raw BUY CE

Raw SELL CE

cc: @MohitGolecha : Could you please help get this prioritized?

Hi @Amit_Kumar_Sharma ,

Yep its on priority. We picked it late August and should be shipping this soon!

1 Like

@MohitGolecha that’s music to my ears :smiley: Thank you so much! Waiting eagerly for the release. Belive me, doing this manually is not good for heart :joy:

Hi @Pradeep_Jaiswar @MohitGolecha
Hope you all are doing well. My question is regarding squaring off Nifty Options positions using APIs.

Note: I am an option buyer and not a seller (shorting) due to huge margin requirements.

I now have code (websockets + API) which BUYs options on its own. The pending part is squaring off.

As per earlier replies by @Pradeep_Jaiswar the standard way to square off option positions is placing the same order with opposite leg.

  1. How to set Target in api SL order - #7 by Pradeep_Jaiswar
  2. How to Square off or Exit order? - #2 by Pradeep_Jaiswar

My question is : To square off my bought PUT or CALL positions, if I place a sell order (same instrument and same quantity), will it need the additional selling margins? Honestly, if I am holding Calls worth 6 lakhs, I do not want to end up in a soup when I try to square-it off by placing SELL order (due to huge margin requirements).

I continuously monitor for target and SL price in my code and want to place SELL Market orders the moment either Target or SL price is met.

Thanks in advance,
Amit

Hi @Amit_Kumar_Sharma, you wont require additional margin in that case.

You can also use our new Exit Positions API, which allows you to exit positions by tags, segments, or both.

Additionally, you can use our Multiple Order API to place multiple orders. This allows for hedging of orders in the sequence specified in the payload.

Thank you.

1 Like