"""
================================================================================
Strategy **D077** — ``s077``
================================================================================
``VVIX/VIX>1.18`` and ``vix_chg_5>4``.

**Exit / structure:** hold **3** sessions, trade kind ``sl``, params ``(11,)``.
Signal logic is implemented only in this module (no imports from sibling strategies).
================================================================================
"""

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": "D077", "theme": "dual_shock", "title": 'VVIX ratio + VIX point spike long straddle'}

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


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