fix顶栏总交易/胜率/盈亏比与账户结算口径对齐,新单仅计已冻结。
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -821,9 +821,10 @@ def header_options_stats_for_window(
|
||||
app_tz,
|
||||
ex: Any = None,
|
||||
) -> dict[str, Any]:
|
||||
"""顶栏总交易/胜率/盈亏比:纯期权(options_trades),全站导航共用,按列表窗过滤.
|
||||
"""顶栏总交易/胜率/盈亏比:与期权统计同一结算口径.
|
||||
|
||||
币本位 realized_pnl 为币数量,须折 U 后再算盈亏比,否则 BTC/ETH 混算会严重失真.
|
||||
新单(有 trading_usdt_before):仅 pnl_settled=1 的账户差分计入;
|
||||
旧单(无 before):仍按原 realized 兼容.币数量须折 U 后再算盈亏比.
|
||||
"""
|
||||
from lib.common.history_window_lib import utc_window_to_bj_sql_strings
|
||||
|
||||
@@ -841,7 +842,11 @@ def header_options_stats_for_window(
|
||||
created_at, closed_at, inst_id, underlying, premium_ccy
|
||||
FROM options_trades
|
||||
WHERE status = 'closed'
|
||||
AND (realized_pnl IS NOT NULL OR realized_pnl_usdt IS NOT NULL)
|
||||
AND (
|
||||
(COALESCE(pnl_settled, 0) = 1 AND realized_pnl_usdt IS NOT NULL)
|
||||
OR (trading_usdt_before IS NULL
|
||||
AND (realized_pnl IS NOT NULL OR realized_pnl_usdt IS NOT NULL))
|
||||
)
|
||||
AND COALESCE(closed_at, created_at) >= ?
|
||||
AND COALESCE(closed_at, created_at) <= ?
|
||||
""",
|
||||
|
||||
Reference in New Issue
Block a user