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:
@@ -78,7 +78,7 @@ from lib.strategy.strategy_trade_labels import (
|
||||
trade_record_monitor_type as resolve_trade_record_monitor_type,
|
||||
trend_plan_id_from_monitor_row,
|
||||
)
|
||||
from lib.instance.journal_form_lib import normalize_journal_entry_reason
|
||||
from lib.instance.journal_form_lib import normalize_journal_direction, normalize_journal_entry_reason
|
||||
from lib.instance.journal_images_lib import (
|
||||
collect_journal_slot_images,
|
||||
enrich_journal_api_item,
|
||||
@@ -1430,6 +1430,9 @@ def init_db():
|
||||
try:
|
||||
c.execute("ALTER TABLE journal_entries ADD COLUMN order_type TEXT")
|
||||
except: pass
|
||||
try:
|
||||
c.execute("ALTER TABLE journal_entries ADD COLUMN direction TEXT")
|
||||
except: pass
|
||||
try:
|
||||
c.execute("ALTER TABLE key_monitors ADD COLUMN direction TEXT DEFAULT 'long'")
|
||||
except: pass
|
||||
@@ -9148,6 +9151,10 @@ def add_journal():
|
||||
if not order_type_norm:
|
||||
flash("请选择下单类型")
|
||||
return _redirect_records()
|
||||
direction_norm = normalize_journal_direction(d.get("direction") or d.get("direction_hint"))
|
||||
if not direction_norm:
|
||||
flash("请选择方向")
|
||||
return _redirect_records()
|
||||
entry_reason_norm = normalize_journal_entry_reason(
|
||||
d.get("entry_reason"), ENTRY_REASON_OPTIONS, allow_legacy=False
|
||||
)
|
||||
@@ -9243,11 +9250,11 @@ def add_journal():
|
||||
conn = get_db()
|
||||
conn.execute(
|
||||
"""INSERT INTO journal_entries
|
||||
(id, open_datetime, close_datetime, hold_duration, coin, tf, pnl, order_type, entry_reason, exit_reason,
|
||||
(id, open_datetime, close_datetime, hold_duration, coin, tf, direction, pnl, order_type, entry_reason, exit_reason,
|
||||
expect_rr, real_rr, early_exit, early_exit_reason, early_exit_trigger, early_exit_note,
|
||||
mood_score, mood_ai_score, mood_ai_comment, mood_issues, post_breakeven_stare,
|
||||
new_trade_while_occupied, note, image, images_json)
|
||||
VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)""",
|
||||
VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)""",
|
||||
(
|
||||
entry_id,
|
||||
normalize_bj_datetime_storage(d.get("open_datetime")),
|
||||
@@ -9255,6 +9262,7 @@ def add_journal():
|
||||
hold_duration,
|
||||
d.get("coin"),
|
||||
d.get("tf"),
|
||||
direction_norm,
|
||||
d.get("pnl"), order_type_norm, entry_reason_norm, exit_reason_stored, d.get("expect_rr"), real_rr_text,
|
||||
early_exit_raw, early_exit_reason_saved, early_exit_trigger, early_exit_note,
|
||||
None, None, None, mood_issues,
|
||||
|
||||
Reference in New Issue
Block a user