feat: 账户方向与币种白名单 env 开关(三所)
Per-instance TRADE_DIRECTION / TRADE_SYMBOL_WHITELIST restricts UI and API for manual orders, key monitors, and strategies; includes sync script for deployment profiles. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -8,6 +8,9 @@
|
||||
<link rel="stylesheet" href="/static/focus_chart_page.css?v=1">
|
||||
</head>
|
||||
<body class="focus-page">
|
||||
{% 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 %}
|
||||
<div class="container">
|
||||
<div class="card">
|
||||
<div class="row" style="justify-content:space-between">
|
||||
@@ -25,13 +28,14 @@
|
||||
</div>
|
||||
<div class="row">
|
||||
<a class="btn" href="/">返回首页</a>
|
||||
<strong class="focus-title">关键位放大(可输入币种)</strong><span class="exchange-tag">{{ exchange_display }}</span>
|
||||
<strong class="focus-title">关键位放大{% if trade_policy.symbol_restrict_enabled %}(选择币种){% else %}(可输入币种){% endif %}</strong><span class="exchange-tag">{{ exchange_display }}</span>
|
||||
</div>
|
||||
<div class="status">最近刷新:<span id="updated-at">--</span></div>
|
||||
</div>
|
||||
<div class="row" style="margin-top:10px">
|
||||
<label>币种</label>
|
||||
<input id="symbol-input" value="{{ default_symbol }}" placeholder="BTC/USDT">
|
||||
{% from 'trade_policy_fields.html' import trade_policy_symbol %}
|
||||
{{ trade_policy_symbol('symbol', 'symbol-input', default_symbol, placeholder='BTC/USDT') }}
|
||||
<label>关键位</label>
|
||||
<select id="key-id">
|
||||
<option value="">无(仅看K线)</option>
|
||||
|
||||
@@ -142,7 +142,8 @@
|
||||
{% endif %}
|
||||
</div>
|
||||
<form id="key-form" action="/add_key" method="post" class="form-row">
|
||||
<input name="symbol" placeholder="BTC 或 BTC/USDT" required>
|
||||
{% from 'trade_policy_fields.html' import trade_policy_symbol, trade_policy_direction %}
|
||||
{{ trade_policy_symbol('symbol', 'key-symbol') }}
|
||||
<select name="type" id="key-type-select" required>
|
||||
{% if position_sizing_mode != 'full_margin' %}
|
||||
<option value="箱体突破">箱体突破</option>
|
||||
@@ -155,9 +156,7 @@
|
||||
<option value="突破触价开仓">突破触价开仓</option>
|
||||
<option value="关键支撑阻力">关键支撑阻力</option>
|
||||
</select>
|
||||
<select name="direction" id="key-direction" required>
|
||||
<option value="">方向</option><option value="long">做多</option><option value="short">做空</option>
|
||||
</select>
|
||||
{{ trade_policy_direction('direction', '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">
|
||||
|
||||
@@ -24,12 +24,9 @@
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
<form id="trend-pullback-form" action="{{ url_for('preview_trend_pullback') }}" method="post" class="form-row">
|
||||
<input name="symbol" placeholder="BTC 或 ETH/USDT" required>
|
||||
<select name="direction" id="trend-direction" required>
|
||||
<option value="">方向</option>
|
||||
<option value="long">做多</option>
|
||||
<option value="short">做空</option>
|
||||
</select>
|
||||
{% from 'trade_policy_fields.html' import trade_policy_symbol, trade_policy_direction %}
|
||||
{{ trade_policy_symbol('symbol', 'trend-symbol', placeholder='BTC 或 ETH/USDT') }}
|
||||
{{ trade_policy_direction('direction', '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,29 @@
|
||||
{# 方向 / 币种:env 账户级限制(三所共用宏) #}
|
||||
{% macro trade_policy_symbol(name, id, value='', required=true, placeholder='BTC 或 BTC/USDT') -%}
|
||||
{% if trade_policy.symbol_restrict_enabled and trade_policy.symbol_whitelist %}
|
||||
<select name="{{ name }}" id="{{ id }}" {% if required %}required{% endif %} class="trade-policy-symbol-select">
|
||||
<option value="">选择币种</option>
|
||||
{% for sym in trade_policy.symbol_whitelist %}
|
||||
<option value="{{ sym }}" {% if value and (value|upper == sym or value|upper.startswith(sym ~ '/')) %}selected{% endif %}>{{ sym }}/USDT</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
{% else %}
|
||||
<input id="{{ id }}" name="{{ name }}" placeholder="{{ placeholder }}" {% if required %}required{% endif %} value="{{ value }}">
|
||||
{% endif %}
|
||||
{%- endmacro %}
|
||||
|
||||
{% macro trade_policy_direction(name, id, required=true, include_empty=true) -%}
|
||||
{% if trade_policy.direction_restrict_enabled and trade_policy.direction_mode == 'long_only' %}
|
||||
<span class="trade-policy-dir-lock" title="账户配置:仅做多">做多</span>
|
||||
<input type="hidden" name="{{ name }}" id="{{ id }}" value="long">
|
||||
{% elif trade_policy.direction_restrict_enabled and trade_policy.direction_mode == 'short_only' %}
|
||||
<span class="trade-policy-dir-lock" title="账户配置:仅做空">做空</span>
|
||||
<input type="hidden" name="{{ name }}" id="{{ id }}" value="short">
|
||||
{% else %}
|
||||
<select name="{{ name }}" id="{{ id }}" {% if required %}required{% endif %}>
|
||||
{% if include_empty %}<option value="">方向</option>{% endif %}
|
||||
{% if trade_policy.allows_long %}<option value="long">做多</option>{% endif %}
|
||||
{% if trade_policy.allows_short %}<option value="short">做空</option>{% endif %}
|
||||
</select>
|
||||
{% endif %}
|
||||
{%- endmacro %}
|
||||
Reference in New Issue
Block a user