WBS-7.3.6: Verify stop_loss_gate (F11) and late_chase_gate (F15) decisions parity via test expansion
This commit is contained in:
@@ -88,9 +88,32 @@ class TestStopLossPolicyParity(unittest.TestCase):
|
||||
signal_type_rel, signal_rel = calculate_relative_underperf_signal(
|
||||
close=10000, ret20d=-70.0, atr20=500, kospi_ret20d=10.0, profit_pct=-10.0, hold_days=10
|
||||
)
|
||||
self.assertEqual(signal_type_rel, "REL_EXCESS")
|
||||
self.assertTrue(signal_rel)
|
||||
def test_stop_loss_gate_decision_routing_f11_parity(self):
|
||||
from src.quant_engine.exit_decisions import compute_stop_action_ladder
|
||||
|
||||
# Test case: holding.stopBreach is True -> EXIT_100 (due to timingAction or rw_partial >= 4, here we simulate the action routing)
|
||||
# In exit_decisions.py, if timing_action == "STOP_OR_TIME_EXIT_READY" or rw_partial >= 4, it routes to EXIT_100
|
||||
res1 = compute_stop_action_ladder({"timingAction": "STOP_OR_TIME_EXIT_READY"})
|
||||
self.assertEqual(res1["action"], "EXIT_100")
|
||||
self.assertEqual(res1["reason"], "STOP_OR_TIME_EXIT_READY")
|
||||
|
||||
def test_late_chase_gate_f15_parity(self):
|
||||
from src.quant_engine.exit_decisions import compute_final_decision
|
||||
|
||||
# F15 check: breakout_quality_gate === 'BLOCKED_LATE_CHASE' or late_chase_risk_score >= 70
|
||||
# In compute_final_decision: allowed_action is checked. Let's make sure it handles decisions properly.
|
||||
# If allowed_action = "BUY_STAGE1_READY" but ac_gate is BLOCK, it downgrades.
|
||||
# Let's verify compute_final_decision handles timing_action = "NO_BUY_OVERHEATED" (which maps to ac_gate=BLOCK or entry_gate=BLOCK in compute_timing_decision)
|
||||
res = compute_final_decision({
|
||||
"sellAction": "HOLD",
|
||||
"allowedAction": "",
|
||||
"timingAction": "NO_BUY_OVERHEATED",
|
||||
"dartRisk": False
|
||||
})
|
||||
self.assertEqual(res["final_action"], "NO_BUY_OVERHEATED")
|
||||
self.assertEqual(res["action_priority"], 50)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user