Quiver Engine

The core principle behind our matching engine is that speed advantages should only matter at economically relevant time scales.

Humans care about whether their trades happen in a fraction of a second or whether they take minutes to execute. Therefore, it makes sense that an order arriving a second earlier has priority over orders arriving later.

However, at the time scales involved in modern high-frequency trading, being first should not matter. Not many people care if their trade takes a millisecond more or less to execute (as long as execution is fair, no front-running happens, etc). So an order arriving a few microseconds earlier than others should not have priority.

This requires a fundamental change in the first-in-first-out (FIFO) model of matching engines. We need to hold orders that arrive roughly at the same time in a batch for them to be processed together.

Once a batch is executed, we need to deal with the fact that there may be competition for some fills. It may be that many buy orders have arrived all at the same time, and that only one of them can execute. That is why we need to run auctions. We need a way to determine the execution priority, and the only fair way is to say that buyers bidding high (or asks offering for low) get to execute first.

Currently, our batches take about 50ms, so you can't see the auctions happening. But you can still see the benefits.

Auctions can often generate a price improvement for limit orders standing on the book. So at Quiver you can put a buy order for $100 in the book, and you might later find out it was executed for less than that!

This is particularly likely to happen when price moves quickly, such as when price moves a lot in a different (e.g. a large centralized exchange). At that moment, different arbitrage bots can send orders roughly at the same time, participating at the auction. Because our auctions implement a property called incentive-compatibility, the game-theoretical equilibria is for arbitrage bots to compete against each other in such a way that they make almost no profits. Even two competing arbitrage bots suffice to reach a near-zero profit equilibrium, as long as they are risk neutral (big enough) and are unable to communicate/collude. Because we can expect almost all of the potential arbitrage profits to end up in price improvement, we can say that the mechanism effectively protects market makers from arbitrage losses.

Engine Cycle

The matching engine algorithm runs in a perpetual cycle. We alternate between ascending-price auctions, in which incoming (taker) buy orders compete to execute against resting ask orders in the book, and descending-price auctions, in which incoming taker sell orders compete to execute against the bids.

In between these two phases of the cycle, there are additional batches for new buy and sell orders to enter the orderbook. The new bids get inserted right after the ascending-price auction, and the new asks right after the descending-price auction.

Moreover, there are some other steps for dealing with positions near bankruptcy (liquidation step) and for specialized bots to aggregate liquidity from external exchanges (sweeper step).

Vickrey Auction

Both the ascending-price and the descending-price auctions follow a generalization of the so-called Vickrey Auction.

In the traditional Vickrey auction, bidders post their prices for a single item, and as expected, the one with the highest price is declared the winner. However, in contrast to what is called a first-price auction, the winner does not necessarily pay its full bid!

Rather, it pays as much as the second-highest bidder (or the limit price of the seller). The reason for that is that the second-highest bid, being the maximum someone else would pay for it, also represents a lower bound for what the winner should have to pay.

One might think that, by selling the item for less than the maximum bid, this mechanism is worse for the seller, but that is not quite the case.

If we attempted to sell for the item for the maximum price, then the winner would immediately regret its bid in retrospect. It will wonder that, by bidding just a little bit more than the second-place bidder, it could have still won the item while paying quite a lot less. Being rational, all bidders will take that into account and bid less in such an auction. As a result, and quite counterintuitively, game theory predicts that such an auction will often generate less revenue for the seller.

The Vickrey auction has a nice property that rational bidders always bid their full value – the maximum value they would be willing to pay if they had to. This property is called incentive-compatibility. It is guaranteed that among the best mechanisms we can always find a mechanism of this type, and there are many practical advantages to doing so.

Quiver-Ausubel Auction

One problem remains in that the Vickrey auction is designed for selling a single item! In our situation, many buyers and sellers are present, trading multiple indistinguishable goods (such as stocks, tokens, or futures contracts). Now we have two problems: not only bidders can put a lower value than their limit price (bid shading), they can also put a lower amount, to avoid causing price impact. This second problem is called demand reduction.

To achieve incentive-compatibility in this new scenario, we need a slightly more complicated algorithm. Fortunately, a 2003 paper gives us a relatively simple algorithm (a generalization of the Vickrey auction) that works for multiple identical items. We have adapted it to allow also for the possibility of multiple sellers with different price limits (as happens when the sellers correspond to orders available in the orderbook).

In the Ausubel Auction, the price increases continuously, and as soon as any of the buyers get into a position in which they could unilaterally end the auction (by retrospectively setting a lower amount to their bids), they acquire (or "clench") this lower amount at the current (lower) price. The auction then continues for the remaining items and bids, until enough demand drops off to match supply.

One consequence is that bidders get to effectively buy at an intermediate price between the final, higher equilibrium price, and the lower equilibrium price that would have happened if the bidder did not exist. This means that large bids in a single auction can execute at a discount.

While it may be counterintuitive to understand why it is important or fair to give a discount to large bidders in a single auction, there are many good arguments for it.

In a uniform-price auction, large bidders end up decreasing the size of their bids to avoid price impact. The Ausubel auction gives just the right discount to the large bidders, so that large bids still cause price impact, but that each additional unit of demand only increases the price for it and additional ones, without also increasing the price paid for all the units bought so far.

Another interesting consequence is that, for the particular scenario in which a single buyer is present, the auction degenerates to the common, well-known first-in-first-out order matching. This means that, unless someone else sends a large order alongside yours, your order will fill just like you would expect in a regular order book exchange.

Because bids are all hidden during the duration of the auction, you also do not have to worry about someone front-running your order during the small auction period.

If you are interested in reading more details, check the auction technical documentation.

Last updated