opensourceprojects.dev

A broadsheet for software that doesn't ask for your email

Memory and a brake for AI trading agents, built from your own losing trades
GitHub RepoImpressions2

Project Description

View on GitHub

Your AI Trading Agent Doesn't Remember What It Cost You Last Time

You've connected an AI agent to your brokerage account, and it can place orders now. But does it know that the last three times it sized up after two losses in a row, it lost money? Probably not—most agents start every session with a clean slate and no memory of your own trading history. TradeMemory Protocol is an open-source, local-first memory and brake for AI trading agents that tries to fix exactly that: it pulls in your fills, finds where your history loses money, and puts those losing trades in front of your agent before the next order.

What It Does

TradeMemory is an MCP server that does two jobs. First, it syncs your closed trades into a local memory—once each, so re-running a sync only stores new trades. Second, it can refuse an order that breaks rules you've set before that order ever reaches the broker. Between those two jobs sits a recall step: recall_memories(order="losses_first") puts every losing trade ahead of the rest, bigger losses in similar conditions first, complete with their size and P&L.

The stats it prints are descriptive summaries of your own history, not predictions. After syncing, you get output like this: after two losses in a row, 5 of 20 trades were 1.5x your usual size or more, and all 20 won 60% and made -$1,500—while the 5 sized-up trades won 20% and made -$1,700. It also reports median hold times (winners 1.5h, losers 9.0h in the example). It's a mirror held up to your own fills.

It's built as an MCP server (20 tools, per the badge) and installs from PyPI. Syncing works with Hyperliquid out of the box using just a public address—no key needed—or Alpaca with your own read-only keys kept in a local file. MT5 and Binance spot sync scripts live in scripts/, and any agent can record a trade manually with remember_trade.

Why It's Cool

  • The problem is real and specific. The README points out that broker guardrails are fixed numbers—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. None of those caps looks at how your own past trades went. TradeMemory is the missing feedback loop.

  • It leads with losses on purpose. Many memory systems rank by recency or by "best" outcomes. Here, the default recall order ranks better outcomes higher (by R multiple, where one was recorded) but keeps at least 20% losses in the list—and the losses_first mode exists precisely so the agent sees what went wrong before it proposes a trade. The server also tells connected agents to call recall before proposing anything.

  • It searches beyond the recent window. Besides a symbol's most recent trades, it searches that symbol's recent losing trades, so an older loss doesn't get crowded out by a pile of newer ones. That's a small design decision that matters a lot if your worst habits show up rarely.

  • Local-first, no key for the easiest path. Hyperliquid sync uses public fills with no key at all, and Alpaca keys stay in a local env file. Nothing about your trade history needs to leave your machine to get started.

  • It's honest about its limits. The README states plainly that Hyperliquid's API only serves recent fills, not full history—so the sooner you sync, the more history you keep. That kind of caveat up front is refreshing.

How to Try It

  1. Install it:
pip install tradememory-protocol
  1. Sync your history—Hyperliquid needs no key:
tradememory sync hyperliquid --address 0xYourAddress

Or Alpaca, with read-only keys in a local file:

tradememory sync alpaca --env-file ~/.secrets/alpaca.env
  1. Read the output. Look at where your history loses money and whether that matches your sense of your own trading.

  2. Connect your agent. For Claude Desktop, add this to claude_desktop_config.json:

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

For Claude Code, it's a one-liner: claude mcp add tradememory -- uvx tradememory-protocol. Cursor and Docker instructions are in the README.

  1. Try recording a trade conversationally: "Record my AAPL long at $195 — earnings beat, institutional buying, high confidence."

The repo is at github.com/mnemox-ai/tradememory-protocol, with getting-started docs, use cases, an API reference, and a dedicated limitations page.

Final Thoughts

TradeMemory isn't a strategy engine and doesn't claim to be—it's a memory layer and a rule-based brake, and the README is careful to frame its statistics as descriptions of your past, not advice about your next trade. That framing is the right one. If you're running an agent against a broker whose guardrails are just fixed size caps, this gives your agent something the broker can't: your own track record, losses included. The main practical caveat is data depth—Hyperliquid only hands over recent fills, so start syncing early if that's your venue. For anyone letting an AI agent near real orders, having it remember what those orders cost seems like a reasonable place to begin.

Back to Projects
Project ID: a9eacc5d-4d63-4a24-aa38-ff392c8aa92dLast updated: October 23, 2026 at 02:49 AM