diff --git a/lib/common/static/instance_theme.css b/lib/common/static/instance_theme.css index 642f245..c8f42b1 100644 --- a/lib/common/static/instance_theme.css +++ b/lib/common/static/instance_theme.css @@ -1629,6 +1629,17 @@ html[data-theme="light"] #strategy-roll-panel .roll-section-title { color: #006e9a !important; } +#strategy-roll-panel .roll-active-groups-table .roll-tp-profit, +#strategy-roll-panel .roll-active-groups-table .roll-status-active { + color: #4cd97f; + font-weight: 600; +} + +html[data-theme="light"] #strategy-roll-panel .roll-active-groups-table .roll-tp-profit, +html[data-theme="light"] #strategy-roll-panel .roll-active-groups-table .roll-status-active { + color: #1a8f4a !important; +} + #roll-preview-box.roll-preview-box { margin: 8px 0; padding: 10px; diff --git a/lib/strategy/strategy_roll_ui_lib.py b/lib/strategy/strategy_roll_ui_lib.py index 43039e0..971b000 100644 --- a/lib/strategy/strategy_roll_ui_lib.py +++ b/lib/strategy/strategy_roll_ui_lib.py @@ -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"]) diff --git a/lib/strategy/templates/strategy_roll_panel.html b/lib/strategy/templates/strategy_roll_panel.html index 99620e0..5edf72f 100644 --- a/lib/strategy/templates/strategy_roll_panel.html +++ b/lib/strategy/templates/strategy_roll_panel.html @@ -55,21 +55,24 @@

活跃滚仓组

- - +
ID币种方向腿数首仓TP当前SL当前均价止盈盈利U
+ {% for g in roll_groups %} + + - + + {% else %} - + {% endfor %}
ID币种方向腿数首仓张数加仓后张数首仓TP当前SL当前均价止盈盈利U状态
{{ g.id }} {{ g.symbol }} {{ g.direction }} {{ g.leg_count }}{% if g.initial_qty is not none %}{{ '%.4g'|format(g.initial_qty) }}{% else %}—{% endif %}{% if g.current_qty is not none %}{{ '%.4g'|format(g.current_qty) }}{% else %}—{% endif %} {% if price_fmt %}{{ price_fmt(g.symbol, g.initial_take_profit) }}{% else %}{{ g.initial_take_profit }}{% endif %} {% if price_fmt %}{{ price_fmt(g.symbol, g.current_stop_loss) }}{% else %}{{ g.current_stop_loss }}{% endif %} {% if g.avg_entry_display %}{{ g.avg_entry_display }}{% elif g.avg_entry is not none %}{{ g.avg_entry }}{% else %}—{% endif %}{% if g.reward_at_tp_usdt is not none %}{{ '%.2f'|format(g.reward_at_tp_usdt) }}{% else %}—{% endif %}{% if g.reward_at_tp_usdt is not none %}{{ '%.2f'|format(g.reward_at_tp_usdt) }}{% else %}—{% endif %}滚仓中
暂无
暂无
diff --git a/tests/test_strategy_roll_ui_lib.py b/tests/test_strategy_roll_ui_lib.py index 61b423d..b83a0a7 100644 --- a/tests/test_strategy_roll_ui_lib.py +++ b/tests/test_strategy_roll_ui_lib.py @@ -30,6 +30,8 @@ def test_compute_roll_chain_metrics_short(): assert per_leg[10]["avg_entry_after"] is not None assert per_leg[11]["avg_entry_after"] is not None assert group_metrics["reward_at_tp_usdt"] is not None + assert group_metrics["initial_qty"] == 3.0 + assert group_metrics["current_qty"] == 8.0 assert per_leg[11]["reward_at_tp_usdt"] >= per_leg[10]["reward_at_tp_usdt"]