While squaring off your hedge position you are required to close the Sell order first of the option before squaring off the Buy order.
If you square-off the Buy order first, the margin required increases for your Sell order as it is now the naked position and it may result in margin shortfall end up attracting margin shortfall penalties or will be squared-off by our RMS (Due to inadequacy in funds).
For Instance, you have taken a hedge position of Bull-Put Spread where you’ve Bought Nifty OTM 14950PE and Sold Nifty ITM 15200PE. The margin required for this position is ₹46,877 (₹40,757.03+ ₹6,120) as displayed below. Now, you’d taken this position with a capital of around ₹50,000.
While squaring off this hedge position of Bull-Put Spread, you’d squared off the 14950PE first then the margin required will shoot up to ₹1.7 Lakhs (As per the above) image and your fund balance available will be ₹-1.2 Lakhs. This may lead to severe repercussions attracting Margin Shortfall Penalties and Other Interest Charges. Even if you square off the 2nd leg (15200PE Short) in a matter of seconds, it might be too late.
Therefore, you are required to square-off the leg with a higher margin (i.e.,15200PE Short) and later square-off the lesser margin leg (14950PE Long)