You got Election in my Blog!

Based on the xkcd page using Intrade state-by-state prediction market prices, I have written my own program to fetch intrade data and show some statistics based on it. You can view its final output here or get the source.

First is the same number shown on the xkcd page, the fraction of elections won by each major-party candidate in a 2-man race according to the state-by-state predictions. Unlike xkcd, I show two decimal places and go into a special exponential mode for numbers very close to 0% or 100%. (I don't know whether this will really be needed, but what the heck)

Second is the number of EV that are within X% of going for a given candidate. The numbers on the "50%" line should total to 538, while in the "20%" line only states within 80..100% for one candidate (that is, a 20% chance of being lost) will be shown in that candidate's column. Those numbers will go down to .1% but only show rows that aren't zeros.

Because this program uses intrade's xml data interface, each run takes only about 4 seconds to do 3 requests (limit 50 "stocks" per request, but 102 stats are requested). xkcd's program used a much slower scheme that included running perl and lynx, then parsing the html with regular expressions. (I never thought I'd say this, but Shame on you, Randall Munroe)

PS I don't have a position on whether the intrade predictions are actually predictive of this election.

Files currently attached to this page:

states.py13.3kB



Entry first conceived on 4 November 2008, 0:23 UTC, last modified on 15 January 2012, 3:46 UTC
Website Copyright © 2004-2024 Jeff Epler