How does Cookie Clicker's stock market work?

Value of one dollar

$1 is one second of the highest cps you achieved in the game.

Suppose you have at most had 1,500 cookies per second. $5 would be 7,500 cookies.

Using stonks to make money

The stock market contains a number of variables fluctuating randomly. You could invest in those that have low prices in the hope that the prices increase. You can invest into stocks to increase your cookie count more rapidly than otherwise possible due to the above.

Let's say you are about to increase that 1,500 cps to 3,000 cps, doubling it. You have 200,000 cookies in the cookie jar, and this increase costs you 100,000. Let's say you spend that remaining 100,000 cookies on dollars, earning you $66 (and leaving c1,000 in the jar). You invest your $66. There are 20% brokerage fees, so you end up with $55 of stock.

If you then immediately sell your stock, that $55 is now worth c165,000. You have just made 66,000 cookies in the stock market.

Details of random fluctuation

The details of such can be found on the wiki at https://cookieclicker.fandom.com/wiki/Stock_Market#Market_Behavior.

There are six modes, slow/fast rise/fall, chaotic, and stable. Each randomly lasts between 1 and 1,000 minutes. The stocks you want to hold for a bit are typically those in slow rise mode. Fast rise is very unstable and tends to last only about 30 minutes, what with every minute having a 3% chance of flipping to fast fall.

After fast rise/fast fall ends normally, chaotic's chance is upped to 70%. Otherwise, the probabilities are:

Stable: 30%
Slow Rise/fall: 20%
Fast Rise/fall: 10%
Chaotic: 10%

Simple Strategy #1: Penny stocks

Due to this fact, our low index stonks tend to actually have a rather bleak future. Everything is centered around zero overall, so due to this little detail, stock prices tend to go down over time overall. There's a limit though, stocks will never go below $1. Instead, they jump up to around $3.50 (to be exact, half the distance to $5).

So the first advice in general to give when trying to monetize the random fluctuations of stocks is to buy when they are below $5, hold, then sell those same stocks when they move above $5, or significantly over the buy price (penny stock trading).

Simple Strategy 2: The delta-effect

The delta parameter tends to stabilize the index prices of other stocks, so the idea here (for a longer-term strategy) is to sell stocks that are above their natural price, and buy below. This natural price is given by equation (4) below.

This tends to work because over longer timescales the stocks tend towards this natural price, with delta starting out positive with every mode change below it and negative with every mode change above it.

This strategy can become even more effective when incorporating knowledge about the system detailed below. If you're sure that the mode just changed, you can compute the natural delta and essentially know that the change in value for a stock for the next few minutes has to be positive (or negative).

There's also the effect from strategy #1 to consider: the true balanced price will be somewhat lower, because there's a total of only 0.64% time spent in fast-rise and 19.36% in fast-fall mode. The excess 18.72% tends to lower the average price (see details below). The true average value ends up being a very complicated expression, likely not easily given by a closed expression but rather by running a model for the real program due to its complexity.

Trading higher valued stocks

As stocks will tend to briefly depart their meandering around the $1-$5 range with spurts upwards (which can last arbitrarily long), it might be interesting to see how to trade higher valued stocks.

For this we need a series of equations. See:

Stonk equations

Higher valued stocks are only worth buying when we know the expected rate of return is positive. That's true for Slow Rise and Fast Rise modes.

In order to figure out whether the stock is in the Slow Rise or Fast Rise mode, we need to look at the behaviour closely and see if there's contradictions with the other modes' equation for a special parameter γ. How to do this?

The stock market is geared such that stocks change every minute by a specific computed value. See equation (1).

With φ being an additional parameter only during Fast Rise/Fast Fall/Chaotic, a value between -3 and 7 in Fast Fall, and -7 and 3 in Fast Rise. It is 0 70% of the time as well. When this happens, Δ is between +/- 0.05 instead of the normal larger range. In chaotic, this chance is 50%, and the value is between -5 and 5.

For computing delta, see equation (2), With n being the index of the stock. E.g. CRL would have index of 0 (zero).

But, ρ is a hidden random value between -0.1 and +0.1, delta is controlled by the stock's current mode.

Record the current price, then record the price the next minute. Then, we know a quantity I'll note as γ (equation 3), the sum of the three randomized factors influencing the price. Here ρ is the always-present randomness of 0.1, β is the randomness for each of the modes, while φ is an extra randomness that is present on some fraction of the stock ticks for the most volatile 3 modes.

How to use this to determine the current mode? Check what the minimum and maximum values are for each mode. Equations 8 though 16.

Strategy #3: Statistics

Here's where things get a little complicated, and we actually have to deal with real-world financial models, dealing with risk, and whatnot. We would want to buy stocks that are in Fast Rise or Slow Rise mode, but it's complicated to figure out what the mode is or the probability of said mode, and the expected rate-of-return as well (which tends to depend on the time spent in the mode so far), or how long to hold. There's some simple rules to get us started with determining the current mode:

Compute the value of γ. To do this, you would have to assume whether the stock is in a stable or 'other' condition. You also need at least 3 data points (current, last minute, and minute before that). Use Euler's numerical integration method for the derivatives (it's also what happens in game, basically). Note that this doesn't compute the γ for the last tick, but the tick before that.

In some cases, Fast Rise is obvious

  • Any γ of less than -5.35 must be fast rise
  • Any γ of less than -3.84, but where the fractional part is below 0.16 or above 0.84 is fast rise or chaotic, with the former being more likely.

The converse holds for Fast Fall

Chaotic can also be instantly spotted:

  • Any |γ| of more than 1.65 with the fractional part in the ranges 0.15-0.35 or 0.65-0.85 must be chaotic.

Otherwise, you would have to construct a probabilistic model. Given that each state lasts a random amount between 1 and 1,000, there's also a base chance to swap denoted by equation 17.

This large number of states makes things a little difficult to do. We're looking at iterating over a 4K square matrix until convergence as one of the steps, for example. For now, the remainder is an exercise for the reader.