## "Simple stock exchange."

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.

created with NetLogo

## WHAT IS IT?

This model represents a simple stock exchange with only one asset traded and two kind of investors: institutional investors and random 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.

## HOW IT WORKS

Hypothesis:
- initial price of asset is generated randomly;
- the random investors decide on buy or sell with the same probability;
- the institutional investors buy or sell the share based on market news;
- the agents can't be indebted: if they run out money and assets, they step out of market.
Every turtles (agents) have a single linear demand and supply function. Agents set demand (supply) price, detracting (adding) a random number between 0 and 1. Then, the quantity is calculated by linear functions generating according to the equation:
y = a - bx : demand function
y = -c + dx : supply function
where
y is the quantity
x is the price
and the coefficients a, b, c and d are random.
In detail, single demand (supply) function is defined choosing values a, b (c, d), representing intercept and slope of the straight line. These values are generated through uniformly distributed shocks in the parameters:
a = (constant1 + ((random-normal 0 1) * w )
b = (-10 + ((random-normal 0 1) * k )
for demand function, and
c = (constant2 + ((random-normal 0 1) * z)
d = (10 + ((random-normal 0 1) * j)
for supply function.
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.

## HOW TO USE IT

Before to push SETUP, it is possible to modify any parameter with the appropriate sliders or to insert values in input cells:
number-investors: number of institutional investor
number-random-investors: number of random investor
constant1: constant of demand function intercept
constant2: constant supply function intercept
w: to increase range of variation in single demand intercept
k: to increase range of variation in single demand slope
z: to increase range of variation in single supply intercept
j: to increase range of variation in single supply slope
All inputs can be changed while the simulation is running, except the sliders.
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.
The GO button will be started the simulation. Equilibrium price and quantity, weighted average demand/supply price and number of buyers/sellers are plotted at every step.

## THINGS TO NOTICE

If user wants to notice what happen at every step of the period, he can click the button STEP ONCE instead of GO (recommended).
Moreover, modifying parameters which influence intercepts, the equilibrium price and quantity have an increase in volatility, and a major increment in quantity is noticed.
If these parameters have been kept high, price will be changeable.

## THINGS TO TRY

During the simulation, the variation of parameters constant1 and constant2 could be interpreted as a "shock" in aggregated demand and aggregated supply, which modify the equilibrium price. Increasing constant2, the main component for single supply functions, the function of aggregated supply is shifted up generating a decerease in the equilibrium price and an increase in equilibrium quantity. In the same way, the aggregated demand function is shifted up increasing constant1, generating an increase in equilibrium price and equilibrium quantity.

## EXTENDING THE MODEL

This 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.

## CREDITS AND REFERENCES

Corso, Ferrauto, Corgiat Mecio, Aggregate demand and supply, available on http://web.econ.unito.it/terna/tesine/aggregate_demand_and_supply.htm
This model was created as a project work for the course of "Computer Science, Simulation and Economics" (2007-2008) held by Professor Pietro Terna, at the Faculty of Economics, University of Turin.