Class MatchEngine

java.lang.Object
eds.model.MatchEngine
All Implemented Interfaces:
IMatchEngine

public class MatchEngine extends Object implements IMatchEngine
Matching engine responsible for executing incoming orders against the current OrderBook.

The engine follows standard price-time priority rules:

  • Incoming orders are matched against the best available price.
  • Execution price is always the price of the resting order.
  • If an order cannot be fully matched, remaining behavior depends on the order type.

Post-matching behavior:

  • Constructor Details

    • MatchEngine

      public MatchEngine()
  • Method Details

    • match

      public IMatchEngine.MatchResult match(Order incoming, OrderBook book, double currentTime)
      Processes an incoming order and attempts to match it against the order book.

      If matching counterpart orders exist, trades are generated until the order is filled or no further matches are possible.

      Specified by:
      match in interface IMatchEngine
      Parameters:
      incoming - the order entering the market
      book - the order book containing resting orders
      currentTime - the simulation timestamp of the event
      Returns:
      a list of Trade objects representing executed trades