This algorithm implements a short straddle strategy that capitalizes on range-bound market conditions and volatility compression, specifically designed to profit from periods of low market volatility and stable price action. The core innovation lies in its use of multi-factor alpha signals that combine open interest dynamics, implied volatility changes, and volatility compression patterns. The algorithm processes 1-minute interval data and calculates implied volatility (IV) for various options (ATM, ITM, and OTM options at different moneyness levels), then computes delta IV changes to capture short-term volatility momentum. The first alpha signal (`alpha`) combines the call-to-put open interest ratio with the inverse of absolute IV changes and volatility, essentially identifying periods when market participants are balanced between calls and puts while volatility is contracting.
The trading logic is based on two sophisticated alpha signals that identify optimal conditions for short straddle positions. The first alpha signal (`alpha`) multiplies the call-to-put open interest ratio by factors that measure volatility compression and stability, with higher values indicating favorable conditions for range-bound trading. The second alpha signal (`alpha2`) uses an exponentially weighted mean of volatility ratios, comparing short-term (20-period) to long-term (200-period) IV changes, combined with how close the open interest ratio is to 1:1 balance. The algorithm generates short straddle signals when both alpha values exceed their respective thresholds (0.75 and 0.8), indicating significant volatility compression, balanced open interest, and stable market conditions. The strategy sells both ATM call and put options simultaneously, with sophisticated risk management including a 50-rupee minimum price filter, per-leg loss limits of 5000 rupees, and margin calculations that account for the combined position. The algorithm only executes trades during specific market hours (10:15 AM to 2:00 PM) and includes logic to handle connected trades where both legs are managed as a single straddle position with cross-referenced stop losses.