"In high-frequency quantitative trading, speed isn't a feature—it's the entire margin."
LatencyEngine is a hybrid C++20 & AsyncIO Python quantitative trading system built for sub-millisecond statistical arbitrage, cross-exchange spread exploitation, and delta-neutral spot-futures funding rate harvesting.
┌────────────────────────────────────────┐
│ LOW-LATENCY WEBSOCKET FEEDS │
│ (Binance • Bybit • Alpaca Market) │
└───────────────────┬────────────────────┘
│ Sub-ms JSON/Binary stream
▼
┌────────────────────────────────────────┐
│ THREAD-SAFE CONCURRENCY QUEUE │
│ (Lockless Ring-Buffer Memory Layout) │
└───────────────────┬────────────────────┘
│ Zero-copy packet dispatch
▼
┌────────────────────────────────────────┐
│ C++ HFT ARBITRAGE ENGINE │
│ (Sub-Millisecond Tick-to-Trade) │
└───────────────────┬────────────────────┘
│
┌────────────────────┴────────────────────┐
▼ ▼
┌────────────────────────┐ ┌────────────────────────┐
│ TRIANGULAR ARBITRAGE │ │ SPOT-FUTURES FUNDING │
│ • Cross-Pair Imbalance │ │ • Delta-Neutral Carry │
│ • Instant Liquidity Run│ │ • 8-Hour Yield Harvest │
│ • Fee-Adjusted Profit │ │ • Auto-Rebalancing Leg │
└───────────┬────────────┘ └───────────┬────────────┘
│ │
└────────────────────┬───────────────────┘
│ Ultra-fast REST / FIX orders
▼
┌────────────────────────────────────────┐
│ REALISTIC EXECUTION HARNESS │
│ • Orderbook Depth Slippage Model │
│ • Taker / Maker Fee Accounting │
│ • Real-Time PnL Risk Circuit Breaker │
└────────────────────────────────────────┘
- C++ Execution Core: High-frequency orderbook state calculation and concurrent thread synchronization with zero heap-allocation overhead in hot paths.
- Python Strategy Layer: Asynchronous multi-venue WebSocket feeds and rapid quantitative alpha iteration.
Continuously scans cycles of crypto currency pairs (e.g. USDT -> BTC -> ETH -> USDT). When cross-rate product deviates beyond cumulative maker/taker fees + slippage buffer, orders are routed simultaneously across legs.
Captures annualized yields (ranging from 15% to 65% APR) by holding long spot and short perpetual futures positions, capturing continuous funding payments without directional market risk.
Features robust backtesting and paper simulation engines that model:
- L2 Orderbook depth consumption
- Exchange network round-trip latency
- Realistic exchange fee tiers (VIP 0 to VIP 9)
- Dynamic liquidation buffers
# Compile HFT engine with O3 optimizations
mkdir build && cd build
cmake ..
cmake --build . --config Release
# Run native arbitrage engine
./hft_arbitrage_engine# Monitor live spreads across pairs
python ws_feeds.py
# Launch real-time arbitrage scanner
python opportunity_hunter.py# Run delta-neutral funding harvester in paper-trading mode
python smart_funding_bot.py --mode paper| Module | Purpose |
|---|---|
HftArbitrageEngine.hpp |
Sub-millisecond tick processing and cross-exchange arbitrage detector |
ThreadSafeQueue.hpp |
Cache-friendly, concurrent message queue for high-frequency tick distribution |
AlpacaClient.hpp |
Modern C++ client for direct market access (DMA) |
arb_engine.py |
Full triangular arbitrage engine and execution manager |
futures_arb_bot.py |
Basis spread and perpetual futures funding rate yield capture |
smart_funding_bot.py |
Automated risk-managed funding arbitrage agent |
sim_realistic.py |
High-fidelity trade simulation with fees, queue position, and slippage |
Quantitative trading and automated market execution carry financial risk. This software is provided for educational and research purposes. Always verify risk controls and API rate limits prior to live capital deployment.
Released under the MIT License. Engineered by AmSach.