Stochastic Processes - Random Walks

Stochastic Processes - Random Walks

Table of contents

According to Wikipedia, a stochastic process is defined as:

  • In probability theory, a stochastic process is a mathematical concept used to represent random quantities that vary over time, or to characterize a sequence of random (stochastic) variables that evolve as a function of another variable, generally time. Each of the random variables in the process has its own probability distribution function and may or may not be correlated with one another. Each variable or set of variables subject to random influences or effects constitutes a stochastic process.

Introduction to Stochastic Processes

After having delved into the articles on the introduction to volatility, it is time to take the next step and address stochastic processes for quantitative traders.

Examples of stochastic processes:

  • The sequence of numbers on a roulette wheel
  • The beats of a human heart
  • The next card a casino dealer will deal
  • The direction a drunk person will take.

This article explores the fundamentals of stochastic processes, revealing how they are used to model random phenomena across various fields. This information will help readers better understand this topic.

Let's imagine we are betting on which direction a drunk person will take at the next intersection.

Stochastic Processes and a Drunk Person?

That is an excellent question. If it weren’t so, we could find some form of reasoning that would make his movement more predictable. However, in this case, we are faced with the personification of randomness, the fruit of liquor and other spirits.

It is impossible to predict his noble trajectory, and the same occurs in financial markets. They cannot be predicted, nor can the causes of this impossibility be deduced (according to the laws of understanding of Hayek), but it is assumed that they are the sum of three factors:

  • New information: can provide market participants with a broader perspective of the situation they are in, since it can complement the information that, at the time of valuation, was incomplete. This generates greater volatility in the market, driven by participants who try to exploit this information to execute trades. The long-term trend is what upholds the most solid principles. This can have a significant impact on the portfolio, affecting the valuation of assets and the price.
  • Information asymmetry: implies that participants never have all the available information, except in what we might call illegal cases. This means that, as new information is obtained, previous decisions are revised and new objectives are set.
  • The idea of the low-probability, high-impact event: can change the situation in an unexpected way; it was masterfully described by Nassim Taleb through the metaphor of the turkey and Thanksgiving. This analogy reminds us that, when information becomes asymmetric, the situation can shift from calm to temporary chaos.

What Is a Stochastic Process?

We can define a stochastic process as the result of an action that presents, at least, one totally random and unpredictable variable.

Stochastic processes represent a human attempt to mathematize totally random phenomena, or those of a complex order that cannot be understood. They are a tool for estimating the impact of a variable or multiple random variables within a specific model. Below, we can classify some examples as stochastic processes.

Example

  • The payout of a sports bet is the amount of money we would win if we guessed correctly and the amount we would lose in the event of a defeat. It is important to note that the outcome of the sporting event is unknown until it occurs. In this context, the results of sporting events can be considered stochastic processes.
  • The next lottery number does not take into account previous draws and its outcome is determined solely by chance. Therefore, we can consider lottery draws to be stochastic processes.

What Is Brownian Motion?

Within stochastic processes, in a discrete-time environment where all events are independent, and in the context of quantitative trading—where it is considered a fundamental factor in the current valuation of the asset—it is held that in the short term markets are random because they are stochastic processes. This is because millions of participants adjust their portfolios through arbitrary decisions, generating noise and a lack of comprehensible order. Nevertheless, in the long term, valuations tend to balance out between the sensible ones and the asset’s price, producing the pendulum effect.

Particles follow Brownian motion.

Brownian motion is a dynamic system that follows Markov’s law, which states that future outcomes are not influenced by past outcomes. It is worth noting that in the computation of the stochastic process, past outcomes do play an important role.

Defining generalized Brownian motion as: the randomness that short-term prices imply plus the sum of their biases, it is assumed that the variation from T to T+1 has two essential components:

Formula

$$ dX_t=μX_t * dt + σX_t * dZ_t $$

And speaking in plain language, Brownian Motion = variance, the diffusion component + mean, the deterministic component

Random walk simulation
Stochastic process simulation: random walk with drift

$$W_t \sim \mathcal{N}(0, t), \quad \mathbb{E}[W_t] = 0, \quad \text{Var}[W_t] = t$$

$$S_t = S_0 \exp\left(\left(\mu - \frac{\sigma^2}{2}\right)t + \sigma W_t\right)$$

Example

  • The price of an avocado in 3 months will start from the current price, and supply and demand will adjust based on the information available at the time of evaluation. Due to the impossibility of foreseeing future information, it is difficult to estimate the future price with certainty today.
  • The S&P 500 quote: Tomorrow’s price is an absolute mystery; any event can alter participants’ valuations, creating volatility.

Random Walks and Stochastic Processes in the Real World

In 1973, professor Burton Gordon Malkiel published his unintentional philosophical treatise “A Random Walk Down Wall Street,” which exposed the embarrassments of the industry and upheld the theory that markets are random. To prove his theory, Burton had a primate do “stock picking” for 14 years and found that it achieved returns that outperformed 85% of funds and the “top US managers” of that time.

This book should be read by anyone who wishes to break their mental schemas and better understand the world of finance. No one is exempt from making mistakes, not even the renowned Warren Buffett and his partner, who are not exempt from strange trades in Asian assets. Even so, even the most deficient technical analysis can generate profits.

This is because finance is not based on an exact science, but on stochastic processes, asymmetric information, and other factors. Investment style is not synonymous with profitability, although there are many investors who have achieved positive results with their analyses, just like gamblers who win in casinos by choosing red or black, or in the lottery.


Returns are strongly influenced by luck, so the only way to achieve a positive mathematical expectation is to trade consistently with a positive mathematical expectation. There is no other fundamental key. The more samples we have, the better, since, although the distribution of financial asset returns does not follow a normal distribution due to its tails, increasing the sample reduces the variance. This allows us to gain a better understanding of the possible outcomes and reduce the associated uncertainty.

Therefore, if our trades have a positive mathematical expectation and we can remain consistent over time, overcoming any losing streak, we will be able to be profitable in the long run. An example that illustrates the randomness of markets is the case of the mouse Mr. Goxx, whose setup allowed its owners to choose the asset and the direction of the trades…

Lavanguardia mr goxx

Stochastic Processes in Python

To provide a better understanding of the concepts we have been discussing, we will illustrate some practical examples of stochastic processes using Python.

Example 1

In this first example, we will demonstrate how increasing the sample size tends to reduce the variance. In cases where the samples are minimal, the results are completely random. However, as we increase the number of repetitions of the experiment, we can observe how the distribution tends to normalize.

To explore stochastic processes, we generate Brownian sequences with the default parameters over a period of 2000 days, and repeat them 5, 10, 20, and 500 times. The “days” variable refers to the length of the movement and, in a financial context, represents a time unit used in the analysis.

import pandas as pd
from aleatory.processes import BrownianMotion 
casos = [5,50,200,5000]
for d in casos:
    brownian = BrownianMotion()
    a = brownian.draw(n=2000, N=d, marginal=True, envelope=True)
    a = brownian.draw(n=2000, N=d, marginal=False, envelope=True)

Namely:

It is important not to misinterpret that as the sample grows, greater certainty in the models and greater predictability of a portfolio's variations are obtained. This idea is completely mistaken, since past returns do not guarantee future returns. The future is uncertain and yet to be built. Any unexpected event can have unforeseen consequences. There are events known as black swans, where occurrences with extremely low probabilities have an impact that can change the world we live in. These events invalidate the models, since it is impossible to predict the impact of each of them or to make a precise attribution of an event's impact on the market. We can only make conjectures based on fundamentals.

Stochastic processes are the result of changes in the interests and objectives of investors in the market, which can lead to overreactions to newly disclosed information.

Markets are places where information plays a fundamental role, and they often present information asymmetries. Regulation in the United States condemns and prosecutes those who trade in the market using non-public information, even their relatives and close associates. The way markets work is based on the assimilation of new information in a particular manner.

In the markets, a situation arises in which new information that was not previously known is revealed, regardless of how it occurs. What matters is that this information emerges after we have made our first investment decision, when we were completely unaware of its existence. Once the information becomes public, the market assimilates it, which often triggers an overreaction.

The overreaction occurs due to the lack of new information to facilitate decision-making regarding the portfolio based on the newly published information. Over time, market operators can improve their valuation methods and estimate or discount the impact of the news on the price. It is important to keep in mind that the term “discounting” refers to the information being considered already reflected in the price, whether by adding to or reducing its value.

This process repeats constantly in the market, in the minds of its participants, generating volatility and uncertainty continuously. The commonly used phrase that “past returns do not guarantee future returns” reflects that what happened at a given moment, based on the objectives and interests of market participants, will not necessarily be repeated in the moment immediately following your purchase. This makes it clear that there are no perfect methods of valuation or prediction, unless the future is known in advance, which is physically impossible at the present time.

Example 2

On this occasion, we will examine the effects of volatility on stochastic processes. Using Brownian motion, we will be able to observe how volatility affects returns.

Let's generate different volatility scenarios:

  • Abnormally low (0.05)
  • Low volatility (0.5)
  • High volatility (2)

The “days” variable refers to the duration of the movement, since in the financial field it is necessary to use a time unit, and in this case we use days. The goal is to observe the effect of volatility as a function of changes in the period and the volatility. The period refers to the number of repetitions of the loop that is performed.

from aleatory.processes import GBM
dias = [50,1000] 
volatility = [0.05,0.5,2]
for d in dias:
    for vol in volatility:
        print('Volatilidad :',vol)
        print('Period :', d)
        brownian = GBM(drift=1.0, volatility=vol, initial=1.0, T=1.0, rng=None)
        a = brownian.draw(n=500, N=d, marginal=True, envelope=True)

Where GBM is:

  • Volatility : 0.5
  • Period : 50
  • Volatility : 2
  • Period : 50
  • Volatility : 0.5
  • Period : 1000
  • Volatility : 0.05
  • Period : 1000
  • Volatility : 2
  • Period : 1000

As a curious fact, in the last case, with high volatility (2) and a period of 1000, we can observe the presence of extraordinarily abnormal values (represented by the red and yellow lines). Some might attribute this to the “miracle” of Bitcoin or other false narratives. However, the reality is that these values are simply the product of chance, and there is no clear explanation for this phenomenon, beyond…

  • The paths of reality are complex and cannot always be easily understood or simplified with magical explanations.
  • It is important to consider block value, energy value, and computational value in a more precise and objective way, rather than resorting to poorly grounded simplifications.
  • Within the realm of current knowledge, it is important to recognize that there are limits to our understanding and that some things may be incomprehensible at this moment, but that does not mean they will be impossible to understand in the future as the scientific method advances.
  • It is essential to be aware of the biases and narrative fallacies that can distort our perception of events. We must not fall into simplistic and absurd explanations, such as claiming that the rise in the price of Dogecoin is due to Musk buying 1% of BTC to sell coffees on Mars.

With all these examples, my goal is to demonstrate the random or chance component that underlies any financial operation, to a greater or lesser degree, as well as the impossibility of predicting with certainty phenomena and their consequences.

Philosophical Foundations of Stochastic Processes

According to Hayek's theory of worlds, an order can understand and explain orders that are simpler or less complex than itself. However, it could never explain its own order or orders more complex than itself.

Tomas Bradanovic: Hayek's Pyramid

For example, chemistry studies a simpler order, such as physics (the exposure of elements to physical changes), and biology or medicine use chemistry or physics to reach conclusions.

As we ascend the pyramid of knowledge, the greater the complexity of understanding it. Hayek's theory is validated in our day-to-day lives, where it is IMPOSSIBLE to predict, with the same precision as in sciences of a lower order such as physics or chemistry, a higher order such as the human mind and the actions of people seeking to satisfy their needs.

Trying to understand the human mind from our own mind is impossible. While in a chemical study results can be predicted with unimaginable precision, a psychological study delves into a world of random variables. It is an order that, given our capacity for understanding, is impossible to grasp.

Furthermore, according to Gödel's incompleteness theorem, no axiomatic system can prove itself; it can only be proven by an axiomatic system of which the aforementioned first system is a subset.

Markets are the result of human action, where people make decisions that favor their own interests over time. As a result, they generate an order that is at a level equal to or higher than our understanding. We must not only understand ourselves—which is impossible—but also understand the whole of the markets and their diversity of interests. We are not designed to grasp the philosophical complexities of the universe, but to survive in a hostile environment such as nature.

Random processes are a way of attempting to mathematize a level of understanding that we cannot reach with the human mind. They serve us as a “testing ground” to seek strategies against the market or to verify the robustness of our models.

Stochastic Processes Summary

Buying beachfront property does not always have a positive mathematical expectation.

This article aims to influence, through the examples presented, the adoption of a stochastic mindset. A mindset prepared to understand stochastic processes and to avoid the inclusion of emotions in the value chain of the investment process. The aim is to relegate the results obtained to mere anecdotes within a stochastic process, where the true value lies in continuously increasing the sample. Short-term results are irrelevant as long as a positive mathematical expectation is maintained. Proper risk management and the elimination of factors that can sabotage the operation, such as spreads in brokers, are some of the important keys.

Resources – Relevant readings:

In this article, UnEspeculador.com offers a framework to model the market from an empirical point of view, with fundamental logic and solid factors.

Recommended Videos on stochastic processes:

  • Burton Malkiel talking about random walks
  • Burton Malkiel talking about his current point of view
  • Summary of A Random Walk Down Wall Street
  • Video on the pendulum theory
  • 3D visualization of random walks
  • Video on the hamster trader
  • Taleb vs correlation
  • Taleb against metrics
  • Taleb for Christians: why correlation is biased
  • Huerta De Soto – Theory of Worlds 1 and 2
  • Huerta De Soto – Theory of Worlds 3

Jesús Cuesta

Odesa (Ucrania)
Inversor desde 2014. Research desde 2017. He trabajado en diferentes gestoras de capital y Hedgefunds Crypto. Apasionado del codigo, los datos y las finanzas. Actualmente localizado en Ucrania.