Add SIM/LIVE switch with API keys saved to .env and OKX live executor.
Enable settings UI for mode/keys, gate strategy start when LIVE is not ready, and stop PM2 from forcing MODE=SIM. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -40,7 +40,8 @@ CREATE TABLE IF NOT EXISTS groups (
|
||||
realized_pnl REAL DEFAULT 0,
|
||||
fees REAL DEFAULT 0,
|
||||
slip_cost REAL DEFAULT 0,
|
||||
note TEXT
|
||||
note TEXT,
|
||||
exec_mode TEXT
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS fills (
|
||||
@@ -58,6 +59,7 @@ CREATE TABLE IF NOT EXISTS fills (
|
||||
slip REAL NOT NULL,
|
||||
notional REAL NOT NULL,
|
||||
ts_ms INTEGER NOT NULL,
|
||||
exec_mode TEXT,
|
||||
FOREIGN KEY(group_id) REFERENCES groups(group_id)
|
||||
);
|
||||
|
||||
@@ -140,8 +142,26 @@ class Database:
|
||||
self._conn.execute("PRAGMA journal_mode=WAL;")
|
||||
self._conn.executescript(_SCHEMA)
|
||||
self._conn.commit()
|
||||
self._migrate_columns()
|
||||
self._ensure_seed()
|
||||
|
||||
def _migrate_columns(self) -> None:
|
||||
"""幂等补列:exec_mode。"""
|
||||
with self._lock:
|
||||
for table, col, decl in (
|
||||
("groups", "exec_mode", "TEXT"),
|
||||
("fills", "exec_mode", "TEXT"),
|
||||
):
|
||||
cols = {
|
||||
str(r[1])
|
||||
for r in self._conn.execute(f"PRAGMA table_info({table})").fetchall()
|
||||
}
|
||||
if col not in cols:
|
||||
self._conn.execute(
|
||||
f"ALTER TABLE {table} ADD COLUMN {col} {decl}"
|
||||
)
|
||||
self._conn.commit()
|
||||
|
||||
def close(self) -> None:
|
||||
with self._lock:
|
||||
self._conn.close()
|
||||
|
||||
Reference in New Issue
Block a user