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:
+4
-30
@@ -105,41 +105,15 @@ async def sim_open_group(
|
||||
|
||||
wkey = window_key()
|
||||
db = get_db()
|
||||
from ..strategy.risk_sizing import apply_risk_sizing_to_ledger
|
||||
from ..strategy.open_pipeline import size_and_gate
|
||||
|
||||
rs = apply_risk_sizing_to_ledger(
|
||||
prep = size_and_gate(
|
||||
index_px=float(pick.underlying_px),
|
||||
option_ask=sizing_ask,
|
||||
db=db,
|
||||
)
|
||||
if not rs.ok:
|
||||
raise HTTPException(status_code=409, detail=rs.detail)
|
||||
|
||||
try:
|
||||
from ..strategy.auto_usdc import ensure_okx_trading_usdc
|
||||
|
||||
ensure_okx_trading_usdc(db)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
try:
|
||||
from ..strategy.open_capacity import assess_open_capacity
|
||||
|
||||
cap = assess_open_capacity(db)
|
||||
if cap.get("perp_can_open") is False or cap.get("option_can_open") is False:
|
||||
detail = (
|
||||
f"{cap.get('perp_label')} · {cap.get('option_label')};"
|
||||
f"永续需≈{cap.get('perp_need_usdt')}U/有{cap.get('perp_have_usdt')}U,"
|
||||
f"期权需≈{cap.get('option_need_usdc')}U/有{cap.get('option_have_usdc')}U"
|
||||
)
|
||||
raise HTTPException(
|
||||
status_code=409,
|
||||
detail=f"资金不足,暂不可开新仓:{detail}",
|
||||
)
|
||||
except HTTPException:
|
||||
raise
|
||||
except Exception:
|
||||
pass
|
||||
if not prep.ok:
|
||||
raise HTTPException(status_code=409, detail=prep.detail)
|
||||
|
||||
count = len(
|
||||
db.fetchall("SELECT group_id FROM groups WHERE group_id LIKE ?", (f"G-{wkey}-%",))
|
||||
|
||||
Reference in New Issue
Block a user