Fix Binance boot using OKX symbols after restart.

Startup ignored DB exchange choice and kept OKX ATM ids under a Binance health label, so option bid/ask stayed empty.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-25 12:13:19 +08:00
parent d701d30c04
commit 586469482e
4 changed files with 52 additions and 6 deletions
+5 -1
View File
@@ -30,9 +30,13 @@ def resolve_frontend_dist() -> Path:
@asynccontextmanager
async def lifespan(app: FastAPI):
settings = get_settings()
db = Database()
set_db(db)
# 必须在 set_db 之后读 DB 覆盖,否则会按 .env 默认 okx 起会话,
# 而 health 显示 DB 里的 binance → 合约号/盘口错乱(期权一直 -/-)
from .exchange.runtime import load_runtime_settings
settings = load_runtime_settings()
engine = StrategyEngine()
set_engine(engine)
engine.ensure_loop()