feat: strategy trade snapshots, DCA detail, and hub trend layout

Persist ended trend pullback and roll group snapshots to a unified records page; show replenishment tiers on instance and hub cards with horizontal single-position layout.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-04 10:45:27 +08:00
parent 1a6b5f55a1
commit 3fb2023efb
21 changed files with 665 additions and 44 deletions
+33 -1
View File
@@ -434,7 +434,9 @@ def enrich_trend_plan(cfg: dict, row) -> dict:
d["floating_mark"] = None
else:
d["floating_pnl"] = d["floating_mark"] = None
return d
from strategy_snapshot_lib import attach_trend_dca_levels
return attach_trend_dca_levels(d)
def _weighted_avg(old_avg, old_amt, fill_px, add_amt):
@@ -502,6 +504,24 @@ def _finalize_plan(cfg: dict, conn, row, result_label: str, exit_price: float) -
if not getattr(cur, "rowcount", 0):
return
conn.commit()
try:
closed = conn.execute(
"SELECT * FROM trend_pullback_plans WHERE id=?", (plan_id,)
).fetchone()
if closed:
from strategy_snapshot_lib import save_trend_plan_snapshot
save_trend_plan_snapshot(
cfg,
conn,
closed,
result_label=result_label,
exit_price=float(exit_price),
pnl_amount=float(pnl_amount) if pnl_amount is not None else None,
)
conn.commit()
except Exception:
pass
if _trend_plan_trade_exists(conn, plan_id):
return
session_date = row["session_date"] or m.get_trading_day()
@@ -937,6 +957,18 @@ def apply_manual_breakeven(cfg: dict, conn, row, offset_pct=None) -> tuple[bool,
if callable(wl):
lines.insert(1, f"**账户:{wl()}**")
send("\n".join(lines))
try:
handoff = conn.execute(
"SELECT * FROM trend_pullback_plans WHERE id=?", (plan_id,)
).fetchone()
if handoff:
from strategy_snapshot_lib import save_trend_plan_snapshot
save_trend_plan_snapshot(
cfg, conn, handoff, result_label="保本移交", exit_price=None, pnl_amount=None
)
except Exception:
pass
return True, None