Include options unrealized PnL in OKX instance header realtime PnL total.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -110,3 +110,18 @@ def resolve_instance_unrealized_pnl(
|
||||
if active_rows and get_metrics_fn:
|
||||
return sum_unrealized_pnl_from_metrics(active_rows, get_metrics_fn)
|
||||
return None
|
||||
|
||||
|
||||
def merge_unrealized_pnl_components(*parts: float | None) -> float | None:
|
||||
"""合并永续与期权等多路未实现盈亏(任一路有值即参与合计)。"""
|
||||
total = 0.0
|
||||
found = False
|
||||
for part in parts:
|
||||
if part is None:
|
||||
continue
|
||||
try:
|
||||
total += float(part)
|
||||
found = True
|
||||
except (TypeError, ValueError):
|
||||
continue
|
||||
return round(total, 2) if found else None
|
||||
|
||||
Reference in New Issue
Block a user