Quant Infrastructure #6 - Simulating Markets - An Introduction
An introduction to simulating and backtesting markets for MFT and HFT.
Table of Contents
An Event-Driven Market Simulator
Market Internals & The Order Book
In the last article, we built an OrderExecutor component and looked at robustly managing limit orders on the exchange. In this article, we introduce the reader to market simulation. Future articles will cover writing a complete, event-driven backtester from candle data.
The article will introduce the concepts relevant to market simulation and lay the groundwork for writing our own simulator in a future article.
This is a broad topic so we will limit ourselves to the event-driven simulator we intend to write.
We will begin with a brief overview to look at what simulators are useful for (in addition to backtesting), and how we will use ours with the infrastructure covered so far in the series.
We will then look at the market internals of CEX Crypto exchanges, crucially the order book, to inform our understanding and intuition of how markets work. We will do this with the goal of simulating markets well and in a way that corresponds to reality — in addition to gaining a better understanding generally.
In the main part of the article, we will look at simulating a market using candlestick data. We will look at the challenges posed by candles, which lack much desirable information, and how to overcome them. We will focus on simulating realistic fill prices and a cost model for achieving this.
The last section briefly addresses concepts relevant to simulating HFT such as latency and the order book's order queue.
Crucially, our end goals are:
To produce a reliable simulator which we understand and can therefore trust and which will be useful in practice.
To improve our understanding of markets.
By proxy, I also wish to save the reader from dealing with any headaches stemming from an unreliable one.
As usual, our focus is on simplicity, robustness and correctness.
This article is an introduction and contains no code, which will come in the future.
Keep reading with a 7-day free trial
Subscribe to TaiwanQuant's Newsletter to keep reading this post and get 7 days of free access to the full post archives.