
Tradememory Protocol
io.github.mnemox-ai由 GitHub 帳號 mnemox-ai 發布v0.5.6更新於 Oct 30, 2026
Tamper-evident decision audit trail and outcome-weighted memory for AI trading agents.
概覽
為 AI 交易代理設計的本地優先記憶與稽核伺服器:記錄交易、在下單前召回虧損交易,並可依你的策略攔截訂單。
- 可以做什麼
- 記錄與召回交易,依結果加權評分,支援虧損優先召回與行為分析
- 讀取代理狀態、策略績效、交易反思與進行中的交易計畫
- 執行交易前風險檢查、策略驗證與資料品質評分
- 透過行情資料、模式探索與回測產生並演化策略
- 匯出並驗證 SHA-256 鏈式稽核紀錄,含每日 Merkle 根
- 可選擇代理券商 MCP 伺服器,依你的策略評估或拒絕下單類工具
- 適用情境
- 當 AI 代理實際交易或草擬交易,而你希望它在提出訂單前看到自己過去的虧損交易、保留可偵測竄改的決策紀錄,或在 Alpaca 等券商連線前加一道策略閘門時適用。
- 執行需求
- 以本地 Python 套件執行(pip 或 uvx;proxy 附加元件需 Python 3.12+)。記憶伺服器與 Hyperliquid 公開成交資料無需金鑰;Alpaca 同步使用本機 env 檔案中的唯讀金鑰。選用金鑰:ANTHROPIC_API_KEY 用於演化與回放,DISCORD_WEBHOOK_URL 用於 MT5 摘要。行情同步、Binance 資料與 RFC 3161 時間戳需要網路。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Tradememory Protocol,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
[PyPI] [Tests] [MCP Tools] [Smithery] [License: MIT]
Getting Started | Use Cases | API Reference | OWM Framework | Limitations | 中文版
TradeMemory remembers what it cost. It is an open-source, local-first memory and brake for AI trading agents: it pulls in your fills, finds where your own history loses money, puts those losing trades in front of your agent before the next order, and can refuse an order that breaks rules you set, before it reaches the broker.
Brokers now let AI agents trade over MCP, with different guardrails: Webull and tastytrade set size or buying-power limits, Interactive Brokers only lets the agent draft an order for you to submit, and Robinhood and Public set no cap you can impose on an external agent (StockBrokers, 2026-09-30). The caps are fixed numbers. None of them looks at how your own past trades went.
Start with your own history
Each closed trade is stored in memory once; running it again stores only new trades. Then it prints where your history loses money. The format, with illustrative numbers:
These are descriptive statistics of your own past trades, not advice about the next one. Hyperliquid's API serves only an address's recent fills, not its whole history, so the sooner it is synced, the more history is kept. Other venues: MT5 and Binance spot sync scripts are in scripts/, and any agent can record a trade with remember_trade.
Before the next order
recall_memories(order="losses_first") puts every losing trade ahead of the rest, the bigger losses in similar conditions first, with their size and P&L. Besides the symbol's most recent trades, it searches the symbol's recent losing trades, so an older loss is not crowded out. The server tells connected agents to call it before proposing a trade. The default order ranks better outcomes higher (by R multiple, where one was recorded) and keeps at least 20% losses in the list.
Connect your agent
Add to Claude Desktop (claude_desktop_config.json):
Then tell Claude: "Record my AAPL long at $195 — earnings beat, institutional buying, high confidence."
Claude Code / Cursor / Docker
Full walkthrough: Getting Started (Trader Track + Developer Track)
Put a brake in front of your broker (preview)
The proxy extra runs TradeMemory between your agent and your broker's MCP server (Alpaca today). Every tool is forwarded unchanged except the order-placing ones, which Mnemox Control evaluates against a policy you own before they reach the broker. Every evaluation, allowed or refused, is recorded and chained into the audit log. An allowed order comes back with your losing trades from similar conditions first, and tradememory sync alpaca later fills in how each forwarded trade ended, in R when the entry carried a stop. The agent you already have keeps working; only one line of its MCP config changes.
Refused by default: symbols outside your list, orders above your notional and position limits, entries without a bracket stop, any new order after your daily-loss or drawdown limit, cancelling the protective stop of an open position, any tool the brake has not classified, and everything while you have run tradememory proxy halt FULL_HALT. Never blocked: closing a position. Orders at or above approval_notional wait for tradememory proxy approve <intent_id> --terms <fingerprint>, which approves exactly the terms you read; the agent retries with the same client_order_id and the same terms, and the proxy forwards it at most once. evaluate_order returns the same decision without placing anything, for pre-checks and for advisory layers in other frameworks. Anything the brake cannot evaluate (a dead quote feed, an unknown asset, an order type the policy does not cover) is refused, not passed through.
Status: tested end-to-end against a stateful fake of Alpaca's MCP server (tests/proxy/), and run against a real Alpaca paper account on 2026-10-01: three refusals (symbol not on the list, entry without a stop, notional over the limit), one allowed one-share bracket order that reached the broker, and one retry with the same client_order_id that was answered from the record without a second order. Options, order replacement, stop-limit and trailing orders are refused rather than evaluated. Your broker keys go only to the broker process the proxy starts; TradeMemory never stores them.
Walkthrough with the real outputs: docs/recipes/alpaca-brake.md.
Three ways it is used
How it works
- Recall — Before trading, retrieve past trades weighted by outcome quality, context similarity, recency, confidence, and emotional state (OWM Framework)
- Record — After trading, one call to
remember_tradewrites to five memory layers: episodic, semantic, procedural, affective, and trade records - Reflect — Daily/weekly/monthly reviews detect behavioral drift, strategy decay, and trading mistakes
- Audit — Every decision is SHA-256 hashed at creation and chained to the one before. Export anytime for review
MCP Tools
All 20 MCP tools + REST API
REST API: 35+ endpoints for trade recording, reflections, risk, MT5 sync, OWM, evolution, and audit. Full reference →
Get help connecting
Running an agent against a broker, or want your history synced and read? Open a brake-integration issue or book 30 minutes. Setup help is free, and the people who use it decide what gets built next.
Audit trail
Every trading decision your agent makes — including decisions not to trade — is recorded as a Trading Decision Record (TDR). Per-record SHA-256 content hashes are linked into a forward-chained audit ledger; every UTC day is summarised by a Merkle root which itself chains across days. Tampering with any historical record invalidates every subsequent link.
Rules that require decision records bind investment firms, not retail users. Under the EU AI Act, the Annex III high-risk logging obligations were postponed to 2 December 2027, and ESMA's February 2026 supervisory briefing on algorithmic trading states that AI-based algorithmic trading is currently excluded from the high-risk scope. The table shows which TradeMemory features map to those texts if and when they apply to you. It is not a compliance claim.
Daily roots are timestamped by an RFC 3161 authority by default since 0.5.3. Not built: signing records with a private key, anchoring to a public log, proving that nothing was left out. See LIMITATIONS.md.
Security
- Memory server (default). Never places orders and never asks for broker keys. Records and recalls only, in a local SQLite file.
- Sync.
tradememory sync hyperliquidreads public data with no key.tradememory sync alpacamakes read-only calls with keys from a file on your machine. Synced trades stay in your local database. - Brake (
proxyextra). Forwards the orders your policy allows to your broker's MCP server. Your broker keys are passed only to the broker process the proxy starts; TradeMemory never stores them. - Outbound calls. RFC 3161 timestamping of daily audit roots, a 32-byte hash with no trade data (on by default;
TRADEMEMORY_TSA=offturns it off).tradememory synccalls the venue you name. The evolution tools read public Binance market data (api.binance.com) when an agent calls them, and evolution calls the Anthropic API only if you setANTHROPIC_API_KEY. Replay calls DeepSeek by default (or Anthropic), and only with that provider's key set. If you installsentence-transformersfor hybrid recall, it downloads its model from Hugging Face on first use. The MT5 and Binance sync scripts inscripts/read their credentials from your environment, and the MT5 one posts trade summaries (symbol, prices, P&L) to a Discord webhook only if you setDISCORD_WEBHOOK_URL. - Tamper-evident, not tamper-proof. Every record is hashed and linked to the one before, with daily Merkle roots. Changing a record breaks the chain; someone who can rewrite the whole database can rebuild it.
Research Status
TradeMemory's OWM framework is grounded in cognitive science (Tulving 1972) and reinforcement learning (Schaul et al. 2015). Current status:
- OWM five-factor scoring: implemented and tested (see the CI badge)
- Statistical validation: DSR, MBL implemented (Bailey-de Prado 2014)
- Audit trail: SHA-256 tamper-evident TDR
- Evolution engine: research phase (strategy generation works, statistical gate pass rate under optimization)
- Hybrid recall: OWM-only mode active, vector fusion available when embeddings configured
- Empirical validation: ongoing (n=14 trades, target n>=100 for statistical significance; at n=14 the confidence intervals are too wide to conclude anything - see validation/final_verdict.md)
Documentation
Contributing
See Contributing Guide · Security Policy
[Star History]MIT, see LICENSE. The optional proxy extra installs Mnemox Control, whose engine is AGPL-3.0-only (a commercial license is available); TradeMemory itself stays MIT. For educational and research purposes only. Not financial advice.
來源:README.md,提交 c87372a
工具
0版本歷史
2- v0.5.6最新Oct 2, 2026
- v0.5.5Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分