Skip to main content

Price Modeling

Geometric Brownian Motion

The current price simulation module uses asset-correlated Geometric Brownian motion (GBM) as the foundation to simulate price trajectories. The standard formula for GBM at a given time step is as follows:

s + (mu * s * dt) + (sigma * s * sqrt(dt) * e)

Here, s is the price at the previous step, mu is the mean of the returns over the historical data (drift), dt is 1/number_of_steps_forward, sigma is the standard deviation of the returns over the historical data (volatility), and e is sample from the normal distribution.

Asset Correlation

The above generates a GBM price trajectory for a single asset, but there is a need to take into account multiple assets and how they correlate with each other over time.

This can be achieved by taking the Pearson correlation coefficient of prices over the historical data (e.g., the past 30 days) and using Cholesky factorization with the correlation matrix to generate the lower triangular covariance matrix. The dot product of this matrix and a matrix of random samples from the normal distribution produces are set of initial prices. Then, at each time step, this initial asset-correlated random multiplier serves as the basis for e.

Brownian Bridge

To support market drift, in which the user may control the general direction of the overall market, a Brownian bridge model is used.

Code

The drift_schedule parameter is a map. The key in the map is the step in the simulation at which the drift value should be updated. The value in the map is a Numpy array of the drift values per asset.

The jump_params optional parameter to the function accepts a tuple of parameters for the Merton Jump diffusion model: jump_lambda, jump_mu, and jump_sigma. If jump_params is not None, the function computes the number of jumps and jump sizes using Poisson and normal distributions, respectively.

The function then simulates prices for multiple correlated assets, considering both the Brownian motion and jump components. The historical and simulated prices are plotted for each asset to visualize the market scenario under the Merton Jump diffusion model, including potential black swan market crashes.

Drift Modes

The construction of the market_drift_mode parameter is determined by the market drift shape for each asset. The following modes are supported:

  • linear: The default market drift mode if none is specified. A constant drift factor that produces a linear growth rate. f(t)=a
  • parabolic: Modulate the drift value based on the progression of time, not the absolute time value. f(t)=a*(2t/T−1)^2, where T is the total time and this will have its max value at t=T/2 and min values at t=0 and t=T.
  • cone: Similar to parabolic but linear. f(t)=a*|2t/T−1|
  • sinusoidal: Modulate the drift periodically over time. f(t)=a*sin(2πt/T+c)
  • ranging: Indicates that the price should move up and down over the course of the simulation. If market_drift is undefined (ergo, set to None), then this will invoke the Ornstein-Uhlenbeck process to revert to the historical mean over the course of the simulation. If market_drift is defined, then this is the same behavior as selecting sinusoidal. Note that the reason for not having sinusoidal be the term for invoking the OU process for cases where market_drift is undefined is because sinusoidal explicitly means oscillating up and down but trending in a particular direction, while ranging means ultimately reverting to the historical mean, which is a market shape that can take many forms beyond just price oscillation.

Simulating Volatility

GBM uses a constant sigma derived from the standard deviation of historical returns to represent volatility. However, volatility may have a seasonal component or change over time. It would be ideal to capture this variance in volatility in addition to correlating each asset in the price simulation.

  • EWMA, or exponentially weighted moving average, is a method simulating volatility. It is adaptive to changing market conditions (EWMA assigns higher weights to recent observations and progressively reduces the influence of older observations, allowing the model to quickly react to changes in market conditions), offers efficient memory usage (only requires maintaining the most recent volatility estimate and a decay factor), provides smooth volatility estimates (EWMA tends to produce smoother volatility estimates compared to methods that rely on simple historical standard deviation calculations and this smoothing effect can be beneficial when analyzing volatility patterns and trends as it helps reduce the impact of noise and short-term fluctuations in the data), and is widely used in practice (EWMA has been widely adopted in finance and risk management applications due to its simplicity, computational efficiency, and satisfactory performance in capturing volatility dynamics, and it is commonly used in areas such as option pricing, risk management, and portfolio optimization). However, EWMA does assume that volatility follows a random walk process and may not capture all complex dynamics present in financial markets, such as long-term memory effects or sudden regime shifts, and therefore is not as suited to dealing with more complex and nuanced volatility patterns as compared to GARCH. In practice, this method is preferred for price simulations over a longer time horizon due to its balance of computational efficiency and accuracy in practice.
  • GARCH, or generalized autoregressive conditional heteroskedasticity models time series and can forecast or simulate variance based on its estimated parameters. Two variants of GARCH have been implemented in the price simulator to model volatility for each asset: ARMA-GARCH and CCC-GARCH.
  • ARMA-GARCH incorporates ARMA, or autoregressive–moving-average model, to model the conditional mean and GARCH to model the conditional volatility. Each asset is modeled and then simulated for the number of steps in the simulation. Each time step's simulated volatility serves as the input for the volatility factor in the next GBM price.
  • CCC-GARCH, or constant conditional correlation GARCH, comprises multiple univariate GARCH processes related to one another with a constant conditional correlation matrix. This covariance matrix is calculated and a Cholesky factorization derives the volatility to be used at each time step in the GBM model.

Note that, if the GARCH model fails to fit (defined here as the maximum simulated volatility exceeding the maximum historical volatility by a factor of more than ten times), then EWMA will be used as a fallback. This is to prevent simulating prices on a poorly-fit GARCH model.