Discussion about this post

User's avatar
Tarun Telang's avatar

First filter out, invalid requests such as requests placed outside stock exchange working hours, requests from clients without sufficient funds, etc. Next, we can first separate the buy and sell orders into separate heap (or priority queue) data structure, with the highest buying price at the top of the buy queue and the lowest selling price at the top of the sell queue. Then, we can iterate through both queues and match orders based on price until one of the queues is empty.

Expand full comment
Keshav Maheshwari's avatar

What happens for pre market orders?

Some average price is decided there

Expand full comment
3 more comments...

No posts