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:
dekun
2026-07-05 00:30:49 +08:00
parent 65b911994c
commit c0ad50a7b5
22 changed files with 814 additions and 35 deletions
@@ -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 %}