knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
The goal of Hedge is to obtain optimal hedge ratios using two different methods: one is traditionally used minimum variance hedge ratio, and the other one is minimizing the semivariance hedge ratio. Based on obtained hedge ratio, the hedging effectiveness is obtained and compared.
You can install the released version of Hedge from CRAN with:
install.packages("Hedge")
And the development version from GitHub with:
# install.packages("devtools") devtools::install_github("sieunyi/Hedge") # For installation with vignette devtools::install_github("sieunyi/Hedge", build_vignettes = TRUE)
## Example ```r library(Hedge)
To properly utilize this package, you first need to import two sets of data: first column with spot price, second column with futures price that you want to calculate the hedge ratio with. Next, name this data set as x.
data(fx) spot_price = fx$...1 futures_price = fx$...2 x = cbind(spot_price, futures_price) source('~/new folder/Hedge/R/hedge.R', echo=TRUE)
Finally, call the function within the package defining the window length you want to compare.
## basic example code WinLen = 15 out1 <- mvhr(x, WinLen) out2 <- svhr(x, WinLen)
# compare hedging effectiveness plot(out2$HE_sv, main = "Hedging effectiveness", type = 'l', col=1) lines(out1$HE, type='l', col=3)
# compare hedge ratio plot(out2$HR_sv, type= 'l', col=1, main = "Hedge ratios") plot(out1$HR, type='l', col=4)
In that case, don't forget to commit and push the resulting figure files, so they display on GitHub and CRAN.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.