Files
fxhnt/tests/unit/test_gate.py
jgrusewski ecc0fa6ee8 feat(cockpit): Phase-1 go/no-go gate (pure, reports-only)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-14 11:33:44 +02:00

31 lines
1.0 KiB
Python

"""Phase-1 go/no-go gate: WAIT until min_days, then GO if forward return+Sharpe clear the spec, else NO_GO."""
from __future__ import annotations
from fxhnt.application.forward_models import ForwardSummary
from fxhnt.application.gate import evaluate_gate
_SPEC = {"min_days": 20, "min_total_return": 0.0, "min_sharpe": 0.5}
def _sm(days, total_return, sharpe):
return ForwardSummary("x", "2026-06-12", days, 1.0 + total_return, total_return, sharpe, -0.05)
def test_wait_before_min_days() -> None:
assert evaluate_gate(_sm(7, 0.05, 3.0), _SPEC).status == "WAIT"
def test_go_when_thresholds_cleared() -> None:
v = evaluate_gate(_sm(25, 0.04, 1.2), _SPEC)
assert v.status == "GO"
def test_no_go_when_return_negative_after_window() -> None:
v = evaluate_gate(_sm(25, -0.02, 1.2), _SPEC)
assert v.status == "NO_GO" and "return" in v.reason.lower()
def test_no_go_when_sharpe_below_floor() -> None:
v = evaluate_gate(_sm(25, 0.04, 0.1), _SPEC)
assert v.status == "NO_GO" and "sharpe" in v.reason.lower()