AI trading memory with outcome-weighted recall and autonomous strategy evolution. 17 MCP tools, 1,233 tests, works with any trading platform.
Give your AI agent persistent trading memory. TradeMemory records every trade, recalls past decisions weighted by outcome quality, discovers behavioral patterns, and autonomously evolves new strategies from raw price data.
Outcome-Weighted Memory (OWM) — 5 memory types (episodic, semantic, procedural, affective, prospective) that score recall by P&L outcome, context similarity, recency, and confidence. Winning trades surface first.
Evolution Engine — LLM-powered strategy discovery. Feed it OHLCV data from any exchange, it generates candidate patterns, backtests them vectorized, validates out-of-sample, and graduates survivors. No manual rule writing.
Platform-agnostic — works with MT5, Binance, Alpaca, or any broker that outputs trade data. 1,233 tests passing. MIT licensed.
pip install tradememory-protocol
Verify:
python -c "import tradememory; print('TradeMemory ready')"
Add to your Claude Desktop MCP config:
{
"mcpServers": {
"tradememory": {
"command": "uvx",
"args": ["tradememory-protocol"]
}
}
}
claude mcp add tradememory -- uvx tradememory-protocol
python -m tradememory
Runs the MCP server on stdio. For the REST API server:
python -m tradememory.server
# Runs on http://localhost:8000
| Tool | Purpose |
|---|---|
get_strategy_performance | Aggregate stats per strategy: win rate, PnL, profit factor, best/worst trades |
get_trade_reflection | Deep-dive into a specific trade's reasoning and lessons learned |
| Tool | Purpose |
|---|---|
remember_trade | Store a trade into all 5 OWM memory layers with automatic behavioral updates |
recall_memories | Outcome-weighted recall — scores memories by P&L, context similarity, recency, confidence |
get_behavioral_analysis | Procedural memory stats: hold times, disposition ratio, lot variance, Kelly criterion |
get_agent_state | Current affective state: confidence level, drawdown %, win/loss streaks, risk appetite |
create_trading_plan | Create a prospective trading plan with entry/exit conditions and risk parameters |
check_active_plans | Check status of active trading plans, evaluate against current market conditions |
| Tool | Purpose |
|---|---|
evolution_fetch_market_data | Fetch OHLCV data from Binance for backtesting and pattern discovery |
evolution_discover_patterns | LLM-powered pattern discovery from price data — generates candidate trading rules |
evolution_run_backtest | Vectorized backtest of a candidate pattern — returns Sharpe, win rate, max drawdown |
evolution_evolve_strategy | Full evolution loop: generate → backtest → select → eliminate across generations |
evolution_get_log | Get log of past evolution runs with graduated strategies and graveyard |
| Tool | Purpose |
|---|---|
export_audit_trail | Export trading decision records with SHA-256 tamper detection for compliance review |
verify_audit_hash | Verify integrity of a trading decision record by recomputing its SHA-256 hash |
Tell your agent these things in natural language.
"Record my trade: XAUUSD long 0.05 lots, entry 5180, exit 5210, profit $150"
"Remember my XAUUSD short trade, entry 5200, exit 5165, profit $175. London session breakout, high volume, confidence 0.8."
"What trades have I taken in similar market conditions? Current context: ranging market, low volatility, Asian session."
Returns memories ranked by outcome-weighted score — winning trades in similar contexts surface first.
"Show my trading performance this week"
"Compare my VolBreakout vs IntradayMomentum strategy performance"
"Show my behavioral analysis — am I cutting winners short?"
Returns disposition ratio, hold time asymmetry, lot sizing variance vs Kelly criterion.
"What's my current confidence level and drawdown?"
"Am I on tilt? Check my affective state."
"Create a trading plan for XAUUSD long if price breaks above 5200 with ATR confirmation"
"Check my active trading plans against current market conditions"
"Evolve a strategy for BTCUSDT on the 1h timeframe — 3 generations, 10 candidates each"
"Discover 5 trading patterns from ETHUSDT 4h data over the last 90 days"
"Backtest this pattern against BTCUSDT 1h data"
"Show me the evolution log — which strategies graduated?"
"Run a reflection on my last 20 trades"
"What patterns have you found in my London session trades?"
Network access during install: pip install downloads from PyPI. Standard Python package installation.
Network access at runtime: The MCP server runs on stdio by default — no network access. The REST server runs on localhost:8000 and does not make outbound requests. If ANTHROPIC_API_KEY is set, the reflection engine and Evolution Engine send data to the Claude API. Evolution Engine fetches OHLCV data from the Binance public API.
Environment variables: All environment variables are optional. They are stored in your local .env file and never logged or sent to external services (except ANTHROPIC_API_KEY which authenticates with the Anthropic API).
File system access: TradeMemory writes to a single SQLite database file (tradememory.db) in the project directory. No files are created or modified outside the project.
No implicit permissions: This skill does not auto-install dependencies, modify system files, or require elevated privileges.
| Variable | Required | Description |
|---|---|---|
ANTHROPIC_API_KEY | No | Enables LLM reflections and Evolution Engine. Without it, reflections use rule-based analysis; Evolution is unavailable. |
TRADEMEMORY_API | No | REST API endpoint, defaults to http://localhost:8000 |
python scripts/demo.py (30 simulated trades, full L1→L2→L3 pipeline)| Skill | Path | Description |
|---|---|---|
| Strategy Validator | .skills/strategy-validator/SKILL.md | Validate trading strategies for overfitting using 4 statistical tests (DSR, Walk-Forward, Regime, CPCV). Use when the user says "validate my strategy", "check my backtest", or "is this overfitting?". |