"""
================================================================================
Strategy **D088** — ``s088``
================================================================================
Ratio ``VIX9D/VIX > 1.08`` and ``VIX<35``.

**Exit / structure:** hold **3** sessions, trade kind ``sl``, params ``(10,)``.
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": "D088", "theme": "vix9d", "title": 'VIX9D above VIX 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:
    v9 = row.get("vix9d_close")
    vx = row.get("vix_close")
    if v9 is None or vx is None or pd.isna(v9) or pd.isna(vx):
        return False
    f9, fx = float(v9), float(vx)
    if fx <= 0 or f9 / fx <= 1.08:
        return False
    if ctx.vix(i) >= 35.0:
        return False
    if ctx.chain_contracts(i) < 80 or not ch.contracts:
        return False
    _ = spy
    return True
