Lesson Learned #031: Procedural Memory for Trading Skills
Lesson Learned #031: Procedural Memory for Trading Skills
ID: LL-031 Impact: Identified through automated analysis
Date: December 14, 2025 Category: ML / Architecture Severity: HIGH (enables skill reuse and continuous improvement) Status: IMPLEMENTED
Executive Summary
Implemented Procedural Memory module that learns, stores, retrieves, and reuses successful trading patterns as āskillsā - neural module-like units that encode what works.
Problem
Our RAG lessons learned system captures what NOT to do (mistakes to avoid), but we had no system to capture what TO do (successful patterns to repeat).
Without procedural memory:
- Each trade starts from scratch
- Successful patterns arenāt systematically captured
- No way to ārememberā what worked in similar conditions
- Canāt build on past successes
Research: Procedural Memory Agents
Based on recent research:
Mem^p Framework (Aug 2024):
āProcedural memory silently compiles habitual skills into executable subroutines, enabling unconscious, fluent action.ā
LEGOMem Framework (Oct 2024):
āDistills successful executions into structured memory units: full-task memories and subtask memories, stored in a memory bank, indexed by semantic embeddings, and reused at inference time.ā
Key insight: Skills are learned from SUCCESSFUL trajectories and retrieved when conditions match.
Solution
Created src/memory/ module implementing:
1. TradingSkill Dataclass
@dataclass
class TradingSkill:
conditions: SkillConditions # WHEN to act
action: SkillAction # WHAT to do
outcome: SkillOutcome # EXPECTED results
# Example: RSI Oversold Bounce
conditions = SkillConditions(rsi_range=(0, 35), trend="up")
action = SkillAction(action_type="buy", stop_loss_pct=-3.0)
outcome = SkillOutcome(expected_win_rate=0.55, confidence=0.6)
2. Skill Library
from src.memory import get_skill_library
library = get_skill_library()
# Retrieve skills for current conditions
skills = library.retrieve_skills(
context={"rsi": 28, "trend": "up", "volume": "high"},
skill_type=SkillType.ENTRY,
)
# Learn from successful trade
library.extract_skill_from_trade(trade_record)
3. Automatic Integration
from src.memory.skill_hooks import enable_skill_learning
enable_skill_learning(orchestrator)
# Now skills are automatically learned from profitable trades
Skill Types
| Type | Purpose | Example |
|---|---|---|
| ENTRY | When to enter | āRSI Oversold Bounceā |
| EXIT | When to exit | āRSI Overbought Fadeā |
| SIZING | Position sizing | āVolatile Market Small Sizeā |
| TIMING | Timing optimization | āMarket Open Momentumā |
| RISK | Risk management | āTrailing Stop in Trendā |
| COMPOSITE | Multi-step workflow | āFull Trade Cycleā |
Skill Conditions
Each skill has conditions that must match:
SkillConditions(
rsi_range=(20, 40), # RSI in range
trend="up", # Price trend
volume_condition="high", # Volume level
regime=MarketRegime.TRENDING_UP,
macd_signal="bullish",
asset_class="crypto",
volatility_percentile=(0, 50),
custom={"sector": "tech"}, # Flexible key-value
)
Skill Outcomes (Self-Improving)
Each skill tracks its own performance:
SkillOutcome(
uses=10, # Times used
wins=7, # Profitable uses
losses=3, # Losing uses
expected_win_rate=0.70, # Current win rate
avg_profit_pct=2.5, # Average profit
confidence=0.65, # Increases with successful uses
)
Skills with poor performance can be automatically deactivated.
Seed Skills (Pre-loaded)
The library starts with proven trading patterns:
- RSI Oversold Bounce - Buy RSI < 35 in uptrend
- RSI Overbought Fade - Sell RSI > 70 in ranging market
- Volume Breakout Entry - Buy on high volume + MACD bullish
- Trend Following Hold - Hold in strong uptrend
- Volatile Market Small Size - Reduce size in volatile conditions
Integration with HICRA
Procedural memory complements HICRA credit assignment:
- HICRA identifies strategic decisions to learn from
- Procedural memory stores those decisions as reusable skills
- Together: learn the right things AND remember them
Expected Improvements
| Metric | Impact |
|---|---|
| Trade consistency | +15-20% (use proven patterns) |
| Learning speed | 2-3x faster (donāt reinvent patterns) |
| Win rate | +3-5% (avoid random exploration) |
| Risk management | Better (skill-based sizing) |
Files Created
src/memory/__init__.pysrc/memory/procedural_memory.py(650 lines)src/memory/skill_hooks.py(200 lines)tests/test_procedural_memory.py(350 lines)
Key Classes
| Class | Purpose |
|---|---|
TradingSkill |
Single skill with conditions, action, outcome |
SkillConditions |
When skill applies |
SkillAction |
What to do (action type, sizing, stops) |
SkillOutcome |
Historical performance, confidence |
SkillLibrary |
Storage, retrieval, learning |
ProceduralMemory |
High-level interface |
SkillLearningHook |
Auto-integration with orchestrator |
Research Sources
Tags
#procedural-memory #skills #learning #neural-modules #memp #legomem