6 Commits
Author SHA1 Message Date
mika@stocksharp.com 536abc52b0 Refuse a market order that has no market, and say so
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.
2026-09-19 23:49:12 +03:00
mika@stocksharp.com 786837968b Fix matching engine and emulation lifecycles 2026-09-14 18:22:25 +03:00
mika@stocksharp.com 735a0e701c Book each maker of an internal cross for what was taken from it
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.
2026-08-22 09:45:25 +03:00
mika@stocksharp.com af7255490c Fix order matcher book consumption 2026-06-14 17:18:57 +03:00
mika@stocksharp.com 0bcf594d25 Use Ecng Common extensions across codebase
Replace standard .NET APIs with Ecng.Common equivalents:
- Math.Min/Max/Abs/Round → .Min()/.Max()/.Abs()/.Round()
- string.IsNullOrEmpty → .IsEmpty()
- string.Format → .Put()
- Encoding.UTF8 → .UTF8()
- Enum.GetValues → Enumerator.GetValues<T>()
2026-03-29 17:04:00 +03:00
mika@stocksharp.com db29e70fde Extract MatchingEngine project from Algo.Testing
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.
2026-03-05 06:25:55 +03:00