# purushothamanshanmugam/ai_hft_simulator architecture

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

## Overview

HFT AI Simulator is a multi-asset trading research platform: its documented workflow prepares market data, trains five model types, runs agents against test data, and reports portfolio and risk results. The tree also shows live-feed, sentiment/alpha, regime, dashboard, and exchange-execution capabilities. Some README-described data modules are absent from the supplied tree, so they are not assigned invented paths; connections for unsampled execution internals are omitted.

Main entry points: [`main.py`](https://github.com/purushothamanshanmugam/ai_hft_simulator/blob/main/main.py) (Pipeline Entry), [`src/simulation/multi_agent_sim.py`](https://github.com/purushothamanshanmugam/ai_hft_simulator/blob/main/src/simulation/multi_agent_sim.py) (Agent Simulation), [`src/dashboard/dashboard.py`](https://github.com/purushothamanshanmugam/ai_hft_simulator/blob/main/src/dashboard/dashboard.py) (Trading Dashboard), [`src/execution/matching_engine.py`](https://github.com/purushothamanshanmugam/ai_hft_simulator/blob/main/src/execution/matching_engine.py) (Matching Engine)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_research["Model Research"]
  node_entry["Pipeline Entry<br/>[main.py]"]
  node_dqn["DQN Trainer<br/>[train_dqn.py]"]
  node_ppo["PPO Trainer<br/>[train_ppo.py]"]
  node_lstm["LSTM Trainer<br/>[train_lstm.py]"]
  node_xgboost["XGBoost Trainer<br/>[train_xgboost.py]"]
  node_transformer["Transformer Trainer"]
end

subgraph group_simulation["Trading Simulation"]
  node_environment["Multi-Asset Environment<br/>[multi_asset_env.py]"]
  node_simulator["Agent Simulation<br/>[multi_agent_sim.py]"]
end

subgraph group_signals["Live Signals"]
  node_liveprocessor["Live Data Processor"]
  node_producer["Kafka Producer<br/>[kafka_producer.py]"]
  node_consumer["Kafka Consumer<br/>[kafka_consumer.py]"]
  node_fetcher["News Fetcher<br/>[news_fetcher.py]"]
  node_sentiment["FinBERT Sentiment"]
  node_sentimentfeatures["Sentiment Features"]
  node_sentimentprovider["Live Sentiment"]
  node_aggregator["Sentiment Aggregator"]
  node_alphasignal["Alpha Signal<br/>[alpha_signal.py]"]
  node_alphaengine["Alpha Scoring<br/>[alpha_engine.py]"]
  node_regime["Regime Detector<br/>[regime_detector.py]"]
end

subgraph group_execution["Exchange Execution"]
  node_matching["Matching Engine<br/>[matching_engine.py]"]
  node_bookengine["Order Book Engine"]
  node_orderbook[("Order Book<br/>[order_book.py]")]
  node_order["Order Model<br/>[order.py]"]
  node_latency["Latency Model<br/>[latency_model.py]"]
end

subgraph group_monitoring["Monitoring"]
  node_risk["Risk Metrics<br/>[risk_metrics.py]"]
  node_dashboard["Trading Dashboard<br/>[dashboard.py]"]
end

node_operator(("Researcher / Operator"))

node_operator -->|"runs"| node_entry
node_entry -->|"trains"| node_dqn
node_entry -->|"trains"| node_ppo
node_entry -->|"trains"| node_lstm
node_entry -->|"trains"| node_xgboost
node_entry -->|"trains"| node_transformer
node_entry -->|"runs"| node_simulator
node_dqn -->|"trains in"| node_environment
node_ppo -->|"trains in"| node_environment
node_simulator -->|"simulates in"| node_environment
node_simulator -->|"loads model"| node_lstm
node_simulator -->|"loads model"| node_xgboost
node_simulator -->|"loads model"| node_transformer
node_simulator -->|"calculates metrics"| node_risk
node_operator -.->|"views results"| node_dashboard
node_dashboard -->|"uses"| node_liveprocessor
node_dashboard -->|"uses"| node_consumer
node_dashboard -->|"uses"| node_alphasignal
node_dashboard -->|"uses"| node_lstm
node_dashboard -->|"uses"| node_transformer
node_sentimentfeatures -->|"fetches news"| node_fetcher
node_sentimentfeatures -->|"scores text"| node_sentiment
node_alphasignal -->|"scores signal"| node_alphaengine
node_alphasignal -->|"detects regime"| node_regime
node_producer -.->|"streams ticks"| node_consumer
node_matching -.->|"matches against"| node_orderbook
node_bookengine -.->|"uses book"| node_orderbook
node_matching -.->|"processes orders"| node_order
node_matching -.->|"models latency"| node_latency

click node_entry "https://github.com/purushothamanshanmugam/ai_hft_simulator/blob/main/main.py"
click node_dqn "https://github.com/purushothamanshanmugam/ai_hft_simulator/blob/main/src/models/train_dqn.py"
click node_ppo "https://github.com/purushothamanshanmugam/ai_hft_simulator/blob/main/src/models/train_ppo.py"
click node_lstm "https://github.com/purushothamanshanmugam/ai_hft_simulator/blob/main/src/models/train_lstm.py"
click node_xgboost "https://github.com/purushothamanshanmugam/ai_hft_simulator/blob/main/src/models/train_xgboost.py"
click node_transformer "https://github.com/purushothamanshanmugam/ai_hft_simulator/blob/main/src/models/train_transformer.py"
click node_environment "https://github.com/purushothamanshanmugam/ai_hft_simulator/blob/main/src/envs/multi_asset_env.py"
click node_simulator "https://github.com/purushothamanshanmugam/ai_hft_simulator/blob/main/src/simulation/multi_agent_sim.py"
click node_risk "https://github.com/purushothamanshanmugam/ai_hft_simulator/blob/main/src/analytics/risk_metrics.py"
click node_dashboard "https://github.com/purushothamanshanmugam/ai_hft_simulator/blob/main/src/dashboard/dashboard.py"
click node_liveprocessor "https://github.com/purushothamanshanmugam/ai_hft_simulator/blob/main/src/live/live_data_processor.py"
click node_producer "https://github.com/purushothamanshanmugam/ai_hft_simulator/blob/main/kafka_producer.py"
click node_consumer "https://github.com/purushothamanshanmugam/ai_hft_simulator/blob/main/kafka_consumer.py"
click node_fetcher "https://github.com/purushothamanshanmugam/ai_hft_simulator/blob/main/src/news/news_fetcher.py"
click node_sentiment "https://github.com/purushothamanshanmugam/ai_hft_simulator/blob/main/src/news/sentiment_engine.py"
click node_sentimentfeatures "https://github.com/purushothamanshanmugam/ai_hft_simulator/blob/main/src/news/build_sentiment_features.py"
click node_sentimentprovider "https://github.com/purushothamanshanmugam/ai_hft_simulator/blob/main/src/news/live_sentiment_provider.py"
click node_aggregator "https://github.com/purushothamanshanmugam/ai_hft_simulator/blob/main/src/news/sentiment_aggregator.py"
click node_alphasignal "https://github.com/purushothamanshanmugam/ai_hft_simulator/blob/main/src/alpha/alpha_signal.py"
click node_alphaengine "https://github.com/purushothamanshanmugam/ai_hft_simulator/blob/main/src/alpha/alpha_engine.py"
click node_regime "https://github.com/purushothamanshanmugam/ai_hft_simulator/blob/main/src/regime/regime_detector.py"
click node_matching "https://github.com/purushothamanshanmugam/ai_hft_simulator/blob/main/src/execution/matching_engine.py"
click node_bookengine "https://github.com/purushothamanshanmugam/ai_hft_simulator/blob/main/src/execution/order_book_engine.py"
click node_orderbook "https://github.com/purushothamanshanmugam/ai_hft_simulator/blob/main/src/execution/order_book.py"
click node_order "https://github.com/purushothamanshanmugam/ai_hft_simulator/blob/main/src/execution/order.py"
click node_latency "https://github.com/purushothamanshanmugam/ai_hft_simulator/blob/main/src/execution/latency_model.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_entry,node_dqn,node_ppo,node_lstm,node_xgboost,node_transformer toneBlue
class node_environment,node_simulator toneAmber
class node_liveprocessor,node_producer,node_consumer,node_fetcher,node_sentiment,node_sentimentfeatures,node_sentimentprovider,node_aggregator,node_alphasignal,node_alphaengine,node_regime toneMint
class node_matching,node_bookengine,node_orderbook,node_order,node_latency toneRose
class node_risk,node_dashboard,node_operator toneIndigo
```

## Components

### Model Research

- [Pipeline Entry](https://github.com/purushothamanshanmugam/ai_hft_simulator/blob/main/main.py): `main.py`
- [DQN Trainer](https://github.com/purushothamanshanmugam/ai_hft_simulator/blob/main/src/models/train_dqn.py): `src/models/train_dqn.py`
- [PPO Trainer](https://github.com/purushothamanshanmugam/ai_hft_simulator/blob/main/src/models/train_ppo.py): `src/models/train_ppo.py`
- [LSTM Trainer](https://github.com/purushothamanshanmugam/ai_hft_simulator/blob/main/src/models/train_lstm.py): `src/models/train_lstm.py`
- [XGBoost Trainer](https://github.com/purushothamanshanmugam/ai_hft_simulator/blob/main/src/models/train_xgboost.py): `src/models/train_xgboost.py`
- [Transformer Trainer](https://github.com/purushothamanshanmugam/ai_hft_simulator/blob/main/src/models/train_transformer.py): `src/models/train_transformer.py`

### Trading Simulation

- [Multi-Asset Environment](https://github.com/purushothamanshanmugam/ai_hft_simulator/blob/main/src/envs/multi_asset_env.py): `src/envs/multi_asset_env.py`
- [Agent Simulation](https://github.com/purushothamanshanmugam/ai_hft_simulator/blob/main/src/simulation/multi_agent_sim.py): `src/simulation/multi_agent_sim.py`

### Live Signals

- [Live Data Processor](https://github.com/purushothamanshanmugam/ai_hft_simulator/blob/main/src/live/live_data_processor.py): `src/live/live_data_processor.py`
- [Kafka Producer](https://github.com/purushothamanshanmugam/ai_hft_simulator/blob/main/kafka_producer.py): `kafka_producer.py`
- [Kafka Consumer](https://github.com/purushothamanshanmugam/ai_hft_simulator/blob/main/kafka_consumer.py): `kafka_consumer.py`
- [News Fetcher](https://github.com/purushothamanshanmugam/ai_hft_simulator/blob/main/src/news/news_fetcher.py): `src/news/news_fetcher.py`
- [FinBERT Sentiment](https://github.com/purushothamanshanmugam/ai_hft_simulator/blob/main/src/news/sentiment_engine.py): `src/news/sentiment_engine.py`
- [Sentiment Features](https://github.com/purushothamanshanmugam/ai_hft_simulator/blob/main/src/news/build_sentiment_features.py): `src/news/build_sentiment_features.py`
- [Live Sentiment](https://github.com/purushothamanshanmugam/ai_hft_simulator/blob/main/src/news/live_sentiment_provider.py): `src/news/live_sentiment_provider.py`
- [Sentiment Aggregator](https://github.com/purushothamanshanmugam/ai_hft_simulator/blob/main/src/news/sentiment_aggregator.py): `src/news/sentiment_aggregator.py`
- [Alpha Signal](https://github.com/purushothamanshanmugam/ai_hft_simulator/blob/main/src/alpha/alpha_signal.py): `src/alpha/alpha_signal.py`
- [Alpha Scoring](https://github.com/purushothamanshanmugam/ai_hft_simulator/blob/main/src/alpha/alpha_engine.py): `src/alpha/alpha_engine.py`
- [Regime Detector](https://github.com/purushothamanshanmugam/ai_hft_simulator/blob/main/src/regime/regime_detector.py): `src/regime/regime_detector.py`

### Exchange Execution

- [Matching Engine](https://github.com/purushothamanshanmugam/ai_hft_simulator/blob/main/src/execution/matching_engine.py): `src/execution/matching_engine.py`
- [Order Book Engine](https://github.com/purushothamanshanmugam/ai_hft_simulator/blob/main/src/execution/order_book_engine.py): `src/execution/order_book_engine.py`
- [Order Book](https://github.com/purushothamanshanmugam/ai_hft_simulator/blob/main/src/execution/order_book.py): `src/execution/order_book.py`
- [Order Model](https://github.com/purushothamanshanmugam/ai_hft_simulator/blob/main/src/execution/order.py): `src/execution/order.py`
- [Latency Model](https://github.com/purushothamanshanmugam/ai_hft_simulator/blob/main/src/execution/latency_model.py): `src/execution/latency_model.py`

### Monitoring

- [Risk Metrics](https://github.com/purushothamanshanmugam/ai_hft_simulator/blob/main/src/analytics/risk_metrics.py): `src/analytics/risk_metrics.py`
- [Trading Dashboard](https://github.com/purushothamanshanmugam/ai_hft_simulator/blob/main/src/dashboard/dashboard.py): `src/dashboard/dashboard.py`

### Other components

- **Researcher / Operator**

## Connections

- Researcher / Operator → Pipeline Entry: runs (evidence: `main.py`)
- Pipeline Entry → DQN Trainer: trains (evidence: `main.py`)
- Pipeline Entry → PPO Trainer: trains (evidence: `main.py`)
- Pipeline Entry → LSTM Trainer: trains (evidence: `main.py`)
- Pipeline Entry → XGBoost Trainer: trains (evidence: `main.py`)
- Pipeline Entry → Transformer Trainer: trains (evidence: `main.py`)
- Pipeline Entry → Agent Simulation: runs (evidence: `main.py`)
- DQN Trainer → Multi-Asset Environment: trains in (evidence: `src/models/train_dqn.py`)
- PPO Trainer → Multi-Asset Environment: trains in (evidence: `src/models/train_ppo.py`)
- Agent Simulation → Multi-Asset Environment: simulates in (evidence: `src/simulation/multi_agent_sim.py`)
- Agent Simulation → LSTM Trainer: loads model (evidence: `src/simulation/multi_agent_sim.py`)
- Agent Simulation → XGBoost Trainer: loads model (evidence: `src/simulation/multi_agent_sim.py`)
- Agent Simulation → Transformer Trainer: loads model (evidence: `src/simulation/multi_agent_sim.py`)
- Agent Simulation → Risk Metrics: calculates metrics (evidence: `src/simulation/multi_agent_sim.py`)
- Researcher / Operator → Trading Dashboard: views results (evidence: `README.md`)
- Trading Dashboard → Live Data Processor: uses (evidence: `src/dashboard/dashboard.py`)
- Trading Dashboard → Kafka Consumer: uses (evidence: `src/dashboard/dashboard.py`)
- Trading Dashboard → Alpha Signal: uses (evidence: `src/dashboard/dashboard.py`)
- Trading Dashboard → LSTM Trainer: uses (evidence: `src/dashboard/dashboard.py`)
- Trading Dashboard → Transformer Trainer: uses (evidence: `src/dashboard/dashboard.py`)
- Sentiment Features → News Fetcher: fetches news (evidence: `src/news/build_sentiment_features.py`)
- Sentiment Features → FinBERT Sentiment: scores text (evidence: `src/news/build_sentiment_features.py`)
- Alpha Signal → Alpha Scoring: scores signal (evidence: `src/alpha/alpha_signal.py`)
- Alpha Signal → Regime Detector: detects regime (evidence: `src/alpha/alpha_signal.py`)
- Kafka Producer → Kafka Consumer: streams ticks (evidence: `README.md`)
- Matching Engine → Order Book: matches against (evidence: `README.md`)
- Order Book Engine → Order Book: uses book (evidence: `README.md`)
- Matching Engine → Order Model: processes orders (evidence: `README.md`)
- Matching Engine → Latency Model: models latency (evidence: `README.md`)
