Add initial funds to fleet stats and color total PnL.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -304,6 +304,7 @@ async def _collect_one_stats(node: dict[str, Any]) -> dict[str, Any]:
|
||||
"name": node["name"],
|
||||
"ok": False,
|
||||
"error": None,
|
||||
"initial_funds": None,
|
||||
"latest_funds": None,
|
||||
"groups": None,
|
||||
"fees_perp": None,
|
||||
@@ -345,9 +346,18 @@ async def _collect_one_stats(node: dict[str, Any]) -> dict[str, Any]:
|
||||
if latest_funds is None:
|
||||
latest_funds = 0.0
|
||||
|
||||
initial_funds = data.get("initial_funds")
|
||||
if initial_funds is None:
|
||||
# 旧版策略机:用最新资金 − 已实现盈亏近似初始资金
|
||||
try:
|
||||
initial_funds = float(latest_funds) - float(data.get("total_pnl") or 0)
|
||||
except Exception:
|
||||
initial_funds = None
|
||||
|
||||
base.update(
|
||||
{
|
||||
"ok": True,
|
||||
"initial_funds": initial_funds,
|
||||
"latest_funds": latest_funds,
|
||||
"groups": data.get("groups"),
|
||||
"fees_perp": data.get("fees_perp"),
|
||||
|
||||
Reference in New Issue
Block a user