"""
================================================================================
Strategy **D072** — ``s072``
================================================================================
Contract count between 80 and 130 + VIX>18.

**Exit / structure:** hold **4** sessions, trade kind ``sl``, params ``(14,)``.
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": "D072", "theme": "liquidity", "title": 'Thin-but-usable chain long straddle'}

HOLD_SESSIONS = 4
TRADE_KIND = "sl"
TRADE_PARAMS = (14,)


def wants_entry(i: int, row: pd.Series, ch: OptionChain, spy: float, ctx: ResearchContext) -> bool:
    nc = ctx.chain_contracts(i)
    if nc < 80 or nc > 130:
        return False
    vx = ctx.vix(i)
    if not math.isfinite(vx) or vx <= 18.0:
        return False
    if not ch.contracts:
        return False
    _ = spy, row
    return True
