模拟盘对齐币本位:钱包支持 ETH/BTC,现货桥与期权权利金走本地撮合。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-08-20 15:16:51 +08:00
parent c8688a11ae
commit 6f721d1e6d
6 changed files with 836 additions and 516 deletions
+18
View File
@@ -14,6 +14,19 @@ def _env_float(key: str, default: float) -> float:
return float(default)
def _ensure_sim_wallet_coin_columns(conn: sqlite3.Connection) -> None:
"""旧库补齐币本位 ETH/BTC 列."""
cols = {
str(r[1])
for r in conn.execute("PRAGMA table_info(sim_wallets)").fetchall()
}
for col in ("funding_eth", "trading_eth", "funding_btc", "trading_btc"):
if col not in cols:
conn.execute(
f"ALTER TABLE sim_wallets ADD COLUMN {col} REAL NOT NULL DEFAULT 0"
)
def init_sim_tables(conn: sqlite3.Connection) -> None:
conn.execute(
"""
@@ -23,10 +36,15 @@ def init_sim_tables(conn: sqlite3.Connection) -> None:
trading_usdt REAL NOT NULL DEFAULT 0,
funding_usdc REAL NOT NULL DEFAULT 0,
trading_usdc REAL NOT NULL DEFAULT 0,
funding_eth REAL NOT NULL DEFAULT 0,
trading_eth REAL NOT NULL DEFAULT 0,
funding_btc REAL NOT NULL DEFAULT 0,
trading_btc REAL NOT NULL DEFAULT 0,
updated_at TEXT
)
"""
)
_ensure_sim_wallet_coin_columns(conn)
conn.execute(
"""
CREATE TABLE IF NOT EXISTS sim_perp_positions (