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:
@@ -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"))
|
||||
|
||||
Reference in New Issue
Block a user