Add OKX-style funds bar with USDT/USDC convert and transfer.
SIM uses multi-wallet balances; LIVE hits OKX asset/account APIs and spot USDC-USDT swap. Funds strip hides sim labeling. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -123,6 +123,16 @@ CREATE TABLE IF NOT EXISTS residual_options (
|
||||
note TEXT,
|
||||
FOREIGN KEY(group_id) REFERENCES groups(group_id)
|
||||
);
|
||||
CREATE TABLE IF NOT EXISTS funds_wallets (
|
||||
id INTEGER PRIMARY KEY CHECK (id = 1),
|
||||
funding_usdt REAL NOT NULL DEFAULT 0,
|
||||
trading_usdt REAL NOT NULL DEFAULT 0,
|
||||
options_funding_usdc REAL NOT NULL DEFAULT 0,
|
||||
options_trading_usdc REAL NOT NULL DEFAULT 0,
|
||||
options_funding_usdt REAL NOT NULL DEFAULT 0,
|
||||
options_trading_usdt REAL NOT NULL DEFAULT 0,
|
||||
updated_at_ms INTEGER NOT NULL
|
||||
);
|
||||
"""
|
||||
|
||||
|
||||
@@ -192,6 +202,19 @@ class Database:
|
||||
"INSERT INTO strategy_state(id, running, phase, rounds_done, updated_at_ms) VALUES (1,0,'idle',0,?)",
|
||||
(now,),
|
||||
)
|
||||
fw = self._conn.execute("SELECT id FROM funds_wallets WHERE id=1").fetchone()
|
||||
if fw is None:
|
||||
led = self._conn.execute(
|
||||
"SELECT equity FROM ledger_meta WHERE id=1"
|
||||
).fetchone()
|
||||
eq = float(led["equity"]) if led else float(s.initial_equity)
|
||||
self._conn.execute(
|
||||
"""INSERT INTO funds_wallets(
|
||||
id, funding_usdt, trading_usdt, options_funding_usdc, options_trading_usdc,
|
||||
options_funding_usdt, options_trading_usdt, updated_at_ms
|
||||
) VALUES (1,?,0,0,0,0,0,?)""",
|
||||
(eq, now),
|
||||
)
|
||||
defaults = {
|
||||
"fee_rate": str(s.fee_rate),
|
||||
"initial_equity": str(s.initial_equity),
|
||||
|
||||
Reference in New Issue
Block a user