Rust-based high-frequency trading infrastructure: TCP tuning, market data pipelines, lightning order placement, risk management, AWS node selection, cross-exchange routing, and high-concurrency storage.
- TCP latency tuning — Low-latency socket options (Nagle off, buffer sizes, keepalive) for exchange and client connections
- Market data pipeline — Ingest ticks, broadcast to subscribers, last-tick cache; ultra-low latency signal distribution
- Lightning order engine — Smart order execution with configurable max slippage (bps) and fast place path
- Risk management — Position/order size limits, daily loss limit, circuit breaker, and risk alerts (info/warning/critical)
- AWS node selection — Probe regions (e.g. Tokyo, Hong Kong, Singapore, Sydney) and select lowest-latency nodes
- Cross-exchange routing — Tokyo/Hong Kong–style hub selection; record fills and track improvement vs baseline (e.g. >30%)
- High-concurrency storage — NVMe-style random read/write store with optional batch writer for throughput
- Rust 1.70+ (e.g.
rustup)
Optional for deployment:
- Docker (for image build and CI/CD)
# Build (release profile: LTO, single codegen unit)
cargo build --release
# Run
cargo run --release
# Test (unit + integration)
cargo test
# Benchmarks
cargo bench# Build image
docker build -t cpu-hft:latest .
# Run container
docker run --rm cpu-hft:latest
# With Compose
docker compose up --buildThe image is multi-stage: Rust builder for release, then a minimal debian:bookworm-slim runtime with the binary and non-root user.
├── Cargo.toml
├── Dockerfile
├── docker-compose.yml
├── README.md
├── plan.txt
├── src/
│ ├── lib.rs # Library root and re-exports
│ ├── main.rs # Demo: pipeline, order, risk, AWS, cross-exchange, storage
│ ├── tcp.rs # TCP tuning
│ ├── market_data.rs # Ticks, pipeline, signal distribution
│ ├── order.rs # Orders, slippage, lightning engine
│ ├── risk.rs # Limits, alerts, circuit breaker
│ ├── aws.rs # AWS region/node latency selection
│ ├── cross_exchange.rs # Hub routing (Tokyo/HK, improvement %)
│ └── storage.rs # High-concurrency K/V and batch writer
├── tests/
│ └── integration_test.rs
└── benches/
├── order_throughput.rs
├── market_data_latency.rs
└── storage_concurrent_rw.rs
- TCP:
TcpTuning::default()(nodelay, buffer sizes, keepalive); extend withsocket2for full tuning. - Risk:
RiskLimits::default()(max position, order size, daily loss, optional VaR); customize before buildingRiskManager. - AWS:
AwsNodeSelector::default_hft_regions()(Tokyo, HK, Singapore, Sydney); replaceprobe_region()with real EC2/HTTP probes in production. - Cross-exchange:
CrossExchangeRouter::new(baseline_latency_us, target_improvement_pct).
- Unit: 14 tests in
src/*.rs(tcp, market_data, order, risk, aws, cross_exchange, storage). - Integration: 2 tests in
tests/integration_test.rs(market data → order → risk; AWS → cross-exchange → storage).
See repository or project policy.