A market order names no price, so only the book can give it one. Sent against a
side holding nothing - an empty book, or a book quoting only the order's own
side - it produced an Active row and then a Done row with the balance still
equal to the volume and no error at all, which reads exactly like an order that
filled as far as it asked to. A strategy could not tell that it had not traded,
let alone why.
The refusal was already written, and switched off: the check that an order with
no price cannot be paid for sits behind an early return taken when money is not
being checked, and money is not checked by default. Whether a market exists is
not a question about money.
Two neighbours stay as they are, and are now pinned: an order the book fills
only part of did find a market, so it ends Done with what it bought; a limit
order carries its own price and rests in an empty book.
Gone with it: a setting naming this behaviour that nothing ever read, and a
variable in the matcher that computed whether anything traded and did nothing
with the answer.
The volume a resting order gave up was computed while consuming it and then thrown
away: the book returned only the orders a level had held, and the adapter worked the
traded volume out afterwards from a balance the consumption had already decremented.
A maker eaten down to its last lot was therefore booked a trade of zero volume, its
position never moved, and downstream the inventory book stayed skewed by the whole
amount for good, because a zero-volume trade is dropped. Orders sitting at a touched
level that the match never reached were booked a phantom trade for the same reason.
The consumed volume now leaves the match with the fill that produced it: ConsumeVolume
yields a MatchFill per resting order - which order, how much of it was taken, what was
left - and MatchTrade.CounterOrders becomes CounterFills. Each maker is booked exactly
what the taker took from it, and an order the match never reached raises nothing.
Move 9 core matching engine files (OrderBook, OrderMatcher, PortfolioManager,
MarginController, OrderLifecycleManager) into standalone MatchingEngine project
with namespace StockSharp.MatchingEngine. MarketEmulator stays in Algo.Testing
and references MatchingEngine. Update all solution files and test references.