Skip to main content
Glama
TradeMemory Protocol

TradeMemory Protocol

by mnemox-ai

PyPI Tests MCP Tools Smithery License: MIT

快速开始 | 使用场景 | API 参考 | OWM 框架 | 局限性 | English


项目状态(2026 年 8 月): 功能完备,处于维护模式——仍会审阅错误和安全报告;不计划新增功能或托管服务。付费服务请参见交易记录分析。

你的交易 AI 患有失忆症。而监管机构已经开始注意到这一点。

它在每次会话中犯同样的错误。它无法解释自己为什么交易。当上下文窗口结束时,它忘记一切。与此同时,MiFID II 正在提高算法决策文档化的标准(第 17 条)。欧盟《人工智能法案》要求对 AI 行为进行系统性日志记录(第 14 条)。你竞争对手的智能体正在从每一笔交易中学习。

AI 交易技术栈缺少一层。每个 MCP 服务器都处理执行——下单、获取价格、读取图表。没有一个处理记忆。

你的智能体可以买入 100 股 AAPL,却无法回答:"上次我在这种条件下买入 AAPL 时发生了什么?"

TradeMemory 就是记忆层。 一次 pip install,你的 AI 智能体就能记住每一笔交易、每一个结果、每一个错误——并带有 SHA-256 防篡改审计追踪。

已被交易者用于生产环境,在每次建仓前运行飞行前检查清单,也被 EA 系统用于每天记录数千条决策。

它能做什么

  • 交易前: 询问你的记忆——上次在这种市场条件下发生了什么?结果如何?

  • 交易后: 一次调用记录一切——五个记忆层自动更新

  • 安全护栏: 置信度跟踪、回撤警报、连败检测——系统会告诉你何时该停止

适用于任何市场(股票、外汇、加密货币、期货)、任何经纪商、任何 AI 平台。TradeMemory 不执行交易,也不触碰你的资金——它只负责记录和回忆。

Related MCP server: AgentRecall

快速开始

pip install tradememory-protocol

添加到 Claude Desktop(claude_desktop_config.json):

{
  "mcpServers": {
    "tradememory": {
      "command": "uvx",
      "args": ["tradememory-protocol"]
    }
  }
}

然后告诉 Claude:"记录我在 $195 做多 AAPL——财报超预期、机构买入、高置信度。"

# Claude Code
claude mcp add tradememory -- uvx tradememory-protocol

# From source
git clone https://github.com/mnemox-ai/tradememory-protocol.git
cd tradememory-protocol && pip install -e . && python -m tradememory

# Docker
docker compose up -d

完整指南: 快速开始(交易者路线 + 开发者路线)

谁在使用 TradeMemory

美股交易者

外汇 EA 系统

合规团队

市场

股票(AAPL、TSLA 等)

XAUUSD(黄金)

多资产

方式

每笔交易前的飞行前检查清单

从 MT5 自动同步

完整决策审计追踪

核心价值

纪律系统——每次决策前的记忆

记录信号被阻止的原因,而不仅仅是已执行的信号

面向监管机构的 SHA-256 防篡改记录

详情

了解更多 →

了解更多 →

了解更多 →

工作原理

  1. 回忆 — 交易前,按结果质量、上下文相似度、时效性、置信度和情绪状态加权检索过往交易(OWM 框架)

  2. 记录 — 交易后,一次调用 remember_trade 写入五个记忆层:情景记忆、语义记忆、程序记忆、情感记忆和交易记录

  3. 反思 — 每日/每周/每月回顾检测行为漂移、策略退化和交易错误

  4. 审计 — 每条决策在创建时即进行 SHA-256 哈希。可随时导出以供审查或提交监管

MCP 工具

类别

工具

描述

记忆

remember_trade · recall_memories

以结果加权评分记录和回忆交易

状态

get_agent_state · get_behavioral_analysis

置信度、回撤、连败、行为模式

规划

create_trading_plan · check_active_plans

带条件触发器的前瞻性计划

风险

check_trade_legitimacy

5 因素交易前门控(完整 / 缩减 / 跳过)

审计

export_audit_trail · verify_audit_hash

SHA-256 篡改检测 + 批量导出

类别

工具

核心记忆

get_strategy_performance · get_trade_reflection

OWM 认知

remember_trade · recall_memories · get_behavioral_analysis · get_agent_state · create_trading_plan · check_active_plans

风险与治理

check_trade_legitimacy · validate_strategy · compute_dqs

进化

evolution_fetch_market_data · evolution_discover_patterns · evolution_run_backtest · evolution_evolve_strategy · evolution_get_log

审计

export_audit_trail · verify_audit_hash · verify_audit_chain · get_daily_root

REST API: 35+ 个端点,用于交易记录、反思、风险、MT5 同步、OWM、进化和审计。完整参考 →

交易记录分析

TradeMemory 本身是免费且自托管的。维护者提供的付费服务是对你自己的交易记录进行统计分析:导出你的 MT4/MT5 历史记录,获得一份描述性统计报告——你的亏损集中在何处、亏损后你的仓位规模如何变化、强制平仓结构,以及你每笔交易实际承担的风险——随后进行一次讲解通话。

仅对过往交易进行描述性统计:不提供交易信号、不提供投资建议、不承诺业绩。交付后你的文件将被删除。

dev@mnemox.ai | 预约通话

企业版与合规

你的智能体做出的每一个交易决策——包括不交易的决策——都会被记录为交易决策记录(TDR)。每条记录的 SHA-256 内容哈希被链接到前向链式审计账本中;每个 UTC 日由 Merkle 根汇总,而 Merkle 根本身又跨日链接。篡改任何历史记录都会使所有后续链接失效。

法规

要求

TradeMemory 覆盖范围

MiFID II 第 17 条

记录每个算法交易决策因素

完整决策链:条件、过滤器、指标、执行

欧盟 AI 法案第 14 条

对高风险 AI 系统进行人工监督

每个决策的可解释推理 + 记忆上下文

欧盟 AI 法案第 12 条

系统生命周期内的自动、防篡改日志

链接 SHA-256 链 + 每日 Merkle 根(1.5 阶段中的 RFC 3161 TSA)

# Verify a single record hasn't been tampered with
verify_audit_hash(trade_id="MT5-7047640363")
# → {"verified": true, "chain_entry": {"sequence_num": 42, ...}}

# Walk the entire chain (or a slice) end-to-end
verify_audit_chain(from_seq=1, to_seq=None)
# → {"verified": true, "checked_count": 1284, "first_break_at": null}

# Daily Merkle root — single 32-byte anchor over every TDR for that day
get_daily_root(date="2026-05-14")
# → {"verified": true, "root_hash": "a05544...", "record_count": 18}

# Bulk export for regulatory submission
GET /audit/export?strategy=VolBreakout&start=2026-03-01&format=jsonl

完整审计链成熟度声明请参见 LIMITATIONS.md,包括 v0.5.2 中尚未包含的内容(TSA 时间戳、外部锚定、zkML 推理证明)。

需要为你的基金定制部署? → dev@mnemox.ai

安全性

  • 绝不接触 API 密钥。 TradeMemory 不执行交易、不转移资金、不访问钱包。

  • 只读和只记录。 你的智能体将决策上下文传递给 TradeMemory。它存储这些内容。仅此而已。

  • 本地优先。 唯一的外呼是每日审计根的 RFC 3161 可信时间戳——一个 32 字节的哈希,不包含交易数据(默认开启;可通过 TRADEMEMORY_TSA=off 关闭)。其他任何内容都不会离开你的机器。

  • SHA-256 链式审计账本。 每条记录在创建时即被哈希并链接到上一条记录。每日 Merkle 根锚定整条链。可在记录、切片或日级别验证完整性。每一层都能检测到篡改;外部锚定(默认使用 TSA)已在路线图上。

  • 1,400+ 项测试通过。 带 CI 的完整测试套件。

研究状态

TradeMemory 的 OWM 框架基于认知科学(Tulving 1972) 和强化学习(Schaul et al. 2015)。当前状态:

  • OWM 五因素评分: 已实现,已测试(1,400+ 项测试)

  • 统计验证: 已实现 DSR、MBL(Bailey-de Prado 2014)

  • 审计追踪: SHA-256 防篡改 TDR

  • 进化引擎: 研究阶段(策略生成可用,统计门控通过率正在优化中)

  • 混合回忆: OWM-only 模式已激活,配置嵌入后可使用向量融合

  • 实证验证: 进行中(n=40 笔交易,统计显著性目标 n>=100)

文档

文档

描述

快速入门

安装 → 首次交易 → 飞行前检查清单

使用场景

3 个真实生产场景

API 参考

所有 REST 端点

OWM 框架

结果加权记忆理论

架构

系统设计与分层

教程

详细演练

MT5 设置

MetaTrader 5 集成

研究日志

进化实验与数据

失败分类

11 种交易 AI 失败模式

中文版

繁体中文

贡献

参见 贡献指南 · 安全政策


MIT — 参见 LICENSE。仅供教育/研究用途。不构成财务建议。

Available Tools

20 tools
check_active_plansA
Idempotent

Check active trading plans against current market context.

Queries all active prospective plans, expires any past their expiry date, and matches remaining plans against the provided context.

Inputs: context_atr_d1, context_regime. Returns: object

check_trade_legitimacyA
Idempotent

Check if the agent has sufficient data and confidence to trade.

Call this before making any trade decision. Evaluates sample size, memory quality, regime experience, streak state, and drawdown to determine whether the agent has earned the right to trade at full size.

Inputs: strategy_name (required), symbol, current_atr_d1, current_regime. Returns: object

compute_dqsA
Idempotent

Compute Decision Quality Score before executing a trade.

Evaluates the quality of the decision process (not outcome) across 5 factors: regime match, position sizing vs Kelly, process adherence (OWM similarity), risk state, and historical pattern.

Inputs: symbol (required), direction (required), strategy_name (required), context_atr_d1, +3 more. Returns: object

create_trading_planA

Create a prospective trading plan that activates when conditions are met.

Stores a rule-based plan in prospective memory. The plan stays active until triggered, expired, or manually cancelled.

Inputs: reasoning (required), trigger_type (required), planned_action (required), trigger_condition (required), +2 more. Returns: object

evolution_discover_patternsA

Discover trading patterns from market data using LLM analysis.

Uses Claude to analyze OHLCV data and generate candidate trading patterns with entry/exit conditions. Each pattern can be backtested afterward.

Inputs: symbol (required), days, count, timeframe, +1 more. Returns: object

evolution_evolve_strategyA

Run full evolution loop — generate, backtest, select, eliminate.

Multi-generation strategy evolution: generates candidate patterns via LLM, backtests on in-sample data, validates survivors on out-of-sample data, eliminates weak hypotheses. Returns graduated strategies and graveyard.

Inputs: symbol (required), days, timeframe, generations, +1 more. Returns: object

evolution_fetch_market_dataA
Idempotent

Fetch OHLCV market data from Binance for evolution analysis.

Downloads historical price bars for backtesting and pattern discovery. Use this before discover_patterns or run_backtest to get data.

Inputs: symbol (required), days, timeframe. Returns: object

evolution_get_logA
Read-onlyIdempotent

Get the log of past evolution runs from this session.

Returns a list of all evolution runs with their results, including graduated strategies, graveyard, token usage, and backtest counts. Data is in-memory (resets on server restart).

Inputs: no named parameters. Returns: object

evolution_run_backtestA
Idempotent

Backtest a candidate pattern against historical OHLCV data.

Takes a pattern dict (from discover_patterns) and runs a vectorized backtest. Returns fitness metrics: Sharpe ratio, win rate, trade count, max drawdown, total PnL.

Inputs: pattern_dict (required), days, symbol, timeframe. Returns: object

export_audit_trailA
Read-onlyIdempotent

Export Trading Decision Records for audit and compliance review.

Provides a complete, tamper-evident record of trading decisions including the memory context (similar trades, beliefs) that informed each decision.

Inputs: end, limit, start, strategy, +1 more. Returns: object

get_agent_stateA
Read-onlyIdempotent

Get the current agent affective state (confidence, risk, drawdown).

Returns confidence level, risk appetite, drawdown percentage, win/loss streaks, equity tracking, and a recommended action based on current drawdown severity.

Inputs: no named parameters. Returns: object

get_behavioral_analysisA
Read-onlyIdempotent

Get behavioral analysis from procedural memory.

Returns aggregate trading behavior stats: hold times, disposition ratio, lot sizing variance, and Kelly criterion comparison.

Inputs: symbol, strategy_name. Returns: object

get_daily_rootA
Idempotent

Get (or rebuild) the daily Merkle root for a UTC date.

The Merkle root summarises every audit_chain entry whose chained_at falls inside the UTC day. Verifying this single 32-byte root proves the integrity of every TDR for that day without re-walking each one.

Inputs: date (required), rebuild, request_tsa, include_token. Returns: object

get_strategy_performanceA
Read-onlyIdempotent

Get aggregate performance stats per strategy.

Use this to evaluate which strategies are working and which need adjustment.

Inputs: symbol, strategy_name. Returns: object

get_trade_reflectionA
Read-onlyIdempotent

Get the full context and reflection for a specific trade.

Use this to deep-dive into a particular trade's reasoning and lessons.

Inputs: trade_id (required). Returns: object

recall_memoriesA
Idempotent

Recall memories using OWM outcome-weighted scoring.

Queries episodic and semantic memories, scores them by outcome quality, context similarity, recency, confidence, and affective modulation. Returns ranked memories with score breakdown.

Use order="losses_first" right before placing a trade: losing trades taken in similar conditions rank first, and the current mood (a losing streak) no longer pushes them down.

Inputs: symbol (required), market_context (required), limit, order, +6 more. Returns: object

remember_tradeA

Store a trade into OWM multi-layer memory with automatic updates.

Writes to episodic memory and automatically updates semantic (Bayesian), procedural (running averages + hold time + Kelly), and affective (EWMA confidence/streaks). Also writes to trade_records for backward compatibility.

Inputs: pnl (required), symbol (required), direction (required), exit_price (required), +14 more. Returns: object

validate_strategyA
Read-onlyIdempotent

Validate a trading strategy using statistical tests (DSR + Walk-Forward + Regime + CPCV).

For educational and research purposes only. Not financial advice.

Upload a trade log CSV (QuantConnect format) or daily returns CSV. The tool runs four statistical tests:

  1. Deflated Sharpe Ratio (DSR) — detects overfitting from multiple testing

  2. Walk-Forward Validation — checks out-of-sample consistency

  3. Regime Analysis — performance across bull/bear/crisis markets

  4. CPCV — cross-validated Sharpe stability across time periods

Inputs: file_path (required), format, strategy_name, num_strategies. Returns: object

verify_audit_chainA
Read-onlyIdempotent

Verify the integrity of the audit chain.

Walks the chain from from_seq (default: 1, the genesis record) to to_seq (default: latest), checking that every record's prev_hash matches the previous record's data_hash, and that each data_hash equals SHA256(prev_hash || content_hash).

Returns a dict with verified, checked_count, first_break_at, reason. A first_break_at of None with verified=True means the chain is intact across the verified range.

Inputs: to_seq, from_seq. Returns: object

verify_audit_hashA
Read-onlyIdempotent

Verify the integrity of a Trading Decision Record.

Recomputes the SHA256 data_hash from stored inputs and compares with the hash computed at decision time. A mismatch indicates tampering.

Inputs: trade_id (required). Returns: object

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4/5.0

    Scored across 20 tools

    Disambiguation4/5

    Most tools target clearly distinct resources and actions, and namespaces (evolution_*, verify_audit_*) help group related operations. However, check_trade_legitimacy vs compute_dqs (both pre-trade gates) and get_agent_state vs get_behavioral_analysis (both aggregate state) have overlapping boundaries an agent could misselect between.

    Naming Consistency4/5

    Nearly all tools follow a predictable snake_case verb_noun pattern (get_*, create_*, verify_*, check_*), with the evolution_* prefix used consistently as a namespace for that subgroup. Minor deviation is the mixed imperative/noun style of remember_trade, recall_memories, and compute_dqs, but the convention remains readable throughout.

    Tool Count4/5

    20 tools is on the heavier side but justified by the breadth of the domain (memory, planning, strategy evolution, audit, validation). Each tool maps to a distinct capability rather than being redundant, so the count is reasonable though slightly toward the upper bound.

    Completeness4/5

    Coverage is strong: memory write/recall, planning create/check, a full evolution loop, and a complete audit trail (export, hash, chain, Merkle root). The notable gap is the planning lifecycle—create_trading_plan mentions manual cancellation but no cancel/update plan tool exists, and there is no delete/update for stored trades.

    Maintenance

    ActivitySlowing
    ResponsivenessMixed handling

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      D
      maintenance
      An MCP server that provides persistent memory for AI agents by storing session snapshots, factual memories, and conversation summaries. It enables seamless continuity between interactions by allowing agents to restore previous emotional states and recall relevant past experiences.
      -
    • A
      license
      A
      quality
      B
      maintenance
      MCP server for persistent, compounding memory that automatically captures corrections and insights across AI sessions, enabling agents to learn and improve over time.
      5
      376
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      MCP server that provides AI agents with persistent memory, cross-agent sharing, and context management, enabling them to remember conversations, track complex tasks, and evolve skills across tools.
      2
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      An MCP server that captures and stores user decisions during AI-agent interactions, offering structured decision memory, cognitive bias detection, and personalized advice from historical patterns.
      2
      -