Interlude - Precise Decimals In Quant Systems (Part 1/2)
Dealing with decimal quantities in MFT and HFT trading systems - a practical overview.
From The Author
A lot of new readers subscribed this week. Welcome, guys! Happy to have you here and I hope to make this publication worth your time.
To give some context for new readers. We’re currently doing component-level discussions and guides for Quant Infrastructure. The most recent articles have gone and will continue like this:
Inventory — robust inventory tracking (completed).
OrderExecutor — limit order submission and management via orders-in-flight.
InstrumentStore — keeping track of instruments traded by the system.
There are also articles on a (very) performant time series data store and an exchange client. I have things planned for after and may do a poll to see what readers would like to see in the future.
This article is an interlude to the main series and deals with different kinds of precise decimals — we postponed the topic in previous articles. It is the first time we write an interlude in this format.
I hope that you will find this publication useful and thank you for your reading!
-TaiwanQuant
Introduction
In today's article, we discuss the topic of precise decimal numbers in quantitative trading systems and implement a fast precise-decimal type suitable for handling and storage of high-frequency data.
We will mention where, why and how precise decimals are used and discuss tradeoffs between three different implementations from the perspective of Quant Infrastructure: two big-decimal types and a fast fixed-point type.
We will implement our own type that is suitable for simulating, trading, and storage of high-frequency order book data and is widely used in HFT. It is likewise useful in MFT and generally for Quant and trading systems.
This article is an interlude to the main infrastructure series. It is written, aside from the implementation part, as a high-level overview rather than a low-level guide, which is a departure from the main series. We also break character by addressing a topic that is closer to HFT rather than MFT.
The article is written mainly from the perspective of MFT as that is where most of my work and experience is in.
I expect this to be most useful to those readers handling or wishing to handle high-frequency data such as order book updates or ticker updates, or other kinds of market data for which preserving discreteness is required and thus floats are unsuitable. We will discuss when this occurs and how to approach these cases.
It will also be relevant to those concerned with the performance and robustness of their infrastructures in both HFT and MFT, especially wrt. simulation times and data store performance.
The article’s purpose is (1) to serve as an introductory and high-level overview of handling precise decimal quantities in Quant trading systems, and (2) to add a useful tool to our Quant engineering toolbox.
It is split into two parts:
In Part 1 (this one) we make address the topic at a high level. The majority of our discussion is here.
In Part 2 we implement a performant decimal type for high-frequency order book data for MFT and HFT for this article’s Subscriber Materials.
Part 2 will release in a few days up to a week. After that, we will resume the main line with the OrderExecutor article.
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.