Sorry if this is a dumb question, but I have trying to figure this out for 3 days now. I am getting this error every time I try to run the portfolio optimization and can't figure it out.
Error in assign(".objectivestorage", list(), envir = as.environment(.storage)) : object '.storage' not found I'm also getting this warning usually at the second and third objectives:
In addition: Warning message: In is.na(le) : is.na() applied to non-(list or vector) of type 'NULL' Here is my code:
##Import Dataset setwd("D:\\Dropbox\\FUND - SSIF\\Portfolio Analysis Package") Stocktrak<- Return.read("SSIF_Data.csv", frequency = "d") # Create Objects for data and column names R <- Stocktrak[, 1:17] colnames(returns) <- c("JEC", "BNS", "AAPL", "PEG", "SLB", "TSM", "HD", "MON", "GWO", "TOT", "XPH", "CVS", "UNP", "KORS", "GNTX", "NWC", "WFC") funds <- colnames(R) # Create an initial portfolio object with leverage and box constraints init <- portfolio.spec(assets=funds) init <- add.constraint(portfolio=init, type="leverage", min_sum=0.99, max_sum=1.01) init <- add.constraint(portfolio=init, type="box", min=0.01, max=0.65) # Create Objectives for eq_meanETL Portfolio Optimization eq_meanETL <- add.objective(portfolio=init, type="return", name="mean") eq_meanETL <- add.objective(portfolio=eq_meanETL, type="risk", name="ETL", arguments=list(p=0.95)) eq_meanETL <- add.objective(portfolio=eq_meanETL, type="risk_budget", name="ETL", min_concentration=TRUE, arguments=list(p=0.95)) # Optimize Portfolio opt_eq_meanETL <- optimize.portfolio(R=R, portfolio=eq_meanETL, optimize_method="DEoptim", search_size=2000, trace=TRUE, traceDE=5)
nrs=600 Stocktrak=matrix(rnorm(nrs*17,0.1,0.05),nrow = nrs) #set any date Stocktrak<- as.xts(Stocktrak,order.by = seq.Date(from=as.Date("2016-03-21")-nrs,by=1,length.out =nrs )) R <- Stocktrak[, 1:17] colnames(R) <- c("JEC", "BNS", "AAPL", "PEG", "SLB", "TSM", "HD", "MON", "GWO", "TOT", "XPH", "CVS", "UNP", "KORS", "GNTX", "NWC", "WFC") funds <- colnames(R)