SimStockExchange
User manual
SimStockExchange is a multi-agent simulation model used to simulate trading behaviour and investigate sotck market dynamics.
Setting parameters
Screens, etc.
Before starting the model, a number of parameters have to be set. To do this, there are separate screens for separate parts of the simulation model.
In this manual the words friend and neighbour will be used. In this context one agent is the neighbour of another if they are directly connected to each other.
The random seed
The first parameter that has to be set is the random seed. By default a (pseudo)random number generator generates the seed, but the user can change this seed, for instance to run several simulations with the same, or almost the same, parameters, and ensure repeatability. The random seed will be used throughout the simulation model during the simulation run.
Stock settings
There are a number of parameters specific to the stocks in the simulation the user can set before the simulation run is started. A user can specify any number of stocks, which is done by filling in appropriate values before clicking on "Add stock". When the user has added the number o stocks desired, clicking on "Done" will close the Stock setting screen, and open the agent group screen. If no stocks have been defined by the user before clicking on "Done", one stock with the default values will be added.
- News levels
- The news levels set how much agents' expectations will fluctuate. The further the values passed to agents are from 0, the more extreme the fluctuations will be. There are two ways of setting this parameter, either as a minimum and maximum value, or as a mean and a standard deviation. If the minimum/maximum option is chosen, a value of -0.2/0.2 means that the expectations of agents will always fluctuate between -20% and +20% of the current stock value. Agents will receive news randomly selected from a uniform distribution between the minimum and maximum values. While it is possible to set both the maximum and minimum to positive values, it is recommended that the minimum should be the negative of the maximum, to ensure that the stock price doesn't immediately, and permanently, crashes or peaks. The values of both fields have to be between -1 and +1. If the option with the mean and standard deviation is chosen, the mean will be the mean expected stock price change, and the standard deviation will be used to generate normally distributed random numbers for variance.
- News frequency
- The frequency at which the news of stocks is updated. The frequency will be a random number of time steps between the minimum and maximum value. The default is 1/1, which means that news will be updated each time step. Both values have to be positive integers.
- Initial price
- The initial trading price of the stock. This must be a positive value.
Agent settings
The user can specify any number of groups of agents with certain characteristics, each group consisting of one or more agents. Again filling in the parameters and clicking "Add group" will add a group of agents with the specified parameters. If a user clicks on "Done" before specifying any groups, a group with the default values will be added.
- Confidence
- The initial confidence values. The confidence values determine to which degree agents listen to the expectations of their friends as opposed to their own expectations. A value of 0.5 means that an agent will give as much weight to its friends as to its own expectations. A value of 0 means the agent will disregard its own expectations totally, and a value of 1 means an agent will not listen to its friends at all. The confidence paramter sets the initial confidence level of each agent. There are two possibilites, either a normally distributed random number, between a minimum and maximum or a number selected from a normal distribution with a mean and a standard deviation. Whichever option is chosen, it should be noted that an agent's confidence will never go below 0 or above 1.
- Simplifying risk reduction
- Agents can choose to either base their expectations on the total expectations of their friends, or on the majority group of either buyers or sellers. The choice to listen to only the buyers or only the sellers, based on the relative sized of both groups is called simplifying behaviour. The parameters min and max determine to which degree agents should follow the simplifying strategy as opposed to the clarifying strategy (where all friends are being listened to). A value of 1 will mean the agent will only use the simplifying strategy, while a value of 0 will mean an agent will only use the clarifying strategy. Agents will receive an initial value randomly between min and max.
- Initial wealth
- The "cash" value is the initial wealth of agents, in liquid funds each agent can use to buy stocks. The "stocks" value is the amount of shares per stock agents receive at the start of a simulation run. The value should preferrably be
initial wealth/(initial stock price*number of stocks). Because of the way the model is parametrized, a different value might cause unforeseen and unwanted dynamics.
- Agents in group
- The number of agents in the group. This should be a positive integer.
Miscellaneous settings
Certain global properties of the model are placed in the right-hand bar which appears when the model has been started. These are:
- Dead agents
- Determines if "dead" agents, that is agents without sufficient funds to continue trading, should be replaced by new agents starting from scratch, or if they should remain in the network.
- Loss aversion type
- The loss aversion type determines how agents respond to possible loss. Linear loss aversion means that agents will act as strongly on expected positive outcomes as negative ones, the amount of buying and/or selling is directly proportional to the expected price change of a stock. The Kahneman/Tversky type makes agents perceive expected loss as a bigger threat, which means that agents are prone to buy less and sell more. For more information, see Kahneman, D., Tversky, A. (1992), "Advances in. prospect Theory: Cumulative representation of Uncertainty", Journal of Risk and Uncertainty vol.5 num.4.
- NetworkType
- The type of network generation used to connect agents. There are six different types to choose from:
- Lattice
- This is a simple square lattice, where agents are connected to the agents to the left, right, top, and bottom of them. Which means each agent has four connections, except agents at the edge of the lattice.
- Torus
- This is the same as the lattice, with the addition that it wraps around at the sides and the top/bottom, meaning that there are no edges as such, and every agent has four connections to other agents.
- Small world
- A small world network where agents are connected to agents close by, except for a small number of connections between "distant" agents, using the algorithm as described in D. J. Watts, S. H. Strogatz, "Collective dynamics of 'small-world' networks", Nature 393, 1998
- BarabasiAlbert
- A scale free network generated by the algorithm as described in A. Barabasi and R. Albert. Emergence of scaling in random networks. Science, 286, 509-512, 1999.
- Scale free
- The same as the previous, but a different implementation of the algorithm.
- Random
- A totally random network where agent get a random amount of connections to randomly chosen agents.
- NumTicks
- This is the number of time steps the simulation should run for. When the simulation run reaches the defined number of steps it will stop and write the final data to log files. A value of 0 means the simulation will run until manually stopped.
- ShowNetChart
- When this is enabled a visualization of the network of agent will displayed during the simulation run.
- ShowWealthHist
- When this is enabled a histogram of the distribution of the wealth of agents will displayed during the simulation run.
- ShowStockPlot
- When this is enabled a plot of stock prices will displayed during the simulation run.
- ShowConnWealthPlot
- When this is enabled a plot of the number of connections vs. the wealth of agents will displayed during the simulation run.
- ShowLinksReturnsPlot
- When this is enabled a plot of the number of connections vs. the returns of agents will displayed during the simulation run. Returns here being the difference between the current total wealth (cash + shares) and the initial wealth.
- ShowNetWealthPlot
- When this is enabled a plot of the agents wealth vs the average wealth of the agent's "friends" will displayed during the simulation run.
- ShowReturnsPlot
- When this is enabled a plot of the returns of stocks (ie. the procentual price changes) will displayed during the simulation run.
- ShowSocialnessWealthPlot
- When this is enabled a plot of the agents' wealth vs the agents' risk reduction strategy value will displayed during the simulation run.
- UpdateConfidence
- This will set if the agents' confidence levels will change based on their trading success and failures. As an example, when this options is enabled, an agent starting off with a high confidence level, and losing money, would start listening to its friends to gain more information.
- WeighFriends
- By default if agents don't weigh the expectations of their "friends", and each connected agent is weighed equally. Enabling the weighing means that the expectations of connected agents will be weighed by the wealth of said agents.
- WeighFriendsWithLinks
- By default if agents weigh the expectations of their friends they do it solely based on the wealth of the friend.
Running the model
Once all parameters have been chosen and stocks and agents have been generated, the model run can be started. This is by pressing the "Play" button on the top toolbar.
By default the stock value plot will be displayed with constantly updated stock information of the stock(s) created. The simulation will continue to run until it reaches the amount of ticks specified in NumTicks. If the value in NumTicks is 0, then the model will continue running until it is manually stopped by pressing the stop button on the main toolbar.
If the model is run offline, a number of logfiles will be created. These logfiles will be placed in a directory called Logs
in the directory where the model was started. The Logs directory will be created automatically if it does not already exist.