Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Does anybody know what happens when the bid is not equal to but higher than the ask? What is the price that will be used? Or will this not lead to a transaction at all?


As others have mentioned this depends on how matching works on the exchange.

The case where the bid is higher or equal to the ask is known as a "crossed book". I most cases, this should never happen and if it does it would be as a result of a bug in the matching algorithm. If you place a buy/sell order with a price that is in excess of the best ask/bid respectively then that order will be matched against the opposite side. Under normal conditions what you suggested should be impossible.

If you want to know more about how order books work, I wrote an article specifically about how this works mechanically: https://www.machow.ski/posts/2021-07-18-introduction-to-limi...


Thank you for this! This is exactly what I was looking for.


No problem, glad it was helpful!


This depends on the matching algorithm.

Generally if a bid is introduced that is higher than the ask, the volume at the ask is matched, then the volume leftover at each ask level is matched in order of price (then time).


I don't know the answer, but I think it would make sense to consider which offer came in first:

First case: you ask for 100 and then I bid 105 --> transaction clears at 100, the ask price

Second case: I bid 105 and then you ask for 100 --> transaction clears at 105, the bid price

This is because I implicitly think about bid offers as "I want to buy this for at most X dollars" and ask offers as "I want to sell this for at least X dollars".

I might be completely wrong though.


Yes, usually transactions are executed at the resting order prices (i.e. whatever is already being advertised in the market, and a transaction can involve multiple orders at different prices).


I believe this results in paying the bid.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: