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:
dekun
2026-07-09 09:27:03 +08:00
parent 4abe8a6ca9
commit d3a44b23db
17 changed files with 325 additions and 85 deletions
+44
View File
@@ -0,0 +1,44 @@
"""复盘表单:下单类型与开仓类型校验(三所共用)."""
from __future__ import annotations
from typing import Optional, Sequence, Tuple
from lib.strategy.strategy_trade_labels import (
JOURNAL_ORDER_TYPE_OPTIONS,
STRATEGY_ENTRY_REASON_OPTIONS,
normalize_journal_order_type,
)
from lib.trade.entry_model_lib import (
TRADE_STYLE_FALLBACK_ENTRY_REASONS,
normalize_review_entry_reason,
)
_LEGACY_JOURNAL_ENTRY_REASONS: Tuple[str, ...] = (
*TRADE_STYLE_FALLBACK_ENTRY_REASONS,
*STRATEGY_ENTRY_REASON_OPTIONS,
)
def normalize_journal_entry_reason(
raw: Optional[str],
allowed: Sequence[str],
*,
allow_legacy: bool = False,
) -> str:
s = normalize_review_entry_reason(raw, allowed)
if s:
return s
if not allow_legacy:
return ""
legacy = (raw or "").strip()
if legacy in _LEGACY_JOURNAL_ENTRY_REASONS:
return legacy
return ""
def journal_entry_reason_valid(raw: Optional[str], allowed: Sequence[str]) -> bool:
return bool(normalize_journal_entry_reason(raw, allowed, allow_legacy=False))
def journal_order_type_valid(raw: Optional[str]) -> bool:
return bool(normalize_journal_order_type(raw))