YAFiMM - Yet Another Financial Market Model

Authors: Giulio Bottazzi
Contact: <bottazzi@sssup.it>
Date: Apr 12 2007
Revision: 1.5
Copyright: GPL

Contents

Getting Started

This package contain programs providing a simulation framework for the analysis of a financial market model. For the description of the model, see the References below.

This package contains various programs:

deterministic
is provided for the study of the deterministic market dynamics obtained under the hypothesis of identical agents
stochastic
provides the stochastic version of the previous system when a random s is considered.
aggregate
is for the market (aggregate) dynamics obtained with "nosy" perturbed agents with short selling allowed
yafimm
a complete agent-based simulation of a market, with prices fixed via different trading protocols (see the paper) among heterogeneous agents with budget constraints
match
test the implementation of the batch auction

Required libraries

The previous programs require the GSL (GNU Scientific Library). For more informations about GSL, including installation procedures on various platforms, check http://www.gnu.org/software/gsl/.

The use of the CBLAS interface provided by the previous library is also assumed in the present package. If you want to use a different library, you should change the LOADLIBES parameter in Makefile to reflect your preferences.

Installation instructions

On Linux the installation is simple. Uncompress the package:

tar xvsf yafimm-version.tar.gz

move to the directory:

cd yafimm-version

configure the package using:

./configure

compile:

make

and install it:

make install

By default, the executable files are placed in /usr/local/bin. If you prefer different location then use the option --prefix of configure. See the file INSTALL for more informations.

How to obtain help

Look at the short help provided by the programs:

yafimm -h
deterministic -h
aggregate -h

There is a still-work-in-progress manual in the directory doc.

Most importantly, read the papers listed in the References below, where the model and its features are (hopefully) clearly explained.

YAFiM CONFIGURATION FILE

The program yfimm reads the description of the market and the agents from a configuration file. The name of this file can be provided at the command line with the option -F. If no file name is provided, yafimm reads the market and agents description from the standard input.

The structure of the configuration file is a sequence of lines. Each line constitutes a record whose field are separated by blank (spaces or tabs) characters. Each record describe one "building block" of the model: the general properties of the market or the characteristic of a group of agents. The generic structure of a line can be represented as:

typeofrecord first_arg second_arg ...

The first field of a line specifies the type of record and can assume the following values:

market         the line describe a market
trendfollower  the line describe a group of "trend following" agents
fundamental    the line describe a group of "fundamental" agents
sophfund       the line describe a group of sophisticated "fundamental" agents
noise          the line describe a group of "noise trading" agents

(Only the first three characters are relevant to identify the type of a record). Line beginning with a "#" are considered comments and are skipped.

If the record describes a group of agents, the second field has a special meaning: it is the number of agents belonging to this group. The rest of the line is formed by couples of the form key=value. The possible values for the key depend on the type of record and are listed below, together with their default value and constraints:

record type key[default] explanation
market type [0] 0 walrasian auction 1 batch auction 2 order book
d [.01] dividend (d>0)
r [.01] riskless return (r>0)
A [1] total amount of risky shares (A>0)
initnoise [.01] initial level of noise on forecasted returns
initnumber [100] number of time steps in market initialization
trendfollower beta [1.] risk aversion (beta>0)
or lamba [.99] EWMA parameter (0<lambda<=1)
noise trader eta [0.0] market orders propensity (0<=eta<=1)
Dy [0.0] personal shock of forecasted return (0<=Dy<=1)
horizon [1] horizon of trading position (integer>0)
shortA [0] switch on (0) or off (1) the budget constraint of A
shortB [0] switch on (0) or off (1) the budget constraint of B
fundamental beta [1.] risk aversion (beta>0)
or lambda [.99] EWMA parameter (0<lambda<=1)
soph. fund. eta [0.0] market orders propensity (0<=eta<=1)
theta [1.0] market efficiency estimation (0<=theta<=1)
Dy [0.0] personal shock of forecasted return (0<=Dy<=1)
horizon [1] horizon of trading position (integer>0)
shortA [0] switch on (0) or off (1) the budget constraint on A
shortB [0] switch on (0) or off (1) the budget constraint on B

The value can be substituted by a comma separated couple min_value,max_value. In this case each agent of the group will be assigned a random value drawn from an uniform distribution with support [min_value,max_value]. Notice that shortA=1 implies shortB=1.

Configuration File Example

This is the situation: the market is a batch auction; the riskless return is .001 and the dividends per share paid at each market round are .001. On the market there are 100 agents acting as trend followers. They use an EWMA rule with parameter .97 for future return forecasting and their risk aversion is randomly chosen between 100 and 200. During the trading, they send market orders (instead of limit order) to the auctioneer 50% of the times. Operating on the market there are also 50 fundamentalists, whose forecasting rule for return supposes a "market efficiency" of .5 and an EWMA coefficient of .94. Their risk aversion is equal to 10. Moreover, they receive random shocks, uniformly distributed in [-2%,2%], to their future price prediction and they always partecipate the market via limit orders. Both types of agents are initialized with forecasts extracted from a random distribution of mean zero and variance 0.01. Fundamentalists can attain short position in bond (i.e. they can borrow money).

This situation described above is represented with the following lines:

#----------- BEGIN OF FILE -------------
market type=1 d=.001 r=.001 noise=.01
trend 100 lambda=0.97 beta=100,200 eta=.5
fund 50 theta=.5 lambda=0.94 beta=10 Dy=.02 shortB=1
#-----------  END OF FILE  -------------

Try the three .ini files provided with the package as an example.

References

G. Bottazzi (2002) "A Simple Micro-Model of Market Dynamics" forthcoming in WHEIA 2002 Proceedings and LEM Working Paper, Sant'Anna School of Advanced Studies, Pisa.

G. Bottazzi, G.Dosi and I. Rebesco (2002) "Institutional Architectures and Behavioural Ecologies in the Dynamics of Financial Markets: a Preliminary Investigation" forthcoming on Journal of Mathematical Economics and LEM Working Paper, Sant'Anna School of Advanced Studies, Pisa.

Package files list

README                      this file
deterministic.c             src of deterministic
aggregate.c                 src of aggregate
match.c                     src of match
Order[.h,.cpp]              class Order
BookOrder[.h,.cpp]          class BookOrder
Market[.h,.cpp]             class Market
Walrasian[.h,.cpp]          definition of Walrasian auction protocol
Batch[.h,.cpp]              definition of Batch auction protocol
Book[.h,.cpp]               definition of Order Book protocol
Agent[.h,.cpp]              class Agent
TrendFollower[.h,.cpp]      class TrendFollower
Fundamentalist[.h,.cpp]     class Fundamentalist
SophFundamentalist[.h,.cpp] class SophFundamentalist
NoiseTrader[.h,.cpp]        class NoiseTrader
Parser[.h,.cpp]             initialization file parser
Yafimm[.h,.cpp]             the main program
fixed.ini                   example initialization file for yafimm
aperiodic.ini               example initialization file for yafimm
test.ini                    example initialization file for yafimm
Makefile
COPYING                     Gnu public Licence
AUTHORS                     list of authors
yafimm.css                  docutils stylesheet


       G.B.