Zocalo Open Source Prediction Markets.

See:
          Description

Packages
net.commerce.zocalo  
net.commerce.zocalo.ajax.dispatch This package allows Zocalo to publish significant events via Log4J and cometd (an AJAX technology).
net.commerce.zocalo.ajax.events This package describes significant events that will be logged via Log4J and cometd (an AJAX technology).
net.commerce.zocalo.claim These classes describe the claims being traded in the market.
net.commerce.zocalo.currency These classes represent conserved currencies that form the basis for exchange.
net.commerce.zocalo.experiment This package contains the classes that configure Zocalo to support experiments.
net.commerce.zocalo.experiment.config The classes in this package provide an interactive editor for configuring experiments.
net.commerce.zocalo.experiment.role This package contains the classes that manage roles for experiments.
net.commerce.zocalo.experiment.states These classes represent the states and state transitions used in experiments.
net.commerce.zocalo.freechart ChartGenerator is a helper class for building charts using JFreeChart.
net.commerce.zocalo.hibernate HibernateUtil is a helper class for storing objects persistently using Hibernate.
net.commerce.zocalo.history Display trading history to the user.
net.commerce.zocalo.html Support for generating HTML.
net.commerce.zocalo.JspSupport Support for generating web pages using JSP (Java Server Pages).
net.commerce.zocalo.JspSupport.printOrders  
net.commerce.zocalo.logging Log4JInitializer is a helper class for logging using Log4J.
net.commerce.zocalo.mail Support for sending mail to the user.
net.commerce.zocalo.market These classes implement the market and process orders.
net.commerce.zocalo.orders These classes describe market orders stored (in a book) for later use.
net.commerce.zocalo.rpc Classes that enable an external agent to trade with the market.
net.commerce.zocalo.service Classes involved in setting up a web service.
net.commerce.zocalo.user These classes provide support for User objects.

 

Zocalo Open Source Prediction Markets. This software supports Prediction Markets and laboratory economics experiments. More information, including downloadable files and complete source code are available at sourceforge.

The core of the Zocalo software consists of a variety of Markets, which allow Users to trade Claims (which have Positions representing particular outcomes). Coupons represent holdings of particular Positions, which can be bought with Funds, which represent money. Currency represents the common elements of Funds and Coupons.

There are three types of Markets: BinaryMarkets are used for prediction markets with two possible outcomes (usually YES and NO), MultiMarkets are for prediction markets with two or more mutually exclusive outcomes, and UnaryMarkets allow for conventional trading of a single asset. These markets can be managed with a MarketMaker that trades with Users directly, or a Book that tracks Users' standing limit Orders that other Users are allowed to accept. BinaryMarkets can be set up with both Book and MarketMaker enabled simultaneously.

There are two primary user interfaces for interacting with the markets. The primary one is ordinary prediction markets, managed by MarketOwner and AllMarkets. A variety of web pages allows users to navigate between different markets of various types, look at the user's trading history, create new markets, etc. The other major interface supports trading in economic lab experiments. An experimenter configures an experiment, which consists of a number of timed rounds in which Users are assigned initial positions in an artificial good, and allowed to trade with other Users.

The Experiment version relies heavily on AJAX to drive the user interfaces and ensure users see other's trades and changes in their holdings immediately. In this version, trades are drawn using "stripcharts" that display a trade per column without regard for timing. The prediction market version uses a database to store all the required information persistently (using Hibernate) for long-lived experiments. The prediction market version displays trading history using graphs generated with JFreeChart.

HTML pages are generated using JSP, though most of the actual content is generated directly in Java.

The Zocalo server uses Jetty to act as a web server. The main() entry points are provided by AllMarkets and ExperimentServer, which use helper classes to set up the Servlets and AJAX connections. AJAX is available in the Prediction Market version, though it isn't used extensively yet.

The project uses Log4J, both to log trading activity and as a transport mechanism for events that trigger AJAX activity. Extensive JUnit tests exercise nearly all of the functionality of Zocalo, though there is no javadoc coverage of these classes. A little documentation exists on the use of Hibernate. There's an ORM-based class diagram, and an outline of some considerations in the use of Hibernate.

© Copyright 2007-2010 Chris Hibbert. All rights reserved.
Portions Copyright 2005, 2006 CommerceNet Consortium LLC.

This software is published under the terms of the MIT license, a copy
of which has been included with this distribution in the LICENSE file.