Add OKX trading-account USDC auto-swap and lock exit target while in position.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-30 00:16:47 +08:00
parent f0b0b91f1b
commit 0837982714
16 changed files with 626 additions and 36 deletions
+7 -1
View File
@@ -20,6 +20,12 @@ _LIVE_BAL_TTL_SEC = 8.0
_notified_while_short: bool = False
def invalidate_live_balance_cache() -> None:
"""兑换/划转后强制下次重拉交易账户余额。"""
_live_bal_cache["ts"] = 0.0
_live_bal_cache["data"] = None
def _f(v: Any) -> float | None:
try:
if v is None or v == "":
@@ -211,7 +217,7 @@ def maybe_notify_funds_short(cap: dict[str, Any] | None = None) -> None:
f"**永续**: {cap.get('perp_label')}",
f"**期权**: {cap.get('option_label')}",
*[f"**详情**: {p}" for p in parts],
"请从资金账户划转到交易账户后重试",
"OKX 开仓前会尝试交易账户市价兑 USDC;仍不足请检查交易账户余额",
],
)
)