Domain knowledge for AI trading memory — Outcome-Weighted Memory (OWM) architecture, 5 memory types, recall scoring, and behavioral analysis. Use when recording trades, recalling similar contexts, analyzing performance, or checking behavioral drift. Triggers on "record trade", "remember trade", "recall", "similar trades", "performance", "behavioral", "disposition", "affective state", "confidence".
TradeMemory implements a cognitive memory architecture for trading agents. Every trade is stored with full context (market conditions, strategy, reasoning, confidence) and recalled using Outcome-Weighted Memory (OWM) — a scoring system that surfaces winning trades in similar contexts first.
This is not a trade journal. It's a memory system that learns which past experiences are most relevant to current decisions.
L1: Raw Trades → L2: Pattern Discovery → L3: Strategy Adjustments
Raw trade events. Each record contains: symbol, direction, entry/exit, P&L, strategy, market context, reflection, timestamp.
When to write: After every completed trade. When to read: When recalling past trades for decision-making.
Strategy knowledge base. Aggregated understanding of what works: "VolBreakout performs best in London session with ATR > $40" is semantic memory.
When to write: Automatically updated when trades are stored via remember_trade.
When to read: When evaluating whether a strategy fits current conditions.
Behavioral baselines. Tracks execution patterns: average hold times per strategy, lot sizing consistency, stop loss adherence, entry timing precision.
When to write: Automatically computed from trade history. When to read: During behavioral analysis and daily reviews.
Emotional/confidence state. Tracks: current confidence level (0-1), drawdown percentage, win/loss streaks, risk appetite, tilt indicators.
When to write: Updated after every trade and during daily reviews. When to read: Before entering trades (am I on tilt?), during risk checks.
Active trading plans. Future-oriented: "If XAUUSD breaks above 5200 with ATR confirmation, go long." Plans have entry conditions, exit conditions, risk parameters, and expiry dates.
When to write: When creating trading plans. When to read: When checking if current market conditions match any active plans.
When you query recall_memories, results are scored by:
| Factor | Weight | Description |
|---|---|---|
| P&L Outcome | 40% | Profitable trades score higher. Magnitude matters. |
| Context Similarity | 30% | How closely the recalled context matches the query context |
| Recency | 20% | Recent trades weighted more (exponential decay) |
| Confidence Calibration | 10% | Trades where confidence matched outcome score higher |
Why outcome-weighted? Traditional trade journals treat all trades equally. OWM amplifies signal from successful decisions in similar contexts. If you've profited 5 times trading London session breakouts, those memories surface strongly when you're evaluating the next London session breakout.
| Tool | Use Case |
|---|---|
get_strategy_performance | Aggregate stats: win rate, PF, P&L per strategy |
get_trade_reflection | Deep-dive into a specific trade's reasoning |
| Tool | Use Case |
|---|---|
remember_trade | Full OWM store: writes to all 5 memory layers |
recall_memories | OWM recall: scored by outcome, similarity, recency, calibration |
get_behavioral_analysis | Procedural memory: disposition ratio, hold times, Kelly criterion |
get_agent_state | Affective state: confidence, drawdown, streaks, risk appetite |
create_trading_plan | Prospective memory: entry/exit conditions, risk parameters |
check_active_plans | Evaluate active plans against current market conditions |
| Mistake | Why It's Bad | Fix |
|---|---|---|
| Recording without context | Useless for recall — can't match future situations | Always include session, volatility, trend state |
| Setting confidence after seeing P&L | Destroys calibration scoring | Set confidence at entry, before outcome is known |
| Ignoring affective state | Trading on tilt leads to revenge trades | Check get_agent_state before every session |
| Never running daily reviews | Behavioral drift goes undetected | Run /daily-review at end of each trading day |
| Storing paper trades as real trades | Pollutes performance metrics | Tag paper trades separately or use a different database |
Trade Closes
↓
remember_trade() → Episodic (raw event)
→ Semantic (strategy knowledge update)
→ Procedural (behavioral baseline update)
→ Affective (confidence/streak update)
→ Prospective (check active plans)
↓
recall_memories() ← OWM scoring
↓
Next Trading Decision