[R-SIG-Finance] [R-sig-finance] efficientPortfolio, setTargetRisk, setTargetReturn

patzoul patzoul at free.fr
Mon Nov 10 23:10:51 CET 2008


I want to find the optimized weights according to a target risk budget. When
I run my code I still have to input the target return otherwise I get an
error. How can I optimize the return based on a level of risk?

Here is the code I am using

library(quantmod)
library(fPortfolio)

# Universe
myAssets <- c("STOXX50E", "GSPC", "N225")
nbAssets <- NROW(myAssets)
myIndices <- paste("^", myAssets, sep="")
myETFs <- c("EEM", "AGG", "GSG")

# Load historical data
getSymbols(c(myIndices, myETFs), from="2007-10-10")

# Combine closing prices
myData <- merge(merge(merge(merge(merge(Cl(STOXX50E), Cl(GSPC), all=FALSE),
Cl(N225), all=FALSE), Cl(EEM), all=FALSE), Cl(AGG), all=FALSE), Cl(GSG),
all=FALSE)
# plot(myData)

myReturns <- as.timeSeries(diff(log(myData)))
Spec = portfolioSpec()
setTargetReturn(Spec) = 0
setTargetRisk(Spec) = 0.10

# Show portfolio data
pfolioData = portfolioData(myReturns, Spec)
# print(pfolioData)

# Compute properties of minimum variance Portfolio:
Ptf = efficientPortfolio(myReturns, Spec, c("maxW[1:6]=0.3333",
"minW[1:6]=-0.3333", "maxsumW[1:6]=1", "minsumW[1:6]=-1"))
print(Ptf)


-- 
View this message in context: http://www.nabble.com/efficientPortfolio%2C-setTargetRisk%2C-setTargetReturn-tp20429076p20429076.html
Sent from the Rmetrics mailing list archive at Nabble.com.



More information about the R-SIG-Finance mailing list