"""
================================================================================
Strategy **D010** — ``s010``
================================================================================

Theme
-----
**VIX velocity shock (path-based, not level-based).**

Economic idea
-------------
Sudden VIX ramps over a **five-session** window embed information about dealer hedging and
stochastic volatility jumps. This sleeve **buys** a short-dated ATM straddle when the
**change** in VIX exceeds **+6 points** in five sessions, regardless of whether VIX is
“high” in an absolute sense. Distinct from post-**percentage** spike rules.

Entry
-----
1. ``i>=6``.
2. ``vix_chg_5 > 6.0`` (absolute point change, not percent).
3. ``iv_atm(10)`` exists (short-dated straddle anchor).
4. ``n_contracts[i] >= 80``.

Exit
----
Long straddle ~10 DTE, hold **3** sessions.
================================================================================
"""

from __future__ import annotations

import math

import pandas as pd

from RenTech.core.options_data_loader import OptionChain
from RenTech.strategy_stack.diverse_theta_strategies_v1.context import ResearchContext

META = {"sid": "D010", "theme": "vix_path", "title": "VIX +6pts/5sessions absolute shock long straddle"}

HOLD_SESSIONS = 3
TRADE_KIND = "sl"
TRADE_PARAMS = (10,)


def wants_entry(i: int, row: pd.Series, ch: OptionChain, spy: float, ctx: ResearchContext) -> bool:
    if i < 6:
        return False
    dv = row.get("vix_chg_5")
    if dv is None or pd.isna(dv) or float(dv) <= 6.0:
        return False
    if ctx.iv_atm_dte(i, 10) is None:
        return False
    if ctx.chain_contracts(i) < 80:
        return False
    if not ch.contracts:
        return False
    _ = spy
    return True
