Chapter 5 · SimulationDouble Auction? ← Chapter 5Price—Trades0Buyer surplus0Seller surplus0Welfare0Your utility—Buyers (bid ↓)Sellers (ask ↑) CloseDouble auction marketA double auction is a two-sided market: buyers submit bids and sellers submit asks, all at the same time. Bids are sorted from high to low and asks from low to high; pairs trade as long as the bid is not below the ask. All trades take place at a single clearing price: the midpoint of the interval between max(last matched ask, first unmatched bid) and min(last matched bid, first unmatched ask). At this price every matched trader wants to trade and no unmatched trader does.UsageRun clearing round clears the current order book. Matched rows turn green and the metrics are updated.Next market event makes the bots revise their bids and asks (at Level 3 a new buyer or seller arrives), then clears again.New market draws new values and costs. Changing the scenario, mode or level also starts a new market.Your row is marked with *. Your utility is value − price for a buyer and price − cost for a seller if you trade; otherwise it is 0.ScenariosStock exchange: buyers put a value on an asset and sellers have reserve prices; bid–ask matching imitates a simplified exchange.Energy market: buyers represent demand and sellers represent generators with different marginal costs.Marketplace (online): buyers and sellers submit orders through a platform for a single standard product.ModesHuman buyer (against bots): you set buyer B1's bid; you gain by buying below your private value.Human seller (against bots): you set seller S1's ask; you gain by selling above your private cost.You manage: the slider sets B1's bid and S1's ask (110 − slider) together; you can watch the clearing point shift.Computer: bots place all the orders; they shade bids below value and asks above cost.LevelsLevel 1: 3 buyers × 3 sellers, easy to follow.Level 2: 5 × 5, deeper competition and a steadier price.Level 3: at each market event a new buyer or seller arrives (up to 8 per side); conditions change over time.Key ideaTrade is efficient when the buyer's value exceeds the seller's cost. Strategic bids (below value) and asks (above cost) determine who trades and how the gains from trade are split; they can also block efficient trades. Welfare = buyer surplus + seller surplus; if someone bids above their value or asks below their cost and trades, their surplus can be negative.