long short portfolio in r

619 views Asked by At

I'm trying to build portfolio with the function Return.portfolio (PerformanceAnalytics package). I have returns for 2 assets in a matrix r. when running: Return.portfolio(r,verbose = T,weights = c(0.5,0.5)) it seems to working. When trying to add rebalance "quarters" I'm getting this error:

"Error in `[<-`(`*tmp*`, k, , value = c(0.639312209726542, 0.639312209726542 : 
  subscript out of bounds".

and I don't understand what is wrong. In addition, when trying to build long-short portfolio: Return.portfolio(r,weights = c(1,-1),verbose = T), its running but the results seems not logical.. Is there a reason for this? thanks guys

0

There are 0 answers