修改交易记录问题
This commit is contained in:
@@ -110,6 +110,10 @@
|
||||
.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}
|
||||
.stats-segment-block{margin-top:20px;padding-top:14px;border-top:1px solid #3a4468}
|
||||
.stats-segment-block h2{font-size:1.05rem;color:#dbe4ff;margin-bottom:8px}
|
||||
.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}
|
||||
@@ -204,6 +208,23 @@
|
||||
</div>
|
||||
{% with msg=get_flashed_messages() %}{% if msg %}<div class="flash">{{ msg[0] }}</div>{% endif %}{% endwith %}
|
||||
|
||||
<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">统计页仍按北京时间 {{ stats_bundle.stats_reset_hour|default(reset_hour) }}:00 切日</span>
|
||||
</div>
|
||||
<div class="export-bar">
|
||||
<span style="color:#9aa">数据导出(v{{ data_export_version }} CSV,UTF-8;交易记录含开仓类型列,复盘单独导出):</span>
|
||||
<a href="/export/trade_records">交易记录</a>
|
||||
@@ -514,7 +535,7 @@
|
||||
</div>
|
||||
<div class="table-wrap">
|
||||
<table>
|
||||
<tr><th>品种</th><th>类型</th><th>方向</th><th>成交</th><th>止损</th><th>止盈</th><th>基数</th><th>杠杆</th><th>持仓分钟</th><th>开仓时间(北京)</th><th>平仓时间(北京)</th><th>盈亏U</th><th>结果</th><th>操作</th></tr>
|
||||
<tr><th>品种</th><th>类型</th><th>方向</th><th>成交</th><th>止损(开仓)</th><th>止盈</th><th>基数</th><th>杠杆</th><th>持仓分钟</th><th>开仓时间(北京)</th><th>平仓时间(北京)</th><th>盈亏U</th><th>结果</th><th>操作</th></tr>
|
||||
{% for r in record %}
|
||||
<tr id="trade-row-{{ r.id }}">
|
||||
{% set pnl_val = (r.pnl_amount or 0)|float %}
|
||||
@@ -522,7 +543,7 @@
|
||||
<td>{{ r.monitor_type }}{% if r.key_signal_type %} · {{ r.key_signal_type }}{% endif %}</td>
|
||||
<td><span class="badge {{ 'direction-long' if r.direction == 'long' else 'direction-short' }}">{{ '做多' if r.direction == 'long' else '做空' }}</span></td>
|
||||
<td>{{ price_fmt(r.symbol, r.trigger_price) }}</td>
|
||||
{% set stop_show = r.effective_stop_loss or r.initial_stop_loss or r.stop_loss %}
|
||||
{% set stop_show = r.display_open_stop_loss or r.initial_stop_loss or r.stop_loss %}
|
||||
{% set tp_show = r.effective_take_profit or r.take_profit %}
|
||||
<td>{{ price_fmt(r.symbol, stop_show) }}</td>
|
||||
<td>{{ price_fmt(r.symbol, tp_show) }}</td>
|
||||
@@ -547,9 +568,10 @@
|
||||
onclick='fillJournalFromTrade({{ {
|
||||
"symbol": r.symbol,
|
||||
"monitor_type": r.monitor_type,
|
||||
"key_signal_type": r.key_signal_type or "",
|
||||
"direction": r.direction,
|
||||
"trigger_price": r.trigger_price,
|
||||
"stop_loss": r.effective_stop_loss or r.initial_stop_loss or r.stop_loss,
|
||||
"stop_loss": r.display_open_stop_loss or r.initial_stop_loss or r.stop_loss,
|
||||
"take_profit": r.effective_take_profit or r.take_profit,
|
||||
"opened_at": r.effective_opened_at,
|
||||
"closed_at": r.effective_closed_at,
|
||||
@@ -629,6 +651,7 @@
|
||||
<input name="real_rr" placeholder="实际RR">
|
||||
<select name="early_exit_trigger" required title="平仓如何触发">
|
||||
<option value="">离场触发(必选)</option>
|
||||
<option value="止盈">止盈</option>
|
||||
<option value="保本止盈">保本止盈</option>
|
||||
<option value="移动止盈">移动止盈</option>
|
||||
<option value="手动平仓">手动平仓</option>
|
||||
@@ -702,12 +725,17 @@
|
||||
<div class="stat-item"><div class="label">持仓占用导致错过(累计)</div><div class="value">{{ occupied_miss_total }}</div></div>
|
||||
</div>
|
||||
<div class="sub" style="margin-bottom:12px;color:#8892b0;font-size:.82rem">
|
||||
已平仓「下单监控」按平仓时间归入<strong>北京时间</strong>下的交易日;胜率按盈笔数/(盈+亏)。历史总开仓(累计):
|
||||
统计分析按<strong>北京时间 {{ stats_bundle.stats_reset_hour }}:00</strong>切日计入;下列为各品类已平仓。历史总开仓(累计):
|
||||
<strong style="color:#cfd3ef">{{ stats_bundle.total_opens_all }}</strong> 次
|
||||
</div>
|
||||
{{ period_stats("日统计", stats_bundle.day) }}
|
||||
{{ period_stats("周统计", stats_bundle.week) }}
|
||||
{{ period_stats("月统计", stats_bundle.month) }}
|
||||
{% for seg in stats_bundle.segments %}
|
||||
<div class="stats-segment-block">
|
||||
<h2>{{ seg.title }}</h2>
|
||||
{{ period_stats("日统计", seg.day) }}
|
||||
{{ period_stats("周统计", seg.week) }}
|
||||
{{ period_stats("月统计", seg.month) }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
@@ -931,8 +959,50 @@ function deleteKeyHistory(id){
|
||||
.catch(()=>{ window.location.href = `${window.location.pathname}?_ts=${Date.now()}`; });
|
||||
}
|
||||
|
||||
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 || "/trade";
|
||||
window.location.href = qs ? (path + "?" + qs) : path;
|
||||
}
|
||||
|
||||
function attachListWindowToExports(){
|
||||
const qs = listWindowQueryString();
|
||||
if(!qs) return;
|
||||
document.querySelectorAll('.export-bar a[href^="/export/trade_records"], .export-bar a[href^="/export/key_monitor_history"]').forEach(a=>{
|
||||
const base = a.getAttribute("href").split("?")[0];
|
||||
a.setAttribute("href", base + "?" + qs);
|
||||
});
|
||||
}
|
||||
|
||||
function loadJournals(){
|
||||
fetch("/api/journals").then(r=>r.json()).then(data=>{
|
||||
const qs = listWindowQueryString();
|
||||
fetch("/api/journals" + (qs ? "?" + qs : "")).then(r=>r.json()).then(data=>{
|
||||
Object.keys(journalCache).forEach(k=>delete journalCache[k]);
|
||||
let html="";
|
||||
data.forEach(o=>{
|
||||
@@ -954,7 +1024,8 @@ function loadJournals(){
|
||||
}
|
||||
|
||||
function loadReviews(){
|
||||
fetch("/api/reviews").then(r=>r.json()).then(data=>{
|
||||
const qs = listWindowQueryString();
|
||||
fetch("/api/reviews" + (qs ? "?" + qs : "")).then(r=>r.json()).then(data=>{
|
||||
Object.keys(reviewCache).forEach(k=>delete reviewCache[k]);
|
||||
let html="";
|
||||
data.forEach(r=>{
|
||||
@@ -1026,7 +1097,13 @@ function setJournalField(name, value){
|
||||
el.value = String(value);
|
||||
}
|
||||
|
||||
const EARLY_EXIT_TRIGGERS = new Set(["保本止盈","移动止盈","手动平仓","止损","其他"]);
|
||||
const EARLY_EXIT_TRIGGERS = new Set(["止盈","保本止盈","移动止盈","手动平仓","止损","其他"]);
|
||||
const KEY_ENTRY_REASON_BY_SIGNAL = {
|
||||
"箱体突破": "关键位箱体突破",
|
||||
"收敛突破": "关键位收敛突破",
|
||||
"斐波回调0.618": "关键位斐波0.618",
|
||||
"斐波回调0.786": "关键位斐波0.786"
|
||||
};
|
||||
|
||||
function splitLegacyEarlyExitReason(raw){
|
||||
const s = String(raw || "").trim();
|
||||
@@ -1116,11 +1193,17 @@ function fillJournalFromTrade(t){
|
||||
if(dirHint){ dirHint.value = t.direction || "long"; }
|
||||
setJournalField("early_exit_trigger", "");
|
||||
setJournalField("early_exit_note", "");
|
||||
setJournalField("entry_reason", "");
|
||||
const kst = String(t.key_signal_type || "").trim();
|
||||
const erFromKey = KEY_ENTRY_REASON_BY_SIGNAL[kst] || "";
|
||||
if(erFromKey && JOURNAL_ENTRY_REASON_OPTIONS.includes(erFromKey)){
|
||||
setJournalField("entry_reason", erFromKey);
|
||||
} else {
|
||||
setJournalField("entry_reason", "");
|
||||
}
|
||||
setJournalField("entry_reason_custom", "");
|
||||
syncJournalEntryReasonOtherUi();
|
||||
const er = String(t.result || "").trim();
|
||||
const exitTrigMap = { 保本止盈: "保本止盈", 移动止盈: "移动止盈", 手动平仓: "手动平仓", 止损: "止损" };
|
||||
const exitTrigMap = { 止盈: "止盈", 保本止盈: "保本止盈", 移动止盈: "移动止盈", 手动平仓: "手动平仓", 止损: "止损" };
|
||||
if(exitTrigMap[er]) setJournalField("early_exit_trigger", exitTrigMap[er]);
|
||||
const note = `来自交易记录自动填充:${t.symbol || "-"} ${t.direction || "-"} | 入场:${t.trigger_price || "-"} 止损:${t.stop_loss || "-"} 止盈:${t.take_profit || "-"} | 类型:${t.monitor_type || "-"}`;
|
||||
setJournalField("note", note);
|
||||
@@ -1211,6 +1294,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