Simulating Asset Prices with Time-Varying Volatility
Summary
The document explores how to generate artificial asset-price paths when constant-volatility geometric Brownian motion does not fit the desired behavior. Its example modifies a GBM-style price update by drawing a separate volatility value at each time step and using a randomly varying drift. It then plots several simulated paths and computes rolling price-level dispersion relative to the local mean as a rough volatility measure.
This is an illustrative experiment rather than a validated simulation method. The document gives code but no comparison against market data, statistical diagnostics, or guidance on choosing the volatility process. The resulting update can differ materially from standard GBM, and the rolling statistic measures variation in price levels rather than return volatility. A more carefully specified stochastic-volatility process would be needed to control features such as volatility clustering and preserve realistic return behavior.
Key ideas
- A GBM-style price update can be modified by allowing volatility to change over time.
- The example draws drift and volatility randomly at each time step to create price paths.
- Rolling dispersion of price levels is not the same as measuring volatility from returns.
- The simulation is exploratory and does not establish that its generated paths resemble real assets.
Tags
Full text
# generating synthetic asset prices
# generating synthetic asset prices
I would like to use geometric brownian motion (gbm) in order to generate artificial asset prices. I know that gbm has constant volatility, therefore I somehow converted it to stochastic in a very crude way which result in something different than gbm. Other than gbm, is there any algorithm or method for such purpose?
thanks!
```
import numpy as np
import math
import matplotlib.pyplot as plt
from random import random
import pandas as pd
plt.close('all')
time = 10000
no_of_reps = 5
volatility_arr = np.zeros([no_of_reps,time+1])
for k in range(0,no_of_reps):
delta_t = 1/time
s0 = 1000
asset_prices = [s0]
gbm_np_array = []
gbm_mean = 0
gbm_std = 0
volatility = abs(np.random.normal(0.5,1,time))
for i in range(0,time):
drift = 0.1*(-1+2*random())
dw = np.random.normal(0,math.sqrt(delta_t))
ds = drift*delta_t*asset_prices[i] + volatility[i]*asset_prices[i]*dw
asset_prices.append(asset_prices[i] + ds)
gbm_np_array = np.asarray(asset_prices)
for i in range(0,len(gbm_np_array)):
gbm_mean = np.mean(gbm_np_array[i:i+50])
gbm_std = np.std(gbm_np_array[i:i+50])
volatility_arr[k,i] = (gbm_std/gbm_mean)
x = plt.plot(np.arange(0,len(asset_prices)),asset_prices)
plt.show()
```
```Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.