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:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user