{
  "id": 18439787,
  "title": "Building a Deterministic Market-Data Replay Engine for Backtesting on QuestDB",
  "url": "https://urgent.news/2026/11/06/building-a-deterministic-market-data-replay-engine-for-backtesting-on",
  "topic": "finance",
  "section": "Finance & Markets",
  "published": "2026-11-06T04:35:54.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/krishna_y/building-a-deterministic-market-data-replay-engine-for-backtesting-on-questdb-2f6l"
  },
  "original_language": "en",
  "account": "This post describes the creation of a deterministic market-data replay engine for backtesting on QuestDB, using real captured order-book data instead of toy CSVs. The author explains why timestamp-equality joins often lead to inaccurate results, as they can introduce future prices into the backtest by matching the nearest quote regardless of direction. To avoid this issue, they use an ASOF JOIN, which retrieves the latest quote whose timestamp has not passed the trade's timestamp. The capture pipeline involves ingesting top-of-book and trade events for a basket of nine stocks into QuestDB using an InfluxDB line protocol. The ingestion process records the events exactly as received, preserving the exchange timestamp and a separate ingestion timestamp. The resulting table, named market_events, includes columns for trade and quote prices, quantities, and sequence numbers. To ensure reproducibility, the author partitions the table by hour and converts older partitions to Parquet format for storage efficiency. The replay engine is implemented in Spring Boot and enforces the discipline of only using information known at each instant, preventing the future from leaking into the backtest.",
  "summary": "The first backtest I ever trusted turned out to be a liar. It showed a Sharpe north of 3, a drawdown curve that looked like a staircase going one direction, and fills so clean I should have known. The strategy bought when a signal fired and sold a few seconds later, and in the backtest it always sold at a price that existed only after the decision was made. I had joined my trades to a quote table…",
  "key_points": [
    "Deterministic market-data replay engine created for QuestDB backtesting",
    "ASOF JOIN used to avoid inaccurate timestamp-equality joins",
    "Marketevents table records trade and quote events with timestamps"
  ],
  "editors_take": "Replacing simple timestamp joins with ASOF JOIN logic eliminates the risk of look-ahead bias, ensuring that backtesting models rely solely on information available at the exact moment of execution.",
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}