Blogger Hacks, Categories, Tips & Tricks

Wednesday, September 20, 2006
Collective Wisdom: From Polls to Markets
In the ceaseless quest for stuff to roll into my sidebar, I thought I'd try that old standard, the reader poll. Beloved by all media, it's found a natural home in the blogosphere. And why not: it's a great way to make your blog interactive, foster a sense of community plus garner some insights into your readership.

The downside is that (as any losing politician will happily point out), polls are meaningless, arbitrary, prone to abuse, afford only a snapshot view and, for participants, finding out the results isn't exactly exhilarating. From a bloghacking perspective, the widespread availability of good quality in-blog polling options means it's very quick and easy to get a polished result with hardly any effort. Honestly, where's the fun in that? So I thought I'd turn all that on its head with integrated prediction markets.

Read on for how to build a deeply-committed interactive community around your blog, using the latest ideas in applied economics and cutting-edge web technology.

The Prediction Market Concept

The idea behind prediction markets is that if you want to know what will happen, you should let people speculate (ie bet) on those outcomes (or events). The hope is that the prices in the market represent the distilled aggregate assessment of the underlying odds (or probabilities) by informed participants. The net effect of a large group of people putting money on the line is that it encourages individuals to divulge their private information, plus movements in prices (ie changes in odds) are quickly assimilated by the market.

These markets have been put to use (very successfully) in a range of human activities. Some of the more notable ones include picking the US president, picking Oscar winners and picking champion sports teams. There was also the unfortunate matter of the US Defense Department's Policy Analysis Market, designed to predict coups and the like. It was lambasted as a "terrorism futures market" and unceremoniously dumped. Of course, big, forward-looking companies like Google are not stymied by knee-jerk popular opinions and so use these internally.

Prediction Markets as Polls

Generally speaking, a poll lets you pick one option (from a set), once. Some might ask about your preferences (not open to speculation), but a lot ask you to make a prediction about the future or other unknowns. This is where Prediction Markets come to the fore.

You need to set up a contract-type for each alternative, with a "pay-off" (say, $100) if that outcome eventuates. You then release a fixed number of contracts of each type (say, 100), and let readers buy and sell at whatever price they wish. If someone thinks the chance of an event is 15%, then they'll pay $15 for a $100 pay-off. (That is, a 15% shot at $100 is worth $15.) If a second person thinks the odds are really 30%, then they'll pay $30 - and the first person will gladly sell them the contract. In this way, market mechanisms ensure that prices tend towards the best assessment of the underlying odds. This is sometimes dubbed "the wisdom of crowds".

Participants can trade as often as they like across whichever outcomes they choose. Typically, they would have a "portfolio" of events at different prices, and they would buy and sell contracts as news comes to hand. When the event materialises, the market owner "closes out" the contracts - the "winning" contracts pay out $100 each and all the rest are worthless. Savvy pundits will make sure they're holding more of the winning contracts than anyone else - and they would have bought them at a cheaper price. (Hey, if you just paid $99 for a winning contract, you're hardly ahead, are you?)

So, you can see why prediction markets out-perform polls: you can "spread your bets" across multiple outcomes, revise your estimates continuously and see what "odds" (prices) others have set. As a blog publisher, this translates into more readers, more monitoring activity, more discussion and an emotional commitment to keep coming back as news comes to hand.

Implementing Prediction Markets

This might be sounding all a bit pie-in-the-sky, right. Well, as they say on the cooking shows, here's one I prepared earlier. The Aussie Rules Misbehaviour Market is a prediction market I set up last month that allows people to speculate on which football club will next see a player appear in court. (We have a problem with criminality amongst professional footballers where I live.) Check out the market link. You can see there are 16 mutually-exclusive options (one for each team in the league). There are presently 13 participants in the market actively trading contracts which, in turn, determines prices. The only footballers in court this past month have been for prior matters (which don't count under my rules), so I haven't "closed out" the current contracts. Once that happens, I'll start it all up again for the next round of speculation.

My technology partner in this dubious exercise is CrowdIQ, a Web 2.0 startup that, amongst things, makes a damn-fine free prediction market product. They host dozens of markets in all sorts of sectors, and I heartily recommend them for this purpose. Please note, this is play money only, so it's egos only at this stage. Still, that's a sufficient motivator to get things rolling.

CrowdIQ makes it easy to setup a market - one minute to create an account and perhaps ten minutes to get the market up and running. It has nice financial engineering flourishes: an IPO (Dutch auction style, like Google) to set the initial prices, limit buys/sells and short selling.

More importantly, they publish the market as an RSS feed. For those of you using Blogger Beta, you should be able to just plug the feed into a sidebar widget and get the information flowing. (Or, install it using WidgetData for nice presentation.) They also have a REST API, which means you can programmatically poke and prod at your market, if you so desire.

Collective Wisdom - Prediction Market Blog Integration

Not surprisingly, I wrote my own hack - humbly dubbed Collective Wisdom (source code) - for rolling in the information. The goals are two-fold. Firstly, to display a formatted list of current contracts and prices in the sidebar. Secondly, to highlight keyword occurrences in the blog text, with current prices and links, much as the financial media does for company name mentions.

While I sweet-talked the principals at CrowdIQ into adopting JSON (Hi, Chris!), there's still some technical foibles, so I run their RSS feed through Singpolyma's Ning converter. The client-side script uses that info to build a drop-down menu with the current contracts and prices, and extra details in the mouseover. It also goes through the blog page, looking for text that matches a contract name and then inserts a link to that contract along with price and other details.

At this point, you might want to check out an example page. In the sidebar, check under "Informants' Tips" for the contract menu. In the blog text, look in the second block of quoted text. You'll see that two team names (Cats and Tiger - it's a feline article) have been dolled up with a fancy stock code and price and linked to the contract on CrowdIQ, with more details in the mouseover.

The Getting of Wisdom

Want that for yourself? Once your market is up and running on CrowdIQ, install this code into the header of your blog (or in the external script, if that's how you arrange things):

<script type="text/javascript" src = "">

<script type="text/javascript">
function setCollectiveWisdom()
// Collective Wisdom Parameters

crowdRSS=' ...xml'; // URL of market RSS feed
crowdNode='collective-wisdom'; // ID of div to put list
scanNode='main-content'; // ID of div to scan for keywords



Update: Code truncated on suggestion of Singpolyma (thanks, chief!).

The options are straightforward: crowdRSS is the URL on CrowdIQ for your market's RSS feed. crowdNode is the ID of the element where the list will be put (see below). scanNode is the ID of the div to scan for keywords. Use this to stop the script interfering with other elements. Depending on your blog template, it might be something like "main-body" or "main" or something. The do... variables simply turn on/off their respective functions. Lastly, if you don't want the highlighting code to use the whole text of the contract name, you can define reN as your own custom regular expression. (In my case, I only wanted to use the last word of the contract name eg "Melbourne Demons".) Don't touch the launch code.

NB: If you don't already have the generic AddLoadEvent utility function defined, copy/paste the ten lines or so into your header too.

Next, in the body template of your blog, put this where you want to see the contract menu appear:

<p id="collective-wisdom"> ... fetching prices from CrowdIQ ... </p>

Change collective-wisdom to match the crowdNode variable above, if you don't like that. And you can use whatever loading message you like.

Finally, all the Collective Wisdom elements have a class associated with them, so you can make them spiffy with CSS. For starters, try putting this into your CSS file (or CSS block in your header):

/* ---( Collective Wisdom ) --- */

font-size: 120%;
text-align: center;

border-bottom: black 1px dotted;

font-weight: normal;
cursor: help;
background: #e0e0e0;

While this is highly-experimental, it seems to work okay under IE (eventually ... *wince* ...) and FireFox. The highlighting function is a bit clunky in that it does a search/replace on the entire document.body.innerHTML, causing a brief re-render at the end of the page load - not ideal, so I'm open to suggestions for improvements. Update: Use scanNode (above) to restrict the search/replace to your blog's main content div. It will now only highlight the first instance of a match, to save repetition throughout the blog.

Also, if I were a bit smarter (or less lazy), I'd have figured out how to re-purpose the FreshTags code for displaying different types of lists, including clouds which would be neat.

Well done on sticking through to the end of this monster post. I hope that you're inspired to set about being the first to create a prediction market based around your blog's topic. Any suggestions, feedback etc welcome - along with ideas for a Freshblog market! "When will Blogger support categories?" would have been great, but that's closed out now ...

Filed in:
Posted at 10:56 PM by Greg.
<    >
Blogger Singpolyma said...
A Blogger-BETA set of instructions for this would be cool ;) And what about using WidgetData, since I've written my post on it now?

I think it fits this hack perfectly!

Also, if you put the load-external-js line after the rest of it, more of that code could be included at the beginning of the external (less template mess!) such as the launchURL and even the addLoadEvent line.

Odd that you would request people add the addLoadEvent themselves instead of just including it in the external fine (which makes it slightly bigger, but easier for n00bz).

I vote that the market should be something Blogger-BETA related...

<    >
Blogger Greg said...
Thanks for the suggestions, Singpolyma. I've updated the code to drop the launching stuff - no reason it can't go in the external script.

WidgetData is definitely the way to go, especially with the namespace issues I've been having (callback functions, onload events, variable names all stepping on each other's toes).

Not to mention the repitition and redundancy in structure and code. This is my fourth or fifth hack in the vein of "grab stuff as RSS, run in it through the XOXO converter to get JSON (with callback) and format the results in the sidebar". And that's not counting FreshTags and related stuff.

I try to use the DOM "properly" (ie createElement, appendChild) where possible, but the lack of a standard for adding event listners means here I reverted to the old generate-HTML, insert-into-innerHTML trick.

Hopefully WidgetData (and a good lightweight event library) will provide the basis to generalise all this stuff to make the inevitable Blogger Beta upgrade enticing, rather than foreboding.

Maybe then I'll get around to knocking together a Blogger Beta how-to for these hacks, with the goal of an "instant sidebar" that people can just drop on to their blog!

<    >
Blogger Johan Sundström said...
Isn't the trouble with "open" markets like "When will Blogger support Trackback?" when the true answer is "when pigs can fly", and thus will never surface (unless somehow provably closed out)?

<    >
Blogger John said...
When will beta be open to all?

Links to this post:

Create a Link

eXTReMe Tracker