Description Usage Arguments Details Value Author(s) See Also Examples
Add the hedged return on the long and short return series.
1 2 | addrtn.hedge(rtn.long, rtn.short, rebFreq = "month", weight = c(1, -1),
fee.long = 0, fee.short = 0)
|
rtn.long |
an xts,timeSeries or zoo object of long portfolio returns,which must be 1 column |
rtn.short |
an xts,timeSeries or zoo object of benchmark or short portfolio returns,which must be 1 column |
rebFreq |
an interval specification, one of "day", "week", "month", "quarter" and "year", optionally preceded by an integer and a space, or followed by "s".See |
weight |
a time series or single-row matrix(vector) containing asset weights. If a vector,the weights time series will be computed automatically via different rebFreq. See example for detail. |
fee.long |
a numeric, giving the Unilateral transaction fee of long asset |
fee.short |
a numeric, giving the Unilateral transaction fee of short asset |
Note that the rowsum of weight is not required to be equal to 1. If the portfolio is not full position, then the sum of weight could be smaller than 1; If credit and short is allowed, then the sum of weight could be smaller than 0 or larger than 1.
a rtn.LSH object of class xts,giving the return series of long,short and hedge, with attr of 'rebtrade' and 'fee'.
Ruifei.Yin
Other LSH-frame building functions: getrtn.LBH
,
getrtn.LSH
, getrtn.bmk
1 2 3 4 5 6 7 8 9 10 11 | rtn.long <- zoo(rnorm(1000,0.001,0.02),as.Date("2010-01-01")+1:1000)
rtn.short <- rtn.long + rnorm(1000,-0.0001,0.003)
rebFreq <- "month"
# use the default weight: full position hedging, rebalancing by month
re <- addrtn.hedge(rtn.long,rtn.short,rebFreq,c(1,-1))
# 70 percent postion hedging,rebalancing by month
re2 <- addrtn.hedge(rtn.long,rtn.short,rebFreq,c(0.7,-0.7))
# use the time series weight
wgt.idx <- unique(as.Date(cut(zoo::index(rtn.long),"month")))
wgt <- xts(matrix(rep(c(0.7,-0.7),each=length(wgt.idx)),length(wgt.idx),2),wgt.idx)
re3 <- addrtn.hedge(rtn.long,rtn.short,weight=wgt) # the same as re2
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.