Fix hub funds overview double-counting OKX USDT with options.

Only add options USDC/USDG onto perpetual USDT totals, repair historical double-counted snapshots, and label the options line as USDC.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-08-07 10:30:34 +08:00
parent 4bc238b014
commit 0b8e5a0914
5 changed files with 134 additions and 19 deletions
+4 -3
View File
@@ -8,7 +8,7 @@ from pathlib import Path
from typing import Any, Optional
from lib.hub.hub_trades_lib import current_trading_day
from lib.hub.hub_options_funds_lib import merge_board_row_balances
from lib.hub.hub_options_funds_lib import merge_board_row_balances, repair_double_counted_fund_entry
from lib.paths import manual_trading_hub_dir
@@ -275,7 +275,7 @@ def _series_from_history(
total = 0.0
n = 0
for key in account_keys:
ac = ac_map.get(key) or {}
ac = repair_double_counted_fund_entry(ac_map.get(key) or {})
t = account_total_usdt(ac.get("funding_usdt"), ac.get("trading_usdt"))
if t is None:
t = _safe_float(ac.get("total_usdt"))
@@ -291,7 +291,8 @@ def _series_from_history(
def _account_series(history: dict[str, dict], key: str) -> list[dict[str, Any]]:
out: list[dict[str, Any]] = []
for day in sorted(history.keys()):
ac = (history.get(day) or {}).get("accounts", {}).get(key) or {}
raw = (history.get(day) or {}).get("accounts", {}).get(key) or {}
ac = repair_double_counted_fund_entry(raw)
t = account_total_usdt(ac.get("funding_usdt"), ac.get("trading_usdt"))
if t is None:
t = _safe_float(ac.get("total_usdt"))