Description Usage Arguments Value Examples
View source: R/obpi_strategy.R
Implements OBPI strategy for commodity price risk management
1 2 3 4 5 6 7 8 9 10 11 12 |
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 |
k |
numeric value for option strike price |
vol |
value for volatility |
r |
value for interest rate |
tdays |
integer assumed number of trading days per year |
daysleft |
integer with days left to option expiry |
tcost |
numeric transaction costs pr unit |
int |
TRUE/ FALSE integer restriction on tradable volume |
instance of the OBPI class
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | # OBPI 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 obpi strategy for buyer
obpi_b <- obpi(q = 10,
tdate = tr_dates,
f = f_gbm,
k = f_gbm[1],
vol = 0.2,
r = 0,
tdays = 250,
daysleft = length(f_gbm),
tcost = 0,
int = TRUE)
# implement obpi strategy for seller
obpi_s <- obpi(q = - 10,
tdate = tr_dates,
f = f_gbm,
k = f_gbm[1],
vol = 0.2,
r = 0,
tdays = 250,
daysleft = length(f_gbm),
tcost = 0,
int = TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.