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:
dekun
2026-07-29 17:06:13 +08:00
parent 1c75db4a19
commit 5c3bd4b654
13 changed files with 1020 additions and 6 deletions
+18 -2
View File
@@ -50,7 +50,15 @@ class Ledger:
(group_id, kind, float(amount), equity, note, now),
)
self.db._conn.commit()
return equity
try:
from ..config import get_settings
from .funds_wallets import SimFundsWallets
if get_settings().is_sim:
SimFundsWallets(self.db).mirror_cash(float(amount), kind=kind)
except Exception:
pass
return equity
def reset_equity(self, amount: float, *, note: str = "重置模拟资金") -> float:
"""将权益与可用资金重置为 amount(reserved 清零)。须在无持仓时调用。"""
@@ -68,7 +76,15 @@ class Ledger:
(None, "reset", amt, amt, note, now),
)
self.db._conn.commit()
return amt
try:
from ..config import get_settings
from .funds_wallets import SimFundsWallets
if get_settings().is_sim:
SimFundsWallets(self.db).reset_from_equity(amt)
except Exception:
pass
return amt
def get_setting_float(self, key: str, default: float) -> float:
v = self.db.get_setting(key)