Dev’s nook is a brand new part of BitShares Information the place builders concerned with the BitShares mission publish technical associated briefs and observations.

As an instructional train, I wished to tackle constructing a order matching engine in C++. The aim right here is to iterate by way of the method of measuring and bettering efficiency.

I think about the preliminary necessities as naive, with later iterations together with removing of floating level calculations, variable precision, 128-bit integers, “mud” dealing with (could also be extra of an implementation query than a efficiency one).

This order matching engine will probably be strictly single-threaded and purposeful. It’s hoped that the enter will probably be clear and optimized (which may very well be offloaded) to enhance throughput.

Tooling will probably be sparse, on goal. The concept right here just isn’t a dialogue of the intricacies of the instruments, however how tweaks to code impacts velocity.

The Concept

The engine will obtain restrict orders that specify the asset held, the asset to be purchased, and the specified value. It can embrace a sequential ID, externally assured to be distinctive (such a key may very well be analyzed later… we’ll see…).

As soon as obtained, the order is processed and if not instantly stuffed, what’s left over is positioned on the order e-book.

Easy, proper? There are various particulars but to be sorted out. So we are going to get began! Keep tuned!

For the primary lower of the order e-book, see this GitHub commit.

Keep tuned for Half II: “Order matching and Container Sorts”.

Supply

Supply hyperlink