eBPF Summit Hackathon 2025 Submission
Turbo-HFT is an ultra-low-latency trading engine that runs entirely inside the Linux Kernel networking path using XDP. By processing market data and executing orders at the driver level, we eliminate the overhead of the OS network stack and context switching.
In modern High-Frequency Trading (HFT), the Operating System is the bottleneck.
- Context Switches: Moving data from Kernel to User Space takes time.
- Network Stack: The Linux TCP/IP stack is designed for compatibility, not raw speed.
- Latency: A standard Python bot has a round-trip time of ~1500µs.
Turbo-HFT moves the trading strategy into the NIC driver.
- Zero-Copy Execution: We parse NASDAQ-style packets and trigger "Buy" orders inside the XDP hook.
- Live Kernel Control: Using eBPF Maps, we can dynamically adjust "Target Prices" or trigger a "Kill Switch" from userspace without recompiling.
- Performance: Achieves ~300µs latency in a virtualized environment (estimated <10µs on bare metal).
Turbo-HFT offers dual-mode command and control. Choose your weapon:
A full-featured dashboard with real-time Chart.js visualization, scrolling event logs, and bank balance tracking.
A lightweight, text-based interface for raw, low-overhead monitoring directly in the terminal.
- Data Plane: C (XDP/eBPF) - The "Muscle"
- Control Plane: Python (BCC/bpftool/Flask) - The "Brain"
- Frontend: HTML5, Bootstrap 5, Chart.js, WebSockets
- Features:
- Deep Packet Inspection (DPI) on UDP payloads.
- Dynamic Quantity Scaling (Buys more when price is lower).
- Live Liquidation Logic: Real-time P&L calculation on "Sell" orders.
First, compile the kernel code and set up the virtual network.
# 1. Build the Kernel Object
make
# 2. Setup Network Namespace
sudo ./setup_env.sh
# 3. Load XDP Engine into the Kernel
sudo ip link set dev veth_hft xdpgeneric obj xdp_hft.o sec xdp
# 4. Start the Exchange Simulator (in a separate terminal)
sudo ip netns exec exchange_ns python3 exchange_sim.py
# Install dependencies
pip3 install flask flask-socketio eventlet
# Run the Server (Must be root to access BPF Maps)
sudo ./venv/bin/python3 web_server.py
Open your browser: Go to http://localhost:5000
sudo python3 dashboard.py
| System | Architecture | Latency (RTT) |
|---|---|---|
| Standard Bot | Python recv() Loop |
~1520 µs |
| Turbo-HFT | eBPF XDP Hook | ~280 µs |
| Speedup | ~5.4x Faster |