Luca Allera Giuseppe Reale

Computer Science and Simulation for Economics

Project work on

"A macroeconomic vision of etf prices."


The applet requires Java 1.4.1 or higher. It will not run on Windows 95 or Mac OS 8 or 9. Mac users must have OS X 10.2.6 or higher and use a browser that supports Java 1.4. (Safari works, IE does not. Mac OS X comes with Safari. Open Safari and set it as your default web browser under Safari/Preferences/General.) On other operating systems, you may obtain the latest Java plugin from Sun's Java site.

powered by NetLogo

view/download model file: a_macroeconomic_vision_of_etf_price.nlogo


The model represents an ETF's price based on a stock index with two kind of investors: institutional investors and private investors. Trading between buyers and sellers are simulated by observing single supply and demand functions and then aggregating them.
Therefore, the interaction take place through aggregated equations. The model computes equilibrium price and quantity at every step.


- initial price of asset is generated randomly;
- macroeconomic variables change their value during the time;
- macroeconomic variables influence the etf price and the investors decisions;
- private investors decide to buy or sell looking at the market news if they are strongly, otherwise they decide by personal informations;
- institutional investors buy or sell ETF analysing the macroeconomic situation;
- private investors can't be indebted, otherwise they step out of market;
- investors can do no actions if they consider it convenient.

Macroeconomic variables are endogenouses to the model: they evolve during the time randomly.
Every turtles have an individual linear demand and supply function. Agents set demand (supply) price, adding (detratting) a random number between 0 and 0.25 to market price. Then, the equilibrium quantity is calculated by linear functions generating according to the equation:
y = a - bx (demand function)
y = c + dx (supply function)

y is the quantity
x is the price

In detail, single demand (supply) function is defined by values a, b (c, d), representing intercept and slope of the straight line. These values are generated in this way:

a = fixed value of 80, plus the sum of the three variations since the beginning until the actual tick that macro variables have had weighted randomly.
(To be more precisely, for the ETF price is good a growth of gdp and a fall of interest rate and oil price).
b = (-5 - random-float 10)

c = fixed value of -70, minus the sum of the three variations since the beginning until the actual tick that macro variables have had weighted randomly.
(Now the effect on ETF price is opposite than the effect on parameter a).
d = (15 - random-float 10)

To aggregate the functions, the auctioneer procedure, given two prices (in the model 5 and 15), sums single quantities to obtain two points of the aggregate demand and supply. The curve is obtained by interpolation of these points. Setting aggregate demand equal to aggregate supply, we obtain equilibrium price and quantity.


Before SETUP, it's possible to modify any parameter with the appropriate sliders and switch and to insert values in input cells:

-Number_investors: number of initial institutional investors (between 1 and 50)
-Number_private_investors: number of initial random investors (between 500 and 10000)
-Manual-weights? if 'on' user can insert the values which he prefers; if 'off' the model will use default weights for the effect genrated by macro variables on ETF price
-Weight_GDP: sensibility of the price to GDP value
-Weight_interest: sensibility of the price to interest value
-Weight_oil: sensibility of the price to oil price
-Market-news_effect: choose if private investors look at market news to take decisions
-Zoom: user can decide how many tick the plots show

After setting parameters and number of agents, the button SETUP can be pushed. In this way turtles are created and the initial price is fixed randomly. All inputs can be changed while the simulation is running, except the sliders of initial number of investors.

The GO button will start the simulation. If user wants to notice what happen at every step of the period, he can use the button STEP ONCE instead of GO.
At each step in interface are plotted:
-equilibrium price and quantity,maximum and minimum price registered until that moment;
-actions of investors: in blue buyers, in red sellers, in yellow inactives;
-the percentuals of buyers, sellers or inactives investors;
-the number of private investors survivor;
-the evolution of macroeconomic variables values during the time;
-variations of the macroeconomic variables.

Moreover, user can decide (by means of switch "Manual-weights?") to use default values with regard to the effect that each macroeconomic variables generates on the ETF price or insert the values which he prefers (note that if this values are kept to zero, price will be extremely stable).
If ETF's price goes to zero or there aren't sufficientes investors to preserve the exchange continuation, the simulation is stopped.


The model can be improved using agents with non-linear demand and supply function and putting into other kind of investors with rational behaviour or more assets traded. Could be use also intelligent adaptive agents or macroeconomic variables which evolve during the time with correlation.


The model is developed on the model "Simple stock exchange" of Claudio La Torre, available on: