Back to problems

Order Book Matching Simulation

Algorithm · Optiver · Medium

Requirements Buyers and sellers place orders at different prices, and unmatched orders remain in an order book. When a new buy order with price p is received: If any resting sell has a price no greater than p, execute a trade against the sell with the lowest price among those candidates. The trade uses that sell's price, and both orders leave the book. If no such sell is available, store the buy order in the book. A new sell order works in the opposite direction: it trades…

Checking your access…