Constant Proportion Portfolio Insurance (CPPI)
Implements CPPI strategy for commodity price risk management
cppi(q, tdate, f, tper, rper, tcost = 0, int = TRUE)
q
: numeric value for quantity to be hedged, either positive (net buyer) or negative (net seller)tdate
: date vector with trading daysf
: numeric futures price vectortper
: numeric target price markup/down to the price on the first trading dayrper
: numeric risk factor as a percentage of the price on the first trading daytcost
: numeric transaction costs pr unitint
: TRUE/FALSE integer restriction on tradable volumeinstance of the CPPI class
# CPPI 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 cppi strategy for buyer cppi_b <- cppi(q = 10, tdate = tr_dates, f = f_gbm, tper = 0.1, rper = 0.1, tcost = 0, int = TRUE) # implement cppi strategy for seller cppi_s <- cppi(q = - 10, tdate = tr_dates, f = f_gbm, tper = - 0.1, rper = 0.1, tcost = 0, int = TRUE)
Useful links