A high-performance algorithmic trading and execution framework engineered for CME equities and commodity futures (ES, MES, NQ, MNQ, CL, GC, YM). Features automated continuous contract rollover management, real-time order flow footprint analytics (CVD), multi-timeframe Anchored VWAP standard deviation bands, and institutional bracket order execution via Interactive Brokers (IBKR).
┌────────────────────────────────────────────────────────────────────────────────┐
│ ⚡ QuantFutures Terminal — Real-Time CME Institutional Order Router │
│ Active Contracts: ES, NQ, MES, MNQ, CL, GC, YM | Gateway: Port 7497 / 7496 │
├────────────────────────────────────────────────────────────────────────────────┤
│ 📅 Continuous Contract: Front Month Active (ESZ6 | Rollover Protocol: ARMED) │
│ 🔬 Order Flow: Net CVD +2,400 contracts (BULLISH_AGGRESSION | VPOC: $5862.50) │
│ 📊 Anchored VWAP: $5860.49 (+2 Sigma: $5868.93 | -2 Sigma: $5852.05) │
│ 🛡️ Bracket Execution: 2x ES BUY @ $5865.00 (Risk: $400.00 | Target: $800.00)│
└────────────────────────────────────────────────────────────────────────────────┘
I build low-latency futures trading software, multi-timeframe VWAP engines, CME execution routers, and institutional risk systems.
- 💬 Telegram: @JanzebBlockdev
- 💼 Fiverr Profile: Verified Quantitative Developer (Fiverr)
- Key Architectural Highlights
- End-to-End Futures Execution Workflow
- Supported CME & NYMEX Contracts
- Continuous Contract & Rollover Management
- Order Flow Footprint & Cumulative Volume Delta
- Anchored VWAP & Volatility Bands
- Institutional Bracket Orders & Margin Guardian
- Interactive Brokers TWS / Gateway Configuration
- Installation & Quickstart
- Explore Connected Quantitative Projects
- Disclaimer
- Automated Continuous Contract Stitching: Automatically detects delivery cycle transitions (HMUZ quarterly codes) and switches active quotes to the highest-volume front-month contract.
-
Order Flow Footprint Engine: Tracks second-by-second diagonal bid/ask imbalances (
$\ge 300%$ ), identifies institutional absorption, and computes real-time Cumulative Volume Delta (CVD). -
Anchored VWAP Variance Bands: Calculates rolling and session-anchored Volume-Weighted Average Price with dynamic
$\pm 1\sigma$ and$\pm 2\sigma$ standard deviation volatility bands. - Synchronized Bracket Order Router: Generates native 3-way parent/child bracket orders (Entry Limit, Stop-Loss Market, and Take-Profit Limit) with automatic OCO cancellation.
- Futures Margin & Circuit Breaker Guardian: Enforces pre-trade initial margin cushion checks, daily loss limits, and emergency news volatility pauses.
flowchart TD
subgraph Market Ingestion
A["Interactive Brokers TWS / CME Globex"] --> B["Continuous Contract Manager (Front-Month Detection)"]
end
subgraph Quantitative Analytics Core
B --> C["Order Flow Engine (CVD & Footprint Imbalances)"]
B --> D["Anchored VWAP & Standard Deviation Bands"]
B --> E["Volume Profile Point of Control (VPOC)"]
end
subgraph Signal & Strategy Synthesis
C --> F{"Delta Divergence & Absorption Detected?"}
D --> G{"Price at VWAP Mean Reversion or Breakout Band?"}
F -- Yes --> H["Construct Long / Short Tactical Entry Signal"]
G -- Yes --> H
end
subgraph Risk & Execution Gate
H --> I["Futures Margin Guardian (Utilization Check & Daily Loss Limit)"]
I -->|Approved| J["Bracket Order Router (Entry + OCO Stop/TP)"]
I -->|Breach| K["[REJECT ORDER] Halt Outbound Submission"]
J --> L["IBKR Native Bracket Order Routing (Port 7497/7496)"]
L --> M["Real-Time Fill Reconciliation & Position Ledger"]
end
| Contract | Underlying Asset | Exchange | Tick Size | Tick Value | Initial Margin (Est.) | Roll Cycle |
|---|---|---|---|---|---|---|
| ES | E-mini S&P 500 | CME | 0.25 pt | $12.50 | $12,650 | HMUZ (Mar, Jun, Sep, Dec) |
| MES | Micro E-mini S&P 500 | CME | 0.25 pt | $1.25 | $1,265 | HMUZ (Mar, Jun, Sep, Dec) |
| NQ | E-mini Nasdaq 100 | CME | 0.25 pt | $5.00 | $17,600 | HMUZ (Mar, Jun, Sep, Dec) |
| MNQ | Micro E-mini Nasdaq 100 | CME | 0.25 pt | $0.50 | $1,760 | HMUZ (Mar, Jun, Sep, Dec) |
| CL | Light Sweet Crude Oil | NYMEX | $0.01 | $10.00 | $6,710 | Monthly (FGHJKMNQUVXZ) |
| GC | Gold COMEX | COMEX | $0.10 | $10.00 | $9,350 | GJMQVZ |
| YM | E-mini Dow Jones ($5) | CBOT | 1.00 pt | $5.00 | $9,900 | HMUZ (Mar, Jun, Sep, Dec) |
Futures contracts expire periodically. Holding past expiration risks forced cash settlement or physical delivery notices.
- Calendar Inspection: Triggers evaluation 8 calendar days prior to contract expiration.
- Volume Crossover Protocol: Initiates calendar roll when secondary contract volume exceeds the current front-month volume: $$\text{Volume}{\text{Next}} > \text{Volume}{\text{Front}}$$
- Automated Stitching: Normalizes historical backtesting bars to eliminate artificial price gaps across rollover events.
Tracks aggressive buying and selling pressure inside each price bar:
-
Diagonal Bid/Ask Imbalance: Flags levels where aggressive market orders exceed limit absorption by
$\ge 300%$ ($3.0\times$ ). -
Institutional Absorption: Detects high volume clusters (
$>5,000$ contracts) with minimal price slippage, signaling passive institutional accumulation or distribution.
-
Band 1 (
$\text{VWAP} \pm 1\sigma$ ): Represents$68.2%$ of standard volume-weighted distribution. -
Band 2 (
$\text{VWAP} \pm 2\sigma$ ): Represents$95.4%$ distribution — statistical extreme overbought/oversold boundaries.
Every futures order is submitted as a synchronized 3-legged structure:
- Parent Order: Limit or Market Entry.
- Stop Loss (Child 1): Stop-market order with defined tick risk.
- Profit Target (Child 2): Limit order tied to Stop Loss via OCO (One-Cancels-Other) logic.
- Enforces maximum margin utilization ceiling (default
$65%$ ). - Enforces daily realized loss limit (default $-$1,500.00$).
- Rejects oversized orders prior to broker submission.
- Open TWS and log in to Paper or Live mode.
- Navigate to File
$\rightarrow$ Global Configuration$\rightarrow$ API$\rightarrow$ Settings. - Verify the following parameters:
- ✅ Enable ActiveX and Socket Clients
- Socket Port:
7497(Paper Trading) or7496(Live Trading) - Uncheck ❌ Read-Only API
- Check ✅ Allow connections from localhost only (or add
127.0.0.1to Trusted IPs)
- Click Apply and OK.
-
Clone repository:
git clone https://github.com/jahanzaib-codes/QuantFutures-Engine.git cd QuantFutures-Engine -
Setup virtual environment & install requirements:
python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate pip install -r requirements.txt
-
Configure Environment:
cp .env.example .env
-
Launch Automated Diagnostic Suite:
python main.py --mode demo
- 🌐 OpenTradeAI — Flagship AI Trading Platform — Open-source multi-asset AI quantitative trading platform with multi-agent consensus and deterministic risk gates.
- 🎯 IBKR Options Intelligence & 0DTE Suite — Institutional SPX 0DTE analytics, GEX profiling, and multi-leg spread execution.
- 📈 IBKR AI Options Trading Bot & GUI — Desktop options terminal with trained XGBoost classifier and backtesting suite.
- 📉 IBKR Automated Trailing Stop Orders — CSV batch trailing stop limit order dispatcher with loss prevention.
- ⚡ Solana Pump.fun 0-Block Sniper Bot — Ultra low-latency meme coin sniper powered by Rust and Jito MEV bundles.
QuantFutures Engine is an open-source software platform developed for quantitative research, algorithmic strategy development, and educational purposes. Futures trading involves substantial financial leverage and high risk of capital loss. Thoroughly paper-trade strategies before committing live capital.
Maintained by Jahanzaib (@jahanzaib-codes)
