Auction winning bid algorithm
Friday, April 25, 2003 03:02 PM
Some pseudocode for determining the winner of a single-item auction where the bidders are all using "auto-bid" (where you tell the system what your maximum bid is, and the system bids for you). I'm just posting this here so I don't forget.

// not shown: insert new bid into bid table

bidders = query("SELECT ... ORDER BY maxBid DESC, bidTime ASC")

winner = bidders[0]
runnerup = bidders[1]

x = winner.maxBid
y = (runnerup == null) ? MIN_BID : runnerup.maxBid + BID_INCREMENT
return min(x, y)