Harden strategy SoT: fail-closed funds gate, shared open pipeline, LIVE switch guards.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-30 01:06:32 +08:00
parent 4c537e7520
commit 200702d066
14 changed files with 471 additions and 139 deletions
+47
View File
@@ -0,0 +1,47 @@
"""资金门 fail-closed 测试。"""
from __future__ import annotations
from app.strategy.open_capacity import funds_gate_blocks
def test_funds_gate_blocks_none() -> None:
blocked, msg = funds_gate_blocks(
{
"perp_can_open": True,
"option_can_open": None,
"perp_label": "a",
"option_label": "b",
}
)
assert blocked is True
assert "未知" in msg or "拒绝" in msg
def test_funds_gate_blocks_false() -> None:
blocked, msg = funds_gate_blocks(
{
"perp_can_open": True,
"option_can_open": False,
"perp_label": "永续可开",
"option_label": "期权不可开",
"perp_need_usdt": 1,
"perp_have_usdt": 10,
"option_need_usdc": 100,
"option_have_usdc": 1,
}
)
assert blocked is True
assert "不可开" in msg or "不足" in msg
def test_funds_gate_ok_only_when_both_true() -> None:
blocked, _ = funds_gate_blocks(
{
"perp_can_open": True,
"option_can_open": True,
"perp_label": "永续可开",
"option_label": "期权可开",
}
)
assert blocked is False