Algorithmintro
Vickrey auction
Also called second-price sealed-bid auction, second-price auction.
Each bidder submits one sealed bid. The highest bidder wins and pays the second highest bid, so bidding one's true value is a weakly dominant strategy.
- Time
- O(n) worst
- Space
- O(1) extra
- Where
- n = the number of bidders
- Model
- Word RAM
- Properties
- comparison baseddeterministiciterative
- Evidence
- Proof sketchCode in 1 languages
- Origin
- William Vickrey, 1961
The Vickrey auction, also called the second-price sealed-bid auction, sells one item. Each bidder submits one sealed bid, the highest bid wins, and the winner pays the highest of the other bids, not its own. Because the price does not depend on the winner's own bid, bidding the true value is a weakly dominant strategy, so the auction is DSIC and gives the item to the bidder who values it most. With private values it has the same outcome as the English auction, in which the price rises until one bidder is left, and it is the one-item case of the VCG mechanism.
In plain words
Everyone writes a price in an envelope. The person with the highest price gets the item, but pays only the second highest price written by someone else. This rule takes away the reason to lie. If you write less than the item is worth to you, you do not lower what you pay when you win, you only risk losing an item you wanted at a good price. If you write more, you only add the risk of winning at a price above your worth. So the best thing to write is exactly what the item is worth to you, whatever the others write.
The problem
One item is for sale to bidders. Bidder has a private value and quasilinear utility: if it wins and pays , and if it loses. The seller sets a reserve , the lowest price at which it sells. The auction is a direct revelation mechanism: it receives bids and must choose a winner (or no sale) and a price. The goal is a rule under which truthful bidding is dominant, the item goes to the highest value at least , and losers pay nothing.
The algorithm
A bid is eligible if it is at least . The variable holds the highest bid seen so far other than that of the current leader , and never less than .
VICKREY(b_1, ..., b_n, r)- 1
w ← NIL; s ← r - 2
for i ← 1 to n: - 3
if b_i ≥ r and (w = NIL or b_i > b_w): ▷ i is the new leader - 4
if w ≠ NIL: s ← b_w ▷ the old leader's bid is now the best other bid - 5
w ← i - 6
else: s ← max(s, b_i) - 7
if w = NIL: return NIL, 0 ▷ no bid reaches the reserve - 8
return w, s ▷ w wins and pays s; all others pay 0
The winner is the smallest index among the highest eligible bids, because line L3 replaces the leader only on a strictly larger bid. The price is . This is the critical bid of the winner: the smallest bid with which it would still win against the same .
Example
Three bidders bid their values and .
| step | leader | ||
|---|---|---|---|
| start | NIL | 0 | |
| 10 | 1 | 0 | |
| 7 | 1 | 7 | |
| 3 | 1 | 7 |
Bidder 1 wins and pays 7, so its utility is . With bidder 1 pays 8. With the item is not sold. With bids the tie goes to bidder 1, which pays 7.
Lies do not help. If bidder 1 bids 6 instead of 10, it loses and gets 0 instead of 3. If it bids 20, it still pays 7. If bidder 2 bids 11 instead of 7, it wins, pays 10, and gets .
With values drawn independently and uniformly from (independent private values), the price is the second-highest value, whose expected value is : for two bidders and for three. With two bidders and the reserve , the expected revenue rises to , the most that any auction can earn here (Myerson's optimal auction). The tests check these numbers by simulation.
Correctness
The proof is in proofs/correctness.md. It shows three facts.
- The output. The loop keeps the invariant that is the first highest eligible bid among the bids seen and is the largest of and the other bids seen. So line L8 returns the first highest eligible bidder and the price .
- Truthful bidding is weakly dominant. Fix the bids of the others and let , which bidder cannot change. A bid above wins and pays , and a bid below loses. So the truthful bid gets , the best of the two outcomes. A bid that changes the outcome either gives up a gain or buys a loss .
- Individual rationality and efficiency. A truthful bidder never gets a negative utility (individual rationality), and with truthful bids the item goes to a highest value that is at least .
The dominance holds for every , with no prior on the values and no assumption that the others are truthful.
Proof: The Vickrey auction picks the highest bid, charges the critical price and makes truthful bidding dominantfull
We use the pseudocode of the page, with bids and a reserve . Call bidder eligible if . Let be the smallest index among the eligible bidders with the largest bid, and if no bidder is eligible. For a bidder , let .
Claim 1. VICKREY returns if some bidder is eligible, and otherwise.
Proof. We use this invariant of the loop of line L2.
(I) Before the iteration for , with : (a) is the smallest index among the eligible bidders of with the largest bid, or NIL if none of them is eligible; (b) .
Initialization. For , line L1 gives and , and both sets are empty.
Maintenance. Assume (I) for .
- If line L3 is true, and either no earlier bidder is eligible or is strictly larger than the best earlier eligible bid. So is the new leader, and it is the smallest index with that bid, because every earlier bid is smaller; (a) holds for . If was NIL, all earlier bids are below and is still correct. Otherwise line L4 sets . This is correct, because , and for every earlier : an earlier eligible has by (a), and an earlier ineligible has . Line L5 makes the leader, so (b) holds for .
- If line L3 is false, either , or . In both cases does not become the leader: an ineligible bid cannot lead, and a tie with goes to the smaller index . So (a) holds for . Line L6 adds to the maximum, so (b) holds for .
Termination. For , (a) says and (b) says . Lines L7 and L8 return the claimed pair.
Claim 2 (truthful bidding is a weakly dominant strategy). Fix , a value and bids of the others. Let be the utility if wins and 0 if it loses. Then for every bid , and .
Proof. The value does not depend on . By Claim 1, bidder wins if and only if and beats every other eligible bid with the tie rule. So there is a threshold: wins when , loses when , and at the tie rule decides, with an outcome that depends only on . When wins, it pays , whatever its bid.
- If , the bid wins and gives . Any other bid gives either (if it wins) or 0.
- If , the bid loses and gives 0. Any winning bid gives .
- If , every bid gives 0, as a win pays .
In all three cases , which is at least and at least 0.
Claim 3 (efficiency). If every bidder bids its value and , the winner has the largest value. With a reserve , the item goes to a bidder of the largest value if that value is at least , and is not sold otherwise.
Proof. Immediate from Claim 1 with .
Cost. The loop runs times, and each iteration does at most two comparisons in line L3 and one maximum in line L6. The time is and the extra space is .
Complexity
One pass over the bids, with at most two comparisons in line L3 and one in line L6 per bid, so the time is and the extra space is . This is optimal up to the constant, since each bid must be read. The fewest comparisons that find the largest and the second-largest of numbers is , with a knockout tournament (selection problem). The implementation uses exact comparisons, so it works with integers, fractions or floats.
Properties
- DSIC. Truthful bidding is a weakly dominant strategy for every bidder.
- Efficient. With truthful bids and , the item goes to the highest value.
- Ex post individually rational and no positive transfers. A truthful bidder has utility at least 0, and no bidder is ever paid.
- Prior-free. The rule and the bidders' strategies need no distribution of values.
- Revenue. In the symmetric independent private values model, the expected revenue is the expected second-highest value. By the revenue equivalence theorem it equals the revenue of the first-price, Dutch, English and all-pay auctions.
- Not strictly dominant. For a fixed many bids are as good as the truth, for example any bid above when . Dominance is weak.
Variants and improvements
- Reserve price. The parameter above. With symmetric bidders whose values have a regular distribution, the Vickrey auction with the reserve , where is the virtual valuation, is optimal for revenue (reserve price). For asymmetric bidders the optimal auction is no longer a Vickrey auction with one reserve.
- identical items. The highest bids win and each pays the -th highest bid. This is the VCG mechanism for units and unit demand, and it is DSIC.
- VCG. For many items and general valuations, the VCG mechanism charges each bidder the welfare loss it causes the others. The Vickrey auction is its one-item case.
- English auction and proxy bidding. The English auction reaches the same outcome by an open, rising price. Online auctions use proxy bidding: the bidder states a maximum, and a program raises its bid by one increment at a time, which is close to a second-price rule.
- Generalized second-price auction. For ranked ad slots, each bidder pays the next bid below. This is not DSIC for more than one slot (generalized second-price auction).
When to use it
Use it when the goal is to give the item to the bidder who values it most and the bidders should not have to guess what the others will bid. It suits automated bidders, since the best strategy is simple and the same for every belief about the others. It is a poor choice when the seller cannot be trusted to report the second bid honestly, when bidders fear that their bid reveals their value to a later negotiation, or when the bidders can collude (Rothkopf, Teisberg and Kahn 1990). Many display advertising exchanges used second-price rules for years and moved to first-price rules around 2019.
Pitfalls
- Weak dominance does not exclude other equilibria. With two bidders of values 10 and 3, the bids form a Nash equilibrium: the low-value bidder wins and pays 0. The truthful equilibrium is the one in dominant strategies, but it is not the only one.
- A cheating seller. The seller sees the bids and can add a fake bid just below the winning bid (a shill bid). The winner then pays nearly its full value, and it cannot detect the change from the outcome alone.
- Collusion. If the second and third bidders agree that only one of them bids, the price drops. DSIC holds for each bidder alone, not for groups.
- Ties. A tie at the top must go to one bidder by a fixed rule, and the winner then pays its own bid. Tests of DSIC must compare utilities with , not , and must use exact arithmetic.
- The reserve is a bid of the seller. The price is , not the second bid alone. Forgetting in line L1 makes the winner pay less than the reserve.
- Values must be private. If a bidder's value depends on what the others know, as in a common value auction, the truthful bid is no longer dominant and the winner's curse appears.
Implementations
Each implementation follows the pseudocode above. A comment @line links a line of code to a line of the pseudocode. Point at a line of the pseudocode to see the matching code. The build runs the native tests of each language.
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/vickrey-auction/. The authors are listed in prov/3GCYFC.jsonl.
from fractions import Fraction
from typing import Sequence, Union
Number = Union[int, Fraction, float]
def vickrey_auction(
bids: Sequence[Number], reserve: Number = 0
) -> tuple[int | None, Number]:
"""Run a second-price sealed-bid auction with a reserve price.
A bid can win only if it is at least the reserve. The highest such bid
wins, and a tie goes to the smallest index. The winner pays the larger of
the reserve and the highest bid of the other bidders. Return the 0-based
index of the winner and the price, or (None, 0) if no bid reaches the
reserve. Losers pay 0.
"""
winner: int | None = None
second: Number = reserve # @line L1
for i in range(len(bids)): # @line L2
b = bids[i]
if b >= reserve and (winner is None or b > bids[winner]): # @line L3
if winner is not None: # @line L4
second = bids[winner] # @line L4
winner = i # @line L5
else:
second = max(second, b) # @line L6
if winner is None: # @line L7
return None, 0 # @line L7
return winner, second # @line L8
def utility(value: Number, bids: Sequence[Number], i: int, reserve: Number = 0) -> Number:
"""Quasilinear utility of bidder i with the given value when the bids are bids."""
winner, price = vickrey_auction(bids, reserve)
if winner != i:
return 0
return value - price
test_vickrey_auction.py 86 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/vickrey-auction/. The authors are listed in prov/3GCYFC.jsonl.
import itertools
import random
from fractions import Fraction
from vickrey_auction import utility, vickrey_auction
def reference(bids, reserve=0):
eligible = [i for i in range(len(bids)) if bids[i] >= reserve]
if not eligible:
return None, 0
top = max(bids[i] for i in eligible)
winner = min(i for i in eligible if bids[i] == top)
others = [bids[j] for j in range(len(bids)) if j != winner]
return winner, max([reserve] + others)
def test_example() -> None:
assert vickrey_auction([10, 7, 3]) == (0, 7)
assert vickrey_auction([3, 7, 10]) == (2, 7)
assert vickrey_auction([10, 7, 3], reserve=8) == (0, 8)
assert vickrey_auction([10, 7, 3], reserve=12) == (None, 0)
def test_edges() -> None:
assert vickrey_auction([]) == (None, 0)
assert vickrey_auction([5]) == (0, 0)
assert vickrey_auction([5], reserve=2) == (0, 2)
assert vickrey_auction([7, 7, 3]) == (0, 7)
assert vickrey_auction([3, 7, 7]) == (1, 7)
assert vickrey_auction([2, 2], reserve=2) == (0, 2)
assert vickrey_auction([Fraction(1, 3), Fraction(1, 2)]) == (1, Fraction(1, 3))
def test_against_reference() -> None:
rng = random.Random(1)
for _ in range(2000):
n = rng.randrange(0, 7)
bids = [rng.randrange(0, 6) for _ in range(n)]
r = rng.randrange(0, 5)
assert vickrey_auction(bids, r) == reference(bids, r)
def test_truthful_bidding_is_dominant() -> None:
grid = range(0, 6)
for reserve in (0, 2):
for others in itertools.product(grid, repeat=2):
for i in range(3):
for value in grid:
truthful = list(others[:i]) + [value] + list(others[i:])
u_true = utility(value, truthful, i, reserve)
assert u_true >= 0
for lie in grid:
bids = list(others[:i]) + [lie] + list(others[i:])
assert u_true >= utility(value, bids, i, reserve)
def test_price_does_not_depend_on_winning_bid() -> None:
rng = random.Random(2)
for _ in range(500):
bids = [rng.randrange(0, 20) for _ in range(4)]
w, p = vickrey_auction(bids)
raised = list(bids)
raised[w] += rng.randrange(0, 10)
assert vickrey_auction(raised) == (w, p)
def mean_revenue(n, reserve, trials, seed):
rng = random.Random(seed)
total = 0.0
for _ in range(trials):
_, price = vickrey_auction([rng.random() for _ in range(n)], reserve)
total += price
return total / trials
def test_revenue_uniform() -> None:
# Each price is in [0, 1]. With 20000 trials, Hoeffding gives
# P(|mean - expectation| > 0.02) <= 2 exp(-16) < 1e-6.
assert abs(mean_revenue(2, 0, 20000, 3) - 1 / 3) < 0.02
assert abs(mean_revenue(3, 0, 20000, 4) - 1 / 2) < 0.02
assert abs(mean_revenue(2, 0.5, 20000, 5) - 5 / 12) < 0.02
assert abs(mean_revenue(1, 0.5, 20000, 6) - 1 / 4) < 0.02
History
Vickrey (1961) studied auctions as games of incomplete information. He defined the sealed-bid auction in which the winner pays the second-highest bid, proved that bidding the true value is dominant, and noted that it gives the same result as the English auction with private values. He also computed, for uniform values, that the first-price auction earns the same expected revenue, which is an early case of revenue equivalence. Second-price rules were in use earlier: stamp dealers who ran auctions by mail in the nineteenth century charged the winner the second-highest mailed bid, plus one increment (Lucking-Reiley 2000). Vickrey received the Nobel Memorial Prize in Economic Sciences in 1996, together with James Mirrlees. Clarke (1971) and Groves (1973) extended the idea of charging the externality to general decisions, which led to the VCG mechanism.
References
- William Vickrey, Counterspeculation, auctions, and competitive sealed tenders, Journal of Finance 16(1) (1961), 8-37, the second-price sealed-bid auction, the proof that bidding the true value is dominant, and its relation to the English auction
- Vijay Krishna, Auction Theory, 2nd edition, Academic Press, 2010, Chapter 2, Section 2.2 (second-price auctions, the weakly dominant strategy and the expected payment) and the section on reserve prices in the same chapter
- Tim Roughgarden, Twenty Lectures on Algorithmic Game Theory, Cambridge University Press, 2016, Lecture 2, Section 2.4 (second-price auctions and dominant strategies)
- David Lucking-Reiley, Vickrey auctions in practice, from nineteenth-century philately to twenty-first-century e-commerce, Journal of Economic Perspectives 14(3) (2000), 183-192, the use of second-price rules in stamp auctions by mail before 1961 and the proxy bidding of online auctions
- Michael H. Rothkopf, Thomas J. Teisberg and Edward P. Kahn, Why are Vickrey auctions rare?, Journal of Political Economy 98(1) (1990), 94-109, the reasons why real auctioneers avoid the sealed second-price rule, with the fear that bids reveal values to later negotiations and a cheating auctioneer
Where this leads
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H1 sketch |
|
| Lean | L0 no Lean part |
|
| Code (python) | I0 not checked yet |
|
| Visual | V0 none |
|
| Writing | W2 basic |
|
Tag 3GCYFC Edit this page History Report an error Markdown