-
Notifications
You must be signed in to change notification settings - Fork 1
darkpool design docs
The matching engine is the main componenet of darkpool. It manages buy and sell orders from clients to facilitate trades. The matching engine keeps a list of buy and sell orders in its order books and matches them with market order, limit order and stop order rules. After matching the orders, it records the trade in the ledger and informs the clients. The matching engine also handles canceling of orders that have not been processed.
Each order is either a buy or a sell order. It is also a market, limit or stop order. A market order is bought or sold at the current market price. A limit order is bought or sold only if the price is above or below some threashold set by the user. A stop order is bought or sold until some threashold price set by the user is reached. The orders are stored in the matching engine's order book.
A market order has a type (buy/sell), a quantity, an order id and an account id.
In addition, a limit order has a threashold.
A stop order has the same information as a limit order.
A trade is created when a buy and a sell order are matched. It has account ids for the buyers and sellers, order ids for the buy and sell orders, a price and a quantity.
The database is used to store a history of the transactions made and the current orders in the order books.