# opr1130/ohm-trade-agent-v1 architecture

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

- Interactive diagram: https://gitdiagram.com/opr1130/ohm-trade-agent-v1
- Repository: https://github.com/opr1130/ohm-trade-agent-v1

## Overview

OHM Trade Agent combines an alert-oriented trading service with O’Pip’s market-evidence, decision, paper-trading, and analytics platform. The main user flow accepts operator or TradingView requests through the API, while the broader platform also ingests market observations, builds canonical features, evaluates opportunities, and can track paper-trade outcomes. The graph preserves those distinct capabilities without implying that the advisory API is wired to every O’Pip subsystem. Relationships are limited to source-index references and visible excerpts; unsampled links are omitted or marked unverified.

Main entry points: [`OHM-Trade-Agent-v1/app/opip/decision/engine.py`](https://github.com/opr1130/ohm-trade-agent-v1/blob/main/OHM-Trade-Agent-v1/app/opip/decision/engine.py) (Decision engine), [`OHM-Trade-Agent-v1/app/opip/contracts`](https://github.com/opr1130/ohm-trade-agent-v1/tree/main/OHM-Trade-Agent-v1/app/opip/contracts) (Shared data contracts), [`OHM-Trade-Agent-v1/app/main.py`](https://github.com/opr1130/ohm-trade-agent-v1/blob/main/OHM-Trade-Agent-v1/app/main.py) (FastAPI application), [`OHM-Trade-Agent-v1/app/opip/features/pipeline.py`](https://github.com/opr1130/ohm-trade-agent-v1/blob/main/OHM-Trade-Agent-v1/app/opip/features/pipeline.py) (Feature pipeline)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["API and operations"]
  node_app["FastAPI application<br/>[main.py]"]
  node_routes["API routes<br/>[routes.py]"]
  node_dashboard["Dashboard API<br/>[dashboard.py]"]
  node_cockpit["Cockpit analytics<br/>[cockpit_service.py]"]
end

subgraph group_market["Market intelligence"]
  node_scanner["Market scanner"]
  node_streaming["Market stream worker<br/>[worker.py]"]
  node_marketdata["Market data platform"]
  node_featurepipeline["Feature pipeline<br/>[pipeline.py]"]
  node_featureengine["Feature engine<br/>[engine.py]"]
  node_contracts["Shared data contracts"]
end

subgraph group_decisions["Opportunity decisions"]
  node_decision["Decision engine<br/>[engine.py]"]
  node_committee["Committee roles<br/>[role_router.py]"]
  node_backtest["Backtesting engine<br/>[engine.py]"]
end

subgraph group_trading["Execution and portfolio"]
  node_paper["Paper trade engine"]
  node_exchange["Kraken integration<br/>[kraken.py]"]
  node_portfolio["Portfolio cockpit<br/>[portfolio.py]"]
end

subgraph group_evidence["Evidence and learning"]
  node_canonicalclient["Canonical writer client<br/>[client.py]"]
  node_canonicalserver["Canonical writer server<br/>[server.py]"]
  node_eventstore[("Canonical event store<br/>[storage.py]")]
  node_boundedstore[("Bounded archive storage<br/>[bounded_jsonl.py]")]
  node_risk[("Risk evidence<br/>[storage.py]")]
  node_learning["Learning and readiness"]
end

node_operator(("Operator"))
node_tradingview(("TradingView sender"))

node_operator -->|"submits requests"| node_routes
node_tradingview -->|"sends webhook"| node_app
node_app -->|"mounts router"| node_routes
node_app -->|"mounts router"| node_dashboard
node_cockpit -.->|"reads evidence"| node_eventstore
node_streaming -.->|"uses market data"| node_marketdata
node_streaming -.->|"feeds observations"| node_featurepipeline
node_featurepipeline -->|"computes features"| node_featureengine
node_featureengine -->|"uses contracts"| node_contracts
node_featurepipeline -->|"uses contracts"| node_contracts
node_scanner -.->|"evaluates candidates"| node_decision
node_decision -.->|"uses decision models"| node_contracts
node_committee -.->|"supports evaluation"| node_decision
node_paper -->|"uses outcome contracts"| node_contracts
node_paper -.->|"submits paper signals"| node_exchange
node_portfolio -.->|"projects portfolio"| node_paper
node_canonicalclient -->|"sends writer requests"| node_canonicalserver
node_canonicalserver -.->|"writes events"| node_eventstore
node_eventstore -->|"archives rows"| node_boundedstore
node_risk -->|"stores evidence"| node_boundedstore
node_learning -->|"uses bounded storage"| node_boundedstore
node_backtest -.->|"compares strategies"| node_decision

click node_app "https://github.com/opr1130/ohm-trade-agent-v1/blob/main/OHM-Trade-Agent-v1/app/main.py"
click node_routes "https://github.com/opr1130/ohm-trade-agent-v1/blob/main/OHM-Trade-Agent-v1/app/api/routes.py"
click node_dashboard "https://github.com/opr1130/ohm-trade-agent-v1/blob/main/OHM-Trade-Agent-v1/app/api/dashboard.py"
click node_cockpit "https://github.com/opr1130/ohm-trade-agent-v1/blob/main/OHM-Trade-Agent-v1/app/api/cockpit_service.py"
click node_scanner "https://github.com/opr1130/ohm-trade-agent-v1/tree/main/OHM-Trade-Agent-v1/app/scanner"
click node_streaming "https://github.com/opr1130/ohm-trade-agent-v1/blob/main/OHM-Trade-Agent-v1/app/opip/streaming/worker.py"
click node_marketdata "https://github.com/opr1130/ohm-trade-agent-v1/tree/main/OHM-Trade-Agent-v1/app/opip/market"
click node_featurepipeline "https://github.com/opr1130/ohm-trade-agent-v1/blob/main/OHM-Trade-Agent-v1/app/opip/features/pipeline.py"
click node_featureengine "https://github.com/opr1130/ohm-trade-agent-v1/blob/main/OHM-Trade-Agent-v1/app/opip/features/engine.py"
click node_contracts "https://github.com/opr1130/ohm-trade-agent-v1/tree/main/OHM-Trade-Agent-v1/app/opip/contracts"
click node_decision "https://github.com/opr1130/ohm-trade-agent-v1/blob/main/OHM-Trade-Agent-v1/app/opip/decision/engine.py"
click node_committee "https://github.com/opr1130/ohm-trade-agent-v1/blob/main/OHM-Trade-Agent-v1/app/opip/committee/role_router.py"
click node_paper "https://github.com/opr1130/ohm-trade-agent-v1/blob/main/OHM-Trade-Agent-v1/app/services/paper_trade_engine.py"
click node_exchange "https://github.com/opr1130/ohm-trade-agent-v1/blob/main/OHM-Trade-Agent-v1/app/exchanges/kraken.py"
click node_portfolio "https://github.com/opr1130/ohm-trade-agent-v1/blob/main/OHM-Trade-Agent-v1/app/opip/cockpit/portfolio.py"
click node_canonicalclient "https://github.com/opr1130/ohm-trade-agent-v1/blob/main/OHM-Trade-Agent-v1/app/opip/canonical/client.py"
click node_canonicalserver "https://github.com/opr1130/ohm-trade-agent-v1/blob/main/OHM-Trade-Agent-v1/app/opip/canonical/server.py"
click node_eventstore "https://github.com/opr1130/ohm-trade-agent-v1/blob/main/OHM-Trade-Agent-v1/app/opip/events/storage.py"
click node_boundedstore "https://github.com/opr1130/ohm-trade-agent-v1/blob/main/OHM-Trade-Agent-v1/app/opip/storage/bounded_jsonl.py"
click node_risk "https://github.com/opr1130/ohm-trade-agent-v1/blob/main/OHM-Trade-Agent-v1/app/opip/risk/storage.py"
click node_learning "https://github.com/opr1130/ohm-trade-agent-v1/tree/main/OHM-Trade-Agent-v1/app/opip/learning"
click node_backtest "https://github.com/opr1130/ohm-trade-agent-v1/blob/main/OHM-Trade-Agent-v1/app/backtesting/engine.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_app,node_routes,node_dashboard,node_cockpit,node_tradingview toneBlue
class node_scanner,node_streaming,node_marketdata,node_featurepipeline,node_featureengine,node_contracts toneAmber
class node_decision,node_committee,node_backtest toneMint
class node_paper,node_exchange,node_portfolio toneRose
class node_canonicalclient,node_canonicalserver,node_eventstore,node_boundedstore,node_risk,node_learning,node_operator toneIndigo
```

## Components

### API and operations

- [FastAPI application](https://github.com/opr1130/ohm-trade-agent-v1/blob/main/OHM-Trade-Agent-v1/app/main.py): `OHM-Trade-Agent-v1/app/main.py`
- [API routes](https://github.com/opr1130/ohm-trade-agent-v1/blob/main/OHM-Trade-Agent-v1/app/api/routes.py): `OHM-Trade-Agent-v1/app/api/routes.py`
- [Dashboard API](https://github.com/opr1130/ohm-trade-agent-v1/blob/main/OHM-Trade-Agent-v1/app/api/dashboard.py): `OHM-Trade-Agent-v1/app/api/dashboard.py`
- [Cockpit analytics](https://github.com/opr1130/ohm-trade-agent-v1/blob/main/OHM-Trade-Agent-v1/app/api/cockpit_service.py): `OHM-Trade-Agent-v1/app/api/cockpit_service.py`

### Market intelligence

- [Market scanner](https://github.com/opr1130/ohm-trade-agent-v1/tree/main/OHM-Trade-Agent-v1/app/scanner): `OHM-Trade-Agent-v1/app/scanner`
- [Market stream worker](https://github.com/opr1130/ohm-trade-agent-v1/blob/main/OHM-Trade-Agent-v1/app/opip/streaming/worker.py): `OHM-Trade-Agent-v1/app/opip/streaming/worker.py`
- [Market data platform](https://github.com/opr1130/ohm-trade-agent-v1/tree/main/OHM-Trade-Agent-v1/app/opip/market): `OHM-Trade-Agent-v1/app/opip/market`
- [Feature pipeline](https://github.com/opr1130/ohm-trade-agent-v1/blob/main/OHM-Trade-Agent-v1/app/opip/features/pipeline.py): `OHM-Trade-Agent-v1/app/opip/features/pipeline.py`
- [Feature engine](https://github.com/opr1130/ohm-trade-agent-v1/blob/main/OHM-Trade-Agent-v1/app/opip/features/engine.py): `OHM-Trade-Agent-v1/app/opip/features/engine.py`
- [Shared data contracts](https://github.com/opr1130/ohm-trade-agent-v1/tree/main/OHM-Trade-Agent-v1/app/opip/contracts): `OHM-Trade-Agent-v1/app/opip/contracts`

### Opportunity decisions

- [Decision engine](https://github.com/opr1130/ohm-trade-agent-v1/blob/main/OHM-Trade-Agent-v1/app/opip/decision/engine.py): `OHM-Trade-Agent-v1/app/opip/decision/engine.py`
- [Committee roles](https://github.com/opr1130/ohm-trade-agent-v1/blob/main/OHM-Trade-Agent-v1/app/opip/committee/role_router.py): `OHM-Trade-Agent-v1/app/opip/committee/role_router.py`
- [Backtesting engine](https://github.com/opr1130/ohm-trade-agent-v1/blob/main/OHM-Trade-Agent-v1/app/backtesting/engine.py): `OHM-Trade-Agent-v1/app/backtesting/engine.py`

### Execution and portfolio

- [Paper trade engine](https://github.com/opr1130/ohm-trade-agent-v1/blob/main/OHM-Trade-Agent-v1/app/services/paper_trade_engine.py): `OHM-Trade-Agent-v1/app/services/paper_trade_engine.py`
- [Kraken integration](https://github.com/opr1130/ohm-trade-agent-v1/blob/main/OHM-Trade-Agent-v1/app/exchanges/kraken.py): `OHM-Trade-Agent-v1/app/exchanges/kraken.py`
- [Portfolio cockpit](https://github.com/opr1130/ohm-trade-agent-v1/blob/main/OHM-Trade-Agent-v1/app/opip/cockpit/portfolio.py): `OHM-Trade-Agent-v1/app/opip/cockpit/portfolio.py`

### Evidence and learning

- [Canonical writer client](https://github.com/opr1130/ohm-trade-agent-v1/blob/main/OHM-Trade-Agent-v1/app/opip/canonical/client.py): `OHM-Trade-Agent-v1/app/opip/canonical/client.py`
- [Canonical writer server](https://github.com/opr1130/ohm-trade-agent-v1/blob/main/OHM-Trade-Agent-v1/app/opip/canonical/server.py): `OHM-Trade-Agent-v1/app/opip/canonical/server.py`
- [Canonical event store](https://github.com/opr1130/ohm-trade-agent-v1/blob/main/OHM-Trade-Agent-v1/app/opip/events/storage.py): `OHM-Trade-Agent-v1/app/opip/events/storage.py`
- [Bounded archive storage](https://github.com/opr1130/ohm-trade-agent-v1/blob/main/OHM-Trade-Agent-v1/app/opip/storage/bounded_jsonl.py): `OHM-Trade-Agent-v1/app/opip/storage/bounded_jsonl.py`
- [Risk evidence](https://github.com/opr1130/ohm-trade-agent-v1/blob/main/OHM-Trade-Agent-v1/app/opip/risk/storage.py): `OHM-Trade-Agent-v1/app/opip/risk/storage.py`
- [Learning and readiness](https://github.com/opr1130/ohm-trade-agent-v1/tree/main/OHM-Trade-Agent-v1/app/opip/learning): `OHM-Trade-Agent-v1/app/opip/learning`

### Other components

- **Operator**
- **TradingView sender**

## Connections

- Operator → API routes: submits requests (evidence: `OHM-Trade-Agent-v1/app/api/routes.py`)
- TradingView sender → FastAPI application: sends webhook (evidence: `OHM-Trade-Agent-v1/app/main.py`)
- FastAPI application → API routes: mounts router (evidence: `OHM-Trade-Agent-v1/app/main.py`)
- FastAPI application → Dashboard API: mounts router (evidence: `OHM-Trade-Agent-v1/app/main.py`)
- Cockpit analytics → Canonical event store: reads evidence
- Market stream worker → Market data platform: uses market data
- Market stream worker → Feature pipeline: feeds observations
- Feature pipeline → Feature engine: computes features (evidence: `OHM-Trade-Agent-v1/app/opip/features/pipeline.py`)
- Feature engine → Shared data contracts: uses contracts (evidence: `OHM-Trade-Agent-v1/app/opip/features/engine.py`)
- Feature pipeline → Shared data contracts: uses contracts (evidence: `OHM-Trade-Agent-v1/app/opip/features/pipeline.py`)
- Market scanner → Decision engine: evaluates candidates
- Decision engine → Shared data contracts: uses decision models
- Committee roles → Decision engine: supports evaluation
- Paper trade engine → Shared data contracts: uses outcome contracts (evidence: `OHM-Trade-Agent-v1/app/services/paper_trade_engine.py`)
- Paper trade engine → Kraken integration: submits paper signals
- Portfolio cockpit → Paper trade engine: projects portfolio
- Canonical writer client → Canonical writer server: sends writer requests (evidence: `OHM-Trade-Agent-v1/app/opip/canonical/client.py`)
- Canonical writer server → Canonical event store: writes events
- Canonical event store → Bounded archive storage: archives rows (evidence: `OHM-Trade-Agent-v1/app/opip/events/storage.py`)
- Risk evidence → Bounded archive storage: stores evidence (evidence: `OHM-Trade-Agent-v1/app/opip/risk/storage.py`)
- Learning and readiness → Bounded archive storage: uses bounded storage (evidence: `OHM-Trade-Agent-v1/app/opip/learning/coverage_discontinuity.py`)
- Backtesting engine → Decision engine: compares strategies
