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:
@@ -103,3 +103,24 @@ def test_reserve_perp_margin() -> None:
|
||||
|
||||
assert r["acted"] is True
|
||||
assert wallets.convert.call_args.kwargs["amount"] == 50.0
|
||||
|
||||
|
||||
def test_force_does_not_bypass_cooldown() -> None:
|
||||
import app.strategy.auto_usdc as m
|
||||
import time
|
||||
|
||||
m._last_attempt_ts = time.time()
|
||||
cap = {
|
||||
"option_need_usdc": 100.0,
|
||||
"option_have_usdc": 0.0,
|
||||
"perp_need_usdt": 10.0,
|
||||
"perp_have_usdt": 500.0,
|
||||
"option_can_open": False,
|
||||
}
|
||||
with (
|
||||
patch("app.strategy.auto_usdc._is_okx", return_value=True),
|
||||
patch("app.strategy.auto_usdc.assess_open_capacity", return_value=cap),
|
||||
):
|
||||
r = ensure_okx_trading_usdc(db=MagicMock(), cap=cap, force=True)
|
||||
assert r["acted"] is False
|
||||
assert "冷却" in r["detail"]
|
||||
|
||||
Reference in New Issue
Block a user