中控快照增加初始资金字段,供统计页收益率分母使用。
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -80,6 +80,8 @@ LIVE_TRADING_ENABLED=true
|
|||||||
SIM_DEFAULT_MODE=sim
|
SIM_DEFAULT_MODE=sim
|
||||||
SIM_INITIAL_EQUITY_USDT=10000
|
SIM_INITIAL_EQUITY_USDT=10000
|
||||||
SIM_INITIAL_USDC=0
|
SIM_INITIAL_USDC=0
|
||||||
|
# 实盘初始资金(U);中控收益率=已结算盈亏/该值。不填则中控回退最早余额采样
|
||||||
|
LIVE_INITIAL_EQUITY_USDT=
|
||||||
SIM_FEE_RATE=0.0005
|
SIM_FEE_RATE=0.0005
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# OKX 账户 API(永续 + 期权共用同一套密钥;修改后须重启 PM2)
|
# OKX 账户 API(永续 + 期权共用同一套密钥;修改后须重启 PM2)
|
||||||
|
|||||||
@@ -198,11 +198,36 @@ def _enrich_hub_protocol(snap: dict[str, Any], *, app_module: Any) -> dict[str,
|
|||||||
out["pnl"] = {
|
out["pnl"] = {
|
||||||
"unrealized_usdt": out.get("upl_total_usdc"),
|
"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"] = {
|
out["premium"] = {
|
||||||
"paid_usdt": premium_usdt,
|
"paid_usdt": premium_usdt,
|
||||||
"cash_usdt": cash_usdt,
|
"cash_usdt": cash_usdt,
|
||||||
"equity_usdt": equity_usdt,
|
"equity_usdt": equity_usdt,
|
||||||
"ratio_pct": ratio_pct,
|
"ratio_pct": ratio_pct,
|
||||||
|
"initial_cash_usdt": initial_cash_usdt,
|
||||||
}
|
}
|
||||||
out["positions_brief"] = slim_pos
|
out["positions_brief"] = slim_pos
|
||||||
out["cond_order_locked"] = bool(out.get("cond_order_locked"))
|
out["cond_order_locked"] = bool(out.get("cond_order_locked"))
|
||||||
|
|||||||
Reference in New Issue
Block a user