feat: 币种输入旁实时显示交易所现价

Shared SymbolLivePrice polls /api/order_defaults on input with debounce; wired to trade, key monitor, trend, and key focus forms.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-05 00:42:44 +08:00
parent efe7a57e60
commit 3a740235ac
13 changed files with 273 additions and 14 deletions
+5 -2
View File
@@ -4,10 +4,11 @@
<meta charset="UTF-8">
<script src="/static/instance_theme.js?v=5"></script>
<title>{{ exchange_display }} | 关键位放大</title>
<link rel="stylesheet" href="/static/instance_theme.css?v=5">
<link rel="stylesheet" href="/static/instance_theme.css?v=50">
<script src="/static/symbol_live_price.js?v=1"></script>
<link rel="stylesheet" href="/static/focus_chart_page.css?v=1">
</head>
<body class="focus-page">
<body class="focus-page" data-price-refresh-ms="{{ price_refresh_seconds * 1000 }}">
{% if trade_policy is not defined %}
{% set trade_policy = {'symbol_restrict_enabled': false, 'direction_restrict_enabled': false, 'symbol_whitelist': [], 'allows_long': true, 'allows_short': true, 'badge_text': ''} %}
{% endif %}
@@ -36,6 +37,8 @@
<label>币种</label>
{% from 'trade_policy_fields.html' import trade_policy_symbol with context %}
{{ trade_policy_symbol('symbol', 'symbol-input', default_symbol, placeholder='BTC/USDT') }}
{% from 'symbol_live_price_snippet.html' import symbol_live_price_hint %}
{{ symbol_live_price_hint('key-focus-symbol-live-price', 'symbol-input') }}
<label>关键位</label>
<select id="key-id">
<option value="">无(仅看K线)</option>
@@ -157,6 +157,8 @@
<option value="关键支撑阻力">关键支撑阻力</option>
</select>
{{ trade_policy_direction('direction', 'key-direction') }}
{% from 'symbol_live_price_snippet.html' import symbol_live_price_hint %}
{{ symbol_live_price_hint('key-symbol-live-price', 'key-symbol', 'key-direction') }}
<input name="key_price" id="key-fb-price" step="0.0001" placeholder="做空填高点/做多填低点" style="display:none">
<input name="trigger_entry" id="key-trigger-entry" step="0.0001" placeholder="计划入场价" style="display:none">
<input name="trigger_sl" id="key-trigger-sl" step="0.0001" placeholder="止损价" style="display:none">
@@ -27,6 +27,8 @@
{% from 'trade_policy_fields.html' import trade_policy_symbol, trade_policy_direction with context %}
{{ trade_policy_symbol('symbol', 'trend-symbol', placeholder='BTC 或 ETH/USDT') }}
{{ trade_policy_direction('direction', 'trend-direction') }}
{% from 'symbol_live_price_snippet.html' import symbol_live_price_hint %}
{{ symbol_live_price_hint('trend-symbol-live-price', 'trend-symbol', 'trend-direction') }}
<input name="leverage" type="number" min="1" step="1" placeholder="杠杆(必填)" required>
<input name="risk_percent" type="number" min="0.1" step="0.1" value="5" placeholder="风险%相对可用快照" title="默认5:最坏亏损约≤可用余额×5%">
<input name="sl" step="any" placeholder="止损价" required>
@@ -0,0 +1,10 @@
{# 币种输入旁实时现价(须加载 symbol_live_price.js #}
{% macro symbol_live_price_hint(price_id, symbol_input_id, direction_input_id='') -%}
<span
id="{{ price_id }}"
class="symbol-live-price"
data-symbol-input="{{ symbol_input_id }}"
{% if direction_input_id %}data-direction-input="{{ direction_input_id }}"{% endif %}
aria-live="polite"
>现价:—</span>
{%- endmacro %}