1. How does order matching work?
Orders are matched according to price-time priority, i.e. orders with more aggressive price (higher for buy, lower for sell) have higher priority for matching, and for orders with the same price, their priorities are sorted by submission time ascending. "Open Long" and "Close Short" orders belong to the bid side, while "Close Long" and "Open Short" orders belong to the offer side. On each side, the orders are sorted according to price-time priority. Matching happens when the highest bid price is higher than or equal to the lowest offer price.
2. What happens after the orders are matched?
Once an open long or open short order is matched, corresponding position will be opened. The Average Position Price and Settlement Reference Price will be updated accordingly. When a close long or close short order is matched, corresponding position will be closed. The Average Position Price and Settlement Reference Price will remain the same.
3. How to calculate Average Position Price
Average Position Price = Face Value x (Number of Contracts Held x Original Average Position Price + Number of Contracts Opened x Filled Price) /(( Number of Contracts Held + Number of Contracts Opened) x Face Value)
Settlement Reference Price is set to be the Settlement Price at 4pm Hong Kong time everyday, and will be updated whenever there are new contracts opened. It is equal to the Average Position Price if the position has never been settled.
Example: The latest mark price is 600 USDT/BTC. A user holds 6 BTC long contracts(with Face Value of 0.0001BTC) and his average position price is 500 USDT/BTC.
The user now opens extra 5 long contracts with the details below:
The Average Position Price of the 5 contracts is: ( 0.0001 x 1 x 580 + 0.0001 x1 x 570 + 0.0001 x 3 x 560) /(0.0001x5)= 566
Therefore, the new Average Position Price will be: （0.0001 x 6 x 600+0.0001 x 5 x 566）/（0.0001 x 11）=584.5