Skip to content
Tutorials Center
My learning

Topics

Lesson 36 of 37 ยท Projects and Practice

Project: An Auction Simulator

Build a simulator that compares first-price, second-price and all-pay auctions with reserves, learn bidding strategies by best-response iteration, and measure revenue and efficiency.

In this project you build a small auction laboratory with numpy. It has three parts: a vectorized simulator that measures revenue and efficiency for different rules, a learning bidder that discovers its own strategy by repeated best responses (instead of using the theoretical formula), and a final experiment on bidder asymmetry, where revenue equivalence breaks down.

Part 1: a flexible simulator

An auction here is described by two functions: a payment rule that returns each bidder's payment from the bids, and a bid function that turns values into bids. This lets the same code simulate every format.

Python The simulator core

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

All three are efficient in this equilibrium and give the same revenue, as the revenue equivalence theorem says.

Part 2: a bidder that learns its strategy

Instead of trusting the formula, let the computer find the first-price equilibrium. Represent a bidding strategy as a shade factor function: bid = k * value, with one k. Repeat: all rivals use the current k; one bidder searches over its own k values to find the best response; update k toward it. If the process settles, that k is an equilibrium of the (restricted) strategy set.

Python Learning the first-price equilibrium

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The factor settles near 2/3 for three bidders. The learning view is more general than the formula: it also works when you cannot solve the equilibrium analytically, for example with asymmetric bidders or complicated rules.

Part 3: asymmetric bidders

Revenue equivalence needs the bidders to be symmetric. Suppose bidder 1's value is uniform on [0, 1] but bidder 2's is uniform on [0, 2]. In a second-price auction both bid their value. In a first-price auction, the weaker bidder bids more aggressively. We search for approximately optimal linear strategies by best-response iteration.

Python Revenue with two different bidders

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Linear strategies are only an approximation here (real equilibrium strategies are curves), but three things show up: the weak bidder bids a larger fraction of its value (about 0.48) than the strong bidder (about 0.32), first-price is not perfectly efficient any more (about 88 percent of auctions go to the higher value), because a strong bidder with a slightly higher value can lose to a weak one who bids more aggressively. and revenue differs between the formats (here second-price raises more, about 0.415 against 0.38). Which format wins depends on the distributions, and the exact numbers depend on the linear-strategy restriction.

Part 4: what to try next

  • Reserve prices: add a reserve to run_auction and sweep it from 0 to 0.8 for 2 to 6 bidders. Plot revenue against reserve; the optimum stays at 0.5 for uniform values.
  • Risk aversion: replace the profit by the square root of profit in the learning loop and see first-price bidders shade less.
  • Collusion: let two of the bidders agree that the one with the lower value bids zero in a second-price auction. How much does revenue drop?
  • Winner's curse: simulate a common-value auction where each bidder sees the true value plus noise. A naive bidder who bids their signal loses money on average.

What the simulator teaches

Equivalence Symmetric bidders, same revenue
Learning Best-response search finds equilibria
Asymmetry Breaks equivalence and efficiency
Design levers Reserves, entry and formats
1 / 2

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. In the simulator, why are bids below the reserve replaced with minus infinity?

    Bids under the reserve are excluded, so no sale happens if all bids are void.
  2. 2. What does best-response iteration look for?

    If the process converges, nobody wants to change: that is a Nash equilibrium within the allowed strategies.
  3. 3. With asymmetric bidders, what happens to first-price efficiency?

    The weak bidder bids more aggressively, so a lower-value bidder can win sometimes.
  4. 4. What is the winner's curse in a common-value auction?

    Selection: winning reveals that your estimate was the highest, which is bad news about your estimate.

Summary

  • A vectorized simulator can compare formats, reserves and strategies with one code path.
  • Best-response iteration finds equilibria numerically, even when no formula is available.
  • With symmetric private values, formats earn the same revenue; with asymmetry they do not, and first-price becomes inefficient.
  • Reserves, risk aversion, collusion and common values are natural extensions to explore.

Next: Practice Problems: Sequential, Repeated and Auction Games