tensortrade.stochastic.processes.heston module

tensortrade.stochastic.processes.heston.cox_ingersoll_ross_heston(params: tensortrade.stochastic.utils.parameters.ModelParameters) → numpy.array[source]

Constructs the rate levels of a mean-reverting cox ingersoll ross process.

Used to model interest rates as well as stochastic volatility in the Heston model. The returns between the underlying and the stochastic volatility should be correlated we pass a correlated Brownian motion process into the method from which the interest rate levels are constructed. The other correlated process are used in the Heston model.

Parameters:params (ModelParameters) – The parameters for the stochastic model.
Returns:np.array – The interest rate levels for the CIR process
tensortrade.stochastic.processes.heston.geometric_brownian_motion_jump_diffusion_levels(params: tensortrade.stochastic.utils.parameters.ModelParameters) → numpy.array[source]

Converts a sequence of gbm jmp returns into a price sequence which evolves according to a geometric brownian motion but can contain jumps at any point in time.

Parameters:params (ModelParameters) – The parameters for the stochastic model.
Returns:np.array – The price levels.
tensortrade.stochastic.processes.heston.geometric_brownian_motion_jump_diffusion_log_returns(params: tensortrade.stochastic.utils.parameters.ModelParameters) → numpy.array[source]

Constructs combines a geometric brownian motion process (log returns) with a jump diffusion process (log returns) to produce a sequence of gbm jump returns.

Parameters:params (ModelParameters) – The parameters for the stochastic model.
Returns:np.array – A GBM process with jumps in it
tensortrade.stochastic.processes.heston.get_correlated_geometric_brownian_motions(params: tensortrade.stochastic.utils.parameters.ModelParameters, correlation_matrix: numpy.array, n: int) → numpy.array[source]

Constructs a basket of correlated asset paths using the Cholesky decomposition method.

  • params (ModelParameters) – The parameters for the stochastic model.
  • correlation_matrix (np.array) – An n x n correlation matrix.
  • n (int) – Number of assets (number of paths to return)

np.array – n correlated log return geometric brownian motion processes.

tensortrade.stochastic.processes.heston.heston(base_price: int = 1, base_volume: int = 1, start_date: str = '2010-01-01', start_date_format: str = '%Y-%m-%d', times_to_generate: int = 1000, time_frame: str = '1h', params: Optional[tensortrade.stochastic.utils.parameters.ModelParameters] = None) → pandas.core.frame.DataFrame[source]

Generates price data from the Heston model.

  • base_price (int, default 1) – The base price to use for price generation.
  • base_volume (int, default 1) – The base volume to use for volume generation.
  • start_date (str, default '2010-01-01') – The start date of the generated data
  • start_date_format (str, default '%Y-%m-%d') – The format for the start date of the generated data.
  • times_to_generate (int, default 1000) – The number of bars to make.
  • time_frame (str, default '1h') – The time frame.
  • params (ModelParameters, optional) – The model parameters.

pd.DataFrame – The generated data frame containing the OHLCV bars.

tensortrade.stochastic.processes.heston.heston_construct_correlated_path(params: tensortrade.stochastic.utils.parameters.ModelParameters, brownian_motion_one: numpy.array) → numpy.array[source]

A simplified version of the Cholesky decomposition method for just two assets. It does not make use of matrix algebra and is therefore quite easy to implement.

  • params (ModelParameters) – The parameters for the stochastic model.
  • brownian_motion_one (np.array) – (Not filled)

np.array – A correlated brownian motion path.

tensortrade.stochastic.processes.heston.heston_model_levels(params: tensortrade.stochastic.utils.parameters.ModelParameters) → numpy.array[source]

Generates price levels corresponding to the Heston model.

The Heston model is the geometric brownian motion model with stochastic volatility. This stochastic volatility is given by the cox ingersoll ross process. Step one on this method is to construct two correlated GBM processes. One is used for the underlying asset prices and the other is used for the stochastic volatility levels.

Parameters:params (ModelParameters) – The parameters for the stochastic model.
Returns:np.array – The prices for an underlying following a Heston process


This method is dodgy! Need to debug!

tensortrade.stochastic.processes.heston.jump_diffusion_process(params: tensortrade.stochastic.utils.parameters.ModelParameters) → numpy.array[source]

Produces a sequence of Jump Sizes which represent a jump diffusion process.

These jumps are combined with a geometric brownian motion (log returns) to produce the Merton model.

Parameters:params (ModelParameters) – The parameters for the stochastic model.
Returns:np.array – The jump sizes for each point in time (mostly zeroes if jumps are infrequent).