# deskiziarecords/trade architecture

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

- Interactive diagram: https://gitdiagram.com/deskiziarecords/trade
- Repository: https://github.com/deskiziarecords/trade

## Overview

1. **Repository shape**
   - This is a multi-language trading/research monorepo, not a single app.
   - The main production-oriented path is the Python package under `trading_engine/aegis`, backed by several Rust crates in `hyperion` and other Rust subprojects.
   - Around that core are offline research notebooks/scripts, dataset prep pipelines, broker adapters, and deployment tooling.

2. **Primary runtime: `trading_engine/aegis`**
   - `trading_engine/aegis/main.py` is the central Python entrypoint.
   - The package is split into clear subsystems: `app`, `config`, `execution`, `risk`, `simulators`, and `zeta_flux`.
   - This is the orchestration boundary where signals, risk checks, and execution decisions are assembled into one trading flow.

3. **Signal generation / regime logic**
   - `trading_engine/aegis/zeta_flux` contains the signal/regime side of the system: `reversal_predictor`, `chromadb_regime`, `sos27x_sentinel`, `akts`, and related modules.
   - These components appear to consume market features and produce directional or regime-aware outputs before execution.
   - The tests in `trading_engine/tests/unit` and `tests/integration` indicate this layer is independently validated.

4. **Execution and routing**
   - `trading_engine/aegis/execution` contains the execution logic, with submodules for `ipda_core`, `aecabi`, and `urol`.
   - `trading_engine/aegis/config/brokers` includes broker-specific configuration for IB, LMAX, and Oanda, so execution is explicitly broker-abstracted.
   - This is the point where strategy output becomes broker-facing order/action logic.

5. **Risk and governance boundary**
   - `trading_engine/aegis/risk` implements hierarchical risk control via `governance_hierarchy.py` and `hierarchy.py`.
   - The README’s “Adelic” and “Causal Truth Gating” ideas map to this kind of layer: it sits between signal generation and execution and can veto or constrain actions.
   - `trading_engine/tests/unit/test_adelic.py` and `tests/test_sos27x.py` suggest risk/constraint behavior is a first-class subsystem.

6. **Low-latency Rust infrastructure: `hyperion`**
   - `hyperion` is a Rust workspace with several crates focused on performance-sensitive plumbing.
   - `rpd_net` handles socket/uring/zero-copy style networking concerns.
   - `rpd_executor` and `rpd_executor/src/pipeline.rs` suggest streamed execution pipelines.
   - `fix-encoder` is a FIX protocol encoding layer.
   - `schur_engine` and `ev-atr` indicate specialized mathematical / allocation / confluence components.
   - Architecturally, this is the systems boundary for ingestion, encoding, and transport.

7. **Alternative Rust pipelines**
   - `ASYNCRONIC-SYSTEM-rs` is another standalone Rust engine with `core`, `pipeline`, `analysis`, and `config` modules.
   - It includes `indicators`, `kill_zone`, `state`, and pipeline stages like `aecabi`, `ipda`, and `urol`.
   - `position-sizing-rs` and `multi-signal-rust` are additional Rust crates that likely provide reusable trading/math primitives rather than the main orchestration path.

8. **Adapters and external integration**
   - `MCP-SERVERS/ipda-mcp.py` and `MCP-SERVERS/metatrader5-mcp.py` are explicit integration points to external tooling/services.
   - `ipda-backend` is a separate Python/Rust-backed service boundary with `api/main.py`, `core/engine.py`, and a Rust library under `src/lib.rs`.
   - These are the places where the system likely exposes control or data access to other agents/tools or broker/execution environments.

9. **Data and offline processing**
   - The repo carries many EUR/USD minute-bar datasets in `candels`, `data-hist`, `eur-usd-dataset`, `eur-usd-dataset-ask`, and `uer2`.
   - Output folders such as `annotated_candles.csv`, `pattern_sequence.txt`, and `training_data.csv` show a pipeline that transforms raw candles into labeled sequences and training artifacts.
   - `data-hist/encoder.py`, `eur-usd-dataset/encoder.py`, and `data/data-pull.py` suggest offline ingestion, encoding, and dataset consolidation are separate from live execution.

10. **Research, visualization, and prototype space**
   - `3d-app-components`, `standalone-strategies`, `pine-scripts`, and `magnet-market` contain experimental signal visualizations, geometry/state-space tools, and strategy prototypes.
   - The 3D and manifold-oriented files (`pca-reduced-space.py`, `persistent-homology.py`, `liquidity_field.py`, `surface-plot.py`, etc.) are analysis aids, not the main runtime.
   - `pine-scripts` and `magnet-market` provide cross-language strategy research in Python, Rust, and TradingView-oriented artifacts.

11. **Deployment and build boundaries**
   - `Makefile`, `deployment/docker`, and `scripts/*.sh` define the build/run orchestration.
   - The repo is clearly set up for mixed-language builds: Cargo for Rust crates, Python packaging/requirements for the engine side.
   - `docs/` contains architecture and theory material that appears to define the intended system model alongside the code.

12. **High-level data flow to diagram**
   - The clearest architecture diagram is: market data and historical candles enter Rust ingestion/encoding layers, flow into Python/JAX signal and risk layers, then into execution adapters and broker integrations.
   - Offline datasets also flow into encoder/annotation scripts and research notebooks, producing features and labels that feed back into strategy development.
   - The Python trading engine and the Rust low-latency crates are the main boundary: math/decision logic on one side, transport/execution plumbing on the other.

Main entry points: [`trading_engine/aegis/execution/ipda_core/ipda_core.py`](https://github.com/deskiziarecords/trade/blob/main/trading_engine/aegis/execution/ipda_core/ipda_core.py) (Execution core), [`hyperion/rpd_executor/src/pipeline.rs`](https://github.com/deskiziarecords/trade/blob/main/hyperion/rpd_executor/src/pipeline.rs) (RPD executor), [`trading_engine/aegis/zeta_flux`](https://github.com/deskiziarecords/trade/tree/main/trading_engine/aegis/zeta_flux) (Zeta Flux), [`trading_engine/aegis/main.py`](https://github.com/deskiziarecords/trade/blob/main/trading_engine/aegis/main.py) (Aegis main)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_python_engine["Python trading engine"]
  node_main_entry["Aegis main<br/>python entrypoint<br/>[main.py]"]
  node_app_layer["App layer<br/>runtime app<br/>[app.py]"]
  node_signal_layer["Zeta Flux<br/>signal/regime"]
  node_reversal_predictor["Reversal model<br/>signal model"]
  node_regime_store["Regime store<br/>regime memory<br/>[chromadb_regime.py]"]
  node_sentinel["SOS27x sentinel<br/>constraint guard<br/>[sos27x_sentinel.py]"]
  node_risk_layer["Risk governance<br/>risk control"]
  node_execution_layer["Execution core<br/>order routing<br/>[ipda_core.py]"]
  node_aecabi_exec["AECABI<br/>execution stage<br/>[aecabi.py]"]
  node_urol_exec["UROL<br/>execution stage<br/>[urol.py]"]
  node_broker_config["Broker config<br/>broker settings"]
  node_simulator["Simulator<br/>backtest sim<br/>[sim1.py]"]
end

subgraph group_rust_infra["Rust runtime stack"]
  node_rpd_net["RPD net<br/>rust networking"]
  node_rpd_exec["RPD executor<br/>rust pipeline<br/>[pipeline.rs]"]
  node_fix_encoder["FIX encoder<br/>protocol codec<br/>[encoder.rs]"]
  node_schur_engine["Schur engine<br/>math engine<br/>[schur.rs]"]
  node_asyncronic["Asyncronic RS<br/>alt rust engine"]
end

subgraph group_research["Research and prototypes"]
  node_research_tools["Research tools<br/>prototype suite"]
  node_magnet_market["Magnet market<br/>research stack<br/>[main.py]"]
end

subgraph group_data["Data and offline prep"]
  node_dataset_prep["Dataset prep<br/>offline pipeline<br/>[encoder.py]"]
  node_candles["Market candles<br/>historical data"]
end

subgraph group_integration["Adapters and deployment"]
  node_ipda_backend["IPDA backend<br/>service backend<br/>[engine.py]"]
  node_mcp_servers["MCP servers<br/>tool bridge<br/>[ipda-mcp.py]"]
  node_deployment["Deployment<br/>build/run"]
end

node_candles -->|"raw bars"| node_dataset_prep
node_dataset_prep -->|"features/labels"| node_research_tools
node_main_entry -->|"boot"| node_app_layer
node_app_layer -->|"signals"| node_signal_layer
node_signal_layer -->|"predict"| node_reversal_predictor
node_signal_layer -->|"context"| node_regime_store
node_signal_layer -->|"gate"| node_sentinel
node_sentinel -->|"constraints"| node_risk_layer
node_risk_layer -->|"allow/veto"| node_execution_layer
node_execution_layer -->|"stage"| node_aecabi_exec
node_execution_layer -->|"stage"| node_urol_exec
node_execution_layer -->|"routes"| node_broker_config
node_execution_layer -->|"simulate"| node_simulator
node_rpd_net -->|"transport"| node_rpd_exec
node_rpd_exec -->|"encode"| node_fix_encoder
node_rpd_exec -->|"math"| node_schur_engine
node_asyncronic -.->|"pipeline"| node_rpd_exec
node_asyncronic -.->|"confluence"| node_schur_engine
node_ipda_backend -->|"expose"| node_mcp_servers
node_deployment -->|"run"| node_main_entry
node_deployment -->|"build"| node_rpd_net
node_magnet_market -->|"prototype"| node_research_tools
node_main_entry -.->|"plumbing"| node_rpd_exec
node_execution_layer -.->|"service"| node_ipda_backend

click node_main_entry "https://github.com/deskiziarecords/trade/blob/main/trading_engine/aegis/main.py"
click node_app_layer "https://github.com/deskiziarecords/trade/blob/main/trading_engine/aegis/app/app.py"
click node_signal_layer "https://github.com/deskiziarecords/trade/tree/main/trading_engine/aegis/zeta_flux"
click node_reversal_predictor "https://github.com/deskiziarecords/trade/blob/main/trading_engine/aegis/zeta_flux/reversal_predictor.py"
click node_regime_store "https://github.com/deskiziarecords/trade/blob/main/trading_engine/aegis/zeta_flux/chromadb_regime.py"
click node_sentinel "https://github.com/deskiziarecords/trade/blob/main/trading_engine/aegis/zeta_flux/sos27x_sentinel.py"
click node_risk_layer "https://github.com/deskiziarecords/trade/blob/main/trading_engine/aegis/risk/governance_hierarchy.py"
click node_execution_layer "https://github.com/deskiziarecords/trade/blob/main/trading_engine/aegis/execution/ipda_core/ipda_core.py"
click node_aecabi_exec "https://github.com/deskiziarecords/trade/blob/main/trading_engine/aegis/execution/aecabi/aecabi.py"
click node_urol_exec "https://github.com/deskiziarecords/trade/blob/main/trading_engine/aegis/execution/urol/urol.py"
click node_broker_config "https://github.com/deskiziarecords/trade/tree/main/trading_engine/aegis/config/brokers"
click node_simulator "https://github.com/deskiziarecords/trade/blob/main/trading_engine/aegis/simulators/sim1.py"
click node_rpd_net "https://github.com/deskiziarecords/trade/tree/main/hyperion/rpd_net/src"
click node_rpd_exec "https://github.com/deskiziarecords/trade/blob/main/hyperion/rpd_executor/src/pipeline.rs"
click node_fix_encoder "https://github.com/deskiziarecords/trade/blob/main/hyperion/fix-encoder/src/encoder.rs"
click node_schur_engine "https://github.com/deskiziarecords/trade/blob/main/hyperion/schur_engine/src/schur.rs"
click node_asyncronic "https://github.com/deskiziarecords/trade/tree/main/ASYNCRONIC-SYSTEM-rs/src"
click node_ipda_backend "https://github.com/deskiziarecords/trade/blob/main/ipda-backend/core/engine.py"
click node_mcp_servers "https://github.com/deskiziarecords/trade/blob/main/MCP-SERVERS/ipda-mcp.py"
click node_dataset_prep "https://github.com/deskiziarecords/trade/blob/main/data-hist/encoder.py"
click node_candles "https://github.com/deskiziarecords/trade/tree/main/candels"
click node_research_tools "https://github.com/deskiziarecords/trade/tree/main/3d-app-components"
click node_magnet_market "https://github.com/deskiziarecords/trade/blob/main/magnet-market/python/main.py"
click node_deployment "https://github.com/deskiziarecords/trade/tree/main/deployment/docker/Dockerfile"

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_main_entry,node_app_layer,node_signal_layer,node_reversal_predictor,node_regime_store,node_sentinel,node_risk_layer,node_execution_layer,node_aecabi_exec,node_urol_exec,node_broker_config,node_simulator toneBlue
class node_rpd_net,node_rpd_exec,node_fix_encoder,node_schur_engine,node_asyncronic toneAmber
class node_research_tools,node_magnet_market toneMint
class node_dataset_prep,node_candles toneRose
class node_ipda_backend,node_mcp_servers,node_deployment toneIndigo
```

## Components

### Python trading engine

Primary orchestration and decision-making runtime.

- [Aegis main](https://github.com/deskiziarecords/trade/blob/main/trading_engine/aegis/main.py): python entrypoint · Central Python entrypoint for the trading engine. · `trading_engine/aegis/main.py`
- [App layer](https://github.com/deskiziarecords/trade/blob/main/trading_engine/aegis/app/app.py): runtime app · Top-level application wiring and entry coordination. · `trading_engine/aegis/app/app.py`
- [Zeta Flux](https://github.com/deskiziarecords/trade/tree/main/trading_engine/aegis/zeta_flux): signal/regime · Signal generation and regime-aware market interpretation. · `trading_engine/aegis/zeta_flux`
- [Reversal model](https://github.com/deskiziarecords/trade/blob/main/trading_engine/aegis/zeta_flux/reversal_predictor.py): signal model · Directional/reversal prediction logic. · `trading_engine/aegis/zeta_flux/reversal_predictor.py`
- [Regime store](https://github.com/deskiziarecords/trade/blob/main/trading_engine/aegis/zeta_flux/chromadb_regime.py): regime memory · Chromadb-backed regime context and retrieval. · `trading_engine/aegis/zeta_flux/chromadb_regime.py`
- [SOS27x sentinel](https://github.com/deskiziarecords/trade/blob/main/trading_engine/aegis/zeta_flux/sos27x_sentinel.py): constraint guard · Sentinel layer for signal gating and monitoring. · `trading_engine/aegis/zeta_flux/sos27x_sentinel.py`
- [Risk governance](https://github.com/deskiziarecords/trade/blob/main/trading_engine/aegis/risk/governance_hierarchy.py): risk control · Hierarchical veto and constraint logic between signal and execution. · `trading_engine/aegis/risk/governance_hierarchy.py`
- [Execution core](https://github.com/deskiziarecords/trade/blob/main/trading_engine/aegis/execution/ipda_core/ipda_core.py): order routing · Python execution boundary that turns decisions into actions. · `trading_engine/aegis/execution/ipda_core/ipda_core.py`
- [AECABI](https://github.com/deskiziarecords/trade/blob/main/trading_engine/aegis/execution/aecabi/aecabi.py): execution stage · Execution-stage logic for structured order handling. · `trading_engine/aegis/execution/aecabi/aecabi.py`
- [UROL](https://github.com/deskiziarecords/trade/blob/main/trading_engine/aegis/execution/urol/urol.py): execution stage · Execution-stage logic for routing and order lifecycle. · `trading_engine/aegis/execution/urol/urol.py`
- [Broker config](https://github.com/deskiziarecords/trade/tree/main/trading_engine/aegis/config/brokers): broker settings · Broker-specific configuration for IB, LMAX, and Oanda. · `trading_engine/aegis/config/brokers`
- [Simulator](https://github.com/deskiziarecords/trade/blob/main/trading_engine/aegis/simulators/sim1.py): backtest sim · Local simulation path for validating strategy behavior. · `trading_engine/aegis/simulators/sim1.py`

### Rust runtime stack

Low-latency transport, encoding, and execution plumbing.

- [RPD net](https://github.com/deskiziarecords/trade/tree/main/hyperion/rpd_net/src): rust networking · Socket, uring, and zero-copy network plumbing. · `hyperion/rpd_net/src`
- [RPD executor](https://github.com/deskiziarecords/trade/blob/main/hyperion/rpd_executor/src/pipeline.rs): rust pipeline · Streamed execution engine and pipeline coordinator. · `hyperion/rpd_executor/src/pipeline.rs`
- [FIX encoder](https://github.com/deskiziarecords/trade/blob/main/hyperion/fix-encoder/src/encoder.rs): protocol codec · FIX message encoding and message framing. · `hyperion/fix-encoder/src/encoder.rs`
- [Schur engine](https://github.com/deskiziarecords/trade/blob/main/hyperion/schur_engine/src/schur.rs): math engine · Specialized allocation/confluence and routing math. · `hyperion/schur_engine/src/schur.rs`
- [Asyncronic RS](https://github.com/deskiziarecords/trade/tree/main/ASYNCRONIC-SYSTEM-rs/src): alt rust engine · Standalone Rust engine with core, analysis, and pipeline stages. · `ASYNCRONIC-SYSTEM-rs/src`

### Research and prototypes

Experimental strategy, geometry, and visualization code.

- [Research tools](https://github.com/deskiziarecords/trade/tree/main/3d-app-components): prototype suite · 3D visualization, geometry, and strategy prototypes. · `3d-app-components`
- [Magnet market](https://github.com/deskiziarecords/trade/blob/main/magnet-market/python/main.py): research stack · Cross-language signal research and spectral/magnet-inspired modeling. · `magnet-market/python/main.py`

### Data and offline prep

Historical market data, encoding, and label-generation pipelines.

- [Dataset prep](https://github.com/deskiziarecords/trade/blob/main/data-hist/encoder.py): offline pipeline · Historical candle ingestion, encoding, and label generation. · `data-hist/encoder.py`
- [Market candles](https://github.com/deskiziarecords/trade/tree/main/candels): historical data · EUR/USD minute-bar datasets used for research and training. · `candels`

### Adapters and deployment

External integrations, backend services, and build/run tooling.

- [IPDA backend](https://github.com/deskiziarecords/trade/blob/main/ipda-backend/core/engine.py): service backend · Separate backend service exposing IPDA engine functionality. · `ipda-backend/core/engine.py`
- [MCP servers](https://github.com/deskiziarecords/trade/blob/main/MCP-SERVERS/ipda-mcp.py): tool bridge · Agent/tool integration points for external control surfaces. · `MCP-SERVERS/ipda-mcp.py`
- [Deployment](https://github.com/deskiziarecords/trade/tree/main/deployment/docker/Dockerfile): build/run · Containerization and shell scripts for runtime setup. · `deployment/docker/Dockerfile`

## Connections

- Market candles → Dataset prep: raw bars · Historical candles are encoded and labeled for offline use.
- Dataset prep → Research tools: features/labels · Prepared datasets feed analysis and prototype notebooks/scripts.
- Aegis main → App layer: boot · Main entrypoint initializes the application layer.
- App layer → Zeta Flux: signals · Application orchestration invokes signal/regime logic.
- Zeta Flux → Reversal model: predict · Core signal generation uses reversal prediction.
- Zeta Flux → Regime store: context · Regime-aware retrieval and state inform decisions.
- Zeta Flux → SOS27x sentinel: gate · Sentinel logic monitors and constrains signals.
- SOS27x sentinel → Risk governance: constraints · Sentinel outputs are enforced through risk governance.
- Risk governance → Execution core: allow/veto · Risk layer decides whether execution can proceed.
- Execution core → AECABI: stage · Execution core delegates to AECABI stage logic.
- Execution core → UROL: stage · Execution core delegates to UROL stage logic.
- Execution core → Broker config: routes · Execution is parameterized by broker-specific configuration.
- Execution core → Simulator: simulate · Execution logic is also exercised through simulation.
- RPD net → RPD executor: transport · Networking feeds the streamed execution pipeline.
- RPD executor → FIX encoder: encode · Execution pipeline emits FIX-formatted messages.
- RPD executor → Schur engine: math · Pipeline uses specialized math/routing primitives.
- Asyncronic RS → RPD executor: pipeline · Alternative Rust engine implements similar staged processing.
- Asyncronic RS → Schur engine: confluence · Rust subsystem shares routing/allocation ideas.
- IPDA backend → MCP servers: expose · Backend services are surfaced through external tool bridges.
- Deployment → Aegis main: run · Deployment scripts and containers launch the Python engine.
- Deployment → RPD net: build · Deployment supports the Rust networking/runtime pieces.
- Magnet market → Research tools: prototype · Magnet-market research complements the visualization and strategy space.
- Aegis main → RPD executor: plumbing · Python trading flow connects to Rust low-latency infrastructure.
- Execution core → IPDA backend: service · Execution and IPDA functionality can be delegated to the backend boundary.
