simprice {derivmkts}R Documentation

Simulate asset prices

Description

simprice computes simulated lognormal price paths, with or without jumps. Saves and restores random number seed.

simprice(s0, v, r, tt, d, trials, periods = 1, jump = FALSE, lambda = 0, alphaj = 0, vj = 0, seed = NULL, long = TRUE, scalar_v_is_stddev = TRUE)

Usage

simprice(s0, v, r, tt, d, trials, periods, jump, lambda,
    alphaj, vj, seed, long, scalar_v_is_stddev)

Arguments

s0

Initial price of the underlying asset

v

If scalar, default is volatility of the asset price, defined as the annualized standard deviation of the continuously-compounded return. The parameter scalar_v_is_stddev controls this behavior. If v is a square n x n matrix, it is assumed to be the covariance matrix and simprice will return n simulated price series.

r

Annual continuously-compounded risk-free interest rate

tt

Time to maturity in years

d

Dividend yield, annualized, continuously-compounded

trials

number of simulated price paths

periods

number of equal-length periods in each simulated path

jump

boolean controlling use of jump parameters

lambda

expected number of jumps in one year (lambda*tt) is the Poisson parameter

alphaj

Expected continuously compounded jump percentage

vj

lognormal volatility of the jump amount

seed

random number seed

long

if TRUE, return a long-form dataframe with columns indicating the price, trial, and period. If FALSE, the returned data is wide, containing only prices: each row is a trial and each column is a period

scalar_v_is_stddev

if TRUE, scalar v is interpreted as the standard devaition; if FALSE, it is variance. Non-scalar V is always interpreted as a covariance matrix

Value

A dataframe with trials simulated stock price paths

Examples

# simple Monte Carlo option price example. Since there are two
# periods we can compute options prices for \code{tt} and
# \code{tt/2}
s0=40; k=40; v=0.30; r=0.08; tt=0.25; d=0;
st = simprice(s0, k, v, r, tt, d,  trials=3, periods=2, jump=FALSE)
callprice1 = exp(-r*tt/2)*mean(pmax(st[st$period==1,] - k, 0))
callprice2 = exp(-r*tt)*mean(pmax(st[st$period==2,] - k, 0))



[Package derivmkts version 0.2.4 Index]