Skip to content

About

⚡ Sub-Millisecond C++20 & Async Python HFT Statistical Arbitrage, Cross-Exchange Spread & Delta-Neutral Funding Engine

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⚡ LATENCY-ENGINE: HIGH-FREQUENCY STATISTICAL ARBITRAGE & FUNDING ENGINE

License: MIT Core: Modern C++20 Python: 3.10+ Execution: Sub-Millisecond Strategy: Delta-Neutral

"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.


🏛️ High-Frequency Trading Architecture

                       ┌────────────────────────────────────────┐
                       │     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 │
                       └────────────────────────────────────────┘

🚀 Core Quantitative Capabilities

1. Hybrid C++20 / Python Execution Architecture

  • 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.

2. Multi-Venue Triangular Arbitrage

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.

3. Delta-Neutral Futures Funding Rate Harvester

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.

4. Realistic Slippage & Latency Simulation

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

🛠️ Quickstart & Usage

1. Build Native C++ Engine

# Compile HFT engine with O3 optimizations
mkdir build && cd build
cmake ..
cmake --build . --config Release

# Run native arbitrage engine
./hft_arbitrage_engine

2. Run Market Data Feeds & Opportunity Hunter

# Monitor live spreads across pairs
python ws_feeds.py

# Launch real-time arbitrage scanner
python opportunity_hunter.py

3. Deploy Funding Rate Arbitrage Bot

# Run delta-neutral funding harvester in paper-trading mode
python smart_funding_bot.py --mode paper

📂 Codebase Overview

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

⚠️ Risk Disclaimer

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.


🛡️ License

Released under the MIT License. Engineered by AmSach.

About

⚡ Sub-Millisecond C++20 & Async Python HFT Statistical Arbitrage, Cross-Exchange Spread & Delta-Neutral Funding Engine

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages