This algorithm implements a short strangle strategy that capitalizes on correlation compression in the options market, specifically designed to profit from periods of low market correlation between different strike prices and the underlying asset. The core innovation lies in its use of correlation-based signals derived from the relationship between various options strikes (ATM, ITM, and OTM options at different moneyness levels) and the Nifty 50 spot price. The algorithm calculates rolling correlations over a 375-minute window (approximately 6.25 hours) for each option contract, then combines these correlations into composite measures that capture the overall correlation structure of the options market. It also incorporates volatility dynamics by comparing recent volatility against historical maximum volatility to identify periods of relative market calm.
The trading logic is based on two primary alpha signals that identify optimal conditions for short strangle positions. The first alpha signal (`alpha`) aggregates the absolute correlations across ATM, OTM, and ITM options, with the negative sign indicating that lower correlations (more compression) generate higher alpha values. The second alpha signal (`alpha7`) combines correlation differentials between ITM and OTM options with volatility compression, measuring how much the recent volatility has compressed relative to its historical maximum. The algorithm generates short strangle signals when both alpha values exceed 0.8, indicating significant correlation compression and volatility contraction. The strategy sells both call and put options at strikes 100 points away from ATM (creating a wider strangle), with a 2% risk allocation SL and only executes trades during specific market hours (10:15 AM to 2:00 PM) to avoid high volatility periods at market open and close. It carry forwards the Strangle overnight and squares it off at 3pm the next day.