My latest project: IrcBook

Lately I’ve been doing a lot more programming than usual. In fact, I don’t remember writing as much code for a single project in such a short time in years. It was all a matter of finding the right project, I suppose. So what is IrcBook?

You may be familiar with the notion of prediction markets. If not, don’t worry, I’m about to explain it.

What’s a prediction market?

Let’s say we want to know whether a given uncertain event will take place or not. Now that Apple’s doing their keynote, let’s imagine we wanted to know if they’re about to launch a new iPhone.1 The typical way people go about it is to collect and read lots of sources, think very hard, and issue a more or less calculated response on that basis. As you can imagine, this is not a very accurate procedure.

A better way is to aggregate information from different people. In the book The Wisdom of Crowds, James Surowiecki points out that putting together the independent assessments of different individuals is likely to yield results which are closer to correct than most people would guess, and outperform individual experts. A prediction market is a form of information aggregator, based on a market metaphor, but the key is not so much in the notion of trade, as in the way it allows a set of individuals to communicate and put together their views on how likely an event is.

Following our example, we might have a market running on the claim new_iphone_2016. Every such claim has a description of an uncertain event. Users can buy and sell coupons, which are stamped as “yes” or “no”. At the time of maturation, if the event occurs, those who hold “yes” coupons turn them in for cash, let us say 100 EUR, while those who hold “no” coupons get nothing. If the event didn’t take place, the situation would be the opposite.2

The exchange can run in a cash-neutral fashion, or for a fee. Coupons are conditional obligations (I will pay you 100 EUR if X happens), and they are always issued in pairs, so that having both at once is the equivalent of 100 EUR.

Coupon issuance.

Let’s say Alice thinks a new iPhone is at least 70% likely to be issued, and Bob thinks it’s 30% or less. Alice places a buy order for a “yes” coupon, at a price of 70 EUR. Bob places a buy order for a “no” coupon at a price of 30 EUR. These orders are matched, they pay 100 EUR in total to the exchange, and get issued their corresponding coupons. These 100 EUR they paid to the exchange will be, in due time, awarded to one of the coupon holders.

Coupon transfer.

These coupons are fully transferrable, payable to the bearer, and Alice and Bob may decide to sell them later. For example, if Charlie thinks a new iPhone is 80% likely and is willing to pay that much, Alice may happily sell him a “yes” coupon for 80 EUR, and make 10 EUR profits. If Denis thinks there’s a 50% chance there won’t be an iPhone, he may well be interested in buying a “no” coupon from Bob.

Coupon cancellation.

Coupons are cancelled at maturation. Either because they get redeemed for money, or because they become worthless. This is not the only case when coupons may be cancelled, though. Let’s imagine our friends Alice and Bob still have their coupons and want to sell them. Alice is willing to sell at 75 (5 EUR profit) and Bob willing to sell at 25 (5 EUR loss). Since there are no other matching orders, they return their pair of coupons to the exchange, get 75 and 25 EUR each, and the coupons are destroyed. Thus the exchange’s obligations remain constant.

What about shorting?

Finally, let us consider Eve and Frank. Eve wants a “yes” coupon and is willing to pay 60 EUR. Frank is a speculator and wants to bet against Eve, but has no “yes” coupons to sell her. However, Frank can do the following: buy a pair of coupons (yes and no) for 100 EUR, sell the “yes” coupon to Eve for 60 EUR, and retain the “no” coupon for himself, at a total cost of 40 EUR. You may have notice this is the same situation Bob finds himself in, when he buys a “no” coupon. From a technical standpoint, selling a coupon you don’t have is equivalent to buying a coupon of the opposite side.

But where’s the prediction?

So this is pretty similar to other types of markets in derivatives, but how does it help us solve the initial problem? How do we know how likely a new iPhone is? The answer is surprisingly simple: through the price.

The market aggregates the opinion of its participants setting a price for the coupons. This price is the collective belief about the likelihood of the event. In markets with enough liquidity (large numbers of buyers and sellers) this mechanism is surprisingly powerful, and has been used to predict the outcome of elections more successfully than other methods.

Why is the price the likelihood? Because of the way it interacts with the expected value of a coupon. Let’s run an example.

You think a new iPhone is 35% likely. How valueable is a “yes” coupon to you? To calculate this, we multiply each probability times the payoff and we add it up:

  • No new iPhone has a probability of 65% and a payoff of 0: so 0.
  • New iPhone has a probability of 35% and a payoff of 100: so 35.
  • 0 + 35 = 35.

If anyone offered “yes” coupons at lower than 35 EUR, you should buy them, since their expected value for you is higher (assuming here risk-neutral agents). Likewise, if anyone offered more than 35 EUR for a “yes” coupon, you should sell them.

This way, the price of the asset approximates the collective belief. In illiquid markets we may get a spread instead (30-35, for example).

How IrcBook makes it work.

Ok, so now you know what a prediction market is. What is IrcBook and how does it work?

IrcBook is a play money exchange. It doesn’t use real money, so don’t go thinking you can get rich from it. It’s a game, and a way to find out how likely a community thinks a thing is to occur.

As its name indicates, it runs on IRC, though I’m giving fairly serious thought to extending it so it can operate on Twitter and through the web. So far, in order to play IrcBook you must use freenode. You need a registered nick, and a bit of an understanding for how IRC works. You can play it by sending private messages to IrcBook, or in public in the channels #ircbook, ##politics and ##marxism where the bot lurks.

First you register an account by sending $register and wait for one of the bot owners to confirm you. We’re adding this step in order to avoid people creating tons of sockpuppet accounts and manipulating the market. On registration, you get 1000000 credits, which I must remind you once again have no real cash value whatsoever.

From that time on, you can place orders with $buy and $sell, see the ticker for a claim with $ticker, the list of claims and their descriptions with $claims, or create new claims to run markets on with $create, among many other things. You can read the command set if you wish.

After that it’s all about how good you are at trading and exploiting other people’s changing beliefs. You can have different strategies, and try to get money from being right and collecting on your coupons, or simply from anticipating the changing beliefs of the market. That’s all up to you.

  1. If you’re reading this, you probably already know the answer, but let’s pretend you don’t. 

  2. It’s possible to operate non-binary markets where coupons yield a prorated amount, from zero to some maximum, depending on the value of some variable. For example, there could be a market about the maximum summer temperature which would pay 0 if it’s less than 25c, 20 if it’s between 25 and 30c, 40 if it’s between 30 and 35c, 60 if it’s between 35 and 40c, 80 between 40 and 45c, or 100 from 45c on. However these are more complicated to run and interpret, and IrcBook does not support them, so we’ll assume binary markets from now on.