1

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) 
1
  • I could not reproduze your error/ warning. That code works for me with simulated returns 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) Commented Mar 24, 2016 at 13:32

2 Answers 2

3

place the following before optimize.portfolio

.storage <<- new.env() 
Sign up to request clarification or add additional context in comments.

Comments

-1

Editing

Change the trace = FALSE

It will work. First time here.

Optimize Portfolio

opt_eq_meanETL <- optimize.portfolio(R=R, portfolio=eq_meanETL, optimize_method="DEoptim", search_size=2000, trace=FALSE, traceDE=5)

2 Comments

This is not an answer to the question.
Sorry, I changed the answer. First time here. Inside the package source code we have the following message: #we can't pass trace=TRUE into constrained objective with DEoptim, because it expects a single numeric return That is why we receive the error

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.