# deskiziarecords/hyperion architecture

> Architecture diagram of the GitHub repository deskiziarecords/hyperion, 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/hyperion
- Repository: https://github.com/deskiziarecords/hyperion

## Overview

1. **Repository shape**
   - This is primarily a **Rust 2021 crate** that looks like a single executable plus library modules (`src/main.rs`, `src/lib.rs`).
   - There is also a **Python sidecar/research layer** (`main_hybrid.py`, `logic/*.py`) that appears to prototype or mirror some of the same signal-processing ideas, but the main architecture is Rust-first.

2. **Top-level responsibility**
   - The repo is organized around a **market strategy engine** for an IPDA-style trading model.
   - The core job is: ingest live market data, derive a market state, decide whether a regime/phase change has occurred, and then route execution across venues.

3. **Shared domain model**
   - `src/types.rs` defines the main data structures used across the system: price frames, market context, and strategy-level abstractions.
   - This file is the main boundary for what counts as “market truth” inside the engine, and it likely feeds both analysis and execution layers.

4. **Market data pipeline**
   - `src/data/realtime.rs` and `src/data/candle_builder.rs` form the ingestion path from raw ticks/streaming data into higher-level candle/price-frame objects.
   - This is the front of the runtime data flow: external market feed → normalized realtime events → aggregated candles/frames used by the strategy logic.

5. **Strategy state machine**
   - `src/continuum.rs` is the centerpiece of the strategy, described in the README as the `HamiltonianEngine`.
   - It models regime transitions such as consolidation, expansion, retracement, reversal, and stasis, using volatility/range conditions and “displacement veto” style filters to decide when a move is actionable.

6. **IPDA and liquidity logic**
   - `src/ipda.rs`, `src/kill_zone.rs`, `src/urol.rs`, and `src/aecabi.rs` are the strategy-specific analytical modules.
   - These likely encapsulate price-delivery assumptions, session/time-window logic, liquidity targeting, and other internal concepts that feed the state machine and signal generation.

7. **Order routing and execution boundary**
   - `src/routing.rs` and `src/engine/execution.rs` represent the handoff from signal to trade action.
   - The router decides how an order should be split or dispatched, while the execution layer translates that decision into broker-specific actions.

8. **Runtime state management**
   - `src/engine/state.rs` is the internal bookkeeping layer for the running strategy.
   - This is where current position/order status, active regime, and other execution-time state would be maintained so that routing and strategy logic stay synchronized.

9. **Exchange/broker integrations**
   - `src/brokers/bitget.rs`, `bybit.rs`, `mexc.rs`, and `okx.rs` are venue adapters behind `src/brokers/mod.rs`.
   - These modules are the external-service boundary of the system: they isolate exchange-specific APIs, auth, order formats, and response handling from the core strategy logic.

10. **Python research/prototype layer**
   - The `logic/` directory contains standalone Python implementations of related analytic ideas, including reverse-period detection and adelic/koopman-inspired helpers.
   - This looks like a research sandbox rather than the main runtime path, useful for experimentation, validation, or alternative signal derivations.

11. **End-to-end data flow**
   - The likely live path is: **broker/market feed → realtime ingestion → candle construction → strategy/state computation in `continuum`/`ipda`/`types` → routing decision → execution through broker adapters**.
   - The core architecture is therefore a tight in-memory streaming pipeline, not a service-oriented system with databases or message brokers visible in the tree.

12. **What to draw as boundaries**
   - Separate the diagram into four main boxes: **Market Data Ingestion**, **Strategy/State Engine**, **Routing & Execution**, and **Broker/Venue Adapters**.
   - Put the Python `logic/` folder off to the side as an auxiliary analysis/prototyping track, and treat `src/types.rs` as the shared contract layer that connects the whole system.

Main entry points: [`src/continuum.rs`](https://github.com/deskiziarecords/hyperion/blob/main/src/continuum.rs) (Hamiltonian engine), [`src/brokers/mod.rs`](https://github.com/deskiziarecords/hyperion/blob/main/src/brokers/mod.rs) (Broker hub), [`src/lib.rs`](https://github.com/deskiziarecords/hyperion/blob/main/src/lib.rs) (Rust crate), [`src/data/realtime.rs`](https://github.com/deskiziarecords/hyperion/blob/main/src/data/realtime.rs) (Realtime feed)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_g_ingest["Market Data Ingestion"]
  node_n_realtime["Realtime feed<br/>ingest<br/>[realtime.rs]"]
  node_n_candles["Candle builder<br/>aggregation<br/>[candle_builder.rs]"]
end

subgraph group_g_strategy["Strategy / State Engine"]
  node_n_types["Shared types<br/>domain model<br/>[types.rs]"]
  node_n_continuum{{"Hamiltonian engine<br/>regime state machine<br/>[continuum.rs]"}}
  node_n_ipda["IPDA logic<br/>strategy model<br/>[ipda.rs]"]
  node_n_killzone["Kill zones<br/>session filter<br/>[kill_zone.rs]"]
  node_n_urol["UROL<br/>liquidity logic<br/>[urol.rs]"]
  node_n_aecabi["AECABI<br/>analysis module<br/>[aecabi.rs]"]
end

subgraph group_g_exec["Routing & Execution"]
  node_n_routing["Order router<br/>routing<br/>[routing.rs]"]
  node_n_exec["Execution layer<br/>[execution.rs]"]
  node_n_state["Runtime state<br/>state management<br/>[state.rs]"]
end

subgraph group_g_brokers["Broker / Venue Adapters"]
  node_n_brokers_mod["Broker hub<br/>adapter hub<br/>[mod.rs]"]
  node_n_bitget["Bitget<br/>venue adapter<br/>[bitget.rs]"]
  node_n_bybit["Bybit<br/>venue adapter<br/>[bybit.rs]"]
  node_n_mexc["MEXC<br/>venue adapter<br/>[mexc.rs]"]
  node_n_okx["OKX<br/>venue adapter<br/>[okx.rs]"]
end

subgraph group_g_python["Python Research Layer"]
  node_n_python_main["Hybrid runner<br/>python entry<br/>[main_hybrid.py]"]
  node_n_py_logic["Research logic<br/>analysis sandbox"]
end

node_n_lib["Rust crate<br/>crate entry<br/>[lib.rs]"]
node_n_main["Main entry<br/>binary entry<br/>[main.rs]"]

node_n_main -->|"starts"| node_n_lib
node_n_lib -->|"shares model"| node_n_types
node_n_lib -->|"ingests"| node_n_realtime
node_n_realtime -->|"builds"| node_n_candles
node_n_candles -->|"feeds"| node_n_continuum
node_n_types -->|"structures"| node_n_continuum
node_n_continuum -->|"uses"| node_n_ipda
node_n_continuum -->|"filters"| node_n_killzone
node_n_continuum -->|"consults"| node_n_urol
node_n_continuum -->|"augments"| node_n_aecabi
node_n_continuum -->|"updates"| node_n_state
node_n_state -->|"guides"| node_n_routing
node_n_routing -->|"dispatches"| node_n_exec
node_n_exec -->|"adapts to"| node_n_brokers_mod
node_n_brokers_mod -->|"includes"| node_n_bitget
node_n_brokers_mod -->|"includes"| node_n_bybit
node_n_brokers_mod -->|"includes"| node_n_mexc
node_n_brokers_mod -->|"includes"| node_n_okx
node_n_python_main -->|"runs with"| node_n_py_logic
node_n_py_logic -.->|"mirrors"| node_n_continuum

click node_n_lib "https://github.com/deskiziarecords/hyperion/blob/main/src/lib.rs"
click node_n_main "https://github.com/deskiziarecords/hyperion/blob/main/src/main.rs"
click node_n_types "https://github.com/deskiziarecords/hyperion/blob/main/src/types.rs"
click node_n_realtime "https://github.com/deskiziarecords/hyperion/blob/main/src/data/realtime.rs"
click node_n_candles "https://github.com/deskiziarecords/hyperion/blob/main/src/data/candle_builder.rs"
click node_n_continuum "https://github.com/deskiziarecords/hyperion/blob/main/src/continuum.rs"
click node_n_ipda "https://github.com/deskiziarecords/hyperion/blob/main/src/ipda.rs"
click node_n_killzone "https://github.com/deskiziarecords/hyperion/blob/main/src/kill_zone.rs"
click node_n_urol "https://github.com/deskiziarecords/hyperion/blob/main/src/urol.rs"
click node_n_aecabi "https://github.com/deskiziarecords/hyperion/blob/main/src/aecabi.rs"
click node_n_routing "https://github.com/deskiziarecords/hyperion/blob/main/src/routing.rs"
click node_n_exec "https://github.com/deskiziarecords/hyperion/blob/main/src/engine/execution.rs"
click node_n_state "https://github.com/deskiziarecords/hyperion/blob/main/src/engine/state.rs"
click node_n_brokers_mod "https://github.com/deskiziarecords/hyperion/blob/main/src/brokers/mod.rs"
click node_n_bitget "https://github.com/deskiziarecords/hyperion/blob/main/src/brokers/bitget.rs"
click node_n_bybit "https://github.com/deskiziarecords/hyperion/blob/main/src/brokers/bybit.rs"
click node_n_mexc "https://github.com/deskiziarecords/hyperion/blob/main/src/brokers/mexc.rs"
click node_n_okx "https://github.com/deskiziarecords/hyperion/blob/main/src/brokers/okx.rs"
click node_n_python_main "https://github.com/deskiziarecords/hyperion/blob/main/main_hybrid.py"
click node_n_py_logic "https://github.com/deskiziarecords/hyperion/blob/main/logic/reverse_period_detector.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_n_realtime,node_n_candles toneBlue
class node_n_types,node_n_continuum,node_n_ipda,node_n_killzone,node_n_urol,node_n_aecabi toneAmber
class node_n_routing,node_n_exec,node_n_state toneMint
class node_n_brokers_mod,node_n_bitget,node_n_bybit,node_n_mexc,node_n_okx toneRose
class node_n_python_main,node_n_py_logic toneIndigo
class node_n_lib,node_n_main toneNeutral
```

## Components

### Market Data Ingestion

Realtime feed normalization and candle/frame construction.

- [Realtime feed](https://github.com/deskiziarecords/hyperion/blob/main/src/data/realtime.rs): ingest · Normalizes incoming live market data into internal events. · `src/data/realtime.rs`
- [Candle builder](https://github.com/deskiziarecords/hyperion/blob/main/src/data/candle_builder.rs): aggregation · Aggregates realtime events into candles and price frames. · `src/data/candle_builder.rs`

### Strategy / State Engine

Shared domain model and regime detection logic.

- [Shared types](https://github.com/deskiziarecords/hyperion/blob/main/src/types.rs): domain model · Core market and strategy data structures shared across the engine. · `src/types.rs`
- [Hamiltonian engine](https://github.com/deskiziarecords/hyperion/blob/main/src/continuum.rs): regime state machine · Core strategy engine for consolidation, expansion, retracement, reversal, and stasis. · `src/continuum.rs`
- [IPDA logic](https://github.com/deskiziarecords/hyperion/blob/main/src/ipda.rs): strategy model · Price-delivery and market-structure assumptions feeding signals. · `src/ipda.rs`
- [Kill zones](https://github.com/deskiziarecords/hyperion/blob/main/src/kill_zone.rs): session filter · Session and time-window logic used by the strategy. · `src/kill_zone.rs`
- [UROL](https://github.com/deskiziarecords/hyperion/blob/main/src/urol.rs): liquidity logic · Liquidity-oriented strategy heuristics and targeting rules. · `src/urol.rs`
- [AECABI](https://github.com/deskiziarecords/hyperion/blob/main/src/aecabi.rs): analysis module · Additional strategy analysis and signal support. · `src/aecabi.rs`

### Routing & Execution

Signal handoff, order state, and trade execution.

- [Order router](https://github.com/deskiziarecords/hyperion/blob/main/src/routing.rs): routing · Decides how trade actions should be split or dispatched. · `src/routing.rs`
- [Execution layer](https://github.com/deskiziarecords/hyperion/blob/main/src/engine/execution.rs): execution · Turns routing decisions into broker-facing actions. · `src/engine/execution.rs`
- [Runtime state](https://github.com/deskiziarecords/hyperion/blob/main/src/engine/state.rs): state management · Maintains current position, order, and regime bookkeeping. · `src/engine/state.rs`

### Broker / Venue Adapters

Exchange-specific integration layer.

- [Broker hub](https://github.com/deskiziarecords/hyperion/blob/main/src/brokers/mod.rs): adapter hub · Shared module that exposes venue adapters. · `src/brokers/mod.rs`
- [Bitget](https://github.com/deskiziarecords/hyperion/blob/main/src/brokers/bitget.rs): venue adapter · Bitget exchange integration. · `src/brokers/bitget.rs`
- [Bybit](https://github.com/deskiziarecords/hyperion/blob/main/src/brokers/bybit.rs): venue adapter · Bybit exchange integration. · `src/brokers/bybit.rs`
- [MEXC](https://github.com/deskiziarecords/hyperion/blob/main/src/brokers/mexc.rs): venue adapter · MEXC exchange integration. · `src/brokers/mexc.rs`
- [OKX](https://github.com/deskiziarecords/hyperion/blob/main/src/brokers/okx.rs): venue adapter · OKX exchange integration. · `src/brokers/okx.rs`

### Python Research Layer

Prototype and analytical implementations outside the main Rust runtime.

- [Hybrid runner](https://github.com/deskiziarecords/hyperion/blob/main/main_hybrid.py): python entry · Python-side prototype or orchestration entrypoint. · `main_hybrid.py`
- [Research logic](https://github.com/deskiziarecords/hyperion/blob/main/logic/reverse_period_detector.py): analysis sandbox · Standalone Python implementations of related signal and detection ideas. · `logic/reverse_period_detector.py`

### Other components

- [Rust crate](https://github.com/deskiziarecords/hyperion/blob/main/src/lib.rs): crate entry · Primary Rust library and executable entrypoints. · `src/lib.rs`
- [Main entry](https://github.com/deskiziarecords/hyperion/blob/main/src/main.rs): binary entry · Rust executable entrypoint. · `src/main.rs`

## Connections

- Main entry → Rust crate: starts · Binary uses the shared Rust library.
- Rust crate → Shared types: shares model · Core modules depend on the shared market contract.
- Rust crate → Realtime feed: ingests · Library pulls live market data into the pipeline.
- Realtime feed → Candle builder: builds · Realtime events are aggregated into candles and frames.
- Candle builder → Hamiltonian engine: feeds · Constructed market frames drive regime analysis.
- Shared types → Hamiltonian engine: structures · Strategy state machine works over shared market types.
- Hamiltonian engine → IPDA logic: uses · Regime logic incorporates IPDA-style assumptions.
- Hamiltonian engine → Kill zones: filters · Session windows constrain actionable signals.
- Hamiltonian engine → UROL: consults · Liquidity heuristics inform signal quality.
- Hamiltonian engine → AECABI: augments · Additional analysis supports the core engine.
- Hamiltonian engine → Runtime state: updates · Strategy transitions are persisted into runtime state.
- Runtime state → Order router: guides · Current state influences order routing decisions.
- Order router → Execution layer: dispatches · Routing results are handed to execution.
- Execution layer → Broker hub: adapts to · Execution targets the broker integration layer.
- Broker hub → Bitget: includes · Broker hub exposes Bitget adapter.
- Broker hub → Bybit: includes · Broker hub exposes Bybit adapter.
- Broker hub → MEXC: includes · Broker hub exposes MEXC adapter.
- Broker hub → OKX: includes · Broker hub exposes OKX adapter.
- Hybrid runner → Research logic: runs with · Python entrypoint uses the research sandbox.
- Research logic → Hamiltonian engine: mirrors · Python logic prototypes similar analytical ideas.
