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 ""
|
||||
|
||||
Reference in New Issue
Block a user