Local, open-source, AI-only journal, memory, and calibration substrate for LLM trading agents.
Project description
Trade Trace
Local calibration journal for LLM prediction-market trading agents.
Trade Trace is a continuity and evaluation layer for an agent's prediction-market process. It is not a trader.
Trade Trace helps an LLM prediction-market agent keep an auditable local record of market context, probability forecasts, decisions, resolutions, and lessons that should carry into the next session.
It stores a local SQLite journal, scores binary prediction-market forecasts when resolutions are supplied, produces deterministic retrospective reports, and gives the agent a typed memory graph for observations, reflections, and playbook rules. Agents can use it through MCP stdio, a JSON-first CLI, and Python report/read-model functions.
Trade Trace never places trades, stores broker or wallet credentials, phones home, or gives financial advice. Its Polymarket adapter is opt-in, agent-triggered, disabled by default, and requires caller-supplied configuration; there is no default RPC endpoint.
Why it exists
LLM trading agents can research markets and write reasoning, but process memory is fragile when it lives only in transcripts. Trade Trace makes that process inspectable:
| Agent problem | Trade Trace surface |
|---|---|
| Forecasts disappear into chat history | Forecasts become scored, queryable journal rows |
| Outcomes are remembered anecdotally | Supported binary forecasts get Brier and calibration diagnostics |
| Mistakes are free-text and hard to audit | Reports return metrics with drill-down record IDs |
| New sessions repeat old reasoning | Recall returns relevant observations, reflections, and playbook rules |
| Lessons smear across unrelated trades | Strategies scope decisions, reports, recall, and reflection |
| Retry loops duplicate writes | Idempotency keys make writes replay-safe |
The product question is simple: can an agent become more auditable, calibratable, and process-aware over time without giving the journal execution power?
How it works
The loop is intentionally narrow:
- The agent binds or records a prediction market and captures snapshots.
- The agent records binary probability forecasts and optional decisions.
- The caller supplies or explicitly fetches resolutions when they are known.
- Trade Trace scores supported forecasts and produces deterministic reports.
- The agent writes reflections/playbook updates; the next session recalls relevant lessons.
Trade Trace supplies the storage, contracts, scoring, and reporting substrate. The calling agent supplies judgment, market data, outcomes, and any trading action outside this project.
What it includes
- Agent-native PM journal: markets, snapshots, binary forecasts, optional decisions, resolutions/outcomes, reflections, playbooks, strategies, and tags.
- Forecast scoring: supported binary forecasts can be scored against final outcomes, including Brier and calibration diagnostics.
- Deterministic reports: calibration, forecast diagnostics, source quality, audit readiness, risk/opportunity diagnostics, P&L where local projection data exists, strategy health/performance, recall receipts, review bundles, lifecycle, and work-queue views.
- Typed memory graph: retain, recall, and reflect over observations, reflections, and playbook rules, with typed links back to journal rows.
- Strategies and playbooks: group related market decisions under named strategies and version process rules without turning either into trading recommendations.
- Agent continuity:
report.work_queue,report.lifecycle, andreport.bootstrapexpose local process obligations for fresh sessions. They do not schedule work, assign tasks, fetch data, or recommend trades. - MCP and CLI parity: the same tool registry, JSON envelopes, validation semantics, stable error codes, schemas, and dry-run/idempotency contracts back both transports.
- Local-first storage: one SQLite database, append-only/auditable events, JSONL export/import surfaces, and SHA-256-verified backup/restore.
What it is not
- Not a trade executor: no order placement, routing, signing, broker keys, wallet keys, seed phrases, or private keys.
- Not a default market-data fetcher: no background venue queries, scheduler, broker state, order books, or webhooks. The Polymarket adapter is explicit opt-in and agent-triggered.
- Not a dashboard: the former human Console UI was removed. Supported surfaces are MCP stdio, CLI, and Python/reporting APIs.
- Not financial advice: reports are retrospective diagnostics and process review, not trade recommendations or edge claims.
- Not a generic memory framework, backtester, scheduler, tax tool, or social platform: the schema is prediction-market-shaped and local.
Install from source
Trade Trace is pre-release. The current source is being prepared for the v0.0.2 prediction-market pivot; no stable public release has been cut yet. Until a public release artifact is available, install from a checkout:
python3 -m pip install -e .
export TRADE_TRACE_HOME="$HOME/.trade-trace"
tt journal init
Requirements: Python 3.11+ and SQLite with FTS5. MCP support is bundled in the base package.
Optional vector recall support is available from source with:
python3 -m pip install -e '.[embeddings]'
The embeddings extra adds the optional local ONNX/tokenizers runtime. It does not enable vectors, download model weights, or send memory text to an API provider. In v0.0.2 the supported provider enum is none|local; local model assets must be imported explicitly with tt --confirm model import --src <pre-staged-dir> --idempotency-key <key>, and remote/API embedding providers are unsupported.
Intel Mac note: current onnxruntime releases do not ship macOS x86_64 wheels. Intel Mac users should either use BM25 recall or manually pin a compatible older onnxruntime (for example 1.19) in their local environment.
Connect an agent over MCP
Start the local stdio MCP server:
trade-trace-mcp
Configure your MCP host to launch that command locally. Do not configure HTTP, SSE, websocket, or TCP transport.
{
"mcpServers": {
"trade-trace": {
"command": "trade-trace-mcp",
"args": [],
"env": {
"TRADE_TRACE_HOME": "/absolute/path/to/.trade-trace",
"MCP_ACTOR_ID": "agent:research-bot"
}
}
}
}
Then verify the connection:
- list MCP tools;
- call
journal.status; - call
tool.schemawith no arguments; - call
tool.schemafor the first write you intend to use; - dry-run writes with
_dry_run: truebefore committing.
See docs/AI_AGENT_MCP_GETTING_STARTED.md for the full MCP setup guide.
Use the CLI
The CLI mirrors the MCP catalog by replacing dots in MCP tool names with spaces (for example, market.bind becomes tt market bind). It emits JSON by default; streaming list/read paths use NDJSON envelopes. The current default public catalog contains 69 registry-generated tools (the scope-reignin freeze/cut landed it at 56, then 13 decision-time tools were added). A further 40 Product-B tools (autonomous-ops, reconciliation/execution-truth, and the anchored-calibration unit) are frozen behind an experimental tier — hidden from the default catalog but still dispatchable via MCP_INCLUDE_EXPERIMENTAL=1 or tool.schema {"include_experimental": true}. tool.schema is the source of truth and includes compatibility metadata such as legacy_name for renamed tools and hints for removed legacy callers.
tt journal init
tt tool schema
tt tool schema --tool forecast.add
tt market bind --external-id polymarket:event-123 --source manual --mechanism clob --state open
Use tool.schema as the source of truth for exact fields, enums, examples, dry-run support, and required metadata. For a complete agent loop, read docs/AGENT_GUIDE.md.
Safety and privacy
- Local by default: SQLite at
$TRADE_TRACE_HOME/trade-trace.sqlite. - No default outbound network: fresh local journal use and MCP stdio startup are tested to make no outbound calls.
- No telemetry: no analytics, phone-home, auto-update, or background sync.
- No credential persistence: credential-shaped inputs are dropped or rejected; secret-looking free text is scanned before insertion.
- Append-only audit posture: source/event tables are immutable; corrections append new rows/events instead of overwriting history.
- Replay-safe writes: retryable writes use idempotency keys. For supported write tools, the server auto-derives a deterministic
auto:key when callers omit one; callers may still pass an explicit key to control the dedupe domain. Safe replays return the original event; semantic conflicts returnIDEMPOTENCY_CONFLICT. - Verified backups: backup manifests use SHA-256 verification before restore.
Read SECURITY.md for vulnerability reporting and supported-version policy.
Docs map
| Start here | For |
|---|---|
docs/AI_AGENT_MCP_GETTING_STARTED.md |
First MCP connection and safe write loop. |
docs/AGENT_GUIDE.md |
Full agent journal loop, continuity surfaces, patterns, and pitfalls. |
docs/CLAUDE_CODE.md, docs/CLAUDE_DESKTOP.md, docs/IDE_MCP_SETUP.md |
Client setup recipes. |
docs/VISION.md |
Product north star and non-goals. |
docs/PRD.md |
Working product requirements and milestone scope. |
docs/architecture/contracts.md |
CLI/MCP JSON envelope, parity, error codes, and schemas. |
docs/architecture/persistence.md |
SQLite, events, outbox, idempotency, and append-only invariants. |
docs/architecture/memory-layer.md |
Memory graph, recall, embeddings posture, and typed edges. |
docs/architecture/reports.md |
Report filters, drill-down, review bundles, and work queue. |
docs/architecture/scoring.md |
Forecast scoring, Brier/calibration metrics, and lifecycle caveats. |
License
MIT. See LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file trade_trace-0.0.2.post463.tar.gz.
File metadata
- Download URL: trade_trace-0.0.2.post463.tar.gz
- Upload date:
- Size: 454.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
66efd0e32b7588fdbc96b2e94cd06f9c5d57ee569ee76dce86748f2d60812cf4
|
|
| MD5 |
37f572a2fb771701b2447857f9e83dff
|
|
| BLAKE2b-256 |
e1a489dda07bdb2373320e6b12615f2b9763adbf4bb9d3754ab08ba4be44eac9
|
Provenance
The following attestation bundles were made for trade_trace-0.0.2.post463.tar.gz:
Publisher:
workflow.yml on mcrescenzo/trade-trace
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
trade_trace-0.0.2.post463.tar.gz -
Subject digest:
66efd0e32b7588fdbc96b2e94cd06f9c5d57ee569ee76dce86748f2d60812cf4 - Sigstore transparency entry: 1672558453
- Sigstore integration time:
-
Permalink:
mcrescenzo/trade-trace@aa8a796818a8b8a4914028dc0d25829bab63d4d4 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/mcrescenzo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yml@aa8a796818a8b8a4914028dc0d25829bab63d4d4 -
Trigger Event:
push
-
Statement type:
File details
Details for the file trade_trace-0.0.2.post463-py3-none-any.whl.
File metadata
- Download URL: trade_trace-0.0.2.post463-py3-none-any.whl
- Upload date:
- Size: 557.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c36d5f459b04ed5af97ddbee49971d59477ceff1b1719a793eb1cdf9436ff478
|
|
| MD5 |
348533f0a8b4a7e24cab7bdc288991ae
|
|
| BLAKE2b-256 |
e210510ddcb609919f55ef894f5d9bf22d78244cc1df7162ca97dd61cce5ed55
|
Provenance
The following attestation bundles were made for trade_trace-0.0.2.post463-py3-none-any.whl:
Publisher:
workflow.yml on mcrescenzo/trade-trace
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
trade_trace-0.0.2.post463-py3-none-any.whl -
Subject digest:
c36d5f459b04ed5af97ddbee49971d59477ceff1b1719a793eb1cdf9436ff478 - Sigstore transparency entry: 1672558488
- Sigstore integration time:
-
Permalink:
mcrescenzo/trade-trace@aa8a796818a8b8a4914028dc0d25829bab63d4d4 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/mcrescenzo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yml@aa8a796818a8b8a4914028dc0d25829bab63d4d4 -
Trigger Event:
push
-
Statement type: