KE Forums KE product support community

Working with CMM (Cellular Market Model)

Discussions relating to the open source Java application CMM (Cellular Market Model)

by Kaleb » Tue May 06, 2014 2:01 pm

Cellular Market Model:

The Cellular Market Model is a cellular automata based on the concept of majority rules. CMM is designed to simulate commodity markets by assuming that most traders do not trade based on economic logic, but instead buy and sell commodities based on what their neighbors are buying and selling.

Cellular Automata:

A cellular automaton (CA) is a type of discrete model that is used in math, physics and lots of other applications. A CA simply bases its state on the state of its neighbors at each time step. The CA lattice consists of a grid of cells that has a finite number of states. There can be two states, like a binary system, or hundreds of thousands of states depending on the model. A cell updates its state at each time step based on some update rule that consists of getting information from its neighbors and then doing a calculation with that information to determine the new state.

Majority Rules:

Majority rules works like this. Suppose each cells has N neighbors with ni opinions. The probability of choosing an opinion is Pi =ni/N. For example, if you had two competing opinions, a threshold would occur at 50% of the population. If any state gained more than 50% of the population, the other state would have less than 50% of the population. The state with the majority would win, thus majority rules.

Try it out!

Create your own democratic commodities market! Get the KE forked version of David Bahr's Cellular Automaton Explorer ( and load up the Cellular Market Model. Now you can create your own awesome looking capitalist simulations with your very own winners and losers! Make investors skittish or content with social temperature, or give certain states a PR boost with social force! Use simulated annealing and noise to help create stable markets! Influence celebrity cells to do your bidding!

Financial Stylized Facts:

What you should find in a good model:

There are a number of stylized facts found in the time series of financial assets that have been discovered through statistical properties. These stylized facts appear in all forms of financial assets and are common in most.

These stylized facts are what you are looking for in financial models. In some models they all exist, in other models none of the stylized facts exist. Clearly, the better the model can replicate the stylized facts found in the real world, the better the model is.

Excess volatility:

Many empirical studies point out to the fact that it is difficult to justify the observed level of variability in asset returns by variations in “fundamental” economic variables. In particular, the occurrence of large (negative or positive) returns is not always explainable by the arrival of new information on the market.

Heavy tails:

The (unconditional) distribution of returns displays a heavy tail with positive excess kurtosis. A Gaussian distribution is used to describe how random variables tend to cluster around a single mean value. A Gaussian distribution is generally defined as a kurtosis (k): k = 3. A kurtosis (k): k > 3 indicates a leptokurtic distribution with a sharp peak and heavy tails. My NYSE data from 1993 to 2011 indicated an average kurtosis of around 32. Other data sets indicated a kurtosis of around 38 from the 1950’s to the 2000’s. This indicates “heavy tails” or “fat tails”, which are usually associated with more risk in financial markets. The heavy tail is more consistent with a Lorentz Distribution as they are not seen in Gaussian distributions. The heavy tails observed in these distributions correspond to large fluctuations in prices, ”bursts” of volatility which are difficult to explain only in terms of variations in fundamental economic variables.

Absence of autocorrelations in returns:

(Linear) autocorrelations of asset returns are often insignificant, except for very small intraday time scales (t > 20 minutes) where microstructure effects come into play.

Volatility clustering:

As noted by Mandelbrot, “large changes tend to be followed by large changes, of either sign, and small changes tend to be followed by small changes.” A quantitative manifestation of this fact is that, while returns themselves are uncorrelated, absolute returns |rt| or their squares display a positive, significant and slowly decaying autocorrelation function: corr(|rt|, |rt+τ |) > 0 for τ ranging from a few minutes to a several weeks.

Volume/volatility correlation:

Trading volume is positively correlated with market volatility. Moreover, trading volume and volatility show the same type of “long memory” behavior.

Majority Rules:
Majority Rules is based on the principle that people tend to formulate opinions and take actions that emulate the majority of their neighbors. A lattice can be used to define the type of social network that makes up the cells neighborhood.

Majority Rules is a stochastic model and relies on probabilities to create phase transitions in the dominant states. These phase transitions are what cause the unpredictable, and sometimes large, state fluctuations seen in the models.

I need to know more!

The best introduction to the Cellular Market Model is David Bahr's lecture notes on Social CA. The notes cover the details of majority rules and the effects of temperature, social force and power-law neighborhood connectivity. You can find it here

The Rule:

Majority rules works like this. Suppose each cells has N neighbors with ni opinions. The probability of choosing an opinion is Pi =ni/N. For example, if you had two competing opinions, a threshold would occur at 50% of the population. If any state gained more than 50% of the population, the other state would have less than 50% of the population. The state with the majority would win, thus majority rules. External variables can be used to modify the phase transition points of majority rules.

Social Force:

Social Force reflects external factors that could change how a cell behaves. Political advertisements, public awareness advertisements, news, commercials, and anything else that might change how someone behaves can be likened to Social Force. More technically, Social Force can be used to shift the phase transition points on the X-axis. This simply takes probability from one state and, effectively, adds it to another.

For example, if you again assume two competing opinions, and you make opinion #1 20% more likely than opinion #2 with social force, then you have shifted the transition points on the x-axis. Before social force was introduced, there was a phase transition at 50% of the population. After the social force was applied, opinion #1 only needs 30% of the population to create a phase transition while opinion #2 needs 70% of the population to create a phase transition in its favor.

Social Temperature:

Social Temperature is a measure of how volatile a crowd is. Angry people are very quick to act, while content people have more important things to do, and are slower to act. Technically, Social Temperature can be added to make the phase transitions less steep, effectively slowing the rate at which cells decide to change. This is done by increasing a new variable, T, into the probability function.

With social temperature, the function now looks like Pi = (ni/N) ^(1/T). When T = 1, the exponent is one and the function is just itself, majority rules. As T → ∞ the exponent approaches 0 and the probability space becomes very small. This increases the probability that a cell will change its mind and represent angry cells. As T → 0, the exponent gets very large, and the probability space becomes enormous. So large, that the probability that the cell will change its mind becomes almost nothing. These are content cells.

Market Model:

A modification of majority rules might be able to simulate some of the stylized facts of market volatility. Majority Rules can have many different assets available to traders at any time. We assume that each cell on the lattice is a trader. It is fair to assume that if a cell is not trading, it is not part of the model.

For simplification, we also assume that the trader must hold one, and only one asset at all times. The cells have choices in that cells can chose to buy, sell, or trade an asset at each time step. However, the decision to buy, sell, or trade depends on majority rules, and a sell is always immediately followed by a buy. Each cell has the choice to sell one asset and purchase another at each time step, although the cells neighborhood remains unchanged.


Since Majority Rules can have cells who trade in multiple assets, the total transaction quantity is found for each asset. Since each cell can only hold one asset at a time, and cannot trade in volume, the total transaction quantify is simply the number of cells currently holding the asset minus the number of cells who held the asset at the previous generation. If demand went up, there will be more cells holding the asset at the current generation and the price will increase. If demand went down, there will be fewer cells holding the asset at the current generation and the price will decrease.

The Pricing Rule:

pricei+1 = pricei + (C * (numberOfCellsi – numberOfCellsi-1))

C is some scalar constant 0 < c < 1 that is used to reflect how sensitive investors are to changes in the number of people holding the asset.

Code: Select all
// Long term derivative version
for (int i = 0; i < currentQuantity.length; i++)
        // finds the change (derivative) in the number of each asset
        transactionQuantity[i] = currentQuantity[i]
                        - previousQuantity[i];
        // multiply by a scaler that reflects how much the
        // price reacts to a change in the derivative of the asset
        currentValue[i] = currentValue[i] + C
                        * ((transactionQuantity[i]));
        // deal with negative values
        if (currentValue[i] < 0)
                currentValue[i] = 0;
Site Admin
Posts: 11
Joined: Tue Apr 01, 2014 2:26 pm

by ruthgibby » Fri Sep 29, 2017 5:17 am

its very helpfull to read all the information..
Posts: 1
Joined: Fri Sep 29, 2017 5:05 am

Return to CMM (Cellular Market Model)