denarius-exchange / denarius

An open-source financial exchange
Other
35 stars 5 forks source link

Matching policy #4

Closed analyticbastard closed 10 years ago

analyticbastard commented 10 years ago

The matching engine currently matches orders at the counterpart's price. This depends on which dosync transaction succeeds, and can result in different matching prices for the same configuration, i.e., Book={ASK size=1 price=10, BID size=1 price=9} Can cross at price 9 if the transaction for the ASK order succeeds or at price 10 if it is the one for the BID order. This is important for market orders, which are matched against themselves at market price (at limit counterpart's best price). This is not fair for one of the sides. A policy should be implemented to cope with this issue.

penberg commented 10 years ago

I don't understand what the problem is.

Assuming that we have an order book that looks like this:

Bid Size Bid Price Ask Price Ask Size
1 9.0 10.0 1

If there's a buy market order, it must match with the ask side at price 10.0 and if there's a sell market order, it must match with the bid side at price 9.0 as per price-time-priority rules:

http://www.eurexchange.com/exchange-en/trading/market-model/matching-principles/

Perhaps I misunderstood what you're saying here?

analyticbastard commented 10 years ago

What you say is correct. But I mean a more complex situation. The matching engine, as it is now, works as follows:

Type Bid Size Bid Price Ask Price Ask Size Type
L 1 9.0 10.0 1 L
M 1 1 M

And the transaction that success in the matching engine is that of the bid market order, then it crosses at 10 (reference opposite limit order) with the available ask market order. On the contrary, if the transaction that succeeds is the ask market order, the reference opposite limit price is 9 and the matching crosses both market orders at 9.

It might be me but this behaviour seems a little arbitary and I would think an explicit policy should take care of such things.

penberg commented 10 years ago

If there are no limit orders in the same side as the market order, I think all exchanges just cancel or reject the order. So the order book never gets into the kind of state you're describing.

analyticbastard commented 10 years ago

OK thanks, I close the issue. Market order removal in absence of limit orders can be implemented then.

penberg commented 10 years ago

IIRC if a market order shoots through all price levels, the unfilled part is also canceled in most exchanges. So market orders are never left resting in the order book.