Quantitative Trading Strategy Series (1): Market Making

Insert picture description here

Market Making Strategy

The core idea of ​​the Market Making (MM) strategy: keep every transaction profitable without holding a position. The characteristic is to compete for transaction opportunities and profits on the trading market, high-frequency trading, small profits but quick turnover. The largest well-known market makers in the US stock market (once) such as: Knight Capital Group's transactions in Equity in 2009 reached 980 million transactions, an average of 600,000 transactions per hour, but the average return per transaction was .01%-.10%, on the market The magnitude of the spread (note: the spread, or Spread, is (sell price-buy price)/fair price).

Quantitative trading in the field of digital currency lacks industry standards and does not have a strict Trader/Broker/Clearing House/Exchange distinction. Each role is currently represented by various exchanges. The advantage is that traders do not need to be subject to the supervision and exploitation of various links in the traditional financial field, and can directly face the market; worse, because they face the market directly, risks are often uncontrollable. Especially in the face of a digital asset trading field controlled by a limited number of "whale" accounts.

However, most of the trading strategies in the traditional financial field can be directly migrated to the digital asset trading field. Including Market Making strategy.

Counterparty in the transaction

In a deal, there must be a Maker and a Taker. Maker is the inquirer, that is, it provides a certain amount of assets to sell (or buy) at a certain price. Taker is the buyer (or seller). The reason for the distinction between Maker/Taker is that Maker, as the inquirer, provides "liquidity" for this transaction, enabling Taker to get what it wants.

Each exchange usually adopts different fee rules for the Maker/Taker in a transaction. The difference in rules comes from the regulation of the "liquidity" of the exchange. In exchanges or markets with insufficient liquidity, the method of reducing or returning the handling fee is usually used to incentivize Maker orders, that is, inquiry orders, so that "liquidity" is guaranteed in quantity.

Currently, all digital asset transactions that adopt the Maker fee return strategy are:

  1. BitMEX contract (return 2.5 million)
  2. WBFex spot (return 2)

MM strategy introduction

BitMEX Trading API
WBFex Trading API

Imagine that if you can predict the arrival time of the next Taker sell order and predict the quantity of the order, then Maker can calmly open a new inquiry order on the spread of a few ticks above the existing buy one. , That is, the new buy one price, and the taker order is traded before the old buy one. On exchanges with rebates, this transaction will bring about a gain of about 10,000 in terms of trading volume.

After the transaction is completed, the MM strategy will immediately predict the arrival of the next Taker buy order, and place a sell order at a few ticks above the transaction price (and at the same time a few ticks lower than the existing sell order), and wait for the taker to complete the transaction. . If the transaction is completed, it will bring another 10,000 income, and the position in the hand is 0.

This is an ideal scenario, namely MM strategy can comfortably buy low and sell high, to earn spreads and fees returned. All kinds of MM strategies are constantly approaching this ideal scenario, using artificial intelligence algorithms or random dynamic programming algorithms on software; using faster computing clusters on hardware and colluding with exchanges A faster network connection channel (co-location).

Earn handling fee $

In the high-frequency MM market-making strategy of small profits but quick turnover , fee reduction is particularly important. This is usually because the profit of buying low and selling high in the short term (milliseconds or microseconds) is usually in the order of in case to one thousand, so the handling fee must be lower than this order to maintain the continuous profitability of the MM strategy . Therefore, whether it is traditional financial exchanges, such as NASDAQ , NYSE , or digital asset exchanges, such as BitMEX , WBFex , have adopted Maker reduction or even negative rate measures to encourage Maker orders to meet the trading needs of other users of the exchange.

BitMEX Trading API
WBFex Trading API

MM transaction code

    def place_orders(self):
        """Create order items for use in convergence."""

        buy_orders = []
        sell_orders = []
        # Create orders from the outside in. This is intentional - let's say the inner order gets taken;
        # then we match orders from the outside in, ensuring the fewest number of orders are amended and only
        # a new order is created in the inside. If we did it inside-out, all orders would be amended
        # down and a new order would be created at the outside.
        for i in reversed(range(1, settings.ORDER_PAIRS + 1)):
            if not self.long_position_limit_exceeded():
                buy_orders.append(self.prepare_order(-i))
            if not self.short_position_limit_exceeded():
                sell_orders.append(self.prepare_order(i))

        return self.converge_orders(buy_orders, sell_orders)

    def prepare_order(self, index):
        """Create an order object."""

        if settings.RANDOM_ORDER_SIZE is True:
            quantity = random.randint(settings.MIN_ORDER_SIZE, settings.MAX_ORDER_SIZE)
        else:
            quantity = settings.ORDER_START_SIZE + ((abs(index) - 1) * settings.ORDER_STEP_SIZE)

        price = self.get_price_offset(index)

        return {
    
    'price': price, 'orderQty': quantity, 'side': "Buy" if index < 0 else "Sell"}

Guess you like

Origin blog.csdn.net/weixin_47368014/article/details/106501876