ramseshk 9cf871be46 Fix order pricing: 1-tick advantage at best bid/ask + process guard
A-S was quoting at best bid/ask (0% win) — orders filled but
0.04% round-trip maker fee exceeded spread capture.
Now: bid+1 / ask-1 = captures spread minus 1 tick each side.

Signal-driven strategies: same 1-tick pricing instead of
0.03% offset that crossed the book or sat too far away.

Added fcntl file lock to prevent duplicate live nodes.
Added IOC fallback (market-crossing) when post-only rejected.

A-S win rate: 0% → 25% (first 8 trades with new pricing)
2026-08-06 09:47:21 +00:00

FTDT Quant Lab

Production multi-strategy quant trading system running on Hyperliquid.
Live testnet node, paper trading simulator, historical backtesting, and real-time dashboard.

Live: https://ftdt.io/cv


Stack

Layer Technology
Runtime Python 3.13 (async trading)
API Client nautilus_trader (Hyperliquid SDK, Rust bindings)
Dashboard Next.js 16 (static export) + shadcn/ui + Framer Motion
Design System Hallmark Cobalt — Ubuntu font, hairline borders, cool paper palette
Reverse Proxy Caddy → auto HTTPS
WebSocket FastAPI (live/paper streaming)
Data PostgreSQL 17 (ftdt_quant), JSON metrics files
Backtesting Custom dollar-bar engine + numpy
Infra OVH VPS (4 vCPU, 8GB RAM, Debian 13), 2GB swap

~5,300 lines of Python + TypeScript. 67 commits since July 2026.


Repository Structure

ftdt-quant-lab/
├── live/
│   ├── node.py                  # Live trading node — testnet, 9 strategies
│   └── paper_trader.py          # Paper trading — mainnet data, 10 strategies
├── strategies/
│   ├── orderbook_imbalance.py   # L2 bid/ask volume skew (OBI)
│   ├── iceberg_detection.py     # Whale TWAP accumulation detection
│   ├── funding_arb.py           # Delta-neutral carry — spot/perp funding
│   ├── pairs_trading.py         # BTC/ETH ratio Z-score (1.5σ)
│   ├── avellaneda_stoikov.py    # Dual-sided stochastic control MM
│   ├── kalman_pairs/            # Kalman-filter adaptive hedge ratio
│   ├── hawkes_ofi.py            # Hawkes process order flow
│   ├── deep_lob.py              # Deep LOB CNN feature extraction
│   ├── queue_imbalance.py       # Weighted queue dynamics
│   ├── hurst_vpin.py            # Hurst exponent + VPIN directional
│   ├── hurst_vpin_live.py       # Lightweight Hurst/VPIN for live tick stream
│   └── quant_report.py          # QF-Lib style quant analytics
├── dashboard/
│   ├── server.py                # FastAPI backend — WS, REST, static files
│   └── next/
│       └── src/
│           ├── app/             # Main page + layout
│           ├── components/      # QuantReport, StrategyCard, L2Terminal
│           └── lib/             # Types, API client
├── backtests/
│   ├── run.py                   # Backtest runner
│   └── results/
│       └── historical/          # JSON backtest snapshots (32 entries)
├── common/                      # Shared utilities
│   ├── risk.py, risk_manager.py
│   ├── hyperliquid_api.py
│   └── portfolio.py, metrics.py
├── config/
│   └── fee_tiers.py             # Perp/spot fee schedules
└── infrastructure/
    ├── Caddyfile                # Reverse proxy config
    └── systemd/                 # Service units (pending)

Strategies — Current State

Live Node (Hyperliquid Testnet — 9 strategies, $100 each)

# Strategy Type Asset Size PnL Trades Win
1 Order Book Imbalance reversal BTC 0.000200 $0.00 0
2 Iceberg Detection momentum BTC 0.000210 $0.00 2 0%
3 Funding Rate Arb carry BTC 0.000220 $0.00 0
4 Pairs Trading stat_arb ETH 0.006000 +$0.74 9 67%
5 Avellaneda-Stoikov market_making BTC 0.000230 -$1.35 32 0%
6 Momentum Breakout momentum ETH 0.000500 $0.00 0
7 Mean Reversion reversal ETH 0.000500 $0.00 0
8 Kalman Pairs stat_arb ETH 0.005000 $0.00 0
9 Hurst VPIN momentum BTC 0.000240 $0.00 0

Execution: GTC POST-ONLY limit orders. Signals every 5 ticks (5s), dual-sided for A-S.
Fee model: Maker 0.02% (testnet).

Paper Trader (Hyperliquid Mainnet data — 10 strategies, $100 each)

Same set + Queue Imbalance. Real mainnet orderbook + funding data. Fee model: taker 0.05% / maker 0.02%. Trades simulated with 1bps slippage.


Historical Backtests

32 backtest snapshots across 8 strategies × 4 coins (BTC, ETH, HYPE, VVV).
Hurst/VPIN BTC: 46 trades, 96% win rate, +1.10% on synthetic trending data.


Priority Analysis

Strategies showing real signal

Strategy Signal Status
Pairs Trading +$0.74, 67% win rate — only profitable live strategy
Avellaneda-Stoikov ⚠️ 32 trades but losing — spread capture not covering fees
Iceberg Detection ⚠️ 2 trades — rare signals, needs threshold tuning
Hurst VPIN 🔬 96% win in backtest, 0 live trades — very selective
Mean Reversion 0 trades — VWAP deviation not crossing 1.0σ
Momentum 0 trades — Bollinger 1.2σ too tight for ETH

Recommendation: focus investment here

  1. Pairs Trading#1 priority. Only live winner. Extend to more pairs (SOL, ARB, OP). Add Kalman dynamic hedge ratio. This is the clearest path to sustained PnL.

  2. Hurst/VPIN#2 priority. Backtest shows strong edge (96% win). Needs real market data (not synthetic) and 3-day candle feed to trigger more signals. The selectivity IS the edge — don't dilute it.

  3. Avellaneda-Stoikov — Needs inventory control. 32 trades losing because adverse selection. Add skew-aware quoting (update reserve price based on queue imbalance).

  4. Iceberg Detection — Lower detection threshold. Currently requires 7/10 consecutive ticks same direction — too strict.

  5. Funding Rate Arb — Real Hyperliquid funding data already plumbed. Test threshold from 3% → 1% APR. Prefunding detection (predict next rate before announcement).

  6. Backtest engine — Replace synthetic data with real Hyperliquid candles. Add walk-forward optimization. The hurst_vpin.py infrastructure is ready.

Skip for now

  • OBI / Mean Reversion / Momentum — 0 trades. Signal thresholds need fundamental redesign, not just tuning.
  • Cartea-Jaimungal / Gueant MM — academic models, not adapted to crypto microstructure.
  • DeepLOB / Hawkes OFI — dependency-heavy, no live integration.

Next Steps

# Clone and deploy
git clone https://git.ftdt.io/rams/ftdt-quant-lab.git
cd ftdt-quant-lab
python3 -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt        # (pending — currently manual)

# Start services
python live/node.py &                  # Trading node
python live/paper_trader.py &          # Paper simulator
python dashboard/server.py --port 9175  # Dashboard backend

Roadmap

  • Docker Compose for reproducible deployment
  • Walk-forward backtest on real Hyperliquid candle data
  • Extend Pairs Trading to BTC/SOL, BTC/ARB
  • Hurst/VPIN 3-day candle feed → real live signals
  • Memory leak proofing — current guard at 512MB RSS
  • systemd service unit files for auto-restart
  • Grafana + Prometheus monitoring dashboard

Built with Hermes Agent · Hallmark Cobalt · Ubuntu fonts

S
Description
Quantitative trading lab — Nautilus Trader strategies on Hyperliquid Testnet. Part of my professional portfolio.
Readme 2.8 MiB
Languages
Python 60.7%
TypeScript 19.8%
HTML 18.8%
CSS 0.4%
JavaScript 0.3%