|Date:||August, 31 2007|
The installation should be straightforward. Unpack the package:
tar -xzvf naif.tar.gz
move inside the source directory:
run the configure script:
then build the files:
and install them:
for more detailed instructions see the file "INSTALL".
NAIF is a program for simulating the trading activities of a heterogeneous group of agents in a simple two-assets economy. The basic framework for the underlying model was developed by M. Anufriev, G. Bottazzi and F. Pancotto. P.Dindo collaborated in the most recent generalizations (see References below).
This program reads data from the configuration file combined with some command line options and prints the result in ASCII format into the standard output. NAIF is written in C and requires some external libraries (see Required Libraries). It has been tested and used on the Gentoo Linux distribution but should run, in principle, on any Unix platform. No other OSes have been tested.
Please notice that the program has been written for personal use, and is distributed under the GPL license (see the file COPYING) in the hope it could be of help to other people, but without any implied warranty.
NAIF is written in C and requires two non-standard libraries, Matheval and Regexp. Download both libraries from http://sourceforge.net/.
The program reads the config file with investment functions of different agents and simulate the price dynamics of the market with such behaviors. All parameters are provided in the command line. The initial conditions are provided in the command line as well, while the initial shares assigned to different agents are read from the file.
The basic usage of the program is:
naif [options] < [config file]
Each line of the file is the description of one agent or one group of agents. The lines beginning with a # symbol are considered comments and ignored.
The definition of each agent is a comma separated list of parameters whose value is set with an assignment of the form:
The possible parameters are
The arguments of the investment function are of the type xy_z where x is a string of three characters which denotes the type of argument and the following (integer) numbers y and z stands for possible specifiers. The meaning of the specifiers depend on the type of argument
The following line:
defines an agent who invests, at each time step, a share of wealth in the risky asset which is proportional to the sum of the last realized return (ret1) and the third central moment of the realized yields estimated through CWMA (cwy3) on the last 12 (_12) time steps. The initial agent's endowment is 10 (w=10) of which 30% is invested in the risky security (x=.3) and the remaining in the riskless one.
A small modification:
leads to a definition of analogous agent, but now, at each time step, a random component is drawn from an uniform distribution on [-.005,.005] and added to the agents' investment function. In other words, the agent's investment function is:
f=ret1+cwy3_12+u with u i.i.d. in [-.005,.005]
The next line:
describes the same agent, whose investment choice is truncated in order to be in interval [0.01,0.99]. (This guarantees the boundedness of the dynamics!) The agent's investment function is:
f=max(0.01,min(0.99,ret1+cwy3_12+u)) with u i.i.d. in [-.005,.005]
A group of similar agent can be defined prepending to the agent definition an integer number, which denotes the number of agents in the group, followed by a column ':'. For instance:
stands for a group of fifty agents similar to the agent discussed above. Notice that due to the i.i.d. nature of the random component of the investment function, the investment decisions of the different agents of the group usually will not be identical.
The following options are in use. The default values are shown in . Notice that the outcome is controlled by the option -O:
|-t||simulation length |
|-T||transient length |
|-s||skip this number of steps in output |
|-S||set the seed of the random number generator |
|-r||riskless return [.01]|
dividend structure. Define parameters values using pairs 'name=values'. Names are 'type', 'mean' and 'stdev'. [type=0,mean=.02,stdev=0]
List of types:
|-R||initial return structure. Define parameters values using pairs 'name=values'. Names are 'mean' and 'stdev'. [mean=.02,stdev=0]|
|-Y||initial yield structure. Define parameters values using pairs 'name=values'. Names are 'mean' and 'stdev'. [mean=.02,stdev=0]|
|-O||set the output, list of t:step, r:return, p:price, w:wealth, x:avg.inv.share, y:yield, d:dividend, A:risky asset, B:riskless asset, X:inv.shares, W:wealth shares, [rx]|
Any simulation is completely specified only when the initial conditions are defined. For the simulations in NAIF there are three things that have to be specified: initial agent's portfolio, initial market history and initial values of agent's forecast variables. Below we analyze each of these three aspects.
Each agent i is given an initial wealth level (w_i) and an initial share of wealth (x_i) invested in the risky assets. These quantities can be explicitly specified using the parameter w and x in the configuration file. If not specified, their default values are 1 and .5, respectively. From these quantities, the initial portfolio composition of each agent is determined as:
A_i = x_i w_i / \sum_j x_j w_j B_i = (1-x_i) w_i / \sum_j x_j w_j
where A_i and B_i stand for the initial amount of risky and riskless security, respectively. These values should be positive in order the initial market conditions could be defined. Otherwise, the message "Agents specification does not allow to define initial price." is printed.
The initial price (for time t=0) of the risky security, according to the initialization of the agents' portfolio defined above, is set to 1.
The generation of the first dividend (for time t=1) depends on the market process specified in the command line. If the process is described by means of the yield, then yield "yld1" is accordingly generated and first dividend coincides with "yld1" since p_0=1. If the process is described by means of the dividend (i.e. if the dividend is assumed to be growing), initial value of the dividend is set to .001.
The first price (for time t=1) is determined using the agents' investment functions, already.
Moreover, an initial "fake" histories of both price returns and dividend yields are generated. The lengths of these histories are set to a value large enough to provide an initial value for each estimator (see below). The returns and yields are identically and independently extracted from an uniform distribution. The mean and variance of the distributions for the return and yield can be specified from the command line. Both parameters have a default value of 0.
The initial value assigned to agent's forecast variables depends on their nature. Past returns variables (ret, yld) and equally weighted averages (cwr and cwy) are computed on the initial return or yield history, respectively, generated according to the procedure described above. Conversely, to the EWMA estimators (ewr and ewy), which are (in principle) functions of an infinite set of returns, a value is assigned which is equal to the last return raised to the order of the estimator. For example, if ret is the last return of the initial history of returns, ewr1 is set to r, ewr2 is set to r^2, ewr3 to r^3, etc. Notice that the memory parameter "lambda" doesn't play any role in the initial value of the estimator.
Some examples of the use of NAIF program can be found in README.examples file.
Using the data in standard output one can produce plots of the generated time series. We provide lines to generate plots with GNUPLOT, a portable command-line driven interactive data and function plotting utility for UNIX, IBM OS/2, MS Windows, DOS, Macintosh, VMS, Atari and many other platforms.
AUTHORS contact information COPYING GNU Public License NEWS list of modifications ChangeLog "" "" INSTALL installation information README this file README.examples files with usage examples naif.c source code of program naif test##.cfg different configuration files with examples plot.gp gnuplot script for example plots tools.c C utility functions tools.h C utility functions header file naif.css stylesheet for HTML docutils