Forward Testing with Monte Carlo
We all know backtesting, but how about forward testing? This is the first of a series of tutorials where we discuss methods for simulating cryptos prices. Let's explore!
- ๐ฒ We will devote the first thread in this series to the Monte Carlo (MC) method.
- ๐ MC method is a simulation technique used to model the behavior of complex systems like crypto prices, markets, LP positions, etc.
- ๐๐ป Useful when a direct prediction is not possible.
It works by repeating three simple steps:
- Sample from a probability distribution that represents our understanding of the underlying system ๐ฒ
- Repeat this process many times ๐
- Take the average of some quantity of interest over all these simulations ๐ค
The above is meant to simulate events that are unpredictable & can only be simulated using random number generation. In the case of crypto, this could involve estimating values for asset volatility, drift, etc., and then using these values to simulate future price movements of an asset.
By repeating steps 1-3 multiple times, we can generate a large number of different scenarios for the future price of the asset. This allows us to understand the potential range of outcomes and estimate the likelihood of different price levels.
Let's consider a simple example: Suppose Alice is standing at a position x0, and that she takes one step to the right or to the left each w/ 50% chance.
Questions:
- Where do we expect Alice to be after N steps?
- How likely is it for her to get 20 steps away from x0?
We can answer this using MC!
- Simulate Alice's random path for N steps, M times (M large)
- Take the mean of her position after N steps, and the # of times she was 20 steps away from x0.
Taking M=1000, N=100 yields:
- Expected position โ 0.0
- Prob. 20 steps away = 6.8%
Monte Carlo simulations can also be used to generate Value-at-Risk (VaR) measures, which indicate the maximum potential loss that an investment in a crypto asset could experience over a given time horizon. Read more about VaR measures here ๐
1/13 How do you know if one LP position or portfolio is riskier than another?
โ Panoptic (@Panoptic_xyz) February 7, 2023
Is LPing riskier than HODLing?
This is the first of a series of threads where we discuss different types of risk, how to interpret them, and how to hedge them.
Let's dive in!
A standard model to simulate asset prices is the so-called Geometric Brownian Motion (GBM). It assumes that the rate of change of the price of an asset follows a random walk with constant volatility and a drift term representing the expected return. In math-y terms, let denote an asset with price process . Furthermore, let ฮผ denote the drift parameter of the price process and its volatility, and let denote the standard Wienner process. We say that follows a Geometric Brownian motion (GBM) if satisfies the following stochastic differential equation:
Given an initial price S0, it follows from Itoโs lemma that
An exemplary Python implementation to sample a price process S modeled as a GBM is shown below ๐ป
- mu = drift
- sigma = volatility
- T = time horizon
- N = number of steps
- S0 = price at time 0
Let's use our code to simulate the daily ETH price for the next year!
Example: ETH price
- ๐ฎ We simulate 1000 prices, 1 year into the future
- ๐ค sigma = 0.845, mu = -0.47 from historical data
- ๐ 95% VaR, yearly= -49%
- ๐ 95% CVaR, yearly = -72%
- ๐ฒ Probability of price > $3,000 at any time = 12%
Comments on the above:
- ฮผ & ฯ influenced by the time period they're estimated (e.g., negative drift due to ๐ last April)
- Useful to reassess the above with different parameter values!
- VaR and CVaR are worst-case scenarios (95% confidence) and are useful metrics to mange risks/hedge
- ฮผ & ฯ can be made stochastic, too โ more powerful model
- MC can be used to price options & estimate Greeks
- We used GBM model, which might not be suitable for pools or stablecoins
- Can we use MC to simulate these? We'll discuss in future Research Bites!
Summary:
- MC is a simulation-based approach to modeling complex systems like crypto prices.
- Provides valuable insights into potential outcomes & risk levels.
- While not perfect & can be influenced by the assumptions, it remains a very valuable tool!