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:
@@ -3824,7 +3824,9 @@ def enrich_active_trend_plan_row(row):
|
||||
d["floating_mark"] = float(m["mark_price"])
|
||||
else:
|
||||
d["floating_mark"] = None
|
||||
return d
|
||||
from strategy_snapshot_lib import attach_trend_dca_levels
|
||||
|
||||
return attach_trend_dca_levels(d)
|
||||
|
||||
|
||||
def opened_at_str_to_ms(opened_at_str):
|
||||
@@ -4602,6 +4604,25 @@ def _trend_finalize_plan(conn, row, result_label, exit_price, closed_at=None):
|
||||
if not getattr(cur, "rowcount", 0):
|
||||
return
|
||||
conn.commit()
|
||||
try:
|
||||
cfg = app.extensions.get("strategy_trend_cfg") or {}
|
||||
closed = conn.execute(
|
||||
"SELECT * FROM trend_pullback_plans WHERE id=?", (plan_id,)
|
||||
).fetchone()
|
||||
if closed and cfg:
|
||||
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 get_trading_day()
|
||||
@@ -5457,7 +5478,11 @@ def render_main_page(page="trade"):
|
||||
elif pr:
|
||||
trend_preview_expired = True
|
||||
strategy_extra = {}
|
||||
if page in ("strategy", "strategy_trend", "strategy_roll"):
|
||||
if page == "strategy_records":
|
||||
from strategy_ui import strategy_render_extras
|
||||
|
||||
strategy_extra = strategy_render_extras(conn, page)
|
||||
elif page in ("strategy", "strategy_trend", "strategy_roll"):
|
||||
from strategy_ui import fetch_roll_page_data
|
||||
|
||||
strategy_extra = fetch_roll_page_data(
|
||||
|
||||
@@ -248,6 +248,7 @@
|
||||
<div class="top-nav">
|
||||
<a href="/trade" class="{% if page == 'trade' %}active{% endif %}">交易执行</a>
|
||||
<a href="/strategy" class="{% if page in ('strategy', 'strategy_trend', 'strategy_roll') %}active{% endif %}">策略交易</a>
|
||||
<a href="/strategy/records" class="{% if page == 'strategy_records' %}active{% endif %}">策略交易记录</a>
|
||||
<a href="/records" class="{% if page == 'records' %}active{% endif %}">交易记录与复盘</a>
|
||||
<a href="/stats" class="{% if page == 'stats' %}active{% endif %}">统计分析</a>
|
||||
</div>
|
||||
@@ -422,6 +423,8 @@
|
||||
{% elif page in ('strategy', 'strategy_trend', 'strategy_roll') %}
|
||||
{% set can_trade_trend = can_trade %}
|
||||
{% include 'strategy_trading_page.html' %}
|
||||
{% elif page == 'strategy_records' %}
|
||||
{% include 'strategy_records_page.html' %}
|
||||
{% endif %}
|
||||
|
||||
{% if page == 'records' %}
|
||||
|
||||
Reference in New Issue
Block a user