by Andy Freeland
The Futures Market requires
PyYAML. These can be easily installed with pip:
pip install -r requirements.txt.
The Futures Market can be run with the
runserver-dev script, which uses Django's management command functionality to run the application on port 8000 with the Tornado server. This is fine for testing purposes, but for production use see Deployment. To setup a development database, run the
http://hostname/admin/will bring you to the admin interface where you can edit objects.
http://hostname/will take you to the interface to create markets.
http://hostname/marketname/will take you to the market manager view.
http://hostname/marketname/tradername/will take you to an individual trader portfolio.
Data is stored in an SQLite database called futures-market.db. Once the market is running, YAML-formatted data can be uploaded. An example can be found in
For installing all of the server software, see
nginx can also be configured for multiple processes, with some information about that at http://www.hyperionreactor.net/blog/running-tornado-production and http://www.tornadoweb.org/documentation/overview.html#running-tornado-in-production.
setup-productionto setup the database and collect the static files.
runserver-productionto start the server.
runserver-productiontakes an optional port number as an argument and defaults to port 8000. The included nginx.conf is set to listen on ports 8000 and 8001.
The URL prefix in production can be configured in
futures_market/settings_production.py. This lets you host the market at URLs like
http://hostname/markets/ rather than
futures_market directory contains the project itself. The only files that matter here are
settings.py, containing all of the application settings, and
urls.py which maps urls to applications.
templates contains the templates, HTML files using the Django Templating Language.
market is the actual market application.
static contains static files (CSS/JS). The CSS uses the inuit.css framework with a very small
screen.css for other styling.
management contains a
runtornado.py command for Django's management commands. This wraps the application for serving by the Tornado server.
models contains all of the data models for Holding, Market, Order, Stock, Trader.
Of the files in
urls.py maps urls to views.
views.py is where the actual logic of the market lies.