← Home

Architecture Deep Dive

Layer 0 Strategy Qualification Engine

Offline Backtesting Sandbox — The Gatekeeper of Strategy Quality

Philosophy

No strategy touches live market data until it proves a mathematical edge. This layer operates entirely offline, acting as a rigorous scientific testing ground. The system treats each strategy as a hypothesis that must be validated through statistical evidence.

How It Works

Promotion Criteria

Output

Strategies marked PROMOTED are inserted into the Dim_Strategy_Registry SQL table. Rejected strategies are logged with reasons for future research.

Key File

src/research/layer0_multi_asset_evaluator.py

Layer 1 Market Regime Detection

The Weather Report — Dynamic Market State Classification

Philosophy

Markets behave differently in different conditions. A trend-following strategy that thrives in strong trends will bleed in a sideways market. Layer 1 independently classifies the "weather" for each asset so downstream layers can make informed decisions.

Algorithm

Regime Labels

RegimeATRADXMarket Condition
Trending_HighVolHighHighStrong directional moves with large candles
Trending_LowVolLowHighSteady trends with small-bodied candles
Ranging_HighVolHighLowChoppy, volatile, no clear direction
Ranging_LowVolLowLowQuiet, tight-range consolidation

Data Pipeline

ingest_regimes.py fetches 10,000+ hours of H1 data per asset, applies K-Means clustering, and writes regime labels to the Fact_Market_Regime SQL table with timestamps, ATR, and ADX values.

Key Files

src/layer1_regime/regime_clustering.py | src/layer1_regime/ingest_regimes.py

Layer 2 Live Strategy Bank

Signal Generators — Continuous Market Scanning

Philosophy

Promoted strategies from Layer 0 run continuously on live market data. They scan for entry conditions and emit raw signals. Critically, these signals are never sent directly to the broker—they must pass through the AI Gatekeeper first.

Process

Active Strategies

StrategyTypeEntry Logic
Trend_EMA_ADXTrend50/200 EMA crossover + ADX > 25
Range_BollingerRangeBollinger Band reversion + RSI < 30
Trend_DonchianTrend20-period Donchian channel breakout
Range_StochasticRangeStochastic oversold bounce

Layer 3 ML Meta-Labeler

The AI Gatekeeper — Contextual Signal Filtering

Philosophy

The ML model does not predict price. It evaluates the historical probability of a specific strategy succeeding in the current market regime. This is meta-labeling: the model labels the quality of the signal, not the direction of the market.

Model Specifications

ParameterValue
AlgorithmXGBoost (multi:softprob)
ClassesBUY (1), HOLD (0), SELL (-1)
Boosting Rounds300
Max Depth4 (shallow to prevent overfitting)
Learning Rate0.05 (conservative)
Subsample0.8
Train/Test Split70/30 chronological
Confidence Threshold0.75

Feature Set

Labeling Method

24-hour lookahead determines if a trade would hit 2x ATR profit before 1x ATR loss. This creates a strict 1:2 R/R ground truth for training.

Key Files

archieved/src/ml/feature_engineering.py | archieved/src/ml/train_xgboost.py

Layer 4 & 4.5 Dynamic Risk & Portfolio Correlation

The Shield — Trade & Portfolio Risk Management

Layer 4: Trade-Level Risk

Layer 4.5: Portfolio Correlation Guard

Example: EUR/USD BUY signal approved by Layer 3 → Layer 4.5 checks portfolio → GBP/USD BUY already open (high USD correlation) → EUR/USD trade BLOCKED to prevent hidden leverage

Layer 5 Telemetry & Visualization

The Dashboard — Human Oversight & Auditing

Purpose

Provides real-time visibility into every layer of the system. Designed for human oversight, not automation.

Planned Features

Technology

Python Streamlit for rapid iteration, with Power BI as a reporting companion.

Database Schema

SQL Server with ODBC v17 Driver

Dimension Tables

TablePurpose
Dim_AssetSymbol registry (EUR_USD, GBP_USD, USD_JPY)
Dim_Market_RegimeRegime definitions and volatility indices
Dim_Strategy_RegistryPromoted strategy names and logic descriptions
Dim_Indicator_LibraryTechnical indicator catalog
Dim_Model_MetadataML model versions and training metadata

Fact Tables

TablePurpose
Fact_Market_PricesOHLCV candles (H1 granularity)
Fact_Indicator_ValuesPre-calculated indicator values
Fact_SignalsRaw signals with confidence scores
Fact_Trade_ResultsExecuted trades with P&L
Fact_Market_RegimeRegime classifications per asset per timestamp