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:
+22
-11
@@ -67,14 +67,16 @@ from lib.key_monitor.false_breakout_key_monitor_lib import (
|
||||
storage_bounds_from_key_price,
|
||||
)
|
||||
from lib.strategy.strategy_trade_labels import (
|
||||
STRATEGY_ENTRY_REASON_OPTIONS,
|
||||
JOURNAL_ORDER_TYPE_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.exchange.okx_orders_lib import cancel_okx_all_open_orders, fetch_okx_all_open_orders
|
||||
from lib.instance.journal_images_lib import (
|
||||
collect_journal_slot_images,
|
||||
@@ -175,7 +177,7 @@ from lib.trade.position_sizing_lib import (
|
||||
from lib.trade.trade_policy_lib import load_trade_policy
|
||||
from lib.trade.entry_model_lib import (
|
||||
build_intraday_entry_reason_options,
|
||||
build_trend_div_entry_reason_options,
|
||||
build_journal_entry_reason_options,
|
||||
enrich_entry_model_display,
|
||||
hub_meta_entry_context,
|
||||
migrate_entry_model_columns,
|
||||
@@ -1134,8 +1136,8 @@ EARLY_EXIT_TRIGGERS = (
|
||||
"其他",
|
||||
)
|
||||
|
||||
# 趋势户:大分歧A/B/小分歧 + 策略(关键位本实例关闭)
|
||||
ENTRY_REASON_OPTIONS = build_trend_div_entry_reason_options(STRATEGY_ENTRY_REASON_OPTIONS)
|
||||
# 趋势户:复盘开仓类型仅 entry model;策略/风格项已拆至下单类型
|
||||
ENTRY_REASON_OPTIONS = build_journal_entry_reason_options()
|
||||
|
||||
STATS_SEGMENT_DEFS = (
|
||||
("all", "全部交易", {"segment": "all"}),
|
||||
@@ -1148,9 +1150,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 normalize_early_exit_trigger(raw):
|
||||
@@ -1430,6 +1431,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
|
||||
@@ -6722,6 +6726,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,
|
||||
@@ -8776,7 +8781,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()
|
||||
@@ -8869,11 +8880,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")),
|
||||
@@ -8881,7 +8892,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