# s583381747/nq-quant architecture

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

- Interactive diagram: https://gitdiagram.com/s583381747/nq-quant
- Repository: https://github.com/s583381747/nq-quant

## Overview

NQ Quant is a quantitative trading system for Nasdaq futures. Its documented production workflow detects trade zones from completed 5-minute bars, then executes and manages trades bar-by-bar on 1-minute data, producing trade outcomes for analysis. The feature layer supplies market structure, FVG, session, and bias calculations; a separate ML/backtest workflow trains and evaluates alternative signals. NinjaTrader has a documented port of the production engine. Several subsystem links below come from README or SOURCE INDEX references; unsampled implementation details are not inferred.

Main entry points: [`experiments/unified_engine_1m.py`](https://github.com/s583381747/nq-quant/blob/master/experiments/unified_engine_1m.py) (1m hybrid engine), [`models/train_xgb.py`](https://github.com/s583381747/nq-quant/blob/master/models/train_xgb.py) (Model training), [`features/fvg.py`](https://github.com/s583381747/nq-quant/blob/master/features/fvg.py) (FVG detection), [`experiments/chain_engine.py`](https://github.com/s583381747/nq-quant/blob/master/experiments/chain_engine.py) (Chain zones)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_market_features["Market features"]
  node_market_data[("Market data")]
  node_sessions["Sessions and levels<br/>[sessions.py]"]
  node_fvg["FVG detection<br/>[fvg.py]"]
  node_displacement["Displacement<br/>[displacement.py]"]
  node_swings["Swing points<br/>[swing.py]"]
  node_bias["Bias and regime<br/>[bias.py]"]
  node_entry_signals["Entry signals<br/>[entry_signals.py]"]
  node_pa_quality["PA quality<br/>[pa_quality.py]"]
  node_news_filter["News filter<br/>[news_filter.py]"]
end

subgraph group_trading_runtime["Trading runtime"]
  node_chain_engine["Chain zones<br/>[chain_engine.py]"]
  node_live_engine["1m hybrid engine"]
  node_bar_engine["Bar-by-bar engine"]
  node_backtest_engine["Backtest execution<br/>[engine.py]"]
  node_reporting["Trade reporting<br/>[report.py]"]
end

subgraph group_research_ml["Research and ML"]
  node_pipeline["V2 pipeline<br/>[run_v2_pipeline.py]"]
  node_model_training["Model training<br/>[train_xgb.py]"]
  node_model_evaluation["Model evaluation<br/>[evaluate.py]"]
  node_research["Strategy research"]
end

subgraph group_platforms["Trading platforms"]
  node_nt8_hybrid["NinjaTrader port<br/>[HybridEngine1m.cs]"]
end

node_market_actor(("Market data provider"))
node_operator(("Trader or analyst"))

node_market_actor -.->|"provides bars"| node_market_data
node_market_data -.->|"feeds execution"| node_live_engine
node_live_engine -->|"uses chain logic"| node_chain_engine
node_chain_engine -->|"detects gaps"| node_fvg
node_chain_engine -->|"checks displacement"| node_displacement
node_chain_engine -->|"checks structure"| node_swings
node_chain_engine -->|"filters entries"| node_news_filter
node_live_engine -->|"builds session levels"| node_sessions
node_live_engine -->|"computes bias"| node_bias
node_live_engine -->|"detects zones"| node_fvg
node_live_engine -->|"computes fluency"| node_displacement
node_live_engine -->|"tracks swings"| node_swings
node_live_engine -->|"blocks entries"| node_news_filter
node_operator -->|"runs pipeline"| node_pipeline
node_pipeline -->|"trains model"| node_model_training
node_pipeline -->|"evaluates model"| node_model_evaluation
node_pipeline -->|"backtests signals"| node_backtest_engine
node_pipeline -->|"generates report"| node_reporting
node_model_training -->|"builds candidates"| node_entry_signals
node_model_training -->|"adds bias features"| node_bias
node_model_training -->|"adds quality features"| node_pa_quality
node_model_training -->|"uses gap features"| node_fvg
node_model_training -->|"uses session features"| node_sessions
node_entry_signals -->|"tracks gaps"| node_fvg
node_entry_signals -->|"checks displacement"| node_displacement
node_pa_quality -->|"uses gap context"| node_fvg
node_bias -->|"uses gap context"| node_fvg
node_bias -->|"uses fluency"| node_displacement
node_bias -->|"uses session levels"| node_sessions
node_operator -.->|"explores strategies"| node_research
node_nt8_hybrid -->|"ports chain logic"| node_chain_engine
node_nt8_hybrid -->|"ports bias logic"| node_bias
node_nt8_hybrid -->|"ports gap logic"| node_fvg
node_nt8_hybrid -->|"ports session logic"| node_sessions
node_nt8_hybrid -->|"ports news filter"| node_news_filter

click node_market_data "https://github.com/s583381747/nq-quant/tree/master/data"
click node_sessions "https://github.com/s583381747/nq-quant/blob/master/features/sessions.py"
click node_fvg "https://github.com/s583381747/nq-quant/blob/master/features/fvg.py"
click node_displacement "https://github.com/s583381747/nq-quant/blob/master/features/displacement.py"
click node_swings "https://github.com/s583381747/nq-quant/blob/master/features/swing.py"
click node_bias "https://github.com/s583381747/nq-quant/blob/master/features/bias.py"
click node_entry_signals "https://github.com/s583381747/nq-quant/blob/master/features/entry_signals.py"
click node_pa_quality "https://github.com/s583381747/nq-quant/blob/master/features/pa_quality.py"
click node_news_filter "https://github.com/s583381747/nq-quant/blob/master/features/news_filter.py"
click node_chain_engine "https://github.com/s583381747/nq-quant/blob/master/experiments/chain_engine.py"
click node_live_engine "https://github.com/s583381747/nq-quant/blob/master/experiments/unified_engine_1m.py"
click node_bar_engine "https://github.com/s583381747/nq-quant/blob/master/ninjatrader/bar_by_bar_engine.py"
click node_backtest_engine "https://github.com/s583381747/nq-quant/blob/master/backtest/engine.py"
click node_reporting "https://github.com/s583381747/nq-quant/blob/master/backtest/report.py"
click node_pipeline "https://github.com/s583381747/nq-quant/blob/master/run_v2_pipeline.py"
click node_model_training "https://github.com/s583381747/nq-quant/blob/master/models/train_xgb.py"
click node_model_evaluation "https://github.com/s583381747/nq-quant/blob/master/models/evaluate.py"
click node_research "https://github.com/s583381747/nq-quant/tree/master/experiments"
click node_nt8_hybrid "https://github.com/s583381747/nq-quant/blob/master/ninjatrader/HybridEngine1m.cs"

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_market_data,node_sessions,node_fvg,node_displacement,node_swings,node_bias,node_entry_signals,node_pa_quality,node_news_filter toneBlue
class node_chain_engine,node_live_engine,node_bar_engine,node_backtest_engine,node_reporting toneAmber
class node_pipeline,node_model_training,node_model_evaluation,node_research toneMint
class node_nt8_hybrid toneRose
class node_market_actor,node_operator toneIndigo
```

## Components

### Market features

- [Market data](https://github.com/s583381747/nq-quant/tree/master/data): `data`
- [Sessions and levels](https://github.com/s583381747/nq-quant/blob/master/features/sessions.py): `features/sessions.py`
- [FVG detection](https://github.com/s583381747/nq-quant/blob/master/features/fvg.py): `features/fvg.py`
- [Displacement](https://github.com/s583381747/nq-quant/blob/master/features/displacement.py): `features/displacement.py`
- [Swing points](https://github.com/s583381747/nq-quant/blob/master/features/swing.py): `features/swing.py`
- [Bias and regime](https://github.com/s583381747/nq-quant/blob/master/features/bias.py): `features/bias.py`
- [Entry signals](https://github.com/s583381747/nq-quant/blob/master/features/entry_signals.py): `features/entry_signals.py`
- [PA quality](https://github.com/s583381747/nq-quant/blob/master/features/pa_quality.py): `features/pa_quality.py`
- [News filter](https://github.com/s583381747/nq-quant/blob/master/features/news_filter.py): `features/news_filter.py`

### Trading runtime

- [Chain zones](https://github.com/s583381747/nq-quant/blob/master/experiments/chain_engine.py): `experiments/chain_engine.py`
- [1m hybrid engine](https://github.com/s583381747/nq-quant/blob/master/experiments/unified_engine_1m.py): `experiments/unified_engine_1m.py`
- [Bar-by-bar engine](https://github.com/s583381747/nq-quant/blob/master/ninjatrader/bar_by_bar_engine.py): `ninjatrader/bar_by_bar_engine.py`
- [Backtest execution](https://github.com/s583381747/nq-quant/blob/master/backtest/engine.py): `backtest/engine.py`
- [Trade reporting](https://github.com/s583381747/nq-quant/blob/master/backtest/report.py): `backtest/report.py`

### Research and ML

- [V2 pipeline](https://github.com/s583381747/nq-quant/blob/master/run_v2_pipeline.py): `run_v2_pipeline.py`
- [Model training](https://github.com/s583381747/nq-quant/blob/master/models/train_xgb.py): `models/train_xgb.py`
- [Model evaluation](https://github.com/s583381747/nq-quant/blob/master/models/evaluate.py): `models/evaluate.py`
- [Strategy research](https://github.com/s583381747/nq-quant/tree/master/experiments): `experiments`

### Trading platforms

- [NinjaTrader port](https://github.com/s583381747/nq-quant/blob/master/ninjatrader/HybridEngine1m.cs): `ninjatrader/HybridEngine1m.cs`

### Other components

- **Market data provider**
- **Trader or analyst**

## Connections

- Market data provider → Market data: provides bars
- Market data → 1m hybrid engine: feeds execution
- 1m hybrid engine → Chain zones: uses chain logic (evidence: `experiments/unified_engine_1m.py`)
- Chain zones → FVG detection: detects gaps (evidence: `experiments/chain_engine.py`)
- Chain zones → Displacement: checks displacement (evidence: `experiments/chain_engine.py`)
- Chain zones → Swing points: checks structure (evidence: `experiments/chain_engine.py`)
- Chain zones → News filter: filters entries (evidence: `experiments/chain_engine.py`)
- 1m hybrid engine → Sessions and levels: builds session levels (evidence: `README.md`)
- 1m hybrid engine → Bias and regime: computes bias (evidence: `README.md`)
- 1m hybrid engine → FVG detection: detects zones (evidence: `README.md`)
- 1m hybrid engine → Displacement: computes fluency (evidence: `README.md`)
- 1m hybrid engine → Swing points: tracks swings (evidence: `README.md`)
- 1m hybrid engine → News filter: blocks entries (evidence: `README.md`)
- Trader or analyst → V2 pipeline: runs pipeline (evidence: `README.md`)
- V2 pipeline → Model training: trains model (evidence: `run_v2_pipeline.py`)
- V2 pipeline → Model evaluation: evaluates model (evidence: `run_v2_pipeline.py`)
- V2 pipeline → Backtest execution: backtests signals (evidence: `run_v2_pipeline.py`)
- V2 pipeline → Trade reporting: generates report (evidence: `run_v2_pipeline.py`)
- Model training → Entry signals: builds candidates (evidence: `models/train_xgb.py`)
- Model training → Bias and regime: adds bias features (evidence: `models/train_xgb.py`)
- Model training → PA quality: adds quality features (evidence: `models/train_xgb.py`)
- Model training → FVG detection: uses gap features (evidence: `models/train_xgb.py`)
- Model training → Sessions and levels: uses session features (evidence: `models/train_xgb.py`)
- Entry signals → FVG detection: tracks gaps (evidence: `features/entry_signals.py`)
- Entry signals → Displacement: checks displacement (evidence: `features/entry_signals.py`)
- PA quality → FVG detection: uses gap context (evidence: `features/pa_quality.py`)
- Bias and regime → FVG detection: uses gap context (evidence: `features/bias.py`)
- Bias and regime → Displacement: uses fluency (evidence: `features/bias.py`)
- Bias and regime → Sessions and levels: uses session levels (evidence: `features/bias.py`)
- Trader or analyst → Strategy research: explores strategies
- NinjaTrader port → Chain zones: ports chain logic (evidence: `README.md`)
- NinjaTrader port → Bias and regime: ports bias logic (evidence: `README.md`)
- NinjaTrader port → FVG detection: ports gap logic (evidence: `README.md`)
- NinjaTrader port → Sessions and levels: ports session logic (evidence: `README.md`)
- NinjaTrader port → News filter: ports news filter (evidence: `README.md`)
