Stochastic Data¶
Generating Price Data using Stocastic Processes
Geometric Brownian Motion (GBM)
Fractional Brownian Motion (FBM)
Heston Stochastic Volatility Model
Cox Ingersoll Ross (CIR)
Ornstein Uhlebneck stochastic process
Model Parameters
The model parameters class contains all of the parameters used by the following stochastic processes. The parameters have been prefixed with the name of the stochastic process they are used in. Calibration of the stochastic processes would involve looking for the parameter values which best fit some historical data.
all_s0This is the starting asset valueall_timeThis is the amount of time to simulate forall_deltaThis is the delta, the rate of time e.g. 1/252 = daily, 1/12 = monthlyall_sigmaThis is the volatility of the stochastic processesgbm_muThis is the annual drift factor for geometric brownian motionjumps_lamdaThis is the probability of a jump happening at each point in timejumps_sigmaThis is the volatility of the jump sizejumps_muThis is the average jump sizecir_aThis is the rate of mean reversion for Cox Ingersoll Rosscir_muThis is the long run average interest rate for Cox Ingersoll Rossall_r0This is the starting interest rate valuecir_rhoThis is the correlation between the wiener processes of the Heston modelou_aThis is the rate of mean reversion for Ornstein Uhlenbeckou_muThis is the long run average interest rate for Ornstein Uhlenbecksheston_aThis is the rate of mean reversion for volatility in the Heston modelheston_muThis is the long run average volatility for the Heston modelheston_vol0This is the starting volatility value for the Heston model
import random
import tensortrade.stochastic as sp
%matplotlib inline
Geometric Brownian Motion
data = sp.gbm(
base_price=100,
base_volume=5,
start_date="2010-01-01",
times_to_generate=1000,
time_frame='1H'
)
data.close.plot()

Heston Stochastic Volatility Model
data = sp.heston(
base_price=100,
base_volume=5,
start_date="2010-01-01",
times_to_generate=1000,
time_frame='1H'
)
data.close.plot()

Fractional Brownian Motion
data = sp.fbm(
base_price=100,
base_volume=5,
start_date="2010-01-01",
times_to_generate=1000,
time_frame='1H'
)
data.close.plot()

Cox Ingersoll Ross (CIR)
data = sp.cox(
base_price=100,
base_volume=5,
start_date="2010-01-01",
times_to_generate=1000,
time_frame='1H'
)
data.close.plot()

Ornstein Uhlenbeck Process
data = sp.ornstein(
base_price=100,
base_volume=5,
start_date="2010-01-01",
times_to_generate=1000,
time_frame='1H'
)
data.close.plot()
