According to wikipedia:
Natural ordering
- Order the buyers in decreasing order of their bid: b1≥b2≥...≥bn.
- Order the sellers in increasing order of their bid: s1≤s2≤...≤sn.
- Let k be the largest index such that bk≥sk (the "breakeven index"). Every price in the range [max(sk,bk+1),min(bk,sk+1)] is an equilibrium price, since both demand and supply are k. It is easier to see this by considering the range of equilibrium prices in each of the 4 possible cases (note that by definition of k, bk+1 < sk+1):
I've found a counterexample where the price range formula doesn't work, and I wanted to check if I'm on the right track.
Let:
Asks = [2.1, 2.2, 2.3, 2.4, 2.5]
Bids = [2.4, 2.3, 2.2, 2.1, 1.0]
^
In this case, k = 2 (indexing from 1).
According to the price range formula, the equilibrium would lie between [2.2, 2.3]. But if it was 2.2, then 2 sellers would accept it and*3* buyers would accept it. This isn't a state of equilibrium since the number of accepted buyers and sellers are unequal.
Strictly between $2.2$ and $2.3$ you are in equilibrium at a quantity of $2$. If the price exactly matches a bid or ask that person doesn't care if the transaction happens or not. This makes the quantity unclear at that point and equilibrium is within the range of possibility. If someone does a careful presentation they should make clear what happens when the transaction price exactly equals a bid or ask. The Wikipedia article does say that the transaction will happen if the price matches the bid or ask but it is not clear that the analysis really reflects that as your example shows. I think using the indifference of buyers/sellers will cover that, but have not worked it carefully.
The proof that this works is easy if you assume all the prices are distinct. Say you have $m$ bids and $n$ asks. At a price of $0$ you have demand of $m$ and supply of $0$. Define the imbalance as the demand minus the supply. At a price of $0$ the imbalance is $m$. At a very high price you have demand of $0$ and supply of $n$ for an imbalance of $-n$. As you raise the price from $0$ the imbalance is reduced by $1$ for each price, bid or ask, that you cross. Somewhere you have to go through $0$ and the equilibrium will hold for an interval between two prices. If some prices are exactly the same, the imbalance can change more than $1$ and you might miss $0$. It is reasonable to say that if the price is exactly at a bid or ask the person doesn't care if they transact or not. In that case you can have prices that match and the equilibrium can be found at one of the prices. Some of the people who have quoted that price will transact and some will not.