A Framework For Financial Markets Modeling and Simulation: Alessio Setzu March 2007
A Framework For Financial Markets Modeling and Simulation: Alessio Setzu March 2007
Alessio Setzu
March 2007
Contents
Introduction ix
6 Conclusions 108
List of Figures
normal t. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
3.3 Daily time series for prices (top) and returns (bottom) in the case
and m = 0.8. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
4.4 Dynamics of wealth of Random and Random* for a typical simula-
and non − DP T . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
4.9 Dynamics of wealth with all eight types of traders for a typical sim-
5.1 Daily time series for euro-dollar exchange rate (top) and returns
(bottom). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
5.2 Survival probability distribution of standardized logarithmic returns.
5.3 Daily time series for stock prices (top) and returns (bottom). . . . 101
5.4 Daily time series for euro-dollar exchange rate (top) and returns
(bottom). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
5.6 Daily time series for stock prices (top) and returns (bottom). The
inationary shock is applied at the end of the step number 1000. . . 105
5.7 Daily time series for euro-dollar exchange rate (top) and returns
5.8 Daily time series for euro-dollar exchange rate (top) and volumes
5.9 Daily volatility for the stock prices between step 500 and 1500 of
steps. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
4.1 Mean and standard error of volatility with trend followers and
random traders. The results are multiplied by 103 . . . . . . . . 83
4.2 Mean and standard error of volatility with fundamentalists and
random traders. The results are multiplied by 103 . . . . . . . . 85
4.3 Mean and standard error of volatility with fundamentalists
trend followers and random traders. The results are multi-
plied by 103 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
4.4 Mean and standard error of Volatility with random traders.
The results are multiplied by 103 . . . . . . . . . . . . . . . . 90
Introduction
Financial markets belong to the class of things that sound to be simple, but
that are indeed very complicated. They are dynamic systems made up of a
large number of economic elements engaged in continuous interactions, which
give rise to intricate aggregate regularities and to complex phenomena at the
macro level. The main result of the trading activity is price time series, that
exhibit many well known empirical properties also known as stylized facts.
In recent years, the large availability of nancial data allowed to deepen the
knowledge about price processes and, together with the new developments in
mathematics, physics and computer science, contributed to transform nance
in a quantitative science.
Researchers faced with the analysis and modeling of nancial markets
for tens of years. But classical theories, based on a single fully rational
representative agent, failed to reproduce all the properties of real markets.
Also, they have been able to make only limited progress in resolving many
important practical and policy relevant open issues, like those related to the
instability of nancial markets. In contrast, new behavioural approaches,
characterized by markets populated with bounded rational, heterogeneous
agents emerged. In recent years, this research eld has been combined with
the realm of agent-based simulation models, and a number of computer-
simulated, articial nancial markets have been built.
This thesis presents an agent-based computer simulation framework for
building theoretical models in economics and nance. In an articial nancial
market each microscopic element of the overall system, and each kind of
interaction among them, has to be modeled and individually represented.
The computer simulation approach allows to track the evolution of each
component of the system, and to investigate on the aggregate behaviour and
to look for emergent phenomena. This approach has been already applied
in other sciences to study complex systems, and its main advantage is that
it allows to deal with issues where analytic solutions would be impossible.
The proposed model includes many realistic trading features, and has
been validated by showing that the simulated time series exhibit the main
empirical properties of real nancial markets. This articial market has been
developed using object-oriented software techniques, and is aimed to be easily
extended and composed, yielding multi-asset and multi-market simulations.
The thesis is organized as follows. Chapter 1 gives the historical back-
ground on the models in economics and nance. It also provides a brief guid-
ance in the development of an articial market, and it presents an overview
of the major statistical properties of real economic time series.
The current version of the simulation framework is the result of an in-
cremental and iteractive process: Chapter 2 summarizes its evolution, from
the original system, built on the basic ideas of the Genoa Articial Stock
Market model, until now. It also provides some details on the simulation
software, and on the verication and validation methodology.
The subsequent Chapters run through again the system evolution, and
deeply analyse the dierent versions. Each chapter introduces one major
open issue in economics and nance, then provides details on the specic
model that has been developed to study that problem, including the de-
scription of its extensions and modications in comparison with the previ-
ous version, and nally discusses the results. In particular, Chapter 3 faces
the problem of understanding the potential impact of the Tobin tax on a
multi-asset nancial market. Chapter 4 analyses the impact of margin re-
quirements and of short-sale constraints on prices and volatility, and their
connections with stock market crashes. Chapter 5 is about the interaction
between two stock markets located into two dierent countries, and their
inuence on the Foreign Exchange Market. Chapter 6 concludes the thesis
and suggests questions for the future work.
Chapter 1
Financial markets are at the heart of each modern economy. They can be
described as evolving complex systems, characterized by the interaction of
many simple interacting units. Today, nancial markets are continuously
monitored, and an enormous amount of electronically stored nancial data
is available. The result is an explosion of interest in this eld, that attracts
a large number of researchers attempting to model and forecast nancial
markets. It is well known that economists and mathematicians have a long
tradition in studying nancial system, but a growing number of physicists
is trying to compete with them in explaining economic phenomena. This
fact is conrmed by the emerging Econophysics research eld, which applies
theories and methods originally developed by physicists in order to solve
problems in economics. Also, the large availability of nancial data allowed
to deepen the knowledge about price processes, and many so-called styl-
ized facts have been discovered in price series, e.g., the fat tails of return
distributions, the absence of autocorrelation of returns, the autocorrelation
2
Economists have faced the problem of studying and modeling economic sys-
tems for hundred of years, but in the second part of the 20th century, nance
has witnessed an important revolution. The classical representative rational
agent paradigm has been replaced by a large number of agents characterized
by heterogeneous behaviours. Also, the increasing power of computers has
favored a shift from analytically tractable models with a representative agent
to complex systems, that require the implementation of simulation models
and use numerical methods as an important tool of analysis. Finally, full
rationality has been replaced by bounded rationality (see Hommes; 2002).
1.1 Historical background 4
The study of economic systems has a very long history, and some concepts
and ideas behind the models developed in recent times nd their fundamen-
tals in classical economics and nance. In the traditional approach, many
simple analytically tractable models have been developed, and the math-
ematics has been the main tool of analysis. These models makes many
assumptions regarding the economy and the individuals in order to keep
the analytical tractability, but they are often unrealistic. They are based
on the rational expectations theory and on the notion of the representative,
perfectly rational agent.
The rationality of agents is one key concepts of economics and nance.
In a full rational expectations framework, all agents make use of all available
information in determining how to best meet their objectives. The Rational
Expectation Hypothesis (REH) is a theory in economics originally proposed
by Muth (1961) and later developed by Lucas (1972). If the agents try to
forecast future variables taking into account all available information, they
will not make systematic errors, and the value of the observed variables will
be equal to the values predicted by the model, plus a random error.
The rational expectation theory provides the ground to build models
based on the notion of representative agent, having rational expectations.
A representative agent model is such that the cumulative behaviour of all
agents might as well be the actions of one agent maximizing her expected
utility function. Its origins can be traced to the 19th century, but it was
Lucas (1972) in the 1970s who really popularized the representative agent.
The only trace of heterogeneity in the rational expectations framework
resides in the fact that the agents may have dierent utility functions, but
it is not heterogeneity of beliefs, because the agents are given all relevant in-
1.1 Historical background 5
The EMH, the representative agent and rational expectations have provided
the theoretical basis for economics and nance during the seventies and large
part of the eighties. But during the eighties new ndings shook the classical
theories to their foundations (for a good review of these developments refer
to Hommes (2005)).
In that years, many empirical studies appeared showing evidence against
the EMH. One of the most important ndings was that price volatility of
many nancial time series is clustered. It means that price uctuations are
strongly temporally correlated, and that periods of low volatility are inter-
spersed with high volatility periods (see, e.g. Mandelbrot; 1963; Engle; 1982).
Moreover, the largest prices movements often happened even though little or
no news about economic fundamentals occurred (Cutler et al.; 1989). Sev-
eral authors claimed that uctuations in stock prices are too large compared
to those due to the underlying economic fundamentals (Shiller; 1981, 1989;
LeRoy and Porter; 1981), and that bubbles can be originated by the dier-
ence between real prices and fundamentals values (Summers; 1986; Campbell
and Shiller; 1988).
As said in Section 1.1.1, the EMH leads to a no trade equilibrium, and
many no trade theorems have been obtained. For instance, Milgrom and
Stokey (1982) stated that if markets are perfectly ecient, then even though
some traders may possess private information, none of them will be in a po-
sition to prot from it. The no trade assumption is clearly in sharp contrast
with the high trading volume of real markets, and represents a point against
the ecient market hypothesis.
1.1 Historical background 7
trend follower (chartist) traders. They were among the rst to develop a
market maker who adjusts prices with respect of the aggregate excess de-
mand. The excess demand both of fundamentalists and chartists is computed
using linear rules. They found that if the percentage of chartist is too high
the market can become unstable, and concluded that the interaction of dif-
ferent agents with dierent behaviour could explain some features of the
dynamics of prices. Chiarella (1992) considered a non-linear extension of the
model, and showed that the non-linear system is characterized by a stable
equilibrium, but if the number of chartists is too high the price trend tends
to destabilize the system and prices exhibit periodic limit cycles.
The models introduced above represent just some examples of a huge
number of studies that analyse the interaction between chartists and funda-
mentalists, and that can be considered as a branch of the HAM also known
as the fundamentalist and chartist approach. The reported models are not
fully rational, because each group of agents does not know anything about
the other. But what happens if there are fully rational agents too? Friedman
(1953) has been the rst to argue that non rational investors cannot survive
the market competition because they will be driven out of the market by
rational investors eventually in the process of natural selection. There are
many HAM that try to test the so called Friedman's hypothesis, for instance
those that include two further kinds of traders: rational traders and noise
traders.
The notion of noise trader was introduced by Black (1986): noise traders
are individual who trade on what they think is information, but is in fact
merely noise. This idea allowed Black to justify the large volumes of trading
activity that occurs in real markets. The activity of noise traders makes
it dicult to understand what is noise and what is good information, so
1.1 Historical background 9
rational traders are obliged to look for more information without a break.
This behaviour favors large volumes and gives traders the opportunity to
earn prots by exploiting their information.
More recently, De Long et al. (1990a,b) provided evidence that noise
traders may survive in the long run, and that they may gain more money than
rational ones. They found that rational traders perceive the risk introduced
by the presence of the other traders and, under certain conditions, they
are not able to get control over the dynamics generated by the non-rational
traders. It follows that the presence of many categories of agents cannot
be considered only a temporary condition, so contradicting the Friedman's
hypothesis.
The Wall Street stock market crash in October 1987 fed the interest
in nancial market models and reinforced the idea that the classical models
based on a representative rational agent cannot explain the behaviour of real
markets. Also, new empirical studies showed that there is not direct relation
between fundamental news and stock price movements (Cutler et al.; 1989),
and that the strange behaviour of the US dollar during the mid eighties was
absolutely unrelated to economic fundamentals (Frankel and Froot; 1986).
During the seventies and the eighties there were many developments in
mathematics and physics, such as chaos theory and complex systems. These
concepts stimulated many HAM works of the eighties and of the nineties,
because they can be used to model the unpredictable price paths by using
simple laws. For instance, the models by Beja and Goldman (1980) and
Chiarella (1992) exhibit chaotic dynamics. One inuential paper is that by
Day and Huang (1990), who proposed a discrete time model with a funda-
mentalist and a noise representative agent. The model shows complicated
deviations from the equilibrium price, that are similar to real stock market
1.1 Historical background 10
uctuations with chaotic switchings between bull markets and bear market
regimes.
During the nineties an impressive number of HAMs have been devel-
oped. They explored a wide set of assumptions and proposed new kinds of
heterogeneity, in terms of new kinds of trading strategies, learning capabili-
ties, adaptive techniques, and interactions among individuals. However, the
most part of these models concentrated on behavioural assumptions while
neglecting the market structural assumptions. Structural assumptions are
those related to the structure of the market, for instance the trading proce-
dures which dene the rules of the market and the price clearing mechanisms.
Behavioural assumptions are the trading strategies and the roles by which
the traders take their decisions LiCalzi and Pellizzari (2002). Raberto (2003)
and the survey by Hommes (2005) covers the more analytic ones and those
that can be handled by means of simple numerical simulations. Some of them
are signicative and deserve a special mention because of their role in HAM
advancement. Challet and Zhang (1997) proposed a minority game model
with N agents who have to choose between two alternatives: the goal is to
be in the smallest group, that is the winner one. The model is interesting
because it is quite simple and is accompanied by a numerical description and
is suitable for analytical solutions. The minority game models share some
characteristics with nancial markets: The agents have limited resources and
rationality, they learn from the performance of past choices, a good strategy
today may become bad when others' behaviour changes, and these models
can reproduce stylized facts (Challet et al.; 2001). The model by Lux (1997,
1999) and by Lux and Marchesi (1999, 2000) succeeded in explaining four
stylized facts simultaneously: prices follow a near unit root process, there
are fat tails in the distribution of short term returns, volatility clustering
1.1 Historical background 11
and a forecasting system, and agents build their behaviour on prices and
dividends by matching specic forecasting rules and knowledge to current
market conditions. One of the main goals was to proof that market com-
plexity may be induced by the endogenous evolution of the system, rather
than exogenous phenomena. In particular, one objective was to understand
if the market converges to a tractable rational expectation equilibrium, and
to understand what happens when the market does not converge. Another
goal was to analyse the dynamics of learning and the eects on the market
equilibrium. Arthur et al. (1997) showed that if the rate of exploration of
alternative forecasts is high, the market exhibits a complex regime and a
rich psychological behaviour emerges. Periods of technical trading regime
appear, where fundamental strategies tend to be punished by the market.
The SF-ASM platform has been also extended by other researchers, such as
Joshi et al. (1998) who studied the interaction between technical and funda-
mental trading, and Tay and Linn (2001) who extended the set of classiers
of the SF-ASM by adding a fuzzy logic system. The SF-ASM is a pioneer-
ing work that has shown the way forward the creation of articial nancial
markets with heterogeneous agent. Also, it suggested that simulated price
series can be analysed to check for consistency with the stylized facts of real
data. It is worth noting that, though the SF-ASM is able to replicate these
facts qualitatively, no attempt is made to quantitatively line them up with
results from real nancial data.
The experience of the Santa Fe Articial Stock Market stimulated the
development of several other projects. For instance, Basu et al. (1998), at
Sandia National Laboratories (SNL), developed an agent-based microeco-
nomic simulation model of the US economy.
Recently, a project for developing an articial nancial market started at
1.1 Historical background 15
in past prices and base their investment decision upon simple trend
following trading rules. Noise traders act randomly, regardless any
specic information of the security. Their presence is sometimes nec-
essary in order to provide liquidity to the market. The majority of the
models proposed in the literature are less or more complex variants of
these basic ideas.
These remarks point out that there are many decisions that have to be
taken in order to develop an articial nancial market model. Also, each
component adds a degree of complexity to the overall result. The are some
guidelines that could help to do the right choices. The rst one is: think big,
start small and scale fast. A good articial nancial market may become a
framework that allows to study complex and large system, with many kinds
of agents playing simultaneously in more than one market with dierent as-
sets. However, the development of such a model is not an easy task, and one
could easily get lost in it. The best solution is to outline the general architec-
ture of the system, and then develop the simplest solution that could work, in
agreement with the agile philosophy. For instance, one could start producing
a model with one kind of assets only, one kind of agents and a simple price
clearing mechanism. Then, it is possible to iteratively add complexity to
the model. The second suggestion is to make use of a suitable programming
language. The agent-based models t perfectly with the object-oriented pro-
gramming languages (Tveit; 2001; Gilbert and Bankes; 2002), which allow
to model each agent as an instance of a particular class. Also, in order to
scale fast is useful to adopt a proper software development process, such as
an agile methodology (the most famous one is eXtreme Programming (XP)
Beck; 1999; Beck and Andres; 2004), but also a powerful Integrated Develop-
ment Environment (IDE), capable to assist the developers during the whole
of software implementation. Finally, the price time series produced by the
1.3 Stylized Facts 19
articial market have to exhibit the same statistical features of real markets,
the so called stylized facts. But this is not a suggestion, it is the necessary
condition that allows to validate the model: it is a must.
It is by now well known that the economic time series of almost all nancial
assets exhibit a number of non trivial statistical properties called stylized
empirical facts. No completely satisfactory explanation of such features has
yet been found in standard theories of nancial markets, but more than fty
years of empirical studies conrm their presence. For a complete discussion
about stylized facts and statistical issues see Pagan (1996); Cont (1997);
Cont et al. (1997); Farmer (1999); Mantegna and Stanley (1999); Bouchaud
(2000) and the interesting paper by Cont (2001). There is a set of stylized
facts which appear to be the most important and common to a wide set of
nancial assets: unit root property, fat tails and volatility clustering.
distributed with mean zero and variance σ 2 , the process is a random walk 2 .
Several statistical procedures have been proposed to test for the presence
of unit roots, such as the original Dickey and Fuller (1979) test and the
subsequent augmented Dickey-Fuller (ADF) test statistic (Dickey and Fuller;
1981). If x(t) = log [p(t)], where p(t) is the price of an asset at time t,
one is usually unable to reject the null hypothesis H0 : ρ = 1 against the
alternative hypothesis H1 : ρ < 1. If the logarithm of prices follows a random
walk process, the future asset prices are unpredictable based on historical
observations. Also, the volatility of prices can grow without limits in the
long run. These ndings t very well with the ecient market view of asset
price determination.
The autocorrelation of raw returns is often insignicant, except for very small
intraday time scales. It is well known that the autocorrelation decays to zero
in less then fteen minutes for all real price time series (Cont; 2001). It seems
that this property could give support to the EMH, because one can consider
returns as independent variables. However, the absence of linear autocorre-
lation is not sucient to exclude that there is some time dependence in price
returns.
The GASM was born in the early 2000's at the University of Genoa. The
original project is described in Raberto et al. (2001), and the acronym means
Genoa Articial Stock Market. The name was devoted to the project's
birthplace, that in the Middle Ages was a major nancial centre, where
I.o.u. and the derivatives were invented (Briys and de Varenne; 2000).
The rst release of GASM was an articial nancial market with hetero-
geneous agents that traded on a single asset. The agents had only limited
nancial resources and adopted a simple trading strategy: they were zero
intelligence traders and issued random orders, constrained by their resources
and past price volatility. The price formation process was a clearing house,
a mechanism that determines the clearing price by crossing the demand and
the supply curves given by the current limit orders. These ingredients were
sucient to build an articial market able to reproduce the main stylized
2.2 The Original Model 24
facts of nancial markets: volatility clustering and fat tails in the distribution
of price returns.
Since then, the GASM has been extended and a number of works has
been published (see, e.g. Marchesi et al.; 2003; Raberto; 2003; Raberto et al.;
2003; Cincotti et al.; 2003, 2005). The project is being jointly developed
by Genoa and Cagliari Universities since 2005, and the ultimate goal of our
work is to develop a general framework for nancial market simulation. First,
we re-engineered the original model and the software system, and then we
extended its features and functionalities in order to address some open issues
in nancial markets.
This section presents the main characteristics of the original GASM we used
to develop the present release of the simulation framework. In the basic
model, only one risky asset was traded in exchange for cash. The agents had
limited resources and there were four dierent trading strategies. The price
formation process was based on the intersection of the supply and demand
curves. Note that the original GASM includes many more features than
those described in this Section, but here are discussed only those that we
used to lay the foundations of the new model.
2.2.1 Agents
Random Traders
The mean µ is set at a value equal to 1.01 in order to have a spread be-
tween the limit prices of sell/buy orders (Raberto et al.; 2003). The standard
deviation of this distribution, si depends on the historical market standard
deviation, σi (τi ), computed on a past price series whose length, τi , depends
on each trader memory, according to equation 2.2:
si = k ∗ σ(τi ), (2.2)
where k is a constant that is usually set in the range between 3 and 4 and
τi is randomly drawn for each trader from a uniform distribution of integers
from 10 to 100 (Raberto et al.; 2003).
2.2 The Original Model 26
Fundamentalist traders
Fundamentalists strongly believe that each asset has got a fundamental price,
pf , related to factors external to the market and, sooner or later, the price
will revert to that fundamental value. The fundamental price is the same for
all fundamentalists. If a fundamentalist decides to trade, she places a buy
(sell) order if the last price p(t − 1) is lower (higher) than the fundamental
price pf . Fundamentalists' order limits are set exactly equal to pf , and their
size (in stocks for sell orders and in cash for buy orders) equals a random
fraction of the current amount of stocks or cash owned by the trader.
Momentum Traders
Momentum traders are trend followers. They play the market following past
price trends, and strictly rely on price information. Momentum traders buy
(sell) when the price goes up (down). They represent, in a simplied way,
traders following technical analysis rules and traders following a herd be-
haviour. A time window τi is assigned to each momentum trader at the
beginning of the simulation through a random draw from a uniform distri-
bution of integers in the range 10 to 50 days. If the momentum trader issues
a limit order, the limit price li (t) is set at the stock's price of the previous
time step plus an increment (decrement) proportional to the price dierence
computed in the time window τi , as shown in equation 2.3.
· ¸
p(t) − p(t − τ )
li (t) = p(t) · 1 + (2.3)
τ p(t − τ )
If the momentum trader issues a sell order, the order size is a random
fraction of the number of shares owned by the trader herself. In the case
of a buy order, the trader employs a random fraction of her cash, and the
number of demanded stocks is the ratio between that fraction and the limit
2.2 The Original Model 27
price li (t).
Contrarian traders
Contrarian traders are trend-followers too, but they speculate that, if the
stock price is rising, it will stop rising soon and fall, so it is better to sell
near the maximum, and vice versa. A time window (τi ) is assigned to each
contrarian trader at the beginning of the simulation in the same way as for
momentum traders. The contrarian trader's order limit price and quantity
are computed in the same fashion as the momentum traders, but in the
opposite direction.
The price formation process is based on the intersection of the demand and
supply curves. The limit orders are all collected after each simulation step,
and the market is cleared by crossing the supply and demand curves given
by the current limit orders. The orders that are compatible with the new
price are executed, while the ones that do not match the clearing price are
discarded. The original algorithm, described in Raberto et al. (2001), is very
simple and direct and can be summarized as following.
Let be U the number of buy orders and V the number of sell orders issued
© ª
by the traders at a certain time step t = th . Also, let abu (th ), bu (th ) , u =
1, ..., U , be the data associated to the U buy orders. In each pair, the quantity
of stock to buy, abu (th ), is associated with its limit price, bu (th ). As regards
the V selling orders, they are represented by the pairs: {asv (th ), sv (th )},
v = 1, ..., V . Here the quantity to sell is asv (th ), while its associated limit
price is sv (th ). The cleared price, p∗ , is determined by intersecting the two
functions:
2.2 The Original Model 28
X
fth (p) = abu (th ) (Demand curve) (2.4)
u|bu (th )≥p
X
gth (p) = asv (th ) (Supply curve) (2.5)
v|sv (th )≤p
The orders matching the new price p∗ , i.e. buy orders with maximum price
lower than or equal to p∗ , and selling orders with minimum price higher than
or equal to p∗ , are executed. Subsequently, the amount of cash and assets
owned by each trader are updated.
Figure 2.1 shows the shape of the demand and of the supply curves in
a case derived from a simulation. The resulting clearing price p∗ is deter-
mined by the x-axis coordinate of the intersection point between the two
curves. Note that in this example the unbalance towards buy orders causes
an increase of price.
Figure 2.1: Price Clearing Mechanism. The new price p∗ is determined by the
intersection between the demand and supply curve. The gure is drawn from a
simulation.
2.3 The Reengineering Process 29
The main goal of this research has been the development of a general frame-
work for nancial market simulation. The project made use of the experience
gained with the original model, and improved its architecture and extended
its functionalities in order to build a exible and easily modiable system,
that could be rapidly adapted and extended to study, model and analyse the
plenty of open issues of real nancial markets.
The current version of the model includes both structural and behavioural
assumptions. Structural assumptions are indicative of those trading mecha-
nisms which dene the market rules, while behavioural assumptions refer to
trading strategies and the rules used by traders for making their decisions
(LiCalzi and Pellizzari; 2002). The software system obtained is exible and
easily modiable. The software framework is able to model the impact of
transaction taxes on traders' behaviour and wealth, the eects of short selling
and margin trading, the interplay of stock and option market, the interplay
between stock markets in dierent currencies, with an exchange market in
between. In fact, this framework has been developed in subsequent steps,
each one aimed to extend and generalize the previous one:
2.3 The Reengineering Process 30
1. Its rst version was able to model and simulate a stock market pop-
ulated by dierent kinds of autonomous heterogeneous agents. The
agents have nite cash and stock amounts; they issue buy/sell limit
orders basing on their behaviour and their constrained budget; both
cash and asset initial endowments are obtained applying a given law,
which can be uniform (all agents have the same initial endowment),
or can be a Zipf's law (agent's initial endowments are distributed ac-
cording to a power law, thus with big dierences among traders). In
this version of the articial stock market there was one stock, traded
in exchange for cash; the stock pays no dividend, and there are no
transaction costs or taxes. The kinds of trader behaviour implemented
in this version are: (i) random traders, who trade at random; (ii) fun-
damentalist traders, who pursue a fundamental value of the stock; (iii)
chartist traders, who follow the market, speculating that if prices are
increasing they will continue to go up, and that if prices are decreasing,
they will continue to drop; (iv) contrarian traders, who act in the oppo-
site way than chartists. In this case, the proposed model exhibited the
key stylized facts of nancial time series and was able to simulate the
long-run wealth distribution of the dierent population of the agents.
in stock and cash. Also, both trade margin requirements and short sale
restrictions were added. We used this version to study the eects of
this kind of trading on daily price volatility and on traders'long-run
wealth distribution.
5. The last version of the framework was made able to simulate a stock
option market, and the underlying stock market. The main goal is
to analyse the impact of the stock option trading on the market of
the underlying security. In this case the software system has been ex-
tended introducing a new kind of trades security, the option, and two
new kinds of traders, one representing traders operating in the option
market, and the other representing the issuer of options (a bank). The
option we model is an European option, which gives the right to buy or
sell another nancial asset (underlying security ) at a specied expira-
tion date for a strike price. There are two types of options, call option
and put option. The software framework allows the owner to exercise
an option at its expiration date, of course only if it is in the money.
The option trader can buy/sell stocks in the stock market, and can
buy stock options in the option market. The bank issues options, and
2.3 The Reengineering Process 32
cover itself in the stock market when option traders exercise their in
the money options when they expire. The main goal of this version of
the framework is to analyse whether the introduction of options have
an impact on underlying asset volatility, and on wealth distribution of
traders.
The rst version of the model includes the main characteristics of the
original GASM described in section 2.2. It was a proactive work, because we
deeply analysed each component of the simulation model and we improved it
by modifying some equations, by updating the trading process and re-tuning
all the parameters. This work has been necessary to make the whole system
more exible and easily modiable. The resulting model is more robust than
the original one both in terms of changes in the parameters and in terms of
changes in the composition of the population of traders. We validated the
new model by showing that it exhibits the main stylized facts of nancial
markets, as found by using the original one. The second and the third version
of the model can be seen as improvements devoted to analyse the eects of
the imposition of dierent rules and regulations on markets. The fourth and
the fth versions explore new kinds of nancial markets, beyond the common
case of the stock markets, and their mutual interaction.
Since that the current version of the framework is the result of an incre-
mental and iterative process, we will introduce its features following the same
approach. In particular, our research originated from some policy-oriented
questions that require models with realistic behaviour, with agents capable
of reacting to institutional changes, such as the imposition of a Tobin tax on
the market. As said above, this topic leaded us to the development of the
second version of the framework. In chapter 3 we introduce the details of
the model and the results obtained with that version of the framework. For
2.3 The Reengineering Process 33
the sake of brevity, it will include the results we found with the rst version
of the model. Chapter 4 describes the improvements made to the model in
order to explore another critical question in nancial literature: the impact
of margin requirements and of short-sale constraints on prices and volatility,
and their relationship with stock market crashes. Finally, Chapter 5 is about
a further extension of the model which allowed us to analyse the interaction
between two stock markets located into two dierent countries, and their
inuence on the FOREX.
This structure has to main advantages: the rst one is that we introduce
the model details gradually, simplifying the treatment and the exposition of
the results. The second one is that each Chapter could be read separately as
a case study, without knowing anything of the details of the other Chapters.
Each one of these three Chapters is structured following the same pattern:
the rst section describes the historical background and the motivations
that leaded to each version of the framework. Then there are details about
the model itself, and the description of its extensions and modications in
comparison with the previous version. Finally, we discuss the simulation
process and the results we found.
Note that this thesis describes the results we found with versions from
one to four, while the last one will be skipped because it is in progress and is
the result of a joint work with other researchers from our group. Details on
the fth version of the model have been presented in 2006 MDEF Conference
(Ecca et al.; 2006), and then summarized in a paper submitted to a special
issue of the Computational Economics Journal.
2.4 Simulation Software 34
3.1 Motivations
The deep nancial crises over the past decade, starting from the Mexican
pesos crisis in 1994 to the Argentina one in 2001, raised serious doubts as to
the ability of free markets to reect the true value of a specic currency. In
fact, too many speculative activities can produce a strong bias in exchange
rates and create a monetary crisis, or at least amplify its eects. Many
observers claim that a tax on currency transactions may prove a powerful
tool for penalizing speculators and stabilizing markets. For these reasons,
in recent years there has been an ongoing interest in the idea advanced by
some economists (among whom the most famous is James Tobin; 1978) to
levy a small tax on currency transactions.
Over the last thirty years the volume of foreign exchange trading has
increased hugely. In 1973, daily trading volume averaged around $15 billion;
today, it averages $ 1.9 trillion (BIS; 2005). Moreover, 90% of the trad-
ing volume concerns short-term transactions. In general, economists believe
that most short-term transactions are of a speculative nature, and many
considered them to be a source of market volatility and instability. Instead,
medium or long term transactions are usually related to real investments.
In 1936, Keynes in The General Theory of Employment, Interest, and
Money (Keynes; 1936) asserted that the levy of a small tax on all stock
exchange transactions should contribute to reducing instability in domestic
stock markets. According to Keynes, this tax should discourage speculators
from trading, resulting in lower price volatility of the taxed asset.
In 1978, the Nobel Prize Laureate in Economics James Tobin (1978) pro-
posed the levy of a small tax (0.1%) on all foreign exchange transactions.
This would penalize short-term speculators but not long-term investors, fa-
voring market stability. Later, several authors (see, e.g. Palley; 1999; Baker;
3.1 Motivations 39
2000; Felix and Sau; 1996; Frankel; 1996; Kupiec; 1995) proposed a similar
solution for other kinds of securities.
On the other hand, some economists disagree with Keynes and Tobin's
views. Friedman (1953) challenged these theories arguing that speculative
trading could stabilize prices.
There are only a few empirical analyses on the eects of transaction taxes
on price volatility. Umlauf (1993) studied Swedish stock market data and
showed that the introduction of a Swedish tax increased the volatility of
stock prices. Its worth noting that the tax level was set at 1% in 1984 and
at 2% in 1986: such values are far too high compared with the percentage
proposed by Tobin.
Habermeier and Kirilenko (2001) analysed the eects of transaction costs
and of capital controls on markets, and showed that they can have negative
eects on price discovery, volatility and liquidity, reducing market eciency.
They produced evidence that the Tobin tax increases market volatility by
discouraging transacting, thereby reducing market liquidity.
(Palley; 2003) argues that the Tobin tax is good for nancial stability,
and that total transaction costs are not necessarily increased by its impo-
sition. Actually, transaction costs could change the composition of traders,
precluding short-term investors from the market. It leads to a reduction in
volatility and consequently in total transaction costs.
Aliber et al. (2003) demonstrated that a Tobin tax on Foreign Exchange
Transactions may increase volatility. They constructed the time series of
monthly transaction costs estimates, volatility and volume, for four curren-
cies (the British Pound, the Deutsche Mark, the Japanese Yen and the Swiss
Franc) for the period 1977 to 1999. They showed that volatility is posi-
tively correlated with the level of transaction costs, while trading volume
3.2 Model Description 40
The model is made up of an economy with two stock markets, each trading
an asset with similar characteristics, as regards prices dynamics and traders'
behaviour.
Each trader is modeled as an autonomous agent, and each is given a
given amount of cash and assets. The simulation software (see Section 2.4)
enables to track the traders' portfolio, the price series history and the orders
issued by each trader for each time step. A time step is conventionally one
day in duration.
First we examined the dynamics of a single market, both without and
with a transaction tax of 0.05% to 0.5%. Then we considered the case of
two markets, examining market trend without tax, and then the eects of
3.2 Model Description 41
introducing the tax rst in one market, and lastly in both markets.
At each time step, each trader trades only within one market. Before
trading takes place, each trader, in accordance with an attraction function
based on expected gain, may decide to leave one market, switching to the
other.
The trader model denes the basic behavioural rules for each kind of
trader. Each kind of trader is tuned setting the values of some parameters,
in such a way that the resulting price series show the well-known stylized
facts, and price volatility is similar to that found in real markets. Each kind
of trader is provided with an activity parameter that roughly controls the
activity of the trader, and her reactivity to the markets, thus inuencing the
trader's contribution to price volatility. After many trials, we were able to
introduce a parameter k common to all kinds of traders an increase in k
leads to an increase in volatility and in volumes.
We concentrated our study on the eects of dierent compositions of
the populations behaviour on taxed (and non taxed) markets. The price
clearing mechanism we used is the same in all simulations, and is neutral
under this respect. Other works analysed market dynamics using dierent
market mechanisms and dierent trade behavioural rules in terms of stylized
facts and of allocative eciency (see, e.g. Bottazzi et al.; 2005).
We studied the case of a single market, to assess the impact of a transac-
tion tax on price volatility and traders' wealth. Then, we studied two related
stock markets, to assess the impact of levying a tax on one of them, and then
on both.
3.2 Model Description 42
The proposed model includes N traders having four dierent kinds of be-
haviour: random, fundamentalist, momentum and contrarian. At each sim-
ulation step, a trader can issue orders with a given probability, which we
usually set at 10% for every trader. In the case of two markets, each trader
chooses the most attractive market, according to her attraction function.
The behaviour of the agents is based on the equations described in Section
2.2. The main limit of the original model was that in order to obtain a good
price process the number of non random traders has to be kept very small.
As described in Raberto et al. (2003), random traders are a thermal bath,
and the number of chartist and fundamentalist traders is always less than
1%. Also, the probability that an agent will issue an order is small and equal
to 2%. We upgraded the and improved the agents' model so that the total
number of agents which use a dierent trading strategy from the random
one can reach the 30% of the total number N of agents, without inuencing
the overall price process. Also the probability that an agent issues orders
can be increased over 5-fold. This result allowed us to deeply analyse the
interactions among the various kinds of populations, in a more realistic way.
Random traders
Fundamentalist traders
Fundamentalists (type F) strongly believe that each asset has got an intrinsic
fundamental value pf . Fundamentalists' order limits are set toward pf , and
their size (in stocks for sell orders and in cash for buy orders) equals a fraction
of the current amount of stocks or cash owned by the trader. This size is
proportional to a term q shown in equation 3.1, where k is the same k used
for random traders in equation 2.2.
|p(t) − pf |
q=k· (3.1)
pf
When a transaction tax is levied, these computations are performed in-
creasing (or decreasing) the current price of the tax value.
Momentum traders
· ¸
p(t) − p(t − τ )
li = p(t) · 1 + k · (3.2)
τ p(t − τ )
3.2 Model Description 44
· ¸
|p(t) − p(t − τ )|
qis = ai (t) · U (0, 1) · 1 + k · (3.3)
τ p(t − τ )
· ¸
ci (t) |p(t) − p(t − τ )|
qib = · U (0, 1) · 1 + k · (3.4)
pi (t) τ p(t − τ )
where U (0, 1) is a random draw from a Uniform Distribution between 0
and 1.
Contrarian traders
The contrarian (type C) trader's order limit price and quantity are computed
in the same fashion as the momentum traders, but in the opposite direction.
The transaction tax is dealt with in the same way as for momentum traders.
Attraction functions
In the case study of two markets, at each simulation step (t), the trader
decides in which market she prefers to trade by evaluating an attraction
function for both markets.
Let AT,i T,i
1 (t) and A2 (t) be the attraction functions for the i-th generic
trader of type T for the rst and the second market, respectively. At each
3.2 Model Description 45
simulation step t, the i-th trader chooses SM1 with probability given by
equation 3.5a, and SM2 with probability given by equation 3.5b.
AT,i
1 (t)
π1i (t) = (3.5a)
AT,i T,i
1 (t) + A2 (t)
The attraction functions have been designed taking into account the char-
acteristics of each sub-population of traders.
In most simulations, the trader populations of two markets do not dier
signicantly no more than a few percentage points. However, in about 1-2%
cases, it may happen that one market becomes too attractive compared to the
other, triggering an avalanche of traders and leaving empty or almost empty
the other market. To avoid this divergent behaviour, we constrained the
values of the probability function π1i (t) to a minimum set at 0.3. This value
is somewhat arbitrary, but it is sucient to obviate the problem completely,
without introducing any signicant side-eect in the simulations.
As regards attraction functions, they have been designed taking into
account the specic characteristics of various kinds of traders.
Random traders represent the bulk of traders operating in the market
for personal reasons, or with no specic trading strategy. When faced with
the possibility of operating in one of two markets, they naturally tend to
prefer the less volatile one. Moreover, they also tend to avoid the market
with higher tax rate. In our model, at each simulation step random traders
choose randomly to buy or sell, with equal probability. If a random trader
decides to sell, her attraction function reects the considerations made above,
and is shown in equation 3.6.
2
AR,i
j,sell = e
σj (τi )
(1 − taxj ) (3.6)
3.2 Model Description 46
The superscript R denotes the random trader, j denotes the j-th asset,
and σj2 (τi ) represents the volatility of the returns computed in the time
window τi specic for each trader. The exponential term ensures that random
traders prefer to sell in a volatile market. The (1 − taxj ) term reduces the
attraction of a taxed market, being taxj the transaction tax imposed in j −th
market. For instance, if the tax is 1% in market j , the term taxj is set at
0.01.
If a random trader decides to buy, she performs this action in a less
volatile market with a higher probability. So, the probability that a random
trader buys in a less volatile market is equal to the probability that a ran-
dom trader sells in a more volatile one. The attraction function is given by
equation 3.7.
2
AR,i
j,buy = e
−σj (τi )
(1 − taxj ) (3.7)
AM,i
j = AC,i
j =e
τi pj (t−τi )
(1 − taxj ) (3.8)
The exponential term ensures that the attraction functions will be always
≥ 1 so that equations 3.5a and 3.5b will not diverge.
Each agent owns a nite amount of nancial resources, that is cash and
stocks. The simulation software is able to keep track of the traders' portfolio,
and the decisions of the individual are inuenced by their limited budget.
Traders' initial endowment, both in cash and in stocks, follows a Zipf's
law. This law usually refers to the frequency of an event relative to it's rank.
George Kingsley Zipf (1949) found that the frequency of use of the English
words in texts decays as a power law of its rank. The frequency f (i) of the
i-th most common word is given by f (i) ∼ i−β , where β ' 1. A power law
y = Cx−a can be expressed by the formula: log(y) = log(C) − a · log(x),
that is a straight line with slope −a on a log-log plot. A power law decay
means that small occurrences are very common, but large ones are extremely
rare. It is worth noting that this regularity is sometimes also referred to as
Pareto. Pareto was interested in the distribution of income. Let be X a
random variable, X is said to follow a Pareto law if P (X ≥ x) = 1/xα ,
where α is a positive constant (Pareto; 1897). In other words, his law means
that there are a few millionaires and many people who make modest income.
3.2 Model Description 48
Note that a power law distribution gives the number of people whose income
is x, and not how many people have an income greater than x. It means that
the power law gives the probability distribution function (PDF) associated
with the cumulative distribution function (CDF) given by Pareto's law. The
three terms: power-law, Zipf and Pareto can refer to the same thing and, in
the case of β = 1 (or α = 1) the power-law exponent a = 2 (see, e.g. Adamic;
2000). This kind of law can be applied to many real phenomena, and holds
also for wealth (Dragulescu and Yakovenko; 2002).
The initial traders' endowment, both in cash and stocks, was obtained
by dividing agents into groups of 20 traders, and applying Zipf's law to
each group. We found that an unequal initial endowment increases trading
volumes and generates logarithmic returns with fatter tails. In the simplest
case of a market with one stock and one currency, the distribution of wealth
among traders is calculated as follows.
Let be C(0) the aggregate amount of cash at the beginning of the sim-
P
ulation C(0) = i ci (0), and A(0) the aggregate amount of stocks A(0) =
P
i ai (0). Also, let p be the average price at which the aggregate value of
stocks equals the total value of cash: p = C(0)/A(0), and let N be the
number of traders. At the beginning of each simulation, the i-th agent
is endowed with an amount of cash ci (0) = Ĉ/i and with an amount of
shares ai (0) = Â/i, where Ĉ and  are two positive constants, such that the
P
average amount of cash owned by the agents of each group 20 k=1 ck (0) is
PN
equal to C(0)/N = i=1 ci (0)/N = ci (0), and the average number of stocks
P20 PN
k=1 ak (0) is equal to A(0)/N = i=1 ai (0)/N = ai (0). We usually set
random traders Raberto et al. (2003). It is the equilibrium price for a closed
market, without external inows or outows of cash. It is due to the budget
constraints, that oblige the price p(t) to oscillate around the equilibrium
value set at C(0)/A(0). Its value is linked with the mean-reverting behaviour
of the simulator, and we selected it as best unbiased fundamental price pf
used by fundamentalists.
In the case of two markets, we found that the equilibrium price depends
√ P
on the square root of the number of markets: p ' m · C(0)/ m i=1 Am (0),
where m is the number of markets. In this case each trader is given with an
average 1, 000 stocks per market, and $70,500.
3.3 Results
As described in the following three Sections, we rst tested the overall be-
haviour of our model, varying the percentage of fundamentalists from zero
to 30%, in steps of 10, and the percentage of chartists from zero to 30% in a
similar fashion. Note that chartists always comprise the same percentage of
momentum and contrarian traders. Then we tested our model keeping the
percentage of fundamentalists (20%) and of chartists (20%) unchanged but
varying the percentage of momentum versus contrarian traders in 5% steps.
Stylized Facts
First, we tested for the presence of the stylized facts broadly explained in
Section 1.3. The results are in agreement with those of the original version of
the GASM (see Raberto; 2003), so this Section provides just concise summary
of the main ndings. For the sake of brevity, the following Chapters will not
report details on the stylized facts, except for those cases which deserve a
special mention. Price series show the usual stylized facts, with fat tails of
returns and volatility clustering. Note that, as discussed in section 3.2, the
trader models are not the same as previous reported simulations, but now all
depend on the same coecient k , able to control traders' reaction to price
trend, and thus to tune market volatility. After many test runs, we set the
value of k at 1.9, which guarantees the appearance of the price series stylized
facts for virtually every trader composition used.
In Figure 3.1 we plot the histogram of daily log-returns. A best-t normal
3.3 Results 51
25
20
15
Density
10
0
−0.25 −0.2 −0.15 −0.1 −0.05 0 0.05 0.1 0.15 0.2 0.25
Returns
Figure 3.1: Histogram of the distribution of daily log-returns. The gure shows the
data related to a simulation superimposed on the best normal t.
0
10
−1
10
ER > |Ret|
−2
10
−3
10
−3 −2 −1
10 10 10
|Ret|
80
70
60
Prices
50
40
30
0 500 1000 1500 2000 2500 3000 3500 4000
Time
0.2
0.1
Returns
−0.1
−0.2
0 500 1000 1500 2000 2500 3000 3500 4000
Time
Figure 3.3: Daily time series for prices (top) and returns (bottom) in the case of
a single-stock closed market.
returns
1
Sample Autocorrelation
0.5
−0.5
0 10 20 30 40 50 60 70 80 90 100
Lag
absolute returns
1
Sample Autocorrelation
0.5
−0.5
0 10 20 30 40 50 60 70 80 90 100
Lag
When the tax is not levied in a closed market, we obtained results similar to
those reported in Raberto et al. (2003), with fundamentalists and contrarian
3.3 Results 54
traders gaining wealth with time, at the expense of momentum traders and,
to a lesser extent, of random traders.
Here we describe the results of several simulations performed varying the
percentage of fundamental and chartist traders from 0% to 30% in steps of
10%, the remainder being random traders. Table 3.1 shows the mean and
standard error of price volatility, computed for the case of no Tobin tax.
Volatility of the returns was computed as the variance during period T :
T
1 X
σr2 = (rt − r̄)2 (3.9)
T −1
t=1
Table 3.1: Mean and standard error of volatility in a single market with no
tax. The results are multiplied by 103 .
Chartist
Fundamentalist 0% 10% 20% 30%
In the presented model, random traders alone are able to create consistent
price volatility, for two main reasons:
5
x 10
1.6
contrarian
1.5 fundamentalist
momentum
1.4 random
1.3
1.2
Wealth
1.1
0.9
0.8
0.7
0 200 400 600 800 1000 1200 1400 1600 1800 2000
Time
Figure 3.5: Dynamics of wealth of the four populations of traders for a simulation
of 2000 steps.
Table 3.2: Mean and standard error of volatility in a single market with 0.1%
tax. The results are multiplied by 103 .
Chartist
Fundamentalist 0% 10% 20% 30%
Table 3.3 shows mean and standard error of price volatility, computed
for a Tobin tax of 0.5%.
For markets with random and fundamentalists traders alone, levying the
tax produces a small reduction in volatility, which varies with fundamentalist
percentage, attaining 5-8% (tax = 0.1%), and as much as 30-40% (tax =
0.5%).
When chartists are taken into account, the tax systematically leads to
an increase in volatility, of up to 80% for tax = 0.1%, and of up to 7-fold for
tax = 0.5%, for the highest percentage of chartists. This eect is evident for
a chartist percentage of 20% or 30%. When chartists only account for 10%
of the entire trader population, the increase in volatility is signicant only
3.3 Results 59
Table 3.3: Mean and standard error of volatility in a single market with 0.5%
tax. The results are multiplied by 103 .
Chartist
Fundamentalist 0% 10% 20% 30%
−3
x 10
8
5
Volatility
1
0 0.001 0.002 0.003 0.004 0.005 0.006 0.007 0.008 0.009 0.01
Tax
Figure 3.6: Price variance as a function of tax rate for 10% fundamentalist and
10% chartist traders.
Table 3.4: Mean and standard error of volatility computed for dierent contrarian
traders percentages, pc . The total percentage of chartists is always 20%. All values
are multiplied by 103 .
rate % Mean (stEr) Mean (stEr) Mean (stEr) Mean (stEr) Mean (stEr)
0.0 1.83 (0.13) 0.62 (0.07) 0.58 (0.06) 1.15 (0.11) 4.88 (0.46)
0.1 1.96 (0.28) 0.95 (0.08) 0.71 (0.07) 1.25 (0.09) 4.31 (0.26)
0.5 4.70 (0.31) 2.26 (0.14) 1.84 (0.14) 2.20 (0.19) 4.78 (0.26)
to the total number of shares (Raberto et al.; 2003). Moreover, the funda-
mental price p(f ) of fundamentalist traders is set to 50 to be consistent with
the mean reverting behaviour. The increase of volatility could be explained
by the reduction of orders when a tax is applied. Note that we have 400
agents, and on average 40 active agents at each time step, resulting in an
average of 20 sell orders and 20 buy orders of dierent sizes. If transac-
tion taxes reduce these numbers, and also the agents' trading amount, the
demand and supply curves from which the price is derived becomes much
fuzzier, magnifying price variations. The relationship between transaction
taxes, market depth and price volatility is also explored by Ehrenstein et al.
(2005), yielding similar results.
In Tables 3.5, 3.6 and 3.7, we report the average daily volumes for the
cases studied. The traded volumes do not change as much as volatility as
trader composition and tax rate are varied. However, note the strong anti-
correlation between volatility and volumes in many cases.
Westerho (2003), using a dierent model with unlimited resources ob-
served a dierent behaviour a reduction in volatility for low tax rates,
increasing as rates are increased. These results conrm how dicult it is to
3.3 Results 62
70
65
60
55
Price
50
45
40
35
0 500 1000 1500 2000 2500 3000 3500 4000
Time
0.2
0.1
Returns
−0.1
−0.2
0 500 1000 1500 2000 2500 3000 3500 4000
Time
Figure 3.7: Daily time series for prices (top) and returns (bottom).
Table 3.5: Mean and standard error of daily volumes in a single market with
0.0% tax. The results are multiplied by 103 .
Chartist
Fundamentalist 0% 10% 20% 30%
Table 3.6: Mean and standard error of daily volumes in a single market with
0.1% tax. The results are multiplied by 103 .
Chartist
Fundamentalist 0% 10% 20% 30%
Table 3.7: Mean and standard error of daily volumes in a single market with
0.5% tax. The results are multiplied by 103 .
Chartist
Fundamentalist 0% 10% 20% 30%
The price volatility values conrm that both markets behave in the same
way. Moreover, in this case the number of traders switching from one mar-
ket to another, and vice-versa, are balanced in both markets. Volatility is
somewhat higher than in the corresponding Table 3.1, denoting that the pres-
ence of two markets, with traders switching between them, tends to increase
price volatility. Again, price volatility decreases with increasing percentages
of chartists, and increases with increasing percentages of fundamentalists.
These experiments conrm the ndings obtained for single markets and two
markets with no tax. The rst observation is that having two markets leads
to a substantial increase in price volatility. This phenomenon might be ex-
plained by the imbalance between cash and stocks with respect to a single
market. However, we performed a number of simulations with one market,
varying traders' initial cash endowment, while leaving their stock endowment
unchanged, but did not notice any change in volatility. Note that volatility
increases 3-4 fold even for markets with just random traders, who switch
from one to the other trying to reduce their risk. They tend to sell in the
more volatile market, and buy in the less volatile one, as shown in equations
3.6 and 3.7 (section 3.2.1). Probably, this behaviour creates an imbalance in
orders resulting in an overall increase in volatility. The intrinsic mean rever-
sion mechanism due to limited trader resources avoids long-term imbalance
between the two markets. The presence of fundamentalists seems to reduce
the increase in volatility, while the combined presence of high percentages
of chartists and fundamentalists magnies it for 20% fundamentalists and
20% chartists, we observed a 8-9 fold increase (see Tables 3.1, 3.8 and 3.9).
In Fig. 3.8 we show the wealth dynamics for the four trader populations
in both markets, for a simulation of 2000 steps. Both fundamentalists and
chartists account for 10% of total trader population. For the two markets,
3.3 Results 66
Table 3.8: Mean and standard error of volatility in market one. The results
are multiplied by 103 .
Chartist
Fundamentalist 0% 5% 10% 20%
Table 3.9: Mean and standard error of volatility in market two. The results
are multiplied by 103 .
Chartist
Fundamentalist 0% 5% 10% 20%
5
x 10
3.8
contrarian
fundamentalist
3.6 momentum
random
3.4
3.2
Wealth
2.8
2.6
2.4
2.2
0 200 400 600 800 1000 1200 1400 1600 1800 2000
Time
Figure 3.8: Wealth dynamics of the four trader populations for a simulation of
2000 steps, for two markets.
Here we discuss the dynamics of two markets, levying the tax in just one of
them (Market 1). When levying a tax on Market 1 transactions, we obviously
found total traders' wealth to decrease over time, because our market model
has limited resources. This decrease aects both cash because the tax
is paid in cash and prices because a cash shortage aects prices. If
the fundamental price (pf ) is not adjusted according to the cash reduction,
in a closed market after a while fundamentalists wealth will also diminish,
because they tend to push prices towards their fundamental value which
eventually becomes unsustainable. They buy all the stocks they can and
then stay still, while the value of their stocks slowly diminishes. However, in
our simulations the cash drain of tax payment is negligible, because the tax
rate is low, the number of transactions made by each trader is also low, and
the number of simulated time steps is limited. Thus, the reported results
3.3 Results 68
Table 3.10: Mean and standard error of volatility in market one, with 0.1%
transaction tax. The results are multiplied by 103 .
Chartist
Fundamentalist 0% 5% 10% 20%
Table 3.11: Mean and standard error of volatility in market two, with 0.1%
transaction tax. The results are multiplied by 103 .
Chartist
Fundamentalist 0% 5% 10% 20%
The eects of the tax observed for a single market (no substantial dif-
ferences for random and fundamentalist traders alone, volatility increase in
the presence of chartists) are fully conrmed in the case of a tax levied on
3.3 Results 69
Table 3.12: Mean and standard error of volatility in market one, with 0.5%
transaction tax. The results are multiplied by 103 .
Chartist
Fundamentalist 0% 5% 10% 20%
Table 3.13: Mean and standard error of volatility in market two, with 0.5%
transaction tax. The results are multiplied by 103 .
Chartist
Fundamentalist 0% 5% 10% 20%
tax market, while the taxed market shows a strong increase, thus adsorbing
to some extent additional volatility from the former.
Table 3.14 shows average daily trading volumes in both markets, for
dierent trader compositions and tax rates. The taxed market is, as always,
Market 1. The values are averaged over 20 simulations, and standard errors
are also given.
As expected, when no tax is levied, average trading volumes do not dier
signicantly from one market to the other. The introduction of the tax leads
to smaller volumes in the taxed market, in all those cases where it results in
a price volatility increase. The dierence in trading volumes is not as large
as the dierence in volatility, at the most in the order of 20%. This nding
conrms, however, that traders tend to shun the taxed market, and that a
lower volume triggers an increase in volatility, as discussed in Section 3.3.1.
Table 3.14: Average daily volumes. Tax levyed on market one only. The
results are divided by 103
0 0 9.49 (1.05) 9.48 (1.04) 9.55 (1.07) 9.46 (1.05) 9.47 (1.07) 9.57 (1.07)
0 10 9.97 (1.05) 10.01 (1.05) 9.81 (1.04) 9.91 (1.05) 9.37 (1.02) 9.85 (1.04)
0 20 10.55 (1.07) 10.63 (1.08) 10.13 (1.05) 10.54 (1.08) 9.26 (1.03) 10.31 (1.05)
10 0 8.61 (0.94) 8.60 (0.94) 8.56 (0.94) 8.61 (0.94) 8.57 (0.94) 8.68 (0.94)
10 10 9.24 (0.99) 9.29 (0.98) 9.05 (0.97) 9.25 (0.99) 8.51 (0.94) 9.25 (0.99)
10 20 10.01 (1.05) 9.95 (1.06) 9.44 (1.01) 9.99 (1.05) 8.40 (0.96) 9.96 (1.04)
20 0 7.91 (0.90) 7.87 (0.90) 7.85 (0.90) 7.89 (0.89) 7.82 (0.89) 7.91 (0.90)
20 10 8.50 (0.94) 8.47 (0.95) 8.30 (0.93) 8.50 (0.94) 7.78 (0.88) 8.58 (0.95)
20 20 9.17 (1.00) 9.12 (0.99) 8.76 (0.98) 9.21 (1.01) 7.77 (0.92) 9.27 (1.01)
Chapter 4
4.1 Motivations
After the great stock market crash of 1929, some restrictions were imple-
mented to ensure the market does not crash again. On one hand, when
prices declined, many investors who had bought stocks on margin tried to
sell their shares disrupting the market. On the other hand, short sellers were
pointed out as one of the main causes of the crash. The U.S. stock market
reacted restricting short-selling and setting margin requirements.
4.1 Motivations 72
In 1934 the U.S. Congress gave the Federal Reserve Board the power to
set initial, maintenance and short sale margin requirements on stock markets.
Margin requirements were set in order to reduce excessive volatility of stock
prices, protect investors from losses due to speculative activities, and reduce
loans by banks to stockholders, moving credit toward more productive assets.
The 1987 stock market crash renewed both political and academic in-
terest on the eectiveness of restriction policies for stocks and derivative
products. Since then, a wide debate on these solutions started, and studies
were performed on the eects of such impositions.
In April 2005, the China Securities Regulatory Commission (CSRC) is-
sued a new plan for state share reform. As reported by Bloomberg News1 ,
China plans to allow investors to take out loans to buy shares and to sell
borrowed stock for the rst time, moves aimed at tapping the country's $4
trillion of bank deposits and boosting trading. The China Securities Regu-
latory Commission may select ve brokerages to start margin-lending and
short-selling services this year". This event will surely renew the interest on
short-selling and margin requirements regulations.
Buying on margin means to borrow money from a bank or a broker-
dealer to buy securities. The margin requirements set the maximum legal
amount that an investor may borrow to increase her purchasing power, so
she can buy securities without fully paying for them. For instance, if the
initial margin requirement is set at 20 percent, an investor can borrow up to
80 percent of the current value of the owned securities.
There has been an heated debate on the eectiveness of margin regula-
tions and on their inuence on asset prices. The central issue is the claim
that margin requirements have an inuence on stock price volatility.
1
For more details see http://www.bloomberg.com
4.1 Motivations 73
position by buying back the shares. If their prediction was right, short sellers
gain a prot.
After the stock market crash of October 1929, many short-sale restric-
tions were imposed on short-selling in the United States. Short sellers were
immediately pointed out as the cause of the collapse, so three regulatory
changes were decided in order to reduce short-selling2 .
Short-selling advocates claim that it increases liquidity, favours risk shar-
ing and increases informational eciency. On the other hand, opponents of
short-selling claim that it causes high volatility, favors market crashes and
panic selling.
Miller (1977) observed that, if short-selling is restricted and investors
have heterogeneous beliefs, the observed price of a security does not reect
the beliefs of all potential investors, but only the opinion of the optimistic
ones. The implication of his idea was that stocks may be overpriced because
of short-selling restrictions. Miller's hypothesis implies a negative relation-
ship between short interest and returns. In recent years, empirical evidence
on this relationship has been pointed out by several studies, among them we
cite Jones and Lamont (2002), Ofek and Richardson (2001) and Chen et al.
(2002).
King et al. (1993) studied the eect of short selling on asset market bub-
bles in an experimental laboratory environment. found that short selling does
not inuence market bubbles. Ackert et al. (2002) conducted experiments on
two asset markets and stated that short selling eliminates the bubble-and-
crash phenomenon. Haruvy and Noussair (2006) studied the relationship
between short-selling constraints and assets prices using a simulation model
based on the work by De Long et al. (1990b). They found that short selling
2
See http://www.prudentbear.com/press_room_short_selling_history.html
4.2 The Extended Model 75
reduces prices to levels below fundamental values and that the reduction of
the bubble-and-crash phenomenon is the consequence of such a trend rather
than of the eectiveness of short selling restrictions.
Some studies examine the relationship between return volatility and
short-sale constraints. Ho (1996) produced evidence that volatility increased
when short-selling prohibition was lifted during the Pan Electric crisis of
1985. Kraus and Rubin (2003) developed a model to predict the eect of
index options introduction on volatility of stock returns. Since short-selling
the stock was restricted, the option was considered as a form of reduction of
this constraint. The model is highly stylized, and it predicts that volatility
can either increase or decrease, depending on model parameters.
Diamond and Verrecchia (1987) asserted that short-sale restrictions can
slow down the response of prices to new information: some investors who
want buy or sell cannot take part in the market bringing a decline in liquidity.
In other words, if short-selling is possible, there is greater liquidity.
consists of agents that can issue orders using their available limited resources.
They are forbidden to sell if they do not have any stock to sell, and they
cannot buy if they do not have enough money to do so. The second one is
made up of traders that are allowed to buy/sell stocks in debt. The agents
can sell stocks without owing them (we will say that they can issue in debt
selling orders ) and buy shares without owing enough money to pay them
(in debt buying orders ). We will name agents belonging to the second group
Debt Prone Trader (DP T ), and we will call agents from the rst group
non-Debt Prone Trader (non − DP T ). Both DP T and non − DP T belong
to one of the four categories of traders described in Chapter 3. For the sake
of brevity we will mark DP T traders with a star (for instance Random*
means Debt Prone Traders of type Random).
It is worth noting that in this case we slightly modied the strategy
of fundamentalist traders. We improved their model by transforming the
trading probability from a constant to a function depending on the current
price p(t) and on the fundamental price pf . At each time step, they decide
whether or not to trade with a probability p depending on the ratio between
pf and p(t). If p(t) = pf , the probability p will be equal to 0.0, and it will
p
increase as a squared function of the ratio max( p(t)
f
, p(t)
pf ). The maximum
value of p is set at 0.1. Note that, if the price of the asset is close to pf , the
trading activity of fundamentalists is low, because the market is not very
attractive for them.
non−DP T are risk-adverse agents, so they trade using their limited resources
without issuing in debt orders. If a non debt prone trader issues a buy (sell)
limit order, the order amount and the limit price are computed as described
4.2 The Extended Model 77
in Chapter 2. Note that here the parameter k is set at a value equal to 1.4.
This choice brings to smaller values of volatility in comparison with those
found in Chapter 3, but these values are still in agreement with those of real
nancial data.
DP T are risk-prone agents. They can borrow money (or stocks) without
paying any interest on it (there are no transaction costs or taxes), but in
debt transactions must be guaranteed by the agents' total wealth. The debt
level of each DP T cannot exceed a certain threshold called safety margin
(m). If a trader exceeds the safety margin she is forced to cover her position
and repay her debts. If an agent has negative wealth wi (t), she goes bankrupt
and is obliged to leave the market. The wealth wi (t) of the generic i − th
trader at time step t is dened as wi (t) = ci (t) + ai (t) · p(t), where ci (t) is
the amount of cash and ai (t) the amount of stocks that the agent holds at
time t. The safety margin is a constraint that can be moved up or down
in order to allow agents to borrow more or less money (stocks), setting the
debt limit. In our tests, the value of m varies from 0.0 to 0.9. If m = 0.0, it
means that both short selling and margin trading are forbidden. If m > 0.0,
it means that short selling and margin trading are allowed. For instance, if
m is set at the maximum value (0.9), it means that margins are set at 10%
and a debt prone trader can borrow stocks (to sell short) or cash (to buy on
margin) up to 90% of her cash (stock value). Each debt prone trader decides
whether to buy or sell rst on the basis of her strategy, then she has two
choices: to trade using her limited resources or to trade borrowing stocks or
money. These choices have equal probability.
If the i − th agent decides to issue an in debt order, the order size has
4.3 Results 78
an upper limit. If the agent issues a buy order, the amount of stocks to
purchase cannot exceed the quantity âbi (t) (see equation 4.1). In debt selling
orders are generated fairly symmetrically relative to in debt buying orders,
the maximum quantity on sale is âsi (t) (see equation 4.2).
ci (t)
âbi (t) = m · ai (t) + b c (4.1)
p(t)
ci (t)
âsi (t) = ai (t) + bm c (4.2)
p(t)
If an agent exceeds her safety margin, she is obliged to cover her position.
In particular, if she holds an amount of assets ai (t) < 0 and âsi (t) < 0, she
is forced to buy the amount of stocks equal to the quantity expressed in
equation 4.3. Symmetrically, if a trader holds an amount of cash ci (t) < 0
and âbi (t) < 0, she is forced to sell an amount of stocks equal to the quantity
expressed in equation 4.4.
ai (t) + m cp(t)
i (t)
abm = d− e (4.3)
1−m
ci (t)
m · ai (t) + p(t)
asm = d− e (4.4)
1−m
4.3 Results
case. Each simulation is usually run with 4000 time steps (corresponding to a
time span of 20 years) and with 400 agents. Then, we opened the market by
varying the cash of the traders, in order to understand how external shocks
inuence volatility, both with and without DP T s.
Random Traders
We rst explored market behaviour when only random traders are present.
We studied volatility trend varying some parameters of the model. Volatility
is dened as the standard deviation of prices in a time window 50 steps long.
We set the Safety Margin at 0.8 and varied the percentage of Random*
traders from 0% to 100% in steps of 25%. The results showed that an
increase in the percentage of random traders able to trade in debt brings a
very slight increase in volatility, as shown in gure 4.1.
We also explored return volatility varying the value of m parameter from
0.1 to 0.9. We observed that volatility looks not aected by m, but for
the highest values of m. This result does not depend on the percentage of
DP T s. In gure 4.2 we report this behaviour for simulations with 50% of
debt prone traders. When m = 0.9, there is an increase in volatility, but
this phenomenon is due to the bankrupt of some traders, which makes the
market unstable. When a trader goes bankrupt, she is forced to cover her
position as far as possible, and then she leaves the market. On one hand,
this fact implies that an amount of stocks are sold or bought at limit prices
low or high enough to have a high probability to be fullled, and on the other
hand it lowers the number of traders. Both eects tend to increase market
volatility.
We found similar results by varying the probability that DP T s issue
4.3 Results 80
−4
x 10
Volatility
2
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Fraction of Random*
Figure 4.1: Mean and standard deviation of price variance as a function of Ran-
dom*. The percentage of DPT was varied from 0% to 100% in steps of 25%, with
m = 0.8.
−4
x 10
5.5
4.5
4
Volatility
3.5
2.5
2
0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9
Margin
of in debt orders; with a high margin equal to 0.8, this yields many bankrupts,
with consequent volatility increase.
−3
x 10
6
4
Volatility
0
0.25 0.3 0.35 0.4 0.45 0.5 0.55 0.6 0.65 0.7 0.75 0.8 0.85 0.9 0.95 1
P(in debt order)
Figure 4.3: Mean and standard deviation of price variance as a function of P(in-
debt), with the percentage of DP T random traders set at 50% and m = 0.8.
Trend Followers
5
x 10
1.35
Random
Random*
1.3
1.25
1.2
1.15
Wealth
1.1
1.05
0.95
0.9
0.85
0 500 1000 1500 2000 2500 3000 3500 4000
Time
Figure 4.4: Dynamics of wealth of Random and Random* for a typical simulation
with m = 0.8 and P (in − debt) = 50%.
Table 4.1: Mean and standard error of volatility with trend followers and
random traders. The results are multiplied by 103 .
0% 10% 20%
Momentum 0.27 (0.04) 0.26 (0.04) 0.30 (0.04)
We then analysed the eects of the dynamics of wealth with the trend
follower traders. We investigated if and how DP T agents inuence this
behaviour. We found that debt prone traders show the same dynamics
of non − DP T traders, but the eects are amplied. Contrarian* traders
gain more than Contrarian traders, Momentum* lose more than Momentum
traders, as shown in gure 4.5.
4.3 Results 84
5
x 10
1.6
Contrarian
1.5 Contrarian*
Momentum
1.4
Momentum*
Random
1.3
1.2
Wealth
1.1
0.9
0.8
0.7
0.6
0 500 1000 1500 2000 2500 3000 3500 4000
Time
Figure 4.5: Dynamics of wealth with trend followers for a typical simulation with
m = 0.8 and P (in − debt) = 50%.
Fundamentalists
Table 4.2: Mean and standard error of volatility with fundamentalists and
random traders. The results are multiplied by 103 .
0% 10% 20%
Fundamentalist 0.27 (0.04) 0.33 (0.04) 0.51 (0.10)
−4 −4
x 10 x 10
4.2 4.8
4.6
4
4.4
3.8
4.2
3.6
4
Volatility
Volatility
3.4 3.8
3.6
3.2
3.4
3
3.2
2.8
3
2.6 2.8
0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Margin P(in debt order)
Figure 4.6: Volatility with a population made of 10% of DPT fundamentalists and
of 90% random traders.
In this section we report the results of tests we conducted using all trader
populations. The main goal was to understand whether or not the results
were merely the sum of the eects of each population.
First, we used momentum, contrarian and fundamentalist traders, setting
the same percentage of agents for each kind of strategy. We found that DP T
traders slightly increase volatility, as shown in table 4.3. In this table, the
reported percentages refer to each kind of traders. So, a percentage of 5%
means that there are 5% of fundamentalists, 5% of momentum and 5% of
contrarian traders.
4.3 Results 86
Table 4.3: Mean and standard error of volatility with fundamentalists trend
followers and random traders. The results are multiplied by 103 .
0% 5% 10%
Fundamentalist, Momentum, Contrarian 0.27 (0.04) 0.28 (0.04) 0.34 (0.06)
Note that the increase in volatility is not due to failures of traders, be-
cause no trader fails during any of these tests. The sensitivity analysis both
of the m parameter and of the probability that debt prone traders issue a
debt order show results similar to those presented in previous sections. The
ndings are shown in gure 4.7.
−4 −4
x 10 x 10
3.6 4
3.8
3.4
3.6
3.2
3.4
3
Volatility
Volatility
3.2
2.8
3
2.6
2.8
2.4
2.6
2.2 2.4
0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Margin P(in debt order)
−4 −4
x 10 x 10
4 5
3.8
4.5
3.6
3.4
Volatility
Volatility
3.5
3.2
3 3
2.8
2.5
2.6
2
0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Margin P(in debt order)
Figure 4.8: Volatility with a population made of all types of traders, both DP T
and non − DP T .
5
x 10
2 Fundamentalist*
Fundamentalist
1.5
Contrarian*
Wealth
Contrarian
Random
1
Random*
Momentum
Momentum*
0.5
0 500 1000 1500 2000 2500 3000 3500 4000
Time
Figure 4.9: Dynamics of wealth with all eight types of traders for a typical simu-
lation with m = 0.8 and P (in − debt) = 50%.
We opened the market by varying the cash of the traders. The main goal is to
understand how external shocks inuence volatility, both with and without
DP T s. The cash variation ∆ci (t) follows the law expressed in equation 4.5.
4.3 Results 89
∆ci (t) is proportional to each trader's wealth and its level depends on the σ
parameter.
returns and in volatility. Figure 4.10 shows the population size superimposed
on prices and the population size superimposed on logarithmic returns for a
simulation with random traders alone, and σ = 10−4 . These gure show a
correspondence between the steps where traders' failures happen, and daily
return variations, which look very high during these steps.
Table 4.4: Mean and standard error of Volatility with random traders. The
results are multiplied by 103
Population σ
Time
Time
0 500 1000 1500 2000 2500 3000 3500 4000
120 400 0 500 1000 1500 2000 2500 3000 3500 4000
0.2 400
110
0.15
395
395
100
0.1
90
390 390
80 0.05
Population Size
Population Size
Prices
Returns
70 385 0 385
60
−0.05
380 380
50
−0.1
40
375 375
−0.15
30
Figure 4.10: Daily time series for prices (a) and returns (b) with random traders
and σ = 10−4 . The dotted line represents the population size.
ation 71.00). If random DP T s are taken into account, the average number
of traders who leave the market increase to 239.10 (with standard devia-
tion 107.78). Figure 4.11 shows the relationship between traders' bankrupts,
prices and returns. In order to remark that debt prone traders tend to fail
more than non − DP T s, gure 4.11 reports the population size of both ran-
dom and random* traders. Note that, if the number of failures is too high
(over 50%), the market will become unsteady. Moreover, in the case of open
market, the results are robust to changes in the values of the safety margin
and of P (in − debt).
We conducted further experiments using dierent traders' populations, as
the ones described in section 4.3.1. We found similar results to those obtained
with only random traders cash inows and outows increase volatility, debt
prone traders tend to declare bankrupt more frequently than non − DP T s of
the same kind, simulations are robust to changes in m and in P (in − debt).
Time
Time
0 500 1000 1500 2000 2500 3000 3500 4000
200 200 0 500 1000 1500 2000 2500 3000 3500 4000
0.2 200
Random
Random* Random
180
0.15 Random*
160
0.1
140
150 150
120 0.05
Population Size
Population Size
Prices
Returns
100 0
80
−0.05
100 100
60
−0.1
40
−0.15
20
0 50 −0.2 50
0 500 1000 1500 2000 2500 3000 3500 4000 0 500 1000 1500 2000 2500 3000 3500 4000
Time Time
Figure 4.11: Daily time series for prices (a) and returns (b) with 50% non − DP T
and 50% DP T random traders, with σ = 10−4 . The dotted line represents the
population size.
Chapter 5
It is well known that the recent nancial crises, starting from the Mexican
pesos crisis in 1994 to the Argentina's in 2001, have been accompanied by
episodes of nancial markets contagion, that is, many countries have expe-
rienced increases in the volatility and comovements of their nancial asset
markets.
Although changes in the statistical properties of prices are predictable
in countries experiencing nancial and exchange rate crises, the patterns of
comovement and of contagion of crises across countries are still not fully
understood. The denition itself of contagion, in fact, varies widely across
literature. A large number of tests have been proposed for assessing the
presence and the level of international contagion, but the results are often
conicting.
The main goal of this Chapter is to analyse the interaction between
two stock markets in two dierent countries, both during tranquil periods
and during a monetary crisis. We developed a multi-agent model with two
5.1 Contagion and interdependence 93
articial stock markets and two dierent currencies, by extending the general
framework described in previous chapters. The starting point of this study
was the development of a foreign exchange market (FOREX), that provides
a link between the two stock markets and sets the current exchange rate.
ments both before and after a shock or a crisis in one market. They dene
contagion as a signicant increase in cross-market linkages after a shock to
one country (or group of countries). This means that contagion occurs only
if cross-market comovements increase signicantly after a shock. On the
other hand, if the markets exhibit a high degree of comovement during peri-
ods of stability, even if the markets continue to be highly correlated after a
shock to one market, this may not constitute contagion. The authors use the
term interdependence to refer to this situation. Forbes and Rigobon test for
contagion by following a correlation analysis approach. According to their
denition, contagion occurs only if there is an increase in the unconditional
correlation coecient. They dene the unconditional correlation coecient
as the traditional correlation coecient adjusted in order to take into account
the bias in heteroscedasticity (see Forbes and Rigobon; 2002).
We consider an economy with two stock markets (SM1 and SM2 ) and one
foreign exchange market (F OREX ). The two stock markets are perfectly
symmetric, except for the accepted trading currency: the stocks of the SM1
are exchanged using the dollar, while those of the SM2 market are ex-
changed using the euro. The F OREX determines the exchange rate be-
tween the dollar and the euro.
At each time step, each trader trades only within one market. Before
trading takes place, each trader, in accordance with an attraction function
based on expected gain may decide to leave a market, switching to the other
one. Note that the trader converts all her money into the currency of the
destination market before leaving the current market. This choice increases
the purchasing power of the trader in the just selected market.
5.2 The Extended Model 95
If a trader decides to buy or sell stocks, she places a limit order on the
selected stock market, as described in Chapter 3.
The FOREX market diers from the stock markets in two main respects:
the traders issue only market orders, and a market maker is assumed to
adjust the exchange rate at the end of each trading period, on the basis
of the excess demand, as described in Section 5.2.1. At the end of each
simulation step, the exchange orders are collected and the new exchange
rate is computed. The FOREX is a closed market, so the total amount
of cash cannot vary during the simulations. If all the exchange orders are
executed at the new exchange rate, the quantity of both dollars and euro
will change. In order to avoid this phenomenon, we randomly choose and
discard a number of orders, to equilibrate the amount of exchanged cash.
Also, in the case of the F OREX the agents issue market orders, whose
size is a random fraction of the current cash owned by the trader herself.
In particular, each market order has information about the currency to sell
(dollar or euro), the order amount, and the currency to buy (euro or dollars).
The order amount cannot exceed the trader's current cash availability, and
the amount of currency that the agent will achieve to buy depends on the
new exchange rate S(t + 1).
We extended the four basic kinds of the agents' behaviour (random, fun-
damentalist, momentum and contrarian) by allowing them to issue market
orders in the FOREX. The only dierence between limit orders and market
orders is that market orders do not have a limit price, so they are executed
at the current price set by the market maker. Each kind of traders issues
market orders using exactly the same strategy used for issuing limit orders.
The extension is obvious, except for fundamentalists, which require further
explanation. Let be Sf the fundamental exchange rate /$ between the dol-
lar and the euro: if S(t) > Sf (S(t) < Sf ), the fundamentalist trader will
place a market order to sell (buy) euro in exchange for dollars.
5.3 Results 97
At each simulation step, each trader chooses the most attractive stock market
by evaluating the attraction functions described in Chapter 3, but in this case
we decided to make some changes. First, not before ve simulation steps
from her last switching (corresponding roughly to one week of trading), each
agent chooses the market to trade in on the basis of her trading strategy.
This choice t better with the case of markets in dierent countries, and
allowed us to remove the constraint πji (t) ≥ 0.3. With regard to random
traders, we simplied their function and we decided that, when faced with
the possibility of operating in one of two markets, they randomly select one
of them. Finally, we decided to allow fundamentalists to switch market. This
choice was made in order to give them the possibility to leave the bearish
market in the case of a crisis. Let be pjf the fundamental price in market
j = 1, 2. The fundamental traders will choose the most protable market
on the basis of the dierence between the current price and the fundamental
price, as given by equation 5.3.
j
|pj (t)−p |
f
j
AF,i
p
j =e
f . (5.3)
5.3 Results
We rst tested the overall behaviour of the FOREX market model, vary-
ing the percentage of fundamentalists and of chartists, while xing the total
number of agents to 400. Note that chartists always comprise the same per-
centage of momentum and contrarian traders. Trader's initial endowment,
both in dollar and euro, was obtained by dividing agents into groups of 20
traders, and applying Zipf's law to each group, as described in Chapter 3.
Here, each agent is given an average amount of $50000 and 50000.
At the beginning of the simulations, the exchange rate between the two
currencies is set at the equilibrium value S(f ), which depends on the ratio
between the total number of dollars and of euro exchanged. Since the total
number of euro is exactly equal to the total number of dollars, both the
starting exchange rate and the fundamental value used by fundamentalists
are set at 1.0. The exchange rate series exhibit the usual stylized facts,
with fat tails of returns and volatility clustering. Figure 5.1 shows both the
daily euro-dollar exchange rate (top) and the daily time series of logarithmic
price returns (bottom) for a typical simulation 10000 steps long, having a
population composed of 10% fundamentalist, 5% momentum and 5% con-
trarian traders. Figure 5.2 shows the survival probability distribution of the
standardized logarithmic return (bold stars) superimposed on the best Gaus-
sian t (solid line). The deviation from Gaussian distribution shows again a
leptokurtic behaviour in the returns tail, with a very well dened power-law
behaviour for high values of returns.
The model is capable, to a certain extent, to reproduce the so called
disconnected puzzle (Obstfeld and Rogo; 2000) which states that the ex-
5.3 Results 99
change rate is usually far from its underlying fundamentals. In our model,
which is completely endogenous and thus characterized by the absence of
external news, the fundamental value of the exchange rate is equal to the
ratio between the total quantity of dollars and the total quantity of euro
owned by the traders, that is 1.0. Figure 5.1 show that the exchange rate
can substantially deviate from 1.0 for periods longer than 250 steps, that
correspond roughly to one year of trading.
1.3
1.2
Exchange Rate
1.1
0.9
0.8
0.7
0 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000
Time
0.1
0.05
Returns
−0.05
−0.1
0 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000
Time
Figure 5.1: Daily time series for euro-dollar exchange rate (top) and returns (bot-
tom).
5.3.2 Two stock markets and the FOREX: putting it all to-
gether
Here we discuss the dynamics of the two stock markets combined with the
foreign exchange market. We performed extensive simulations, 2000 time
steps long, and examined two dierent cases: the behaviour of the whole
economy without any external inuence, and the eects of a sudden depre-
ciation of the dollar.
Each simulation was run using 1200 agents divided into two separate
groups. The rst one was composed of traders acting only in the FOREX
market and had 400 agents. The role of this population is to keep the
5.3 Results 100
0
10
−1
10
ER > |Ret|
−2
10
−3
10
−4
10
−4 −3 −2 −1
10 10 10 10
|Ret|
F OREX alive independently of the two stock markets. The remaining 800
agents form the second group, which trade in the two stock markets following
the rules described in Section 5.2.2. It is worth noting that, on average, the
agents belonging to the second group are equally distributed between the
two stock markets, so all three markets have an average number of traders
equal to 400.
Traders' initial stock and currency endowment was obtained as described
in Chapter 3. Each trader assigned to SM1 is given an average $100000 and
1000 stocks, but no euro or stocks of SM2 . Symmetrically, each agent that
starts to trade in SM2 is given an average 100000 cash and 1000 SM2
stocks. Finally, the agents populating the F OREX is given an average
$100000 and 100000 cash, but they do not own any stock.
Both the starting price pj (0) of the stock j and the fundamental price pjf
√
known by the fundamentalists are equal to j/ 2j − 1 (Cj (0)/Aj (0)), where
Cj (0) is the total cash amount of market j , and Aj (0) is the total number
of shares of market j . The value is equal to $80 for SM1 , and 80 for SM2 .
5.3 Results 101
Similarly, at the beginning of the simulations the exchange rate /$ is set
at a value equal to the ratio between the total number of euro and dollars,
that is 1.0.
Figures from 5.3(a) to 5.5 show the results of a typical simulation 2000
steps long. The trader population is composed of 10% fundamentalists, 10%
momentum, 10% contrarian, and 70% random traders. In particular, gures
5.3(a) and 5.3(b) show the daily prices and daily log-returns for the SM1
stock and SM2 stock respectively. Figure 5.4 show the dynamics of the euro-
dollar exchange rate, and gure 5.5 shows the dynamics of traders' wealth.
All three markets of the model exhibit the key stylized facts of nancial
time series, and the dynamics of wealth distribution is unvaried, with fun-
damentalist and contrarian traders winning at the expenses of random and
momentum traders. The presence of the exchange market does not seem to
inuence by itself the other markets, either with and without the GARCH
eect.
110 110
100 100
90
Prices
Prices
90
80
80 70
60
70
50
0 200 400 600 800 1000 1200 1400 1600 1800 2000 0 200 400 600 800 1000 1200 1400 1600 1800 2000
Time Time
0.15 0.15
0.1 0.1
0.05 0.05
Returns
Returns
0 0
−0.05 −0.05
−0.1 −0.1
0 200 400 600 800 1000 1200 1400 1600 1800 2000 0 200 400 600 800 1000 1200 1400 1600 1800 2000
Time Time
Figure 5.3: Daily time series for stock prices (top) and returns (bottom).
5.3 Results 102
1.5
1.3
1.2
1.1
0.9
0.8
0 200 400 600 800 1000 1200 1400 1600 1800 2000
Time
0.1
0.05
Returns
−0.05
−0.1
0 200 400 600 800 1000 1200 1400 1600 1800 2000
Time
Figure 5.4: Daily time series for euro-dollar exchange rate (top) and returns (bot-
tom).
5
x 10
2.8
2.7 contrarian
fundamentalist
2.6 momentum
random
2.5
2.4
Wealth
2.3
2.2
2.1
1.9
1.8
0 200 400 600 800 1000 1200 1400 1600 1800 2000
Time
Figure 5.7 shows that the dollar shock does not inuence the exchange
rate volatility. On the other hand, both the SM1 and SM2 price volatility
tend to increase in the days following the shock as presented in Figure 5.9(a)
and in Figure 5.9(b) respectively. We computed both weekly and monthly
volatility, but for the sake of brevity we report here only the latter. This
seems to conrm the second regularity quoted above.
We studied the dynamics of both returns and absolute returns corre-
lations between SM1 and SM2 during the tranquil period and during the
dollar crisis. Figure 5.10 shows the correlation analysis of a typical simulation
2000 steps long. The correlation coecients are calculated by considering
not overlapping return series 20 days long. Variables computed using weekly
and monthly returns gave very similar results. We found that the ination-
ary shock in not capable to inuence the correlation coecient dynamics,
which remain more or less the same during the whole of the simulation.
This conrms the fourth regularity quoted above.
On the basis of the denitions given in Section 5.1, we can conclude that
this model is not able to reproduce contagion, because there is no signicant
increment in the correlation values of returns. This result rules out the
possibility to run further tests on contagion, such as that discussed in a
series of papers by Boyer et al. (1997) and by Loretan and English (2000),
which require an increase in the correlation coecients as a necessary and
not sucient condition.
Finally we investigated the covariance dynamics of returns. Figure 5.11
shows that the shock brings to a sharp increase in the covariance of absolute
returns (bottom) and to a decrease in the covariance of raw returns (top).
5.3 Results 105
This result seems to conrm the third regularity identied in (Corsetti et al.;
2001).
180 100
160
90
140
Prices
Prices
120 80
100
70
80
60 60
0 200 400 600 800 1000 1200 1400 1600 1800 2000 0 200 400 600 800 1000 1200 1400 1600 1800 2000
Time Time
0.2 0.2
0.1 0.1
Returns
Returns
0 0
−0.1 −0.1
−0.2 −0.2
0 200 400 600 800 1000 1200 1400 1600 1800 2000 0 200 400 600 800 1000 1200 1400 1600 1800 2000
Time Time
Figure 5.6: Daily time series for stock prices (top) and returns (bottom). The
inationary shock is applied at the end of the step number 1000.
2.5
Exchange Rate
1.5
0.5
0 200 400 600 800 1000 1200 1400 1600 1800 2000
Time
0.1
0.05
Returns
−0.05
−0.1
0 200 400 600 800 1000 1200 1400 1600 1800 2000
Time
Figure 5.7: Daily time series for euro-dollar exchange rate (top) and returns (bot-
tom). The inationary shock is applied at the end of the step number 1000.
5.3 Results 106
Exchange Rate
3
2.5
1.5
0.5
0 200 400 600 800 1000 1200 1400 1600 1800 2000
6 Volumes
x 10
5
0
0 200 400 600 800 1000 1200 1400 1600 1800 2000
Figure 5.8: Daily time series for euro-dollar exchange rate (top) and volumes
(bottom). The inationary shock is applied at the end of the step number 1000.
7 7
6 6
5 5
Volatility
Volatility
4 4
3 3
2 2
1 1
0 0
500 600 700 800 900 1000 1100 1200 1300 1400 1500 500 600 700 800 900 1000 1100 1200 1300 1400 1500
Time Time
Figure 5.9: Daily volatility for the stock prices between step 500 and 1500 of the
simulation. The inationary shock is applied at the end of the step number 1000.
5.3 Results 107
0.5
Ret. Correlation
−0.5
0 10 20 30 40 50 60 70 80 90 100
Time
0.5
|Ret| Correlation
−0.5
0 10 20 30 40 50 60 70 80 90 100
Time
Figure 5.10: Cross correlations of returns (top) and of absolute returns (bottom)
of the two stock price series. Each point in the horizontal axis represents one month
of trading, corresponding to 20 simulation steps.
−4
x 10
5
0
Ret. Covariance
−5
−10
−15
−20
0 10 20 30 40 50 60 70 80 90 100
Time
−4
x 10
5
4
|Ret| Covariance
−1
0 10 20 30 40 50 60 70 80 90 100
Time
Figure 5.11: Covariance of returns (top) and of absolute returns (bottom) of the
stock price series. Each point in the horizontal axis represents one month of trading,
corresponding to 20 simulation steps.
Chapter 6
Conclusions
but only when chartist traders are present in the market. Then, we analysed
the dynamics of two markets, giving each trader the opportunity of choosing
the market she prefers to trade in, according to an attraction function. We
performed simulations on this market pair with no tax levied, and then taxing
one market. Firstly, we observed that, irrespective of trader composition
and tax rate, the interplay of markets leads to an increase in price volatility.
Secondly, we found that, notwithstanding the small transaction tax (typically
0.1-0.5% of transaction cost) and the simple trader models used, the tax
does actually impact heavily on market behaviour, increasing price volatility
and reducing trading volumes. This happens only with trader compositions
sensitive to the tax, namely those including chartist traders. Despite the low
tax rate, introducing the transaction tax increases price volatility, computed
for dierent time horizons, signicantly and reduces trading volumes, though
to a lesser extent. These results concur with many empirical ndings and
provide a measure, using a theoretical model, of the impact of a change in
market regulation. On the other hand, a part of the literature asserts that
speculators tend to leave the taxed markets, that thus become less volatile.
The second case study deals with the impact of margin requirements and
of short sale restrictions on stock markets. Considering the closed market,
we found that if short selling and margin trading are allowed, volatility will
tend to slightly increase. The increase in volatility is substantially unrelated
to restriction levels and to debt proneness of traders. We found that, if
short selling and margin trading are not banned, some traders could declare
bankrupt and leave the market. The number of bankrupts is usually very low
and negligible. Also, the wealth distribution of both DP T and of non−DP T
have the same trend, but for the rst ones the trend is stronger. We showed
that generally the open and the closed market have similar features, except
110
for the fact that in an open market the number of bankrupts increases.
External factors, such as sudden variations of prices and wealth, damage
DP T s much more than non − DP T s, so DP T s tend to fail more easily
than non − DP T s. In general, bankrupts favor high volatility of prices and
may lead to periods of unsteadiness, so we can assert that in this sense the
presence of in debt positions may ease unsteadiness.
Finally, we presented a model made up of two stock markets with dier-
ent currencies, and of a FOREX market enabling traders to exchange their
currencies in order to switch to the other stock market. The markets are
completely closed and self-consistent. There is no external inuences, and
the amount of cash and stocks is kept constant, but for the case of controlled
cash inow simulating an inationary crisis. Simulating a monetary shock
in one market, with a steep, substantial inow of money, yielded a gradual
adaptation to the new fundamental prices in both the aected stock market,
and in the FOREX market, and showed, at least to some extent, three of the
four stylized facts about the spreading of shocks across markets identied
by Corsetti et al. (2001): volatility of prices and covariance between stock
market returns increase during crisis periods, and returns correlation is not
necessary larger than during tranquil periods. The fourth fact, i.e. that
periods of nancial turmoil favor falls in stock prices is not observed, but in
real markets it depends on traders' risk aversion, and on the ability of real
trader to move theirs assets to other investments. This is clearly not possible
in a closed model like this one, so the absence of this behaviour is obvious.
A similar consideration applies to contagion. We shoved that simply linking
two stock markets with an exchange market does not yield an increase in
return correlation when there is a crisis in one of the markets. Again, this is
not unexpected, because in real world contagion is a consequence of strong
111
economic links between economies, and such links are simply not present in
our simple model. It needs to be said also that, while our model is able to get
insight on the intrinsic characteristics of linking two stock markets through
a FOREX market, showing that interesting behaviours arise simply from the
structural properties of the model, in reality FOREX markets are driven by
much more than stock markets' needs and by their internal traders. Much
more features have to be added to the model to reect more thoroughly how
real markets behave.
These three case studies show how the presented agent-based articial
market can be used to develop theoretical models in order to perform tests
and to validate hypotheses in economics and nance. A further extension
of the framework is in progress, and its goal is to analyse the impact of
stock option trading on the market of the underlying security. Although
the current version of the model is able to contribute to open debates which
attract public attention and arise the interest of policy makers, much more
features have to be added to the model to reect more thoroughly how real
markets behave. Among others, we may quote interest rates of bonds, stock
dividends, which could be related to the trend of the economy, also yielding
dierent fundamental values of the stock. Finally, traders' risk aversion has
to be modeled, which might aect the switching probability between markets
in the case of multi-market models. In future works, we plan to address all
these issues by extending the framework again.
Bibliography
Aliber, Z., Chowdhry, B. and Yan, S. (2003). Some evidence that a tobin tax
on foreign exchange transactions may increase volatility, European Finance
Review 7(3): 481510.
Baker, D. (2000). The case for a unilateral speculation tax in the united
state, Technical report, Center for Economic and Policy Research. Brieng
Paper.
BIBLIOGRAPHY 113
BIS (2005). Bank for international settlements: Triennial central bank sur-
vey: Foreign exchange and derivatives market activity in 2004.
Challet, D., Marsili, M. and Zhang, Y.-C. (2001). Minority games and styl-
ized facts, Physica A 299(1-2): 228233.
Challet, D. and Zhang, Y.-C. (1997). On the minority game: Analytical and
numerical studies, Physica A 256(3-4): 514532.
Chan, T. (2001). Articial markets and intelligent agents, PhD thesis, Mas-
sachusetts Intitute of Technology.
Chen, J., Hong, H. and Stein, J. C. (2002). Breadth of ownership and stock
returns, Journal of Financial Economics 66(2-3): 171205.
Cincotti, S., Focardi, S. M., Ponta, L., Raberto, M. and E.Scalas (2005).
The waiting-time distribution of trading activity in a double auction arti-
cial nancial market, in A. Namatame, T. Kaizouji and Y. Aruka (eds),
Economics and Heterogeneous Interacting Agents, Springer-Verlag, Berlin.
Cont, R. and Bouchaud, J.-P. (2000). Herd behavior and aggregate uctua-
tions in nancial markets, Macroecon Dyn 4(2): 170196.
Cont, R., Potters, M. and Bouchaud, J.-P. (1997). Scaling in stock market
data: stable laws and beyond, Science & nance (cfm) working paper
archive, Science & Finance, Capital Fund Management.
Day, R. H. and Huang, W. H. (1990). Bulls, bears and market sheep, J Econ
Behav Organ 14(3): 299329.
Ecca, S., Marchesi, M. and Setzu, A. (2006). Analysis of stock option market
in an articial nancial market. 21-23 September 2006, Urbino, Italy.
Ehrenstein, G., Westerho, F. and Stauer, D. (2005). Tobin tax and market
depth, Quantitative Finance 5(2): 213218.
Forbes, K. J. (2004). The asian u and russian virus: the international trans-
mission of crises in rm-level data, Journal of International Economics
63(1): 5992.
Friedman, M. (1953). The Case for Flexible Exchange Rates, Essays in Pos-
itive Economics, Chicago University Press, Chicago.
Haq, M. u., Kaul, I. and Grunberg, I. (eds) (1996). The Tobin Tax: Coping
with Financial Volatility, Oxford University Press, New York.
Hsieh, A., D. and Miller, M. H. (1990). Margin regulation and stock market
volatility, Journal of Finance 45(1): 329.
Johnson, N. F., Lamper, D., Jeeries, P., Hart, M. L. and Howison, S. (2001).
Application of multi-agent games to the prediction of nancial time series,
Physica A Statistical Mechanics and its Applications 299: 222227.
Kraus, A. and Rubin, A. (2003). The eect of short sale constraint removal
on volatility in the presence of heterogeneous beliefs, International Review
of Finance 4.
Largay, J. and West, R. (1973). Margin changes and stock price behavior,
Journal of Political Economy 81(2): 328339.
Liu, Y., Gopikrishnan, P., Cizeau, P., Meyer, M., Peng, C.-K. and Stanley,
H. E. (1999). The statistical properties of the volatility of price uctua-
tions, Physical Review E 60: 1390.
Ocer, R. R. (1973). The variability of the market factor of the new york
stock exchange, Journal of Business 46(3): 43453.
Palley, T. I. (1999). Speculation and tobin taxes: Why sand in the wheels
can increase economic eciency, Journal of Economics 69: 113 26.
Palley, T. I. (2003). Debating the Tobin Tax, New Rules for Global Finance
Coalition, chapter 2.
market using object oriented technology: the Genoa articial stock market,
PhD thesis, University of Genoa, Italy.