hft-market-replay
Skill13 starsChanged 6 days agoApache-2.0View on GitHub
Build or audit tick-by-tick historical market replay and HFT backtests with explicit feed/order latency, exchange event ordering, queue-aware fills, fees, and market-impact assumptions. Use for high-frequency or passive-order strategy evaluation; not for daily-bar backtests.
In this repository19 other files it gives its agents.
- agent-based-market-simulationSkill
- code-understandingSkill
- etf-arbitrageSkill
- exchange-gateway-engineeringSkill
- execution-analysisSkill
- interview-simulatorSkill
- lob-microstructureSkill
- low-latency-performanceSkill
- market-makingSkill
- mathematical-reasoningSkill
- order-book-reconstructionSkill
- pre-trade-risk-controlsSkill
- production-trading-operationsSkill
- quant-research-validationSkill
- queue-position-modelingSkill
- research-paper-tutorSkill
- socratic-tutorSkill
- tick-data-engineeringSkill
- volatility-market-makingSkill
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 5 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 7
Treat a replay as a model of what the strategy could have observed and what the venue could have executed.
- Distinctive: line 15
Choose fill models: Use MBO reconstruction where valid.
- Distinctive: line 33
Do not describe bar-based fill assumptions as HFT-grade execution simulation.
- Distinctive: line 34
Do not count a fill before exchange arrival or use unreceived market data.
- Distinctive: line 35
Do not let the same historical displayed quantity fill multiple simulated orders unless the model explicitly controls consumption.
≈ “Common” is an estimate: at least 1 in 5 of the 372,429 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
HFT Historical Replay and Backtesting
Treat a replay as a model of what the strategy could have observed and what the venue could have executed. Historical book data is not an execution oracle: simulated orders do not automatically alter the historical market.
Workflow
- Define replay fidelity. Record feed granularity (trades, L1, L2, MBO), venue/session coverage, timestamp semantics, packet sequence availability, and whether the replay is deterministic.
- Separate clocks. Preserve exchange event time, packet receive time, strategy decision time, order-send time, exchange-arrival/ack time, fill time, and local response time wherever available. Document synchronization error and timestamp precision.
- Model latency paths. Represent feed latency, strategy compute delay, outbound order-entry latency, exchange processing/ack delay, and cancel latency separately. Use empirical distributions or conservative envelopes, not a single constant unless justified.
- Specify event ordering. Define what happens when a feed event, strategy timer, order arrival, acknowledgement, trade, and cancel cross. Test same-timestamp ties and out-of-order observations.
- Choose fill models. Use MBO reconstruction where valid. For L2, disclose queue uncertainty and compare conservative/probabilistic models. State whether fills consume displayed liquidity, whether multiple simulated orders can consume the same historical liquidity, and how partial fills work.
- Model fees and economics. Include maker/taker fees, rebates, funding/borrow/carry, tick/lot rounding, hedge costs, and contract multiplier. Report gross and net separately.
- Handle market impact honestly. Historical replay generally assumes the strategy is small enough not to change the historical path unless an impact/agent model is added. State this assumption and test capacity limits separately.
- Avoid future information. Strategy decisions at time
tmay only use messages received byt; a feed event's exchange timestamp does not mean the strategy had already received it. Use actual availability times in feature construction. - Run scenarios. Baseline, conservative latency, stressed latency, conservative queue, alternate fill model, higher fees, and reduced liquidity. Keep parameter selection outside the final evaluation window.
- Produce an audit trail. Save config, data identifiers/hashes, code revision, random seeds, and per-order decision/fill/cancel traces.
Deliverable
- Net P&L decomposition and returns, not only Sharpe.
- Fill ratio, maker/taker mix, partial fills, rejected/cancelled orders.
- Queue and latency assumptions, with sensitivity.
- Turnover, fees/rebates, slippage, impact assumption, and capacity caveats.
- Inventory/exposure distribution and maximum drawdown/tail loss.
- Reproducibility metadata and known simulator limitations.
Guardrails
- Do not describe bar-based fill assumptions as HFT-grade execution simulation.
- Do not count a fill before exchange arrival or use unreceived market data.
- Do not let the same historical displayed quantity fill multiple simulated orders unless the model explicitly controls consumption.
- Backtest success is not evidence of live profitability; do not connect the research run to live trading.
Further reading
- HftBacktest: https://github.com/nkaz001/hftbacktest
- HftBacktest latency models: https://hft.readthedocs.io/en/latest/latency_models.html
- NautilusTrader backtesting concepts: https://nautilustrader.io/docs/latest/concepts/backtesting/
- ABIDES-JPMC: https://github.com/jpmorganchase/abides-jpmc-public
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

