Hi Alexios

This is great stuff, exactly what I was after. Many thanks for this.

Kind regards

Pierre
-----Original Message-----
From: alexios ghalanos [mailto:alex...@4dscape.com] 
Sent: 07 July 2014 15:55
To: Pierre Org; r-sig-finance@r-project.org
Subject: Re: [R-SIG-Finance] FPortfolio / MAxReturnPortfolio

I'm not too familiar with how fPortfolio works, but since you asked for
"alternative code" here is how you can do this with parma:

###############
library(parma)
spec = parmaspec(S = cov(datamatrix), riskB=0.1,
risk="EV",riskType="maxreward", LB = rep(0,8), UB = rep(1,8), budget=1,
forecast=colMeans(datamatrix))
weights(parmasolve(spec, solver="SOCP")) #############

Note the following:
1. The risk (riskB) is an upper bound since this is an inequality constraint
(less than or equal to), and is available to solve for covariance inputs
using an SOCP solver (you can also solve QCQP problems as well).
2. The solution can be completely dominated by one asset (as in the case
above) unless you change risk bound or constraints (UB, LB or some other
linear combinations ... see documentation) 3. You MUST provide a forecast
vector (which is not all zeros).

Regards,

Alexios

On 07/07/2014 12:04, Pierre Org wrote:
>  
> 
> I am working on a small allocation project and have tried to used the 
> maxreturnPortfolio function in the fPortfolio package to find the 
> portfolio that maximise return for a specified level of risk, However 
> the function does not seem to work. It returns zero weights 
> independently of the  level of risk provided as the target. Has anyone 
> had experience of working with that function or could provide an
alternative code ?
> 
>  
> 
>  
> 
> require(timeseries)
> 
> require(fPortfolio)
> 
> require(quantmod)
> 
>  
> 
> ETF <-  
> c('VGSIX','VUSTX','VGTSX','VFISX','VTSMX','VFITX','VEIEX','VIPSX')
> 
> getSymbols(ETF,source = 'yahoo')
> 
> datamat <-
> as.xts(cbind(get("VGTSX")[,4],get("VTSMX")[,4],get("VEIEX")[,4],get("V
> GSIX")
> [,4],get("VUSTX")[,4],get("VFITX")[,4],get("VFISX")[,4],get("VIPSX")[,
> 4]))
> 
> datamatrix <-  as.xts(apply(datamat,2,function(x) diff(log(x))))
> 
> colnames(datamatrix) <-  c('Global Equities Ex US','US 
> Equities','Emerging Markets Stocks',"REITs",'Treasuries 15 - 
> 30Y','Treasuries 5-10Y','Treasuries 1-4Y','US Inflation Linked 7 - 
> 20Y')
> 
>  
> 
> x <- timeSeries(datamatrix, charvec=as.Date(index(datamatrix)))
> 
> Constraints <-  "LongOnly"
> 
> Spec  <- portfolioSpec()
> 
> setTargetRisk(Spec) <- 0.1
> 
> getWeights(maxreturnPortfolio(x, Spec, Constraints)@portfolio)
> 
>  
> 
>  
> 
>  
> 
> VGTSX.Close VTSMX.Close VEIEX.Close VGSIX.Close VUSTX.Close 
> VFITX.Close VFISX.Close VIPSX.Close
> 
>           0           0           0           0           0           0
> 0           0 
> 
>  
> 
>  
> 
>  
> 
> Any help appreciated
> 
> 
>       [[alternative HTML version deleted]]
> 
> _______________________________________________
> R-SIG-Finance@r-project.org mailing list 
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions
should go.
> 
>

_______________________________________________
R-SIG-Finance@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only. If you want to post, subscribe first.
-- Also note that this is not the r-help list where general R questions should 
go.

Reply via email to