bot增加保本
This commit is contained in:
@@ -136,6 +136,8 @@
|
||||
.export-bar{display:flex;flex-wrap:wrap;gap:8px;align-items:center;margin-bottom:12px;font-size:.85rem}
|
||||
.export-bar a{color:#8fc8ff;text-decoration:none;padding:6px 10px;border:1px solid #304164;border-radius:8px;background:#151a2a}
|
||||
.export-bar a:hover{background:#1f2740}
|
||||
.list-window-bar{display:flex;flex-wrap:wrap;gap:8px;align-items:center;margin-bottom:12px;padding:10px 12px;background:#151a2a;border:1px solid #304164;border-radius:10px;font-size:.82rem}
|
||||
.list-window-bar label{color:#9aa;display:flex;align-items:center;gap:6px}
|
||||
.key-history{margin-top:12px;padding-top:10px;border-top:1px solid #2a3150}
|
||||
.key-history h3{font-size:.88rem;color:#b8c4ff;margin-bottom:6px}
|
||||
.key-history .sub{font-size:.72rem;color:#8892b0;margin-bottom:6px}
|
||||
@@ -198,6 +200,27 @@
|
||||
</div>
|
||||
{% with msg=get_flashed_messages() %}{% if msg %}<div class="flash">{{ msg[0] }}</div>{% endif %}{% endwith %}
|
||||
|
||||
|
||||
{% if page in ('records', 'plan_history') %}
|
||||
<div class="list-window-bar">
|
||||
<span style="color:#cfd3ef">列表筛选(<strong>UTC</strong>,默认当日):{{ list_window.label }}</span>
|
||||
<label>预设
|
||||
<select id="win-preset-select" onchange="toggleListWindowCustom()">
|
||||
<option value="utc_today" {% if list_window.preset == 'utc_today' %}selected{% endif %}>UTC 当日</option>
|
||||
<option value="utc_last24h" {% if list_window.preset == 'utc_last24h' %}selected{% endif %}>近 24 小时</option>
|
||||
<option value="utc_last7d" {% if list_window.preset == 'utc_last7d' %}selected{% endif %}>近 7 天</option>
|
||||
<option value="custom" {% if list_window.preset == 'custom' %}selected{% endif %}>自定义</option>
|
||||
</select>
|
||||
</label>
|
||||
<span id="win-custom-range" style="{% if list_window.preset != 'custom' %}display:none{% endif %}">
|
||||
<label>起(UTC) <input type="datetime-local" id="win-from-utc" value="{{ list_window.start_utc.strftime('%Y-%m-%dT%H:%M') }}"></label>
|
||||
<label>止(UTC) <input type="datetime-local" id="win-to-utc" value="{{ list_window.end_utc.strftime('%Y-%m-%dT%H:%M') }}"></label>
|
||||
</span>
|
||||
<button type="button" style="padding:6px 12px" onclick="applyListWindow()">应用</button>
|
||||
<span style="color:#8892b0;font-size:.75rem">统计页仍按北京时间 {{ reset_hour }}:00 切日</span>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="export-bar">
|
||||
<span style="color:#9aa">数据导出(v{{ data_export_version }} CSV,UTF-8;交易记录含开仓类型列及交易所对齐字段):</span>
|
||||
<a href="/export/trade_records">交易记录</a>
|
||||
@@ -339,7 +362,7 @@
|
||||
<h2 style="margin-bottom:8px">趋势回调策略</h2>
|
||||
<div class="rule-tip">
|
||||
① <strong>生成预览</strong>:读取合约 USDT <strong>可用余额快照</strong>并计算计划(不下单)。预览有效期 <strong>{{ trend_pullback_preview_ttl }} 秒</strong>。<br>
|
||||
② <strong>确认执行</strong>:市价首仓 50% + 挂交易所止损;剩余 50% 在止损与补仓区间之间共 {{ trend_pullback_dca_legs }} 档(做多为<strong>上沿</strong>、做空为<strong>下沿</strong>;程序可能因最小张数自动减档)市价补仓;<strong>止盈由程序监控</strong>。<br>
|
||||
② <strong>确认执行</strong>:市价首仓 50% + 挂交易所止损;首仓后可<strong>手动保本</strong>(默认均价+{{ trend_manual_breakeven_offset_pct }}%);剩余 50% 在止损与补仓区间之间共 {{ trend_pullback_dca_legs }} 档(做多为<strong>上沿</strong>、做空为<strong>下沿</strong>;程序可能因最小张数自动减档)市价补仓;<strong>止盈由程序监控</strong>。<br>
|
||||
确认执行时若当前可用余额与预览快照相对偏差 > <strong>{{ trend_preview_max_drift_pct }}%</strong> 会拒绝并要求重新预览。
|
||||
</div>
|
||||
<form id="trend-pullback-form" action="{{ url_for('preview_trend_pullback') }}" method="post" class="form-row">
|
||||
@@ -357,6 +380,45 @@
|
||||
<button type="submit" {% if not can_trade %}disabled style="opacity:.5;cursor:not-allowed"{% endif %}>生成预览</button>
|
||||
</form>
|
||||
<script>
|
||||
|
||||
function listWindowQueryString(){
|
||||
const presetEl = document.getElementById("win-preset-select");
|
||||
const preset = (presetEl && presetEl.value) || new URLSearchParams(window.location.search).get("win_preset") || "utc_today";
|
||||
const q = new URLSearchParams(window.location.search);
|
||||
q.set("win_preset", preset);
|
||||
if(preset === "custom"){
|
||||
const fromEl = document.getElementById("win-from-utc");
|
||||
const toEl = document.getElementById("win-to-utc");
|
||||
if(fromEl && fromEl.value) q.set("from_utc", fromEl.value.replace("T", " ") + ":00");
|
||||
else q.delete("from_utc");
|
||||
if(toEl && toEl.value) q.set("to_utc", toEl.value.replace("T", " ") + ":00");
|
||||
else q.delete("to_utc");
|
||||
} else {
|
||||
q.delete("from_utc");
|
||||
q.delete("to_utc");
|
||||
}
|
||||
return q.toString();
|
||||
}
|
||||
function toggleListWindowCustom(){
|
||||
const preset = document.getElementById("win-preset-select");
|
||||
const box = document.getElementById("win-custom-range");
|
||||
if(!preset || !box) return;
|
||||
box.style.display = preset.value === "custom" ? "" : "none";
|
||||
}
|
||||
function applyListWindow(){
|
||||
const qs = listWindowQueryString();
|
||||
const path = window.location.pathname || "/records";
|
||||
window.location.href = qs ? (path + "?" + qs) : path;
|
||||
}
|
||||
function attachListWindowToExports(){
|
||||
const qs = listWindowQueryString();
|
||||
if(!qs) return;
|
||||
document.querySelectorAll('.export-bar a[href^="/export/trade_records"]').forEach(a=>{
|
||||
const base = a.getAttribute("href").split("?")[0];
|
||||
a.setAttribute("href", base + "?" + qs);
|
||||
});
|
||||
}
|
||||
|
||||
(function(){
|
||||
const dirSel = document.getElementById("trend-direction");
|
||||
const addInp = document.getElementById("trend-add-upper");
|
||||
@@ -490,6 +552,19 @@
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="plan-card-meta" style="margin-top:8px">
|
||||
<form action="{{ url_for('trend_pullback_breakeven', pid=t.id) }}" method="post" class="form-row" style="margin:0;align-items:center" onsubmit="return confirm('将交易所止损移至持仓均价+偏移?仅当新止损优于当前止损时生效。');">
|
||||
<label style="font-size:.78rem;color:#cfd3ef;display:flex;align-items:center;gap:6px">
|
||||
手动保本 偏移%
|
||||
<input name="breakeven_offset_pct" type="number" min="0" step="0.01" value="{{ trend_manual_breakeven_offset_pct }}" style="width:72px;padding:4px 8px">
|
||||
(默认均价+{{ trend_manual_breakeven_offset_pct }}%)
|
||||
</label>
|
||||
<button type="submit" style="padding:6px 12px;background:#1f4a3a;color:#8fc8ff">应用保本止损</button>
|
||||
{% if t.breakeven_applied %}<span style="color:#6ab88a;font-size:.75rem">已保本 {{ (t.breakeven_applied_at or '')[:16] }}</span>{% endif %}
|
||||
{% if t.initial_stop_loss is not none and t.initial_stop_loss != t.stop_loss %}<span style="color:#8892b0;font-size:.75rem">原止损 {{ price_fmt(sym, t.initial_stop_loss) }}</span>{% endif %}
|
||||
</form>
|
||||
</div>
|
||||
<div class="plan-card-meta" style="margin-bottom:0">
|
||||
快照可用: {% if t.snapshot_available_usdt is not none %}{{ money_fmt(t.snapshot_available_usdt) }}U{% else %}—{% endif %}
|
||||
| 计划保证金≈{% if t.plan_margin_capital is not none %}{{ money_fmt(t.plan_margin_capital) }}U{% else %}—{% endif %}
|
||||
@@ -1184,6 +1259,8 @@ function toggleStatsCard(){
|
||||
btn.innerText = collapsed ? "展开" : "折叠";
|
||||
}
|
||||
|
||||
attachListWindowToExports();
|
||||
toggleListWindowCustom();
|
||||
if(document.getElementById("journal-list")) loadJournals();
|
||||
if(document.getElementById("review-list")) loadReviews();
|
||||
const reviewToggle = document.getElementById("review-mode-toggle");
|
||||
|
||||
Reference in New Issue
Block a user