joshriang
← Back to portfolio

Quant research & trading·Python·Published

HFTENGINE

This is a fork of mirkovicdev/HFTENGINE, a replay console that runs one of hftbacktest's tutorial market-making strategies against recorded Binance USDT-M Futures order-book data and shows what the engine sees frame by frame: the local book, every resting order with its queue estimate, feed and order latency, trades, fills and the raw collector feed. I keep it because it is the clearest worked example of why a backtest that looks profitable at the touch is really a bet on fee tier and physical proximity. In the recorded BTCUSDT session the spread was one tick 99.7% of the time, one tick is 0.013 bps, so a 0.02% retail maker fee costs 154 ticks per fill against the 38 ticks a 0.005% rebate pays back; on $413k of notional that is $83 of fees versus $21 of rebate. The data was recorded on a laptop with about 200 ms feed latency and 250 ms round trip, and 24% of the strategy's post-only orders were rejected because the market moved while they were in flight. The repo deliberately shows no P&L, because the strategy is a documentation example and the fills are a probabilistic queue model, not a measurement.

Date
2026
Main stack
Python
Code
github ↗
01
02
  • At a one-tick spread the fee tier is the strategy: 154 ticks of cost per fill versus 38 ticks of rebate is a bigger effect than any signal the market-making logic produces.
  • Latency shows up as adverse selection before it shows up as slippage; 24% post-only rejection is the measurement of being too slow, and it comes from a 200 ms feed on a laptop, not from the strategy.
  • Queue position is inferred from level-2 data, so a backtest/live gap is expected; the discipline is to trade tiny size, plot live against backtest, and fix the queue model before scaling, not after.
03

Scale 0–100: how much this project relied on each skill.