fix: 品种推荐改为最大手数并补算旧缓存。

- 最大手数 = floor(权益×保证金上限%÷1手保证金)
- 加载与 SSE 推送时实时补算,旧缓存缺字段时自动刷新

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-25 12:24:10 +08:00
parent 9875ee6d44
commit 074551490f
7 changed files with 109 additions and 23 deletions
+1 -1
View File
@@ -70,7 +70,7 @@
</div>
<button type="submit" class="btn-primary" style="margin-top:.75rem">保存交易设置</button>
<p class="hint" style="margin-top:.75rem;margin-bottom:0">
保证金上限用于开仓校验与品种推荐手数(默认 30%)。在 <code>.env</code> 配置 <code>SIMNOW_USER</code>,于「持仓监控」连接 CTP;权益与行情优先来自柜台。
保证金上限用于开仓校验与品种最大手数估算(默认 30%)。在 <code>.env</code> 配置 <code>SIMNOW_USER</code>,于「持仓监控」连接 CTP;权益与行情优先来自柜台。
</p>
</form>
</div>
+3 -3
View File
@@ -107,7 +107,7 @@
<div class="card trade-card trade-card-full" id="recommend">
<h2>品种推荐</h2>
<div class="card-body">
<p class="hint">权益 <strong class="text-accent" id="rec-capital">{{ '%.2f'|format(capital) }}</strong> × 保证金上限 <strong>{{ max_margin_pct }}%</strong> 推荐手数;参考止损/止盈按 20 跳、盈亏比 2:1 估算。
<p class="hint">最大手数 = floor(权益 × 保证金上限 <strong>{{ max_margin_pct }}%</strong> ÷ 1手保证金);当前权益 <strong class="text-accent" id="rec-capital">{{ '%.2f'|format(capital) }}</strong>参考止损/止盈按 20 跳、盈亏比 2:1 估算。
{% if recommend_updated_at %}<span class="text-muted">每日后台更新 · 最近 {{ recommend_updated_at }}</span>{% else %}<span class="text-muted" id="rec-updated">等待今日后台刷新…</span>{% endif %}
</p>
<div class="trade-table-wrap">
@@ -116,7 +116,7 @@
<tr>
<th>品种</th><th>交易所</th><th>参考价</th>
<th>参考止损</th><th>参考止盈</th>
<th>1手保证金</th><th>1手手续费</th><th>推荐手数</th><th>状态</th>
<th>1手保证金</th><th>1手手续费</th><th>最大手数</th><th>状态</th>
</tr>
</thead>
<tbody id="recommend-list">
@@ -130,7 +130,7 @@
<td>{% if r.ref_take_profit %}{{ r.ref_take_profit }}{% else %}—{% endif %}</td>
<td>{% if r.margin_one_lot %}{{ r.margin_one_lot }}{% else %}—{% endif %}</td>
<td>{% if r.open_fee_one_lot is defined and r.open_fee_one_lot is not none %}{{ r.open_fee_one_lot }}{% else %}—{% endif %}</td>
<td>{% if r.recommended_lots %}{{ r.recommended_lots }}{% else %}—{% endif %}</td>
<td>{% if r.max_lots is not none and r.max_lots > 0 %}{{ r.max_lots }}{% else %}—{% endif %}</td>
<td><span class="badge {% if r.status=='ok' %}profit{% else %}planned{% endif %}">{{ r.status_label }}</span></td>
</tr>
{% endfor %}