Codex-native trading harness with a Django service plane and MCP execution boundary.
Project description
TradingCodex: Codex-Native Trading Harness
TradingCodex is a local-first trading harness for doing investment work with Codex. It gives Codex a durable operating system: role-separated agents, file-native research memory, a Django service plane, a central local ledger, and an MCP execution boundary that turns risky actions into explicit, auditable service-layer decisions.
It is not an autonomous trading bot. Codex coordinates and explains the work; Django owns durable state and policy; TradingCodex MCP is the only executable agent boundary; live broker adapters are not shipped in the initial core.
Product Concept
TradingCodex exists because serious Codex-assisted investment work should not live only in a chat transcript. Research, source freshness, role handoffs, portfolio context, approvals, policy decisions, execution attempts, and audit records need a system of record that remains inspectable after the thread ends.
The product model is a harness:
| Plane | What it gives you |
|---|---|
| Codex control plane | A generated Codex workspace with one head-manager, nine specialist subagents, role prompts, repo skills, hooks, and project-scoped MCP config. |
| Workspace file plane | Human-readable research markdown, source snapshots, strategy skills, policy exports, and generated ./tcx wrappers inside the user's Codex workspace. |
| Django service plane | Local durable services for policy, orders, approvals, portfolio state, audit, workflows, MCP registry, external router review, API, Admin, and product web. |
| MCP execution boundary | Typed tools, role allowlists, policy checks, approval checks, idempotency, adapter submission, and ledgered results for executable actions. |
Generated workspaces are Codex workbenches, not brokerage accounts. Canonical execution-sensitive state lives in the central local runtime DB:
~/.tradingcodex/state/tradingcodex.sqlite3
What TradingCodex Does
TradingCodex 0.1.0 provides:
- A generated Codex workspace with fixed role topology, project-scoped MCP,
local wrappers, workspace manifest, generated policy/config files, and
./tcx doctorvalidation. - An explicit workspace update path that refreshes generated files, applies central DB migrations, preserves workspace identity/profile state, and re-runs doctor checks.
- A role workflow model where
head-managerdispatches work and specialists return bounded artifacts instead of every agent redoing every part of the investment question. - File-native research memory: markdown artifacts, source snapshots, versioned handoffs, export/search flows, and source/as-of posture that agents and humans can both read.
- Strategy and skill management through workspace files, including
strategy-*skills and role-local optional skills without weakening core role boundaries. - Policy, restricted-symbol, approval, order, execution, portfolio, MCP, and audit services behind a shared Django application layer.
- Experimental paper/stub order lifecycle support: validate intent, create approval receipt, submit approved order, cancel approved order, and record outcomes.
- A local product web surface for browsing agents, skills, research markdown, external MCP router metadata, starter prompts, and operational state.
- Django Admin, Django Ninja API, CLI, and MCP surfaces that call the same service-layer logic instead of creating parallel execution paths.
- A managed external MCP router gate that imports discovery metadata, classifies tool risk, scopes role access, and blocks unsafe direct proxy paths by default.
Quick Start
Choose an empty target directory for the generated Codex workspace. Source checkouts of this repository are for TradingCodex development; generated TradingCodex workspaces are separate Codex projects.
Agents and install helpers do not invent a default workspace path. If the target path is not supplied, ask the user before creating or attaching a workspace.
Install TradingCodex and attach it to a user-selected workspace:
mkdir -p /path/to/target-workspace
cd /path/to/target-workspace
curl -fsSL https://raw.githubusercontent.com/monarchjuno/tradingcodex/main/install.sh | sh -s -- .
Run the smoke check:
./tcx doctor
After installation, fully quit and restart Codex, then open the generated workspace and start from a new thread so project MCP config is reloaded. When TradingCodex MCP autostarts the local service, the dashboard is available at:
http://127.0.0.1:48267/
Start an orchestrated Codex workflow from the generated workspace:
$orchestrate-workflow analyze Apple with public equity research, valuation, portfolio, and risk review
For repeated workspace creation, install the CLI as a user-level tool:
uv python install 3.14
uv tool install --python 3.14 tradingcodex
uv tool update-shell
cd /path/to/target-workspace
tcx attach .
./tcx doctor
See installation.md
for GitHub-main installs, direct uvx, MCP/service details, and additional
smoke checks.
Update an existing generated workspace after a package release:
cd /path/to/target-workspace
curl -fsSL https://raw.githubusercontent.com/monarchjuno/tradingcodex/main/install.sh | sh -s -- --update .
Local Web Dashboard
TradingCodex includes a local Django web surface so users do not have to inspect everything through chat or CLI output. When Codex trusts a generated workspace, project MCP startup also starts the local service and exposes the dashboard at:
http://127.0.0.1:48267/
The dashboard is a review and control surface for the agent roster, required and optional skills, strategy skills, research markdown, external MCP router metadata, starter prompts, policy/order/portfolio/activity status, and local workspace state. It does not spawn Codex agents, approve orders, submit executions, or provide investment recommendations.
For CLI-only sessions, start it manually:
./tcx service runserver
Django Admin is available separately at http://127.0.0.1:48267/admin/ for
local/staff DB inspection.
How A Workflow Moves
TradingCodex is designed around handoffs rather than one giant answer:
- The user asks Codex for an investment workflow.
head-managerclassifies the request, maps the investment universe and workflow lane, and dispatches bounded work to specialist roles.- Analysts create evidence-backed artifacts with source/as-of posture.
- Downstream roles consume accepted upstream artifacts instead of silently filling missing work outside their role.
- Portfolio and risk roles review fit, sizing, limits, restricted symbols, and approval readiness.
- If an executable paper/stub action is requested,
risk-managercreates the approval receipt andexecution-operatorsubmits only through TradingCodex MCP. - Policy decisions, MCP calls, approvals, execution results, and audit events remain inspectable through local service surfaces.
Role Roster
| 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 this one-plus-nine roster. The main agent coordinates and synthesizes; specialist agents own the actual role work.
Architecture
TradingCodex is a Python/Django modular monolith packaged as a local-first tool. The important implementation rule is that every interface calls shared application services:
| Surface | Role |
|---|---|
| Product web | Agents-first review dashboard for roles, skills, research markdown, external MCP router review, starter prompts, and local status. |
| Django Admin | Local/staff DB inspection for policy, orders, portfolio, MCP registry, workflows, integrations, and audit rows. |
| Django Ninja API | Typed local/staff REST and control endpoints. |
| MCP | Agent/tool boundary with typed tools, role scopes, policy checks, and audit. |
| CLI | Local operator commands and generated workspace wrapper behavior. |
Canonical implementation lives in:
tradingcodex_service/application/
tradingcodex_cli/commands/
apps/
workspace_templates/modules/
The baseline frontend uses Django templates, local static HTMX, and local static Alpine. There is no Node, bundler, React, or frontend build step in the core package.
Safety Boundary
TradingCodex treats executable actions as a deterministic service-layer lifecycle:
principal -> capability -> policy -> schema -> approval/idempotency -> adapter -> audit
Important boundaries:
- Product web routes do not spawn agents, generate investment analysis, 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 keeps explicit paths for 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.
Unsupported or weakly sourced workflows should receive conservative readiness
labels such as research-only, screen-grade, not-decision-ready, or
blocked.
Release Status
0.1.0 is the first stable public contract for the generated workspace, Python
CLI, Django service plane, product web, MCP boundary, and documentation set.
The package still uses an alpha development classifier because live broker
adapters and hosted service modes are intentionally outside the initial core.
Documentation
- Installation
- Docs index
- Product direction
- Core concepts and rules
- Harness model
- Roles, skills, and workflows
- Safety policy and execution
- Interfaces and surfaces
- Deployment
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.0.tar.gz.
File metadata
- Download URL: tradingcodex-0.1.0.tar.gz
- Upload date:
- Size: 304.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bf7e9c5457d2f1cad3c2c4081ddd75237ed301245a85a58fb88f154d8b67c6d1
|
|
| MD5 |
26a77049af8b836a335d9f0c752c0c36
|
|
| BLAKE2b-256 |
3f9d58bfa8d3680544b1c12fc4de9af5a7f52f8e9c9991b4f2b458b8155e7e16
|
Provenance
The following attestation bundles were made for tradingcodex-0.1.0.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.0.tar.gz -
Subject digest:
bf7e9c5457d2f1cad3c2c4081ddd75237ed301245a85a58fb88f154d8b67c6d1 - Sigstore transparency entry: 1804388711
- Sigstore integration time:
-
Permalink:
monarchjuno/tradingcodex@7c789731ead70e2210b71f6efc68e8d40b45cb31 -
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@7c789731ead70e2210b71f6efc68e8d40b45cb31 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file tradingcodex-0.1.0-py3-none-any.whl.
File metadata
- Download URL: tradingcodex-0.1.0-py3-none-any.whl
- Upload date:
- Size: 278.6 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 |
0a43e086a2079399390144cf88ebd951c107790575261154767e2df58fe7fdc2
|
|
| MD5 |
1b39be5b6df2399f4898a104bdf1ffe2
|
|
| BLAKE2b-256 |
2bd8bfeceaab717a2f8ce11c74659ac437143bdfb93c1f567c8ed38dee3c39a7
|
Provenance
The following attestation bundles were made for tradingcodex-0.1.0-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.0-py3-none-any.whl -
Subject digest:
0a43e086a2079399390144cf88ebd951c107790575261154767e2df58fe7fdc2 - Sigstore transparency entry: 1804389057
- Sigstore integration time:
-
Permalink:
monarchjuno/tradingcodex@7c789731ead70e2210b71f6efc68e8d40b45cb31 -
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@7c789731ead70e2210b71f6efc68e8d40b45cb31 -
Trigger Event:
workflow_dispatch
-
Statement type: