Benchmark Price Selection Algorithm
Rule 0: Best bid < best inquiry, no order to be traded, no matching;
Rule 1: The principle of maximum trading volume. When the transaction is made at the benchmark price, the maximum transaction volume can be obtained. If multiple prices can meet the maximum transaction volume, it will enter the next step;
Rule 2: The principle of least excess. Excess refers to the difference between the total amount of accumulated buy orders and the total amount of accumulated sell orders at the current price. The principle of minimum excess refers to selecting the price with the smallest absolute value of excess value from the prices satisfying Rule 1. If there are multiple prices that meet this rule, go to the next step.
Rule 3: Market Pressure Principle. When there are multiple prices that satisfy both rules 1 and 2 (the maximum value is max and the minimum value is min), it is necessary to determine the position of the market pressure on the potential price. The excess is all positive, which means buying more and selling less, which is pressure from buyers; all the excess is negative, which means buying less and selling more, which is pressure from sellers; if there are positive and negative excess, there is no obvious pressure from buyers and sellers. The reference price (ref) is determined according to the following rules. If ref is within the [min, max] interval, select ref as the benchmark price; if ref is outside the [min, max] interval, select the min or max closest to ref as the benchmark price.

Last updated