04.Journal & AI post-mortem
Per-trade + daily + general notes, markdown templates, mandatory trade reviews when |R| ≥ 2, GPT analysis with cache, mood / discipline analytics. The journal is the second-most-used surface after Trades — and the one that turns a trade log into a feedback loop.
Three journal layers
The journal lives at three granularities, all in markdown, all queryable:
- Per-trade entries — one body per trade. Backed by
trade_journal_entries. Pre-trade plan + post-trade reflection in one document; the divider you put between them is yours. - Per-day entries — one body per trading date. Backed by
daily_journal_entries. Watchlist, market thesis, end-of-day recap, gratitude — whatever you want to capture at the day level. - General entries — free-form long-form journal, not tied to a trade or a day. Backed by
general_journal_entries. Strategy ideas, books-read notes, mental-game work.
All three load via GET /api/journal/trade/{id}, GET /api/journal/day/{day}, GET /api/journal/general; all three save via the same routes with POST. The body is markdown, rendered with a built-in renderer (no remote CDN — the renderer is vendored).
Templates
Templates live under Settings → Journal Templates. You define them once and the journal editor seeds new entries from the matching template. Each template has:
- Scope — per-trade, per-day, or general.
- Asset-class filter — apply only to options / futures / etc.
- Direction filter — long-only, short-only, both.
- Body — markdown with placeholders:
{{symbol}},{{entry_price}},{{planned_risk}},{{date}},{{r_multiple}},{{tags}}, etc.
Most-specific template wins (asset+direction beats asset, asset beats none). If nothing matches you get an empty editor.
# {{symbol}} — {{date}}
## Pre-trade
- Setup:
- Entry trigger:
- Planned risk: {{planned_risk}}
- Profit target / R-multiple:
## Post-trade
- What happened:
- What I did right:
- What I'd change:
- Lesson:
Mandatory trade reviews — the |R| ≥ 2 rule
Any trade whose absolute R-multiple is ≥ 2 (a big winner or a big loser) is flagged for forced reflection. The trade_reviews table tracks one per qualifying trade; the topbar shows a count of pending reviews; views nag you until they're written.
GET /api/trade-reviews/needed/{account_id}— the worklist.POST /api/trade-reviews— submit a review (status movespending → completed; the body is a small structured form: setup recognized, plan followed, risk size correct, plus free-form notes).
The threshold (2.0 default) and whether to require reviews at all are configurable per-account. Set the threshold to 1.0 to force a review on every trade with a planned-risk entry; set it to 0 to disable.
AI Journal — GPT post-mortem with cache
The AI Journal tile takes a trade ID, fetches the executions + chart bars + your free-form journal entry, builds a prompt, and asks an LLM for a structured post-mortem. Results land in ai_journal_cache keyed by (trade_id, prompt_hash) so a re-render is free.
POST /api/journal-ai/{trade_id}/analyze— runs analysis. HonorsCache-Control: no-cacheto force re-run.- Provider — configured per-user in Settings → AI. Bring-your-own-key (OpenAI / Anthropic / local Ollama). The API key is encrypted at rest with a per-install passphrase.
- Prompt — the default prompt is in
traderview-core::ai_prompt. Override per-user in Settings;{{trade_summary}},{{journal_body}},{{r_multiple}}, and{{ohlc_bars}}are the available variables. - Output — markdown rendered inline. Sections: Setup classification, Plan adherence, Sizing critique, Exit critique, One-line lesson.
The cache is invalidated whenever the underlying trade's executions change (rollup re-fires) so a hand-edit + AI re-run gives a fresh post-mortem without you remembering to bust the cache.
Trade Compare
The Trade Compare tile takes 2-6 trades and renders them side-by-side: small OHLC chart with entry / exit markers, planned-risk vs realized R, hold duration, side-by-side journal bodies. The intended use is "what's different between my best and worst same-setup trades?" Tag-filter to find the cohort first, then compare.
Replay & Tape Replay
Replay reconstructs the price action around a trade: bars before entry, the entry, the hold, the exit. Useful for "where on the chart did I actually pull the trigger?" inspection. Tape Replay goes one level deeper — if you have time & sales captured for the symbol during the trade, it scrolls the prints around your fills so you can study the order-flow context.
Mood & discipline analytics
Two sister views feed off your journal metadata:
- Discipline (
GET /api/discipline/{account_id}) — % of trades with a planned-risk set, % with a journal entry, % with a review completed. Trend over time. The goal is the lagging quantification of "am I actually doing the work?" - Mood Analytics (
GET /api/mood-analytics/{account_id}) — if your journal entries are tagged with a 1-5 mood score (or a free-form word the tagger normalizes), this view correlates mood with R-distribution, day-of-week, and account drawdown. Catches "I trade worst after a green Tuesday morning" type patterns.
focused / scattered / revenge / fomo / patient / impatient / tired). Add to it in Settings → Journal → Mood Vocabulary. Free-form words still flow through but unique mood words don't aggregate.