Codex-native trading harness with a Django service plane and MCP execution boundary.
Project description
TradingCodex: Codex-Native Trading Harness
TradingCodex is a Codex-native trading harness for investors who want agent-assisted research, role separation, workflow discipline, and deterministic execution guardrails in one local-first system.
It is not an autonomous trading bot. Codex coordinates the workflow, Django owns the durable service layer, and TradingCodex MCP is the execution boundary.
Quick Start
python3.14 -m pip install tradingcodex
tcx init ./workspace --force
cd ./workspace
./tcx doctor
Start an orchestrated Codex workflow from the generated workspace:
$orchestrate-workflow analyze Apple with public equity research, valuation, portfolio, and risk review
Open the workspace in Codex and trust the project. The generated project MCP config starts TradingCodex MCP and the local dashboard service together.
After Codex connects, open:
http://127.0.0.1:8000/for the visual harness dashboardhttp://127.0.0.1:8000/admin/for the Django operations console
For CLI-only use outside Codex, the dashboard can still be started manually:
./tcx service runserver
Inspect the local MCP surface:
printf '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}\n' | ./tcx mcp stdio
Create and search DB-backed research memory:
./tcx research create --markdown-file note.md --id note-1 --title "Research Note"
./tcx research search "gross margin"
./tcx research export note-1
Agent Topology
| Layer | Agent | Role summary |
|---|---|---|
| Main agent | head-manager |
Dispatches specialist roles, preserves constraints, and synthesizes completed artifacts. |
| Analysis subagent | fundamental-analyst |
Reviews business quality, financial evidence, company fundamentals, and source claims. |
| Analysis subagent | technical-analyst |
Reviews price action, trend structure, levels, and market behavior. |
| Analysis subagent | news-analyst |
Tracks news, catalysts, events, and freshness-sensitive context. |
| Market-context subagent | macro-analyst |
Covers macro, rates, FX, commodities, policy, and cross-asset context. |
| Market-context subagent | instrument-analyst |
Supports ETF/index, options, crypto market structure, and instrument-level work. |
| Decision-review subagent | valuation-analyst |
Reviews valuation assumptions, sensitivity, and decision-quality gaps. |
| Portfolio subagent | portfolio-manager |
Reviews portfolio fit, sizing, exposure, and draft order readiness. |
| Risk subagent | risk-manager |
Reviews downside, policy constraints, restricted lists, and approval readiness. |
| Execution subagent | execution-operator |
Handles approved paper/stub execution through TradingCodex MCP only. |
The default generated workspace includes one head-manager and nine fixed
subagents. The main agent coordinates; specialist agents produce the actual
role work.
Architecture
TradingCodex separates the local harness into three planes plus one execution boundary:
| Plane | Owns | Interfaces and artifacts |
|---|---|---|
| Codex control plane | Generated workspace instructions, project .codex config, role agents, hooks, and workflow routing. |
Codex workspace files, role prompts, and human-readable trading/* exports. |
| MCP execution boundary | Role tool allowlists, input schemas, policy checks, approval checks, idempotency, and MCP call audit. | TradingCodex MCP tools exposed to allowed roles only. |
| Django service plane | Research memory, policy, orders, approvals, portfolio state, audit, Admin, API, and local web dashboard. | Shared service functions used by CLI, Admin, API, web, and MCP. |
| Adapter boundary | Paper/stub execution adapters for local harness validation. | Live broker adapters are excluded from the initial core. |
Executable actions flow through:
| Step | Meaning |
|---|---|
principal |
The caller identity and role capability. |
capability |
The requested action and permitted role surface. |
policy |
Restricted-list, limit, and execution-policy validation. |
schema |
Typed input validation before service-layer mutation. |
approval/idempotency |
Approval receipt and duplicate-submit protection. |
adapter |
Paper/stub adapter submission. |
audit |
Durable ledger record for the attempt and result. |
The central runtime DB defaults to:
~/.tradingcodex/state/tradingcodex.sqlite3
Generated workspaces are clients and provenance sources. They do not own canonical investment state.
Execution Boundary
TradingCodex treats executable actions as a service-layer lifecycle:
principal -> capability -> policy -> schema -> approval/idempotency -> adapter -> audit
Important boundaries:
- Product web routes do not spawn agents, create approvals, or submit executions.
- REST/Admin/CLI/MCP call shared Django service functions.
- Role MCP allowlists are narrow:
head-managercannot submit orders,risk-managerowns approvals, andexecution-operatorowns execution calls. - Paper/stub execution remains experimental.
- Live broker adapters are not shipped in the initial core.
- Raw broker secrets must not be stored in this repository or generated workspaces.
TradingCodex is research, workflow, and execution-guardrail tooling. It is not financial, investment, legal, tax, or regulatory advice, and it does not provide investment recommendations or guarantee returns.
Supported Workflow Scope
Public equity is the first deeply specified sleeve. The harness is designed to extend across ETF/index, public crypto market, macro/rates/FX/commodities, options, credit-signal, and cross-asset workflows when the required data source, role workflow, and policy boundary exist.
Documentation
Contributing
Contributions use Apache-2.0 with DCO sign-off. See CONTRIBUTING.md.
License
TradingCodex is an Apache-2.0 open-core project.
Source code, generated workspace templates, and project documentation are licensed under the Apache License, Version 2.0 unless marked otherwise. The TradingCodex name, future logos, and official product marks are not granted by the code license. See LICENSE, NOTICE, and TRADEMARKS.md.
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 tradingcodex-0.1.0a1.tar.gz.
File metadata
- Download URL: tradingcodex-0.1.0a1.tar.gz
- Upload date:
- Size: 221.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a2427b42b154757f61ccae46fbb7a7f002ca9b17117c3fe6ca6a651553070db
|
|
| MD5 |
5e1d4d3f23f65f6c519215b2f3b20701
|
|
| BLAKE2b-256 |
1aa1ed3f6a068798ef9fda1866d511e00dd428db0d4b8009f9b531d4e624e965
|
Provenance
The following attestation bundles were made for tradingcodex-0.1.0a1.tar.gz:
Publisher:
release.yml on monarchjuno/tradingcodex
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tradingcodex-0.1.0a1.tar.gz -
Subject digest:
9a2427b42b154757f61ccae46fbb7a7f002ca9b17117c3fe6ca6a651553070db - Sigstore transparency entry: 1756061924
- Sigstore integration time:
-
Permalink:
monarchjuno/tradingcodex@bfaeb4e7668b77c7af8f8699f0e367f79f0cc3af -
Branch / Tag:
refs/heads/main - Owner: https://github.com/monarchjuno
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@bfaeb4e7668b77c7af8f8699f0e367f79f0cc3af -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file tradingcodex-0.1.0a1-py3-none-any.whl.
File metadata
- Download URL: tradingcodex-0.1.0a1-py3-none-any.whl
- Upload date:
- Size: 229.7 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 |
bda40f00790b033cdfbf614d0e4bcf03507e981bddcadc56849eac0176e58bad
|
|
| MD5 |
1458b9ecc5134c7d51ef37572b4b3adf
|
|
| BLAKE2b-256 |
e2613efa8464922da2b4247094dbcc675533df20852f898b8312d3023bfb6146
|
Provenance
The following attestation bundles were made for tradingcodex-0.1.0a1-py3-none-any.whl:
Publisher:
release.yml on monarchjuno/tradingcodex
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tradingcodex-0.1.0a1-py3-none-any.whl -
Subject digest:
bda40f00790b033cdfbf614d0e4bcf03507e981bddcadc56849eac0176e58bad - Sigstore transparency entry: 1756061932
- Sigstore integration time:
-
Permalink:
monarchjuno/tradingcodex@bfaeb4e7668b77c7af8f8699f0e367f79f0cc3af -
Branch / Tag:
refs/heads/main - Owner: https://github.com/monarchjuno
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@bfaeb4e7668b77c7af8f8699f0e367f79f0cc3af -
Trigger Event:
workflow_dispatch
-
Statement type: