Align funds to OKX funding/trading only; fold rules; match settings width.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-29 17:59:28 +08:00
parent 80c561bdce
commit 81e51236c0
8 changed files with 198 additions and 178 deletions
+1 -11
View File
@@ -14,8 +14,6 @@ _ACCT_CODE = {
"funding": "6",
"trading": "18",
"spot": "18",
"options_funding": "6",
"options_trading": "18",
}
@@ -46,10 +44,6 @@ class OkxFundsClient:
"funding_usdc": None,
"trading_usdt": None,
"trading_usdc": None,
"options_funding_usdc": None,
"options_trading_usdc": None,
"options_funding_usdt": None,
"options_trading_usdt": None,
}
try:
rows = self.trade._request("GET", "/api/v5/asset/balances")
@@ -58,10 +52,8 @@ class OkxFundsClient:
bal = _f(row.get("bal")) or _f(row.get("availBal"))
if ccy == "USDT":
out["funding_usdt"] = bal
out["options_funding_usdt"] = bal
elif ccy == "USDC":
out["funding_usdc"] = bal
out["options_funding_usdc"] = bal
except Exception as e:
logger.warning("OKX asset balances failed: %s", e)
@@ -78,10 +70,8 @@ class OkxFundsClient:
eq = _f(row.get("eq")) or _f(row.get("cashBal")) or _f(row.get("availBal"))
if ccy == "USDT":
out["trading_usdt"] = eq
out["options_trading_usdt"] = eq
elif ccy == "USDC":
out["trading_usdc"] = eq
out["options_trading_usdc"] = eq
except Exception as e:
logger.warning("OKX account balance failed: %s", e)
@@ -148,7 +138,7 @@ class OkxFundsClient:
from_code = _ACCT_CODE.get(fa)
to_code = _ACCT_CODE.get(ta)
if not from_code or not to_code:
return {"ok": False, "detail": "账户须为 funding/trading(或 options_* 别名)"}
return {"ok": False, "detail": "账户须为 funding / trading"}
body = {
"ccy": str(ccy).upper(),
"amt": str(amt),