"""
================================================================================
Strategy **D068** — ``s068``
================================================================================
``close > sma_200`` and ``close > 1.03*sma_20`` + VIX<26.

**Exit / structure:** hold **4** sessions, trade kind ``sl``, params ``(16,)``.
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": "D068", "theme": "outside_ma", "title": 'Strong bull separation long straddle'}

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


def wants_entry(i: int, row: pd.Series, ch: OptionChain, spy: float, ctx: ResearchContext) -> bool:
    s20 = row.get("sma_20")
    s200 = row.get("sma_200")
    if s20 is None or s200 is None or pd.isna(s20) or pd.isna(s200):
        return False
    c = float(row["close"])
    if c <= float(s200) or c <= 1.03 * float(s20):
        return False
    vx = ctx.vix(i)
    if not math.isfinite(vx) or vx >= 26.0:
        return False
    if ctx.chain_contracts(i) < 80 or not ch.contracts:
        return False
    _ = spy
    return True
