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:
@@ -0,0 +1,89 @@
|
||||
<style>
|
||||
.strategy-records-page{padding:4px 0 16px}
|
||||
.strategy-records-page h2{margin:0 0 10px;color:#dbe4ff}
|
||||
.strategy-records-tip{font-size:.78rem;color:#8892b0;line-height:1.55;margin-bottom:14px}
|
||||
.strategy-records-table{width:100%;border-collapse:collapse;font-size:.82rem}
|
||||
.strategy-records-table th,.strategy-records-table td{padding:8px 10px;border-bottom:1px solid #2a3150;text-align:left}
|
||||
.strategy-records-table th{color:#8b95b8;font-weight:600;font-size:.74rem}
|
||||
.strategy-records-table tr:hover td{background:rgba(42,63,108,.25)}
|
||||
.strategy-records-table .tag-trend{color:#6ab8ff}
|
||||
.strategy-records-table .tag-roll{color:#ffb020}
|
||||
.strategy-records-detail{margin-top:8px;padding:10px 12px;background:#0f1424;border:1px solid #2a3150;border-radius:8px;font-size:.76rem;color:#cfd3ef;line-height:1.5}
|
||||
.strategy-dca-mini{width:100%;margin-top:6px;border-collapse:collapse;font-size:.72rem}
|
||||
.strategy-dca-mini th,.strategy-dca-mini td{padding:4px 8px;border-bottom:1px solid #243050}
|
||||
.strategy-dca-mini .st-done{color:#4cd97f}
|
||||
.strategy-dca-mini .st-pending{color:#8892b0}
|
||||
.strategy-snap-pnl.pos{color:#4cd97f}
|
||||
.strategy-snap-pnl.neg{color:#ff6666}
|
||||
</style>
|
||||
<div class="strategy-records-page card full">
|
||||
<h2>策略交易记录</h2>
|
||||
<p class="strategy-records-tip">
|
||||
已结束的趋势回调计划与顺势加仓组会在此留存快照(含补仓档位明细)。保本移交、手动结束、止盈止损均会写入。
|
||||
</p>
|
||||
{% if strategy_snapshots %}
|
||||
<div class="table-wrap">
|
||||
<table class="strategy-records-table">
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>策略</th>
|
||||
<th>品种</th>
|
||||
<th>方向</th>
|
||||
<th>结果</th>
|
||||
<th>盈亏U</th>
|
||||
<th>结束时间</th>
|
||||
<th>补仓明细</th>
|
||||
</tr>
|
||||
{% for s in strategy_snapshots %}
|
||||
{% set snap = s.snapshot or {} %}
|
||||
{% set dca = snap.dca_levels if snap.dca_levels is defined else [] %}
|
||||
{% set pnl = s.pnl_amount if s.pnl_amount is not none else snap.pnl_amount %}
|
||||
<tr>
|
||||
<td>{{ s.id }}</td>
|
||||
<td><span class="{% if s.strategy_type == 'trend_pullback' %}tag-trend{% else %}tag-roll{% endif %}">{{ s.strategy_label }}</span></td>
|
||||
<td>{{ s.symbol or s.exchange_symbol or '—' }}</td>
|
||||
<td><span class="badge {{ 'direction-long' if s.direction == 'long' else 'direction-short' }}">{{ '做多' if s.direction == 'long' else '做空' }}</span></td>
|
||||
<td>{{ s.result_label or '—' }}</td>
|
||||
<td class="{% if pnl is not none %}{% if pnl|float > 0 %}strategy-snap-pnl pos{% elif pnl|float < 0 %}strategy-snap-pnl neg{% endif %}{% endif %}">
|
||||
{% if pnl is not none %}{{ funds_fmt(pnl) }}{% else %}—{% endif %}
|
||||
</td>
|
||||
<td>{{ (s.closed_at or '')[:19] }}</td>
|
||||
<td>
|
||||
{% if dca and dca|length %}
|
||||
<details>
|
||||
<summary style="cursor:pointer;color:#8fc8ff">{{ dca|length }} 档</summary>
|
||||
<table class="strategy-dca-mini">
|
||||
<tr><th>档位</th><th>触发价</th><th>张数</th><th>状态</th></tr>
|
||||
{% for lv in dca %}
|
||||
<tr>
|
||||
<td>{{ lv.label or lv.leg_key }}</td>
|
||||
<td>{% if lv.price is not none %}{{ price_fmt(s.symbol or s.exchange_symbol, lv.price) }}{% else %}—{% endif %}</td>
|
||||
<td>{% if lv.contracts is not none %}{{ lv.contracts }}{% else %}—{% endif %}</td>
|
||||
<td class="{% if lv.status == 'done' %}st-done{% else %}st-pending{% endif %}">{{ lv.status_label or '—' }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
</details>
|
||||
{% elif s.strategy_type == 'roll' and snap.legs %}
|
||||
<details>
|
||||
<summary style="cursor:pointer;color:#8fc8ff">{{ snap.legs|length }} 腿</summary>
|
||||
<table class="strategy-dca-mini">
|
||||
<tr><th>#</th><th>状态</th></tr>
|
||||
{% for leg in snap.legs %}
|
||||
<tr>
|
||||
<td>{{ leg.leg_index or loop.index }}</td>
|
||||
<td>{{ leg.status_label or leg.status }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
</details>
|
||||
{% else %}—{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="rule-tip" style="color:#8892b0">暂无策略结束快照。结束趋势回调计划或顺势加仓组后会自动出现在此。</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
@@ -19,6 +19,13 @@
|
||||
.plan-cell .val.pnl-neutral{color:#cfd3ef}
|
||||
.btn-close-plan{padding:7px 14px;background:#5c1e2a;color:#ffb4b4;border:none;border-radius:8px;cursor:pointer;font-size:.82rem;font-weight:600;text-decoration:none;white-space:nowrap;display:inline-block}
|
||||
.btn-close-plan:hover{filter:brightness(1.08)}
|
||||
.plan-dca-block{margin-top:12px;padding-top:10px;border-top:1px dashed #2a3558}
|
||||
.plan-dca-title{font-size:.74rem;color:#8b95b8;margin-bottom:8px;letter-spacing:.02em}
|
||||
.plan-dca-table{width:100%;border-collapse:collapse;font-size:.76rem}
|
||||
.plan-dca-table th,.plan-dca-table td{padding:6px 8px;border-bottom:1px solid #243050;text-align:left}
|
||||
.plan-dca-table th{color:#6a7598;font-weight:600}
|
||||
.plan-dca-table .st-done{color:#4cd97f}
|
||||
.plan-dca-table .st-pending{color:#9aa3c4}
|
||||
@media (max-width:720px){
|
||||
.plan-card-grid{grid-template-columns:1fr}
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@
|
||||
| <span class="accent">{{ trend_add_zone_label(t.direction) }} {{ price_fmt(sym, t.add_upper) }}</span>
|
||||
| 已补仓 <strong>{{ t.legs_done }}/{{ t.dca_legs }}</strong>
|
||||
</div>
|
||||
<div class="plan-card-grid">
|
||||
<div class="plan-card-grid plan-card-grid--metrics">
|
||||
<div class="plan-cell">
|
||||
<span class="lbl">均价</span>
|
||||
<span class="val">{% if t.avg_entry_price is not none %}{{ price_fmt(sym, t.avg_entry_price) }}{% else %}—{% endif %}</span>
|
||||
@@ -155,6 +155,22 @@
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
{% if t.dca_levels %}
|
||||
<div class="plan-dca-block">
|
||||
<div class="plan-dca-title">补仓计划明细</div>
|
||||
<table class="plan-dca-table">
|
||||
<tr><th>档位</th><th>触发价</th><th>张数</th><th>状态</th></tr>
|
||||
{% for lv in t.dca_levels %}
|
||||
<tr>
|
||||
<td>{{ lv.label }}</td>
|
||||
<td>{% if lv.price is not none %}{{ price_fmt(sym, lv.price) }}{% else %}—{% endif %}</td>
|
||||
<td>{% if lv.contracts is not none %}{{ amt_disp(sym, lv.contracts) }}{% else %}—{% endif %}</td>
|
||||
<td class="{% if lv.status == 'done' %}st-done{% else %}st-pending{% endif %}">{{ lv.status_label }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="plan-card-meta" style="margin-top:8px">
|
||||
<form action="{{ url_for('trend_pullback_breakeven', pid=t.id) }}" method="post" class="form-row" style="margin:0;align-items:center" onsubmit="return confirm('确认保本?将结束本趋势计划,持仓移交「下单监控」(备注趋势回调计划),并在交易所同时挂保本止损与计划止盈;后续平仓会写入交易记录。');">
|
||||
<label style="font-size:.78rem;color:#cfd3ef;display:flex;align-items:center;gap:6px">
|
||||
|
||||
Reference in New Issue
Block a user