fix: journal detail contrast and unify AI review journal format across four exchanges
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+52
-2
@@ -1,9 +1,9 @@
|
||||
"""AI 日复盘 / 周复盘:附图收集(各实例共用)。"""
|
||||
"""AI 日复盘 / 周复盘:附图收集与 journal 文本格式化(四所共用)。"""
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import uuid
|
||||
from typing import Callable, List, Optional, Sequence
|
||||
from typing import Any, Callable, List, Mapping, Optional, Sequence
|
||||
|
||||
from journal_chart_lib import (
|
||||
JOURNAL_CHART_ANCHOR_CLOSE,
|
||||
@@ -14,6 +14,56 @@ from journal_chart_lib import (
|
||||
)
|
||||
|
||||
|
||||
def _journal_nz(v: Any, default: str = "无") -> str:
|
||||
if v is None:
|
||||
return default
|
||||
s = str(v).strip()
|
||||
return s if s else default
|
||||
|
||||
|
||||
def journal_row_lines_for_ai(
|
||||
idx: int,
|
||||
row: Mapping[str, Any],
|
||||
*,
|
||||
include_hold_duration: bool = True,
|
||||
) -> str:
|
||||
"""把 journal 字段拼成给 AI 的文本;四所日复盘/周复盘共用。"""
|
||||
lines = [
|
||||
(
|
||||
f"{idx}. {_journal_nz(row.get('coin'))} {_journal_nz(row.get('tf'))} "
|
||||
f"| 盈亏:{_journal_nz(row.get('pnl'))}U "
|
||||
f"| 实际RR:{_journal_nz(row.get('real_rr'))} "
|
||||
f"| 预期RR:{_journal_nz(row.get('expect_rr'))}"
|
||||
),
|
||||
f" 开仓逻辑:{_journal_nz(row.get('entry_reason'))}",
|
||||
f" 平仓/离场(交易员自述):{_journal_nz(row.get('exit_reason'))}",
|
||||
]
|
||||
if include_hold_duration:
|
||||
lines.append(f" 持仓时长:{_journal_nz(row.get('hold_duration'))}")
|
||||
ee_bits = [
|
||||
_journal_nz(row.get("early_exit")),
|
||||
_journal_nz(row.get("early_exit_reason")),
|
||||
_journal_nz(row.get("early_exit_trigger")),
|
||||
_journal_nz(row.get("early_exit_note")),
|
||||
]
|
||||
if any(x != "无" for x in ee_bits):
|
||||
lines.append(
|
||||
" 提前离场记录:"
|
||||
f"{ee_bits[0]} | 原因:{ee_bits[1]} | 触发:{ee_bits[2]} | 备注:{ee_bits[3]}"
|
||||
)
|
||||
mood_bits = f"心态标签:{_journal_nz(row.get('mood_issues'))}"
|
||||
if row.get("mood_score") is not None:
|
||||
mood_bits += f" | 自评心态分:{row.get('mood_score')}"
|
||||
lines.append(f" {mood_bits}")
|
||||
if _journal_nz(row.get("post_breakeven_stare")) != "无":
|
||||
lines.append(f" 保本后盯盘:{_journal_nz(row.get('post_breakeven_stare'))}")
|
||||
if _journal_nz(row.get("new_trade_while_occupied")) != "无":
|
||||
lines.append(f" 占用时新开仓:{_journal_nz(row.get('new_trade_while_occupied'))}")
|
||||
if _journal_nz(row.get("note")) != "无":
|
||||
lines.append(f" 备注:{_journal_nz(row.get('note'))}")
|
||||
return "\n".join(lines) + "\n"
|
||||
|
||||
|
||||
def collect_images_for_ai_review(
|
||||
rows: Sequence,
|
||||
upload_folder: str,
|
||||
|
||||
Reference in New Issue
Block a user