0
$\begingroup$

I am a little confused about how orders get processed in a limit order book, hope to get a better understanding with this post.

If we start off with an order book

Asks:
SELL 2 units at 300
SELL 2 units at 200
SELL 1 units at 100

            Bids:
    BUY 1 units at 50

and a user places a new limit order which causes his account balance to decrease by $400 (2x200 = $400),

New Order: BUY 2 units at 200

Is the resulting order book supposed to be

Order book #1

Asks:
SELL 2 units at 300
SELL 1 units at 200

            Bids:
    BUY 1 units at 50

because his order of quantity 2 first matches with 1 units at 100 then matches 1 units at 200

or should the resulting order book be

Order book #2

Asks:
SELL 2 units at 300
SELL 0.5 units at 200

            Bids:
    BUY 1 units at 50

because his order is of $400, so it first matches with 1 units at 100 for $100, then the remaining $300 matches with 1.5 units at 200.


Based on casually trading on crypto exchanges, I think we should end up with Order book #2.

However, based on reading some code for a Limit order book, it appears we should end up with Order book #1. If so, then what happens to the $400 that was deducted from the trading account when the order of BUY 2 units at 200 was first placed? Is the unused $100 returned back to the user's account after his order has been processed by the matching engine?

Thank you!

$\endgroup$
4
  • $\begingroup$ You have a typo. You said "matches with 1.5 units at 200" while your first example only shows 1 unit at 200 in the beginning. As for your question, scenario 1 is correct unless the venue has some kind of exotic midpoint match algorithm. $\endgroup$
    – rkr
    Jul 30, 2021 at 16:09
  • $\begingroup$ I don't know much about crypto trading, but in traditional markets Scenario 1 is correct. Perhaps crypto exchanges are different? $\endgroup$
    – nbbo2
    Jul 30, 2021 at 17:00
  • $\begingroup$ @noob2 Thanks for confirming that scenario 1 is the typical scenario. What then happens to the cash not used in BUY order? Placing the BUY 2 units at 200 order will deduct $400 from the user's cash account balance, but the matching with 1 units at 100 takes up $100 and matching with 1 units at 200 takes up $200 . How does the exchange handle the additional $100 that was deducted from the user's account? $\endgroup$ Jul 30, 2021 at 19:50
  • 1
    $\begingroup$ The 400 is not deducted but simply frozen or blocked temporarily. When the order(s) are filled the block is removed and the correct amount (which may be less than 400) is deducted. $\endgroup$
    – nbbo2
    Jul 30, 2021 at 19:58

1 Answer 1

2
$\begingroup$

A limit buy means he is willing to pay up to \$200 for 1 unit. Since there is one offer of 1 unit at \$100 that one will be bought out first followed by 1 unit at \$200. So only a total of \$300 of his money will be deducted.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.