Order book for exchange

Hello bubblers,

I am building an orderbook crypto exchange where users can place buy and sell orders which are filled & updated real-time. For example- a user may place a BUY order for 10,000 tokens at price of 1.5 per token with only 5000 tokens available in. SELL order priced at 1.45 while 3000 tokens are available in SELL order priced at 1.47 and another 2000 tokens at 1.49.

The problem i am facing is how to mark all BUY & SELL orders as filled on orderbook type of thing by doing a search based on price criteria’s. I understand we can search for last item and update the database, but it only works if order qty < last item order qty. How to do i apply search orderbook to update fill order on last item -1 or last item -2…so on & till the full order quantity is filled?

Will be grateful for swift reply

Thanks

This topic was automatically closed after 70 days. New replies are no longer allowed.