Fix monitor board crash: avoid shadowing options_open_position_count helper.
Rename the imported counter function so aggregate_monitor_board_totals no longer overwrites it with an int accumulator. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -3,7 +3,10 @@ from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from lib.hub.hub_options_funds_lib import options_float_pnl_usdt, options_open_position_count
|
||||
from lib.hub.hub_options_funds_lib import (
|
||||
options_float_pnl_usdt,
|
||||
options_open_position_count as count_options_positions,
|
||||
)
|
||||
|
||||
|
||||
def _coerce_float(value: Any) -> float | None:
|
||||
@@ -83,7 +86,7 @@ def aggregate_monitor_board_totals(
|
||||
float_pnl_u += sum(position_unrealized_pnl(p) for p in open_pos)
|
||||
|
||||
opt_snap = row.get("options") if "options" in (row.get("capabilities") or []) else None
|
||||
opt_count = options_open_position_count(opt_snap)
|
||||
opt_count = count_options_positions(opt_snap)
|
||||
options_open_position_count += opt_count
|
||||
open_position_count += opt_count
|
||||
opt_upl = options_float_pnl_usdt(opt_snap)
|
||||
|
||||
@@ -43,6 +43,26 @@ def test_aggregate_monitor_board_totals_sums_rows():
|
||||
assert out["float_pnl_u"] == 1.2
|
||||
|
||||
|
||||
def test_aggregate_monitor_board_totals_includes_options():
|
||||
rows = [
|
||||
{
|
||||
"capabilities": ["options"],
|
||||
"options": {
|
||||
"ok": True,
|
||||
"enabled": True,
|
||||
"positions": [{"inst_id": "X"}, {"inst_id": "Y"}],
|
||||
"upl_total_usdc": 1.5,
|
||||
},
|
||||
"agent": {"positions": [], "total_unrealized_pnl": 0},
|
||||
}
|
||||
]
|
||||
out = aggregate_monitor_board_totals(rows, trading_day="2026-07-04", reset_hour=8)
|
||||
assert out["options_open_position_count"] == 2
|
||||
assert out["open_position_count"] == 2
|
||||
assert out["options_float_pnl_u"] == 1.5
|
||||
assert out["float_pnl_u"] == 1.5
|
||||
|
||||
|
||||
def test_summarize_trades_win_loss_amounts():
|
||||
from lib.hub.hub_trades_lib import summarize_trades
|
||||
|
||||
|
||||
Reference in New Issue
Block a user