Research on placing orders around a "micro-price"

Author: jamesPmagic 0x4eF

Original Post Date: 10 Jan 2022

This study is motivated by @Jelle {Cryptobot}'s posts about Stoikov’s micro-price paper on the HB discord. See:

Stoikov’s paper: The Micro-Price: A High Frequency Estimator of Future Prices by Sasha Stoikov :: SSRN

The “micro-price” is the predicted price at a future time.

In Stoikov’s paper, the micro-price lies in between the mid-price and the weighted mid-price. It is closer to the mid-price for a “small-tick asset” (CVX) and closer to the weighted mid-price for a “large-tick asset” (BAC). Level 1 data (top bid and ask) is used to calculate mid-price and weighted mid-price.

In the first part of this study, we look into whether the weighted mid-price could serve as a better “price-source” than the mid price. The price-source is the price around which the bid and ask orders are placed in the market making strategy. A better price-source is one which is better able to capture the spread (fill both the bid and ask orders)

Author: jamesPmagic 0x4eF

Simulation 1:

  • Dataset: BTC/USDT on Binance, 16:42 on 22nd Jan to 00:28 on 23rd Jan (roughly 8 hours)
  • Level 1 data is used to calculate mid-price and weighted mid-price

Algorithm:

  • Bid and ask orders are placed around the price-source, according to specified bid and ask spreads
  • If neither bid or ask are filled, they are refreshed at a specified interval.
  • If one side of the order is filled, the simulation waits until either the other side is filled or a specified stop loss is hit.
    • When the other side of the order is filled ----> Spread is successfully captured.
    • When the stop loss is hit ----> Failed to capture the spread.

Limitations:

  • This is a simple algorithm similar to the futures market making strategy on HB, and doesn’t have the advanced PMM capabilities.
  • We assume that bid and ask orders are filled when the traded price crosses the limit order price.

The datasets, code and results are at this link: GitHub - rkc2000/Hummingbot-Experiments

Results:

  • Since mid-price and weighted mid-price are calculated using only Level 1 data, the difference between them is not very large. So there is no difference between their performances when the bid and ask spreads are relatively large (0.2 or greater)
  • For bid and ask spreads = 0.1, stop loss = 1, order refresh time = 30
    • Mid price : Spread captured 41 times, Failed to capture spread 8 times.
    • Weighted mid price : Spread captured 43 times, Failed to capture spread 8 times.
  • For bid and ask spreads = 0.05, stop loss = 1, order refresh time = 10
    • Mid price : Spread captured 61 times, Failed to capture spread 9 times.
    • Weighted mid price : Spread captured 66 times, Failed to capture spread 9 times.
  • PDF of results: Hummingbot-Experiments/HB Experiments.pdf at main · rkc2000/Hummingbot-Experiments · GitHub

Author: jamesPmagic 0x4eF

I am currently downloading trade data and L2 orderbook data for the following pairs on Binance: BTC/USDT, ATOM/USDT, SUN/USDT

As per @Jelle {Cryptobot}'s suggestion, we will calculate weighted mid-price using top 0.1% or 0.2% of the order book (L2) instead of just the best bid/ask (L1).

Please post any suggestions or recommendations below.

Author: Jelle {Cryptobot} 0xe8f

Hi, awesome contribution, thanks a lot!

What are your initial thoughts on this? I am also curious what the effect is on more illiquid pairs (like the ones on ascendex), but I wonder if you are able to get the correct data.

I am also curious what the effect is of differently weighted top_depths on the weighted mid-price? Another idea is a rolling/exponential moving average of the weighted midprice of the past x ticks, this might not capture sudden changes in the midprice and a potential price direction, but in that way the mid-price would not bounce up and down after every tick if the orderbook changes.

Have you been able to perform any test to evaluate the short term predictive power of the weighted mid-price? Autocorrelation plots or regressions with lagged variables for example :slight_smile:

I wanted to link this discord message in which I mention another paper, so the info does not get lost :slight_smile:

Good job, curious about the other results!

Author: Jelle {Cryptobot} 0xe8f

I have been looking on github and found these repositories that calculate VOI, which is related to the article in the link I sent above.

This one is based on the article and shows all the code + output of volume order imbalance!

This one incorporates both the order flow imbalance (volume order imbalance, “VOI”) & the order imbalance ratio (“OIR”) which is similar to the microprice.

Microprice calculations based on the Paper by Stoikov:

An Medium Artice talking about Order Flow Imbalance and price impact.

Another Medium Article talking about Order Book imbalance in cryptomarkets and mentions the Microprice:

The last two are from the same developer :slight_smile:

Author: Jelle {Cryptobot} 0xe8f

Another research by Stoikov about OFI and the impact on the short term price.

Author: Lefty 0x9F8

Adding another useful article containing comparison of several price signals:

Regarding the linked Medium article, I studied it a few weeks ago and I think the evaluation is not done right and contains a looking-forward bias that makes the results look better than they are. See the comments.

Author: Jelle {Cryptobot} 0xe8f

Super interesting! I think it would be nice if we were able to conduct research like this ourselves based on all the methods described in the articles. If we have the data available and we are able to compute the different methods, we are able to compare them, or even combine them in a simple regression model for example.

I am also curious how well machine learning methods are able to predict the short term price movements (SVM’s, Neural networks, Boosting alog’s like XGBoost). We could also use a binary classification in which they predict if the price in x periods from now will be higher or lower than it is now by computing a P-value.

If I have a dataset with all the promising price parameters discussed in the articles I can use create these models to predict it and analyze it, but I do need help with computing the different parameters :slight_smile:

Optimal Application:

An ideal situation would be to first find the right parameters to build a good model based on our tests of these parameters that showed to have predicting power. Before running a PMM strategy, Hummingbot will pull the data from the Hummingbot PRO backtesting engine, compute the parameters, train the model and when running PMM, let the model predict price movements x times in the future and adjust spreads accordingly.

Author: Jelle {Cryptobot} 0xe8f

Here are two great pieces of content, one is another research about market making and inventory management and one is just a great piece of content in which you can find more content and related researches about this topic.

Author: weltam 0x94F

hi @jamesPmagic this might help you to collect the order book and tick data especially if you are using AWS

Author: BGT Capital 0x6DD

There are multiple papers and research that have proven multiple times micr-price is a lot better than weighted mid-price, which itself is much better than mid-price.

Below are the advantages of using the microprice compared to the mid and weighted mid price.

• The micro-price adjustment is only dependent on the spread and imbalance

• The micro-price is the expected mid-price in the distant future

• In practice, the micro-price converges rapidly and is adequately approximated when we compute the series until τ 6 (time of the 6th price move)

• The micro-price can fit very different microstructures

• The micro-price seems to live between the bid and the ask

I would propose to add a new feature to HB and add micro-price and weighted mid-price to the price sources.

PS: Please find here a brief summary to Stoikov’s micro-price

1 Like