shpi: Step Hedge Portfolio Insurance (SHPI)

View source: R/shpi_strategy.R

shpiR Documentation

Step Hedge Portfolio Insurance (SHPI)

Description

Implements SHPI strategy for commodity price risk management

Usage

shpi(q, tdate, f, daysleft, tper, tcost = 0, int = TRUE)

Arguments

q

numeric value for quantity to be hedged, either positive (net buyer) or negative (net seller)

tdate

date vector with trading days

f

numeric futures price vector

daysleft

integer with days left to contract expiry

tper

numeric target price markup/down to the price on the first trading day

tcost

numeric transaction costs pr unit

int

TRUE/FALSE integer restriction on tradable volume

Value

instance of the SHPI class

Examples

# SHPI for a buyer (seller), where stop loss is set 10% above (below) initial market price.

set.seed(5)
# GBM price process parameters
mu <- 0.2
sigma <- 0.1
S0 <- 100

# time
Y <- 2
N <- 500
delta <- Y/N
t <- seq (0, 1, length = N + 1)

# price process and date vector
W <- c(0, cumsum ( sqrt(delta) * rnorm (N)))
f_gbm <- S0 * exp(mu * t + sigma * W)
tr_dates <- seq(Sys.Date(), Sys.Date()+500, by = "day")

# implement step-hedge strategy for buyer
shpi_b <- shpi(q = 10,
tdate = tr_dates,
f = f_gbm,
daysleft = length(tr_dates),
tper = 0.1,
tcost = 0,
int = TRUE)

# implement step-hedge strategy for seller
shpi_s <- shpi(q = - 10,
tdate = tr_dates,
f = f_gbm,
daysleft = length(tr_dates),
tper = - 0.1,
tcost = 0,
int = TRUE)


sleire/etrm documentation built on Feb. 5, 2023, 9:02 a.m.