fix: trend preview uses USDT profit, snapshot risk budget, and money RR across four exchanges

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-05 16:20:59 +08:00
parent 31756e838d
commit 32f4eec1d3
6 changed files with 223 additions and 70 deletions
+16
View File
@@ -249,6 +249,7 @@ def parse_trend_plan(cfg: dict, form_dict) -> tuple[Optional[dict], Optional[str
leg_list = json.loads(leg_json)
except Exception:
leg_list = []
contract_size = float(market.get("contractSize") or 1)
return {
"symbol": symbol,
"exchange_symbol": exchange_symbol,
@@ -271,6 +272,7 @@ def parse_trend_plan(cfg: dict, form_dict) -> tuple[Optional[dict], Optional[str
"leg_amounts_json": leg_json,
"grid": grid,
"leg_amounts": leg_list,
"contract_size": contract_size,
}, None
@@ -486,6 +488,12 @@ def enrich_trend_plan(cfg: dict, row) -> dict:
d["floating_mark"] = None
else:
d["floating_pnl"] = d["floating_mark"] = None
get_cs = getattr(m, "get_contract_size", None)
if callable(get_cs):
try:
d["contract_size"] = float(get_cs(ex_sym))
except (TypeError, ValueError):
pass
from strategy_snapshot_lib import attach_trend_dca_levels
d = attach_trend_dca_levels(d)
@@ -1097,6 +1105,14 @@ def load_trend_page_context(conn, request_obj, cfg: dict) -> dict[str, Any]:
trend_preview = _row(cfg, pr)
preview_expires_ms = int(pr["expires_at_ms"])
get_cs = getattr(m, "get_contract_size", None)
if callable(get_cs) and not trend_preview.get("contract_size"):
try:
trend_preview["contract_size"] = float(
get_cs(trend_preview.get("exchange_symbol") or trend_preview.get("symbol") or "")
)
except (TypeError, ValueError):
pass
trend_preview, trend_preview_levels = build_trend_preview_level_rows(trend_preview)
elif pr:
trend_preview_expired = True