Fix LIVE open/close double-book and security audit findings.

Prevent expiry dual-close from re-booking option cash, abandon ledger rejection, margin-mode mismatch, and manual close races; harden fill wait and refuse default AUTH_SECRET on LIVE.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-29 20:11:29 +08:00
parent c6e8f6fe1e
commit ec87cf2104
10 changed files with 229 additions and 80 deletions
+8
View File
@@ -36,6 +36,14 @@ async def lifespan(app: FastAPI):
# 而 health 显示 DB 里的 binance → 合约号/盘口错乱(期权一直 -/-)
from .exchange.runtime import load_runtime_settings
app_settings = get_settings()
if not app_settings.is_sim:
secret = (app_settings.auth_secret or "").strip()
if not secret or secret == "change-me-eth-hedge-sim-secret":
raise RuntimeError(
"LIVE 拒绝启动:请在 .env 设置非默认 AUTH_SECRET(勿用 change-me-eth-hedge-sim-secret"
)
settings = load_runtime_settings()
engine = StrategyEngine()
set_engine(engine)