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:
dekun
2026-07-17 12:00:09 +08:00
parent f435e9dfaa
commit f7ba7c2f7d
10 changed files with 63 additions and 11 deletions
+10
View File
@@ -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 ""