[R-SIG-Finance] [R-sig-finance] error with maxreturnPortfolio
patzoul
patzoul at free.fr
Sun Nov 9 17:56:52 CET 2008
I want to optimize a portfolio based on a target level of risk. When I run
the commands below I get an error message saying that the Target Return is
missing.
What am I doing wrong?
Side question: what is the unit of TargetRisk?
library(TTR)
library(zoo)
suppressMessages(library(fPortfolio))
syms <- c("^STOXX50E", "^GSPC", "^N225", "EEM", "AGG", "GSG")
X <- getYahooData(syms[1], start=20070601, quiet=TRUE)
X <- zoo( X$Close, X$Date )
for (i in 2:6){
print(syms[i])
x <- getYahooData(syms[i], start=20070601, quiet=TRUE)
X <- cbind(X, zoo(x$Close, x$Date))
}
plot(X)
colnames(X) <- syms
myReturns <- as.timeSeries(returns(X, percentage = TRUE))
Spec = portfolioSpec()
setOptimize(Spec) = "maxReturn"
setTargetRisk(Spec) = 10
Constraints = "LongOnly"
Ptf = maxreturnPortfolio(myReturns, Spec, Constraints)
weightsLinePlot(Ptf)
--
View this message in context: http://www.nabble.com/error-with-maxreturnPortfolio-tp20408297p20408297.html
Sent from the Rmetrics mailing list archive at Nabble.com.
More information about the R-SIG-Finance
mailing list