TradeMemory Protocol
AI trading memory layer for MT5/forex with 15 MCP tools — store/recall trades, pattern discovery, strategy evolution, and Outcome-Weighted Memory.
What if your trading bot could learn from every mistake — and invent better strategies by itself?
200+ trading MCP servers execute trades. None of them remember what happened.
TradeMemory is the memory layer that changes that.
Why TradeMemory?
"Why does my bot keep making the same mistakes?"
Persistent memory records every trade with full context — entry reasoning, market regime, confidence level, outcome. Pattern discovery finds what you can't see manually.
"My strategy worked for months, then suddenly stopped."
Outcome-weighted recall auto-downweights patterns from old regimes. Your bot adapts without you rewriting a single rule.
"How do I know it's not just overfitting?"
Every pattern carries Bayesian confidence + sample size. Built-in out-of-sample validation. Suspicious patterns get flagged, not blindly followed.
"I just want it to figure out what works."
Evolution Engine: feed raw price data. No indicators, no hand-written rules. It discovers, backtests, eliminates, and evolves — autonomously.
22 months of BTC data. Sharpe 3.84. 477 trades. 91% positive months. Zero human strategy input.
Quick Start
pip install tradememory-protocol
Add to your Claude Desktop config (claude_desktop_config.json):
{
"mcpServers": {
"tradememory": {
"command": "uvx",
"args": ["tradememory-protocol"]
}
}
}
Then say to Claude:
"Record my BTCUSDT long at 71,000 — momentum breakout, high confidence."
Claude Code / Cursor / Other MCP clients
Claude Code:
claude mcp add tradememory -- uvx tradememory-protocol
Cursor / Windsurf / any MCP client — add to your MCP config:
{
"mcpServers": {
"tradememory": {
"command": "uvx",
"args": ["tradememory-protocol"]
}
}
}
From source / Docker
git clone https://github.com/mnemox-ai/tradememory-protocol.git
cd tradememory-protocol
pip install -e .
python -m tradememory
# Server runs on http://localhost:8000
docker compose up -d
Claude Plugin (commands + skills + domain knowledge)
git clone https://github.com/mnemox-ai/tradememory-plugin.git
claude --plugin-dir ./tradememory-plugin
Adds 5 slash commands (/record-trade, /recall, /performance, /evolve, /daily-review) and 3 domain knowledge skills. See tradememory-plugin for details.
Use Cases
Crypto — Feed BTC/ETH trades from Binance. The Evolution Engine discovers timing patterns you'd never find manually. Auto-adapts when market regime shifts.
Forex + MT5 — Auto-sync every closed trade from MetaTrader 5. Persistent memory across sessions means your EA remembers that Asian session breakouts have a 10% win rate — and stops taking them.
Developers — Build memory-aware trading agents with 15 MCP tools + 30 REST endpoints. Your agent starts each session knowing its confidence level, active plans, and which strategies are working.
Architecture
Every memory is scored by five factors when recalled:
| Factor | What It Does |
|---|---|
| Q — Quality | Maps trade outcomes to (0,1). A +3R winner scores 0.98. A -3R loser scores 0.02 — but never zero, because losing memories are recalled as warnings. |
| Sim — Similarity | How similar is the current market context to when the memory was formed? Irrelevant memories get suppressed. |
| Rec — Recency | Power-law decay. 30-day memory retains 71% strength. 1-year memory retains 28%. Gentler than exponential — regime-relevant old memories stay retrievable. |
| Conf — Confidence | Memories formed in high-confidence states score higher. Floor of 0.5 prevents early memories from being ignored. |
| Aff — Affect | During drawdowns, cautionary memories surface. During winning streaks, overconfidence checks activate. |
Based on ACT-R (Anderson 2007), Kelly criterion (1956), Tulving's memory taxonomy (1972), and Damasio's somatic markers (1994). Full spec: OWM_FRAMEWORK.md
Evolution Engine — the hidden ace
The Evolution Engine discovers trading strategies from raw price data. No indicators. No human rules. Pure LLM-driven hypothesis generation + vectorized backtesting + Darwinian selection.
How it works
- Discover — LLM analyzes price data, proposes candidate strategies
- Backtest — Vectorized engine tests each candidate (ATR-based SL/TP, long/short, time-based exit)
- Select — In-sample rank → out-of-sample validation (Sharpe > 1.0, trades > 30, max DD < 20%)
- Evolve — Survivors get mutated. Next generation. Repeat.
Results: BTC/USDT 1H, 22 months (2024-06 to 2026-03)
| System | Trades | Win Rate | RR | Profit Factor | Sharpe | Return | Max DD |
|---|---|---|---|---|---|---|---|
| Strategy C (SHORT) | 157 | 42.7% | 1.57 | 1.17 | 0.70 | +0.37% | 0.45% |
| Strategy E (LONG) | 320 | 49.4% | 1.95 | 1.91 | 4.10 | +3.65% | 0.27% |
| C+E Combined | 477 | 47.2% | 1.84 | 1.64 | 3.84 | +4.04% | 0.22% |
- 91% positive months (20 of 22)
- Max drawdown 0.22% — lower than either strategy alone
- Zero human strategy input. The LLM discovered these from raw candles.
Data from RESEARCH_LOG.md. 11 experiments, full methodology, model comparison (Haiku vs Sonnet vs Opus).
MCP Tools
Core Memory (4 tools)
| Tool | Description |
|---|---|
store_trade_memory | Store a trade with full context |
recall_similar_trades | Find past trades with similar market context (auto-upgrades to OWM when available) |
get_strategy_performance | Aggregate stats per strategy |
get_trade_reflection | Deep-dive into a trade's reasoning and lessons |
OWM Cognitive Memory (6 tools)
| Tool | Description |
|---|---|
remember_trade | Store into all five memory layers simultaneously |
recall_memories | Outcome-weighted recall with full score breakdown |
get_behavioral_analysis | Hold times, disposition ratio, Kelly comparison |
get_agent_state | Current confidence, risk appetite, drawdown, streaks |
create_trading_plan | Conditional plans in prospective memory |
check_active_plans | Match plans against current context |
Evolution Engine (5 tools)
| Tool | Description |
|---|---|
evolution_run | Run a full discover → backtest → select cycle |
evolution_status | Check progress of running evolution |
evolution_results | Get graduated strategies with full metrics |
evolution_compare | Compare generations side by side |
evolution_config | View/update evolution parameters |
REST API (30+ endpoints)
Trade recording, outcome logging, history queries, daily/weekly/monthly reflections, risk constraints, MT5 sync, OWM CRUD, evolution orchestration, and more.
Full reference: docs/API.md
Star History
Contributing
See CONTRIBUTING.md for guidelines.
- Star the repo to follow progress
- Report bugs via GitHub Issues
- Submit PRs for bug fixes or new features
Documentation
| Doc | Description |
|---|---|
| OWM Framework | Full theoretical foundation (1,875 lines) |
| Tutorial (EN) | Step-by-step from install to using memory |
| Tutorial (中文) | 完整教學指南 |
| API Reference | All REST endpoints |
| MT5 Setup | MetaTrader 5 integration |
| Research Log | 11 evolution experiments with full data |
License
MIT — see LICENSE.
Disclaimer: This software is for educational and research purposes only. It does not constitute financial advice. Trading involves substantial risk of loss.
Built by Mnemox
เซิร์ฟเวอร์ที่เกี่ยวข้อง
QMT MCP Server
An MCP server that interfaces with the locally running MiniQMT trading system.
Korea Investment & Securities (KIS) REST API
Provides stock trading and market data using the Korea Investment & Securities (KIS) REST API.
Soccerdata MCP Server
Provides real-time football match information from the SoccerDataAPI using natural language.
Hava Durumu
Provides weather data using the Open-Meteo API.
Relay Protocol MCP Server
An MCP server for the Relay Protocol REST API, enabling cross-chain bridging and token swapping operations.
LiveScore MCP
Real-time football live scores, fixtures, team stats, and player data from 1000+ leagues via SSE transport. Free, no API key required.
porkbun-mcp
MCP server for Porkbun domains and DNS
NebulaFinger MCP
An MCP server interface for the NebulaFinger fingerprint recognition tool.
Pokemon MCP
An MCP server for Pokemon-related functionality.
MCP-Airflow-API
MCP-Airflow-API is an MCP server that leverages the Model Context Protocol (MCP) to transform Apache Airflow REST API operations into natural language tools. This project hides the complexity of API structures and enables intuitive management of Airflow clusters through natural language commands.