Split journal order type from entry reason and fix review edit toggle in embed shell.
Adds order_type to journal uploads, removes legacy swing/trend labels from entry reason options, and ensures review-edit buttons sync when the records tab loads dynamically. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -68,14 +68,17 @@ from lib.key_monitor.false_breakout_key_monitor_lib import (
|
||||
storage_bounds_from_key_price,
|
||||
)
|
||||
from lib.strategy.strategy_trade_labels import (
|
||||
JOURNAL_ORDER_TYPE_OPTIONS,
|
||||
STRATEGY_ENTRY_REASON_OPTIONS,
|
||||
apply_order_monitor_source_labels,
|
||||
entry_reason_for_monitor_type,
|
||||
handoff_trade_miss_reason,
|
||||
normalize_journal_order_type,
|
||||
order_monitor_source_type,
|
||||
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_images_lib import (
|
||||
collect_journal_slot_images,
|
||||
enrich_journal_api_item,
|
||||
@@ -1127,9 +1130,8 @@ STATS_SEGMENT_DEFS = (
|
||||
("key_trigger", "关键位触价开仓", {"segment": "key_trigger"}),
|
||||
)
|
||||
def normalize_entry_reason(raw, custom_text=None):
|
||||
from lib.trade.entry_model_lib import normalize_review_entry_reason
|
||||
|
||||
return normalize_review_entry_reason(raw, ENTRY_REASON_OPTIONS)
|
||||
del custom_text
|
||||
return normalize_journal_entry_reason(raw, ENTRY_REASON_OPTIONS, allow_legacy=True)
|
||||
|
||||
|
||||
def entry_reason_valid_for_storage(s):
|
||||
@@ -1424,6 +1426,9 @@ def init_db():
|
||||
try:
|
||||
c.execute("ALTER TABLE journal_entries ADD COLUMN images_json TEXT")
|
||||
except: pass
|
||||
try:
|
||||
c.execute("ALTER TABLE journal_entries ADD COLUMN order_type TEXT")
|
||||
except: pass
|
||||
try:
|
||||
c.execute("ALTER TABLE key_monitors ADD COLUMN direction TEXT DEFAULT 'long'")
|
||||
except: pass
|
||||
@@ -7122,6 +7127,7 @@ def render_main_page(page="trade", embed_mode=None):
|
||||
trend_manual_count=trend_manual_entry_reason_count(TRADE_POLICY),
|
||||
)
|
||||
),
|
||||
order_type_options=list(JOURNAL_ORDER_TYPE_OPTIONS),
|
||||
key_auto_order_enabled=KEY_AUTO_ORDER_ENABLED,
|
||||
journal_chart_tf_choices=JOURNAL_CHART_TF_CHOICES,
|
||||
journal_chart_default_tf1=JOURNAL_CHART_DEFAULT_TF1,
|
||||
@@ -9122,7 +9128,13 @@ def del_order(id):
|
||||
@login_required
|
||||
def add_journal():
|
||||
d = request.form
|
||||
entry_reason_norm = normalize_entry_reason(d.get("entry_reason"))
|
||||
order_type_norm = normalize_journal_order_type(d.get("order_type"))
|
||||
if not order_type_norm:
|
||||
flash("请选择下单类型")
|
||||
return _redirect_records()
|
||||
entry_reason_norm = normalize_journal_entry_reason(
|
||||
d.get("entry_reason"), ENTRY_REASON_OPTIONS, allow_legacy=False
|
||||
)
|
||||
if not entry_reason_norm:
|
||||
flash("请选择开仓类型")
|
||||
return _redirect_records()
|
||||
@@ -9215,11 +9227,11 @@ def add_journal():
|
||||
conn = get_db()
|
||||
conn.execute(
|
||||
"""INSERT INTO journal_entries
|
||||
(id, open_datetime, close_datetime, hold_duration, coin, tf, pnl, entry_reason, exit_reason,
|
||||
(id, open_datetime, close_datetime, hold_duration, coin, tf, 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")),
|
||||
@@ -9227,7 +9239,7 @@ def add_journal():
|
||||
hold_duration,
|
||||
d.get("coin"),
|
||||
d.get("tf"),
|
||||
d.get("pnl"), entry_reason_norm, exit_reason_stored, d.get("expect_rr"), real_rr_text,
|
||||
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,
|
||||
d.get("post_breakeven_stare"), None, d.get("note"), image_filename,
|
||||
|
||||
Reference in New Issue
Block a user