Auto-fill journal direction from trade records.
Add a required direction field on the review form, persist it, and set long/short when clicking 填入复盘. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -34,6 +34,7 @@
|
||||
typeof formatExitLine === "function" ? formatExitLine(o) : o.exit_reason || "无";
|
||||
const lines = [
|
||||
`币种/周期:${escapeHtml(o.coin || "-")} ${escapeHtml(o.tf || "-")}`,
|
||||
`方向:${escapeHtml((function(){ const d = inferJournalDirection(o); return d ? d.text : "-"; })())}`,
|
||||
`开仓时间:${escapeHtml(o.open_datetime || "-")}`,
|
||||
`平仓时间:${escapeHtml(o.close_datetime || "-")}`,
|
||||
`持仓时长:${escapeHtml(o.hold_duration || "-")}`,
|
||||
|
||||
@@ -42,3 +42,13 @@ def journal_entry_reason_valid(raw: Optional[str], allowed: Sequence[str]) -> bo
|
||||
|
||||
def journal_order_type_valid(raw: Optional[str]) -> bool:
|
||||
return bool(normalize_journal_order_type(raw))
|
||||
|
||||
|
||||
def normalize_journal_direction(raw: Optional[str]) -> str:
|
||||
s = (raw or "").strip().lower()
|
||||
if s in ("long", "buy", "多", "做多"):
|
||||
return "long"
|
||||
if s in ("short", "sell", "空", "做空"):
|
||||
return "short"
|
||||
# 兼容旧隐藏字段 direction_hint
|
||||
return ""
|
||||
|
||||
@@ -545,6 +545,8 @@ function fillJournalFromTrade(t){
|
||||
if(stopHint){ stopHint.value = slPx; }
|
||||
const dirHint = document.getElementById("direction-hint");
|
||||
if(dirHint){ dirHint.value = t.direction || "long"; }
|
||||
const dirNorm = String(t.direction || "long").toLowerCase() === "short" ? "short" : "long";
|
||||
setJournalField("direction", dirNorm);
|
||||
setJournalField("early_exit_trigger", "");
|
||||
setJournalField("early_exit_note", "");
|
||||
const kst = String(t.key_signal_type || "").trim();
|
||||
|
||||
@@ -90,7 +90,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="/static/instance_ui.js?v=9"></script>
|
||||
<script src="/static/instance_ui.js?v=10"></script>
|
||||
<script src="/static/journal_upload_slots.js?v=3"></script>
|
||||
<script src="/static/instance_records_mobile.js?v=2"></script>
|
||||
<script src="/static/time_close_ui.js?v=3"></script>
|
||||
|
||||
@@ -447,7 +447,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="/static/instance_ui.js?v=9"></script>
|
||||
<script src="/static/instance_ui.js?v=10"></script>
|
||||
<script src="/static/journal_upload_slots.js?v=3"></script>
|
||||
<script src="/static/instance_records_mobile.js?v=2"></script>
|
||||
<script src="/static/time_close_ui.js?v=3"></script>
|
||||
@@ -1002,6 +1002,8 @@ function fillJournalFromTrade(t){
|
||||
if(stopHint){ stopHint.value = slPx; }
|
||||
const dirHint = document.getElementById("direction-hint");
|
||||
if(dirHint){ dirHint.value = t.direction || "long"; }
|
||||
const dirNorm = String(t.direction || "long").toLowerCase() === "short" ? "short" : "long";
|
||||
setJournalField("direction", dirNorm);
|
||||
setJournalField("early_exit_trigger", "");
|
||||
setJournalField("early_exit_note", "");
|
||||
const kst = String(t.key_signal_type || "").trim();
|
||||
|
||||
@@ -10,6 +10,11 @@
|
||||
<input name="real_rr" class="journal-field-num" placeholder="实际RR">
|
||||
</div>
|
||||
<div class="form-grid journal-form-row2">
|
||||
<select name="direction" id="journal-direction" class="journal-field-direction" required title="做多/做空">
|
||||
<option value="">方向(必选)</option>
|
||||
<option value="long">做多</option>
|
||||
<option value="short">做空</option>
|
||||
</select>
|
||||
<select name="order_type" id="journal-order-type" class="journal-field-order-type" required title="下单来源:下单监控/关键位/趋势回调/顺势加仓">
|
||||
<option value="">下单类型(必选)</option>
|
||||
{% for ot in order_type_options %}
|
||||
|
||||
Reference in New Issue
Block a user