"""
================================================================================
Strategy **D069** — ``s069``
================================================================================
Yesterday ``ret_1 < -1.8%`` and today ``vix_chg_5 > 0.8``.

**Exit / structure:** hold **3** sessions, trade kind ``sl``, params ``(12,)``.
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": "D069", "theme": "overnight_proxy", "title": 'Large down day then fear rise long straddle'}

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


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