Show initial and current roll position size plus rolling status on active roll groups table.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-08 16:45:32 +08:00
parent f5f302b97e
commit 5ef6affabf
4 changed files with 38 additions and 5 deletions
+18 -1
View File
@@ -106,7 +106,12 @@ def compute_roll_chain_metrics(
group_metrics: 最后一腿后的 {avg_entry, reward_at_tp_usdt}
"""
per_leg: dict[Any, dict] = {}
group_out: dict[str, Any] = {"avg_entry": None, "reward_at_tp_usdt": None}
group_out: dict[str, Any] = {
"avg_entry": None,
"reward_at_tp_usdt": None,
"initial_qty": None,
"current_qty": None,
}
if not isinstance(group, dict):
return per_leg, group_out
direction = (group.get("direction") or "long").strip().lower()
@@ -126,6 +131,8 @@ def compute_roll_chain_metrics(
return per_leg, group_out
qty = float(q0)
avg = float(e0)
group_out["initial_qty"] = round(qty, 4)
group_out["current_qty"] = round(qty, 4)
if tp > 0:
group_out["avg_entry"] = avg
group_out["reward_at_tp_usdt"] = reward_at_tp_usdt(
@@ -154,6 +161,14 @@ def compute_roll_chain_metrics(
}
group_out["avg_entry"] = round(avg, 10)
group_out["reward_at_tp_usdt"] = round(reward, 4) if reward is not None else None
group_out["current_qty"] = round(qty, 4)
if qty_live is not None:
try:
live_qty = float(qty_live)
if live_qty > 0:
group_out["current_qty"] = round(live_qty, 4)
except (TypeError, ValueError):
pass
return per_leg, group_out
@@ -264,6 +279,8 @@ def enrich_roll_page_data(conn, page_data: dict, cfg: dict | None) -> dict:
)
g["avg_entry"] = group_metrics.get("avg_entry")
g["reward_at_tp_usdt"] = group_metrics.get("reward_at_tp_usdt")
g["initial_qty"] = group_metrics.get("initial_qty")
g["current_qty"] = group_metrics.get("current_qty")
if callable(price_fmt) and g.get("avg_entry") is not None:
try:
g["avg_entry_display"] = price_fmt(g.get("symbol"), g["avg_entry"])