fix(binance): show orphan recover banner on trade page load
Trade tab uses refreshPriceSnapshotConditional, not refreshPriceSnapshot; render recover banner there and on server when live exchange position lacks active monitor. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -6888,6 +6888,9 @@ def render_main_page(page="trade"):
|
||||
request_obj=request,
|
||||
trend_cfg=app.extensions.get("strategy_trend_cfg"),
|
||||
)
|
||||
orphan_live_positions = []
|
||||
if not order_list and exchange_private_api_configured():
|
||||
orphan_live_positions = list_orphan_live_positions(conn)
|
||||
conn.close()
|
||||
return render_template(
|
||||
"index.html",
|
||||
@@ -6896,6 +6899,7 @@ def render_main_page(page="trade"):
|
||||
key_history=key_history,
|
||||
stats_bundle=stats_bundle,
|
||||
order=order_list,
|
||||
orphan_live_positions=orphan_live_positions,
|
||||
record=records,
|
||||
total=total,
|
||||
miss_count=miss_count,
|
||||
|
||||
@@ -402,7 +402,19 @@
|
||||
</div>
|
||||
<div class="card">
|
||||
<h2 style="margin-bottom:8px">实时持仓</h2>
|
||||
{% if not order and orphan_live_positions %}
|
||||
{% set o = orphan_live_positions[0] %}
|
||||
<div id="orphan-position-recover" class="orphan-recover-banner" style="display:block;margin-bottom:10px;padding:10px 12px;background:#2a2210;border:1px solid #6b5420;border-radius:6px;font-size:.9rem;color:#e8d5a8">
|
||||
检测到交易所仍有 <strong>{{ o.symbol }}</strong> {{ '空' if o.direction == 'short' else '多' }}仓,但本地监控已中断(误同步时可能无交易记录)。
|
||||
{% if o.recoverable_monitor_id %}
|
||||
<button type="button" class="pos-entrust-btn" onclick="recoverLivePosition({{ o.recoverable_monitor_id }})">恢复监控{% if o.plan_stop_loss and o.plan_take_profit %}并挂止盈止损{% endif %}</button>
|
||||
{% else %}
|
||||
未找到可恢复的监控记录,需在服务器数据库处理。
|
||||
{% endif %}
|
||||
</div>
|
||||
{% else %}
|
||||
<div id="orphan-position-recover" class="orphan-recover-banner" style="display:none;margin-bottom:10px;padding:10px 12px;background:#2a2210;border:1px solid #6b5420;border-radius:6px;font-size:.9rem;color:#e8d5a8"></div>
|
||||
{% endif %}
|
||||
<div class="panel-scroll pos-list pos-list-live">
|
||||
{% for o in order %}
|
||||
<div class="pos-card" id="order-row-{{ o.id }}"
|
||||
@@ -2252,6 +2264,7 @@ function refreshPriceSnapshotConditional(){
|
||||
}
|
||||
});
|
||||
tickOrderHoldDurations();
|
||||
renderOrphanRecoverBanner(data.orphan_live_positions);
|
||||
}
|
||||
}).catch(()=>{});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user