Add CTP auto-connect toggle to stop off-hours reconnect attempts.
When disabled, disconnect immediately and skip auto-reconnect, premarket connect, and TCP probes that fail outside SimNow trading hours. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+17
-1
@@ -200,11 +200,13 @@
|
||||
|
||||
{% call settings_card('ctp', 'CTP 连接', 'settings-ctp-wrap') %}
|
||||
<p class="hint" style="margin-bottom:.85rem">
|
||||
投资者代码、密码、前置地址在此维护(优先于 <code>.env</code>)。保存后将自动断开并用新地址重连 CTP。
|
||||
投资者代码、密码、前置地址在此维护(优先于 <code>.env</code>)。保存后将自动断开并用新地址重连 CTP(须开启下方自动连接)。
|
||||
{% if ctp_status.connected %}
|
||||
<span class="badge profit" style="margin-left:.35rem">已连接</span>
|
||||
{% elif ctp_status.connecting %}
|
||||
<span class="badge planned" style="margin-left:.35rem">连接中</span>
|
||||
{% elif ctp_status.disabled_hint %}
|
||||
<span class="text-muted" style="display:block;margin-top:.35rem">{{ ctp_status.disabled_hint }}</span>
|
||||
{% elif ctp_status.last_error %}
|
||||
<span class="text-loss" style="display:block;margin-top:.35rem">{{ ctp_status.last_error }}</span>
|
||||
{% endif %}
|
||||
@@ -213,6 +215,20 @@
|
||||
<form action="{{ url_for('settings') }}" method="post" id="ctp-settings-form">
|
||||
<input type="hidden" name="action" value="ctp">
|
||||
|
||||
<div class="settings-ctp-auto card" style="margin-bottom:.85rem;padding:.75rem 1rem">
|
||||
<label class="settings-ctp-auto-label" style="display:flex;align-items:flex-start;gap:.65rem;cursor:pointer;margin:0">
|
||||
<input type="checkbox" name="ctp_auto_connect" value="1" {% if ctp_auto_connect %}checked{% endif %}
|
||||
style="margin-top:.2rem;width:auto">
|
||||
<span>
|
||||
<strong>CTP 自动连接</strong>
|
||||
<span class="hint" style="display:block;margin:.25rem 0 0;font-size:.78rem;line-height:1.55">
|
||||
开启:盘前自动连接、断线重连、持仓页可连 CTP。关闭:立即断开所有 CTP 连接,不再尝试重连。
|
||||
SimNow 非交易时段前置常不可用(与快期相同),建议收盘后关闭。
|
||||
</span>
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="settings-ctp-cards-row">
|
||||
<div class="settings-ctp-fold card is-collapsed" data-ctp-fold="simnow">
|
||||
<button type="button" class="settings-ctp-fold-head" aria-expanded="false">
|
||||
|
||||
@@ -19,8 +19,11 @@
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="trade-top-bar-actions">
|
||||
<button type="button" class="btn-primary btn-ctp-sm" id="btn-ctp-connect">{% if ctp_status.connected %}重连 CTP{% else %}连接 CTP{% endif %}</button>
|
||||
<span class="text-muted trade-top-hint">断线自动重连 · 开盘前 30 分钟自动连接</span>
|
||||
<button type="button" class="btn-primary btn-ctp-sm" id="btn-ctp-connect"
|
||||
{% if not ctp_auto_connect %}disabled title="请先在系统设置 → CTP 连接 中开启自动连接"{% endif %}>
|
||||
{% if ctp_status.connected %}重连 CTP{% else %}连接 CTP{% endif %}
|
||||
</button>
|
||||
<span class="text-muted trade-top-hint" id="ctp-auto-hint">{% if ctp_auto_connect %}断线自动重连 · 开盘前 30 分钟自动连接{% else %}CTP 自动连接已关闭{% endif %}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -228,6 +231,7 @@ window.TRADE_FIXED_LOTS = {{ fixed_lots|tojson }};
|
||||
window.TRADE_FIXED_AMOUNT = {{ fixed_amount|tojson }};
|
||||
window.PRODUCT_CATEGORIES = {{ product_categories | default([]) | tojson }};
|
||||
window.__RECOMMEND_ROWS__ = {{ recommend_rows | default([]) | tojson }};
|
||||
window.CTP_AUTO_CONNECT = {{ ctp_auto_connect | tojson }};
|
||||
</script>
|
||||
<script src="{{ url_for('static', filename='js/trade.js') }}?v={{ asset_v }}"></script>
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user