# Order Matching Engine

The task of the order-matching engine is to ensure that trades are executed at the best price by patronizing the lowest asks and highest bids across all available exchanges.

When a new order is created, the engine first tries to execute it on the internal order book. If this does not give the best price, it then uses data provided by a Price Discovery Module to find the exchange or exchanges to which the order should be sent to, depending on the required amount and the depth profile of each exchange.

The order is broken up and sent to the appropriate exchanges based on the findings of this analysis. To fulfil a big order, or an order for a less-popular pair, the trade will generally be divided into tiny portions and spread across several exchanges; in other cases, one exchange may provide the best price for the quantity necessary. These deals are aggregated after a successful execution, and the customer is notified that the order has been completed.

Every order must comply with any one of the following statuses:

* New&#x20;
* Accepted&#x20;
* Filled&#x20;
* Partially&#x20;
* Filled&#x20;
* Cancelled&#x20;
* Partially&#x20;
* Cancelled
* Partially cancelled
