Hi ,
I have 181 csv files. I want to read them at once so I use the following code to import all of the files at once
return= list.files(pattern="*.csv")
for (i in 1:length(return)) assign(return[i], read.csv(return[i],header = F))
the class of the files are data.frame, I want to convert every data frame to xts object, because my next step is to plug in every xts object to the following function
Minsdr_insample_function<-function(x){
# Create an optimized portfolio of returns
init.portfolio <- portfolio.spec(assets = colnames(log.return))
init.portfolio <- add.constraint(portfolio = init.portfolio,
type = "full_investment")
init.portfolio <- add.constraint(portfolio = init.portfolio,
type = "long_only")
init.portfolio <-add.constraint(portfolio = init.portfolio, type="box", min=0, max=1)
minSD.portfolio <- add.objective(portfolio=init.portfolio,
type="risk",
name="StdDev")
x1<- optimize.portfolio(R = x, portfolio = minSD.portfolio,
optimize_method = "ROI", trace = TRUE)
extractWeights(x1)
}
I want to plug in each one of the xts files here
Minsdr_insample_function(every xts object)
any advice is highly appreciated
Thanks