# kevinhayesanderson/autonomous-trading-agent architecture

> Architecture diagram of the GitHub repository kevinhayesanderson/autonomous-trading-agent, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kevinhayesanderson/autonomous-trading-agent
- Repository: https://github.com/kevinhayesanderson/autonomous-trading-agent

## Overview

AQTA is an autonomous US-equity allocation agent. Users initiate portfolio audits, deliberation, previews, or monthly execution through the CLI or MCP server; the monthly pipeline screens candidates, forms committee recommendations, rebalances under risk and capital controls, and can place broker orders. Persistent memory and feedback calibration support later cycles. The README documents additional MCP resources/prompts and paper trading; unsampled implementation links are omitted or marked unverified.

Main entry points: [`trading_agent/core/engine.py`](https://github.com/kevinhayesanderson/autonomous-trading-agent/blob/main/trading_agent/core/engine.py) (Execution Orchestrator), [`trading_agent/core/broker.py`](https://github.com/kevinhayesanderson/autonomous-trading-agent/blob/main/trading_agent/core/broker.py) (Broker Transport), [`server/mcp_server.py`](https://github.com/kevinhayesanderson/autonomous-trading-agent/blob/main/server/mcp_server.py) (MCP Server), [`trading_agent/core/deliberation.py`](https://github.com/kevinhayesanderson/autonomous-trading-agent/blob/main/trading_agent/core/deliberation.py) (Committee Debate)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["User Interfaces"]
  node_cli["CLI<br/>[agent.py]"]
  node_mcp["MCP Server<br/>[mcp_server.py]"]
  node_cycle["Monthly Cycle<br/>[monthly_cycle.py]"]
end

subgraph group_decision["Investment Decisions"]
  node_screen["Quant Screener<br/>[screener.py]"]
  node_intelligence["Fundamental Dossiers<br/>[intelligence.py]"]
  node_deliberation["Committee Debate<br/>[deliberation.py]"]
  node_consensus["Consensus Scoring<br/>[consensus.py]"]
  node_schemas["Structured Schemas<br/>[schemas.py]"]
end

subgraph group_trade["Portfolio &amp; Trading"]
  node_risk["Risk &amp; Tenure<br/>[risk.py]"]
  node_rebalance["Rebalance Logic<br/>[rebalance.py]"]
  node_rebalance_script["Rebalance Engine"]
  node_engine["Execution Orchestrator<br/>[engine.py]"]
  node_execution["Order Execution<br/>[execution.py]"]
  node_wallet["Wallet Drain<br/>[wallet.py]"]
end

subgraph group_state["Memory &amp; Feedback"]
  node_memory[("Persistent Memory<br/>[memory.py]")]
  node_feedback["Retrospective Loop<br/>[feedback_loop.py]"]
  node_git_sync["Git State Sync<br/>[git_sync.py]"]
  node_config["Configuration &amp; Collars<br/>[config.py]"]
end

subgraph group_integration["Broker Integrations"]
  node_auth["Token Resolution<br/>[auth.py]"]
  node_tickertape_auth["Tickertape Login<br/>[tickertape_auth.py]"]
  node_broker["Broker Transport<br/>[broker.py]"]
  node_tickertape["Tickertape / DriveWealth"]
  node_alpaca["Alpaca Paper API"]
end

node_user(("Investor / Client"))

node_user -->|"invokes"| node_cli
node_user -->|"connects"| node_mcp
node_cli -->|"runs pipeline"| node_engine
node_mcp -->|"runs pipeline"| node_engine
node_cycle -->|"runs"| node_feedback
node_cycle -->|"runs"| node_rebalance_script
node_cycle -->|"synchronizes"| node_git_sync
node_cycle -->|"uses login"| node_tickertape_auth
node_engine -->|"screens candidates"| node_screen
node_engine -->|"scores candidates"| node_consensus
node_engine -->|"evaluates holdings"| node_rebalance
node_engine -->|"executes orders"| node_execution
node_engine -->|"audits portfolio"| node_risk
node_engine -->|"loads state"| node_memory
node_engine -->|"syncs state"| node_git_sync
node_consensus -->|"debates candidates"| node_deliberation
node_deliberation -->|"validates output"| node_schemas
node_deliberation -->|"uses candidate data"| node_screen
node_screen -->|"requests screener data"| node_broker
node_rebalance -->|"checks guardrails"| node_risk
node_execution -->|"places orders"| node_broker
node_wallet -->|"previews and places"| node_broker
node_wallet -->|"delegates order"| node_execution
node_risk -->|"audits account"| node_broker
node_broker -->|"reads endpoints"| node_config
node_auth -->|"reads credential paths"| node_config
node_auth -->|"refreshes token"| node_tickertape_auth
node_broker -->|"calls MCP API"| node_tickertape
node_broker -.->|"supports paper API"| node_alpaca
node_memory -->|"uses memory paths"| node_config
node_feedback -->|"calibrates weights"| node_memory
node_cli -->|"reports memory status"| node_memory
node_cli -->|"sync command"| node_git_sync
node_mcp -->|"gets token"| node_auth
node_mcp -->|"queries account"| node_broker
node_mcp -->|"deliberates ticker"| node_deliberation
node_mcp -->|"exposes screener"| node_screen
node_intelligence -.->|"informs committee"| node_deliberation

click node_cli "https://github.com/kevinhayesanderson/autonomous-trading-agent/blob/main/agent.py"
click node_mcp "https://github.com/kevinhayesanderson/autonomous-trading-agent/blob/main/server/mcp_server.py"
click node_cycle "https://github.com/kevinhayesanderson/autonomous-trading-agent/blob/main/scripts/monthly_cycle.py"
click node_screen "https://github.com/kevinhayesanderson/autonomous-trading-agent/blob/main/trading_agent/core/screener.py"
click node_intelligence "https://github.com/kevinhayesanderson/autonomous-trading-agent/blob/main/trading_agent/core/intelligence.py"
click node_deliberation "https://github.com/kevinhayesanderson/autonomous-trading-agent/blob/main/trading_agent/core/deliberation.py"
click node_consensus "https://github.com/kevinhayesanderson/autonomous-trading-agent/blob/main/trading_agent/core/consensus.py"
click node_schemas "https://github.com/kevinhayesanderson/autonomous-trading-agent/blob/main/trading_agent/core/schemas.py"
click node_risk "https://github.com/kevinhayesanderson/autonomous-trading-agent/blob/main/trading_agent/core/risk.py"
click node_rebalance "https://github.com/kevinhayesanderson/autonomous-trading-agent/blob/main/trading_agent/core/rebalance.py"
click node_rebalance_script "https://github.com/kevinhayesanderson/autonomous-trading-agent/blob/main/scripts/rebalance_engine.py"
click node_engine "https://github.com/kevinhayesanderson/autonomous-trading-agent/blob/main/trading_agent/core/engine.py"
click node_execution "https://github.com/kevinhayesanderson/autonomous-trading-agent/blob/main/trading_agent/core/execution.py"
click node_wallet "https://github.com/kevinhayesanderson/autonomous-trading-agent/blob/main/trading_agent/core/wallet.py"
click node_auth "https://github.com/kevinhayesanderson/autonomous-trading-agent/blob/main/trading_agent/core/auth.py"
click node_tickertape_auth "https://github.com/kevinhayesanderson/autonomous-trading-agent/blob/main/scripts/tickertape_auth.py"
click node_broker "https://github.com/kevinhayesanderson/autonomous-trading-agent/blob/main/trading_agent/core/broker.py"
click node_memory "https://github.com/kevinhayesanderson/autonomous-trading-agent/blob/main/trading_agent/core/memory.py"
click node_feedback "https://github.com/kevinhayesanderson/autonomous-trading-agent/blob/main/scripts/feedback_loop.py"
click node_git_sync "https://github.com/kevinhayesanderson/autonomous-trading-agent/blob/main/scripts/git_sync.py"
click node_config "https://github.com/kevinhayesanderson/autonomous-trading-agent/blob/main/trading_agent/core/config.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_mcp,node_cycle,node_user toneBlue
class node_screen,node_intelligence,node_deliberation,node_consensus,node_schemas toneAmber
class node_risk,node_rebalance,node_rebalance_script,node_engine,node_execution,node_wallet toneMint
class node_memory,node_feedback,node_git_sync,node_config toneRose
class node_auth,node_tickertape_auth,node_broker,node_tickertape,node_alpaca toneIndigo
```

## Components

### User Interfaces

- [CLI](https://github.com/kevinhayesanderson/autonomous-trading-agent/blob/main/agent.py): `agent.py`
- [MCP Server](https://github.com/kevinhayesanderson/autonomous-trading-agent/blob/main/server/mcp_server.py): `server/mcp_server.py`
- [Monthly Cycle](https://github.com/kevinhayesanderson/autonomous-trading-agent/blob/main/scripts/monthly_cycle.py): `scripts/monthly_cycle.py`

### Investment Decisions

- [Quant Screener](https://github.com/kevinhayesanderson/autonomous-trading-agent/blob/main/trading_agent/core/screener.py): `trading_agent/core/screener.py`
- [Fundamental Dossiers](https://github.com/kevinhayesanderson/autonomous-trading-agent/blob/main/trading_agent/core/intelligence.py): `trading_agent/core/intelligence.py`
- [Committee Debate](https://github.com/kevinhayesanderson/autonomous-trading-agent/blob/main/trading_agent/core/deliberation.py): `trading_agent/core/deliberation.py`
- [Consensus Scoring](https://github.com/kevinhayesanderson/autonomous-trading-agent/blob/main/trading_agent/core/consensus.py): `trading_agent/core/consensus.py`
- [Structured Schemas](https://github.com/kevinhayesanderson/autonomous-trading-agent/blob/main/trading_agent/core/schemas.py): `trading_agent/core/schemas.py`

### Portfolio & Trading

- [Risk & Tenure](https://github.com/kevinhayesanderson/autonomous-trading-agent/blob/main/trading_agent/core/risk.py): `trading_agent/core/risk.py`
- [Rebalance Logic](https://github.com/kevinhayesanderson/autonomous-trading-agent/blob/main/trading_agent/core/rebalance.py): `trading_agent/core/rebalance.py`
- [Rebalance Engine](https://github.com/kevinhayesanderson/autonomous-trading-agent/blob/main/scripts/rebalance_engine.py): `scripts/rebalance_engine.py`
- [Execution Orchestrator](https://github.com/kevinhayesanderson/autonomous-trading-agent/blob/main/trading_agent/core/engine.py): `trading_agent/core/engine.py`
- [Order Execution](https://github.com/kevinhayesanderson/autonomous-trading-agent/blob/main/trading_agent/core/execution.py): `trading_agent/core/execution.py`
- [Wallet Drain](https://github.com/kevinhayesanderson/autonomous-trading-agent/blob/main/trading_agent/core/wallet.py): `trading_agent/core/wallet.py`

### Memory & Feedback

- [Persistent Memory](https://github.com/kevinhayesanderson/autonomous-trading-agent/blob/main/trading_agent/core/memory.py): `trading_agent/core/memory.py`
- [Retrospective Loop](https://github.com/kevinhayesanderson/autonomous-trading-agent/blob/main/scripts/feedback_loop.py): `scripts/feedback_loop.py`
- [Git State Sync](https://github.com/kevinhayesanderson/autonomous-trading-agent/blob/main/scripts/git_sync.py): `scripts/git_sync.py`
- [Configuration & Collars](https://github.com/kevinhayesanderson/autonomous-trading-agent/blob/main/trading_agent/core/config.py): `trading_agent/core/config.py`

### Broker Integrations

- [Token Resolution](https://github.com/kevinhayesanderson/autonomous-trading-agent/blob/main/trading_agent/core/auth.py): `trading_agent/core/auth.py`
- [Tickertape Login](https://github.com/kevinhayesanderson/autonomous-trading-agent/blob/main/scripts/tickertape_auth.py): `scripts/tickertape_auth.py`
- [Broker Transport](https://github.com/kevinhayesanderson/autonomous-trading-agent/blob/main/trading_agent/core/broker.py): `trading_agent/core/broker.py`
- **Tickertape / DriveWealth**
- **Alpaca Paper API**

### Other components

- **Investor / Client**

## Connections

- Investor / Client → CLI: invokes (evidence: `agent.py`)
- Investor / Client → MCP Server: connects (evidence: `README.md`)
- CLI → Execution Orchestrator: runs pipeline (evidence: `agent.py`)
- MCP Server → Execution Orchestrator: runs pipeline (evidence: `server/mcp_server.py`)
- Monthly Cycle → Retrospective Loop: runs (evidence: `scripts/monthly_cycle.py`)
- Monthly Cycle → Rebalance Engine: runs (evidence: `scripts/monthly_cycle.py`)
- Monthly Cycle → Git State Sync: synchronizes (evidence: `scripts/monthly_cycle.py`)
- Monthly Cycle → Tickertape Login: uses login (evidence: `scripts/monthly_cycle.py`)
- Execution Orchestrator → Quant Screener: screens candidates (evidence: `trading_agent/core/engine.py`)
- Execution Orchestrator → Consensus Scoring: scores candidates (evidence: `trading_agent/core/engine.py`)
- Execution Orchestrator → Rebalance Logic: evaluates holdings (evidence: `trading_agent/core/engine.py`)
- Execution Orchestrator → Order Execution: executes orders (evidence: `trading_agent/core/engine.py`)
- Execution Orchestrator → Risk & Tenure: audits portfolio (evidence: `trading_agent/core/engine.py`)
- Execution Orchestrator → Persistent Memory: loads state (evidence: `trading_agent/core/engine.py`)
- Execution Orchestrator → Git State Sync: syncs state (evidence: `trading_agent/core/engine.py`)
- Consensus Scoring → Committee Debate: debates candidates (evidence: `trading_agent/core/consensus.py`)
- Committee Debate → Structured Schemas: validates output (evidence: `trading_agent/core/deliberation.py`)
- Committee Debate → Quant Screener: uses candidate data (evidence: `trading_agent/core/deliberation.py`)
- Quant Screener → Broker Transport: requests screener data (evidence: `trading_agent/core/screener.py`)
- Rebalance Logic → Risk & Tenure: checks guardrails (evidence: `trading_agent/core/rebalance.py`)
- Order Execution → Broker Transport: places orders (evidence: `trading_agent/core/execution.py`)
- Wallet Drain → Broker Transport: previews and places (evidence: `trading_agent/core/wallet.py`)
- Wallet Drain → Order Execution: delegates order (evidence: `trading_agent/core/wallet.py`)
- Risk & Tenure → Broker Transport: audits account (evidence: `trading_agent/core/risk.py`)
- Broker Transport → Configuration & Collars: reads endpoints (evidence: `trading_agent/core/broker.py`)
- Token Resolution → Configuration & Collars: reads credential paths (evidence: `trading_agent/core/auth.py`)
- Token Resolution → Tickertape Login: refreshes token (evidence: `trading_agent/core/auth.py`)
- Broker Transport → Tickertape / DriveWealth: calls MCP API (evidence: `README.md`)
- Broker Transport → Alpaca Paper API: supports paper API (evidence: `README.md`)
- Persistent Memory → Configuration & Collars: uses memory paths (evidence: `trading_agent/core/memory.py`)
- Retrospective Loop → Persistent Memory: calibrates weights (evidence: `scripts/feedback_loop.py`)
- CLI → Persistent Memory: reports memory status (evidence: `agent.py`)
- CLI → Git State Sync: sync command (evidence: `agent.py`)
- MCP Server → Token Resolution: gets token (evidence: `server/mcp_server.py`)
- MCP Server → Broker Transport: queries account (evidence: `server/mcp_server.py`)
- MCP Server → Committee Debate: deliberates ticker (evidence: `server/mcp_server.py`)
- MCP Server → Quant Screener: exposes screener (evidence: `server/mcp_server.py`)
- Fundamental Dossiers → Committee Debate: informs committee (evidence: `README.md`)
