sim_schwartz: Simulate a _Schwartz_ process using _Rcpp_.

View source: R/RcppExports.R

sim_schwartzR Documentation

Simulate a Schwartz process using Rcpp.

Description

Simulate a Schwartz process using Rcpp.

Usage

sim_schwartz(prici, priceq, theta, innov)

Arguments

prici

The initial price.

priceq

The equilibrium price.

theta

The strength of mean reversion.

innov

A single-column matrix of innovations (random numbers).

Details

The function sim_schwartz() simulates a Schwartz process using fast Rcpp C++ code.

The Schwartz process is the exponential of the Ornstein-Uhlenbeck process, and similar comments apply to it. The prices are calculated as the exponentially compounded returns, so they are never negative. The log prices can be obtained by taking the logarithm of the prices.

The function sim_schwartz() simulates the percentage returns as equal to the difference between the equilibrium price \mu minus the latest price p_{i-1}, times the mean reversion parameter \theta, plus a random normal innovation.

The function sim_schwartz() returns a single-column matrix representing the time series of simulated prices.

Value

A single-column matrix of simulated prices, with the same number of rows as the argument innov.

Examples

## Not run: 
# Define the Schwartz model parameters
prici <- 1.0
priceq <- 2.0
thetav <- 0.01
innov <- matrix(rnorm(1e3, sd=0.01))
# Simulate Schwartz process using Rcpp
prices <- HighFreq::sim_schwartz(prici=prici, priceq=priceq, theta=thetav, innov=innov)
plot(prices, t="l", main="Simulated Schwartz Prices", ylab="prices")

## End(Not run)


algoquant/HighFreq documentation built on Oct. 26, 2024, 9:20 p.m.