{# 实盘下单监控 · 开仓表单(实例页与中控嵌入共用) #}
<form id="add-order-form" action="/add_order" method="post" class="order-monitor-form" data-risk-percent="{{ risk_percent }}">
    <div class="om-row om-row-policy">
        {% from 'trade_policy_fields.html' import trade_policy_symbol, trade_policy_direction with context %}
        {{ trade_policy_symbol('symbol', 'order-symbol') }}
        {{ trade_policy_direction('direction', 'order-direction') }}
        <select id="sltp-mode" name="sltp_mode" title="止盈止损模式">
            <option value="fixed_rr" selected>止盈止损:固定盈亏比</option>
            <option value="price">止盈止损:价格模式</option>
            <option value="pct">止盈止损:百分比模式</option>
        </select>
        {% from 'order_entry_model_fields.html' import order_entry_type_fields with context %}
        {{ order_entry_type_fields() }}
        {% from 'order_leverage_fields.html' import order_leverage_fields with context %}
        {{ order_leverage_fields() }}
    </div>

    <div class="om-row om-row-levels" data-sltp-mode="fixed_rr">
        <label class="om-field" id="om-field-sl">
            <span class="om-field-lab">止损价格</span>
            <input id="order-sl" name="sl" step="any" placeholder="必填" required>
        </label>
        <label class="om-field" id="om-field-rr">
            <span class="om-field-lab">盈亏比</span>
            <input id="order-fixed-rr" name="fixed_rr" type="number" min="0.01" step="0.01" placeholder="默认1.5" value="1.5" title="止盈距离=止损距离×盈亏比">
        </label>
        <label class="om-field" id="om-field-tp" style="display:none">
            <span class="om-field-lab">止盈价格</span>
            <input id="order-tp" name="tgt" step="any" placeholder="止盈价格">
        </label>
        <label class="om-field" id="om-field-sl-pct" style="display:none">
            <span class="om-field-lab">止损%</span>
            <input id="order-sl-pct" name="sl_pct" type="number" min="0.01" step="0.01" placeholder="止损%">
        </label>
        <label class="om-field" id="om-field-tp-pct" style="display:none">
            <span class="om-field-lab">止盈%</span>
            <input id="order-tp-pct" name="tp_pct" type="number" min="0.01" step="0.01" placeholder="止盈%">
        </label>
        <div class="om-live-meta">
            {% from 'symbol_live_price_snippet.html' import symbol_live_price_hint %}
            {{ symbol_live_price_hint('order-symbol-live-price', 'order-symbol', 'order-direction') }}
        </div>
        <button type="submit" class="om-submit{% if not can_trade %} is-blocked{% endif %}" id="om-submit-btn"{% if not can_trade %} disabled aria-disabled="true"{% endif %}>{{ open_position_button_label }}</button>
    </div>

    {% if not intraday_discipline %}
    <div class="om-row om-row-opts">
        <label class="om-check">
            <input type="checkbox" name="breakeven_enabled" value="1" checked>
            <span>移动保本</span>
        </label>
        <span id="order-time-close-wrap" class="order-time-close-wrap om-time-close">
            <label class="om-check" style="margin:0">
                <input type="checkbox" name="time_close_enabled" value="1" id="order-time-close-cb">
                <span>时间平仓</span>
            </label>
            <select name="time_close_hours" id="order-time-close-hours" title="持仓满该时长后自动平仓">
                <option value="1">1h</option>
                <option value="2">2h</option>
                <option value="4" selected>4h</option>
            </select>
        </span>
    </div>
    {% else %}
    <input type="hidden" name="breakeven_enabled" value="0">
    {% endif %}
</form>
{% include 'order_plan_preview_bar.html' %}
