中控快照增加初始资金字段,供统计页收益率分母使用。
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -198,11 +198,36 @@ def _enrich_hub_protocol(snap: dict[str, Any], *, app_module: Any) -> dict[str,
|
||||
out["pnl"] = {
|
||||
"unrealized_usdt": out.get("upl_total_usdc"),
|
||||
}
|
||||
initial_cash_usdt = None
|
||||
try:
|
||||
import os
|
||||
|
||||
if mode == "sim":
|
||||
initial_cash_usdt = float(os.getenv("SIM_INITIAL_EQUITY_USDT") or 10000)
|
||||
else:
|
||||
for key in (
|
||||
"LIVE_INITIAL_EQUITY_USDT",
|
||||
"OPTIONS_INITIAL_EQUITY_USDT",
|
||||
"HUB_INITIAL_CASH_USDT",
|
||||
):
|
||||
raw = (os.getenv(key) or "").strip()
|
||||
if not raw:
|
||||
continue
|
||||
initial_cash_usdt = float(raw)
|
||||
break
|
||||
if initial_cash_usdt is not None and initial_cash_usdt <= 0:
|
||||
initial_cash_usdt = None
|
||||
elif initial_cash_usdt is not None:
|
||||
initial_cash_usdt = round(float(initial_cash_usdt), 4)
|
||||
except (TypeError, ValueError):
|
||||
initial_cash_usdt = None
|
||||
|
||||
out["premium"] = {
|
||||
"paid_usdt": premium_usdt,
|
||||
"cash_usdt": cash_usdt,
|
||||
"equity_usdt": equity_usdt,
|
||||
"ratio_pct": ratio_pct,
|
||||
"initial_cash_usdt": initial_cash_usdt,
|
||||
}
|
||||
out["positions_brief"] = slim_pos
|
||||
out["cond_order_locked"] = bool(out.get("cond_order_locked"))
|
||||
|
||||
Reference in New Issue
Block a user