System Architecture

A look under the hood at how pQuant combines data pipelines, machine learning, and automated execution to go from raw market data to live trades.

How It Works

The system operates through three core phases: data pipeline, modeling, and signal execution. Each phase is designed for reliability, speed, and statistical rigor.

1. Data Pipeline

  • Pulls historical market data for multiple assets across various timeframes
  • Cleans, aligns, and resamples time series data
  • Handles gaps and outliers automatically
  • Generates feature sets combining classical indicators with experimental features

2. Modeling

  • Trains models using traditional statistics and ML techniques
  • Supports novel in-house feature engineering
  • Automatically runs backtests and walk-forward tests on model creation
  • Validates models against out-of-sample data

3. Signal to Trade

  • Models output trade direction with entry, stop-loss, and take-profit levels
  • Execution occurs on the closing tick to avoid intra-bar bias
  • Orders submitted within ~1 second of bar closing
  • Risk management with predefined targets

Architecture Diagrams

High-Level Design

flowchart TB subgraph DataLayer[Data Layer] Market[Live Market Data] --> Pipeline[Data Pipeline] Historical[Historical Data] --> Pipeline Pipeline --> Features[Feature Engineering] end subgraph ModelLayer[Model Layer] Features --> Training[Model Training] Training --> Validation[Backtesting & Walk-Forward] Validation --> Models[(Model Store)] end subgraph ExecutionLayer[Execution Layer] Models --> Scorer[Signal Scorer] LiveCandles[Live OHLC Candles] --> Scorer Scorer --> Signals[Trade Signals] Signals --> RiskMgmt[Risk Management] RiskMgmt --> Broker[Broker API] end Broker --> Orders[Order Execution
~1 second latency] classDef data fill:#1e2433,stroke:#3b82f6,color:#e4e6eb,stroke-width:2px classDef model fill:#141925,stroke:#10b981,color:#e4e6eb,stroke-width:2px classDef exec fill:#0a0e1a,stroke:#f59e0b,color:#e4e6eb,stroke-width:2px class Market,Historical,Pipeline,Features data class Training,Validation,Models model class Scorer,LiveCandles,Signals,RiskMgmt,Broker,Orders exec

Trading Bot Workflow

sequenceDiagram autonumber participant Market as Market Feed participant Bot as Trading Bot participant Model as ML/Stats Model participant Risk as Risk Manager participant Broker as Broker API loop Every Candle Close Market->>Bot: New OHLC Candle Bot->>Bot: Transform to Features Bot->>Model: Score Features Model-->>Bot: Entry/Stop/Target Bot->>Risk: Validate Signal Risk-->>Bot: Approved/Rejected opt Signal Approved Bot->>Broker: Submit Order Note over Broker: ~1 second from
candle close Broker-->>Bot: Order Confirmation end end

Model Lifecycle

stateDiagram-v2 [*] --> DataCollection: Pull Historical Data DataCollection --> FeatureGen: Generate Features FeatureGen --> Training: Train Model Training --> Backtest: Run Backtest Backtest --> WalkForward: Walk-Forward Test WalkForward --> Evaluation: Evaluate Performance Evaluation --> Deployment: Above Threshold Evaluation --> Discard: Below Threshold Deployment --> LiveTrading: Deploy to Production LiveTrading --> Monitor: Monitor Performance Monitor --> EdgeDecay: Detect Edge Decay EdgeDecay --> RefreshModel: One-Click Refresh RefreshModel --> DataCollection: Fresh Data Discard --> [*] note right of EdgeDecay Models show strong initial edge that decays over time as market conditions change end note note right of RefreshModel Automated model regeneration with fresh data via UI control end note

Agent Control Surface

flowchart LR Agent[LLM Agent Team] --> API[Trading System API] API --> BotMgmt[Bot Management] API --> ModelOps[Model Operations] API --> Feature[Feature Engineering] API --> Experiment[Experiment Results] BotMgmt --> BotActions[Spin Up/Decommission Bots] ModelOps --> ModelActions[Create/Refresh Cycles] Feature --> FeatureActions[Feature Selection
Hyperparameter Sweeps] Experiment --> ExpActions[Summarize Results] classDef agent fill:#8b5cf6,stroke:#a78bfa,color:#e4e6eb,stroke-width:2px classDef api fill:#1e2433,stroke:#3b82f6,color:#e4e6eb,stroke-width:2px classDef action fill:#141925,stroke:#10b981,color:#e4e6eb,stroke-width:1px class Agent agent class API,BotMgmt,ModelOps,Feature,Experiment api class BotActions,ModelActions,FeatureActions,ExpActions action

Technical Notes

Execution Latency: The system achieves order submission within ~1 second of candle close, ensuring minimal slippage while avoiding intra-bar look-ahead bias.
Feature Engineering: Combines classical technical indicators with proprietary experimental features that have shown statistically significant predictive power in testing.
Model Store: Maintains versioned models with full metadata including training parameters, validation metrics, and deployment history for reproducibility and audit trails.

Glossary

Backtest
Evaluate a strategy on historical data with no look-ahead bias. Tests how the strategy would have performed if traded in the past.
Walk-Forward Test
Train on a window of data, test on the next out-of-sample period, then roll forward. Provides a more realistic assessment of model performance.
Break-Even Win Rate
The win rate implied by a strategy's risk-reward ratio (ignoring fees and slippage). As fees/slippage increase, the required win rate to be profitable increases.
Edge Decay
The phenomenon where a trading model's performance deteriorates over time as market conditions change or other participants discover and arbitrage away the inefficiency.
OHLC
Open, High, Low, Close — the four main data points that define a price candle in financial markets.
MES / M2K
Micro E-mini S&P 500 and Micro E-mini Russell 2000 futures contracts — smaller versions of standard futures contracts suitable for testing strategies with lower capital requirements.