You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The new CVXR method introduced a bug when reading the optimize_method user input. This happens if the uses CVXR and defines an optimizer (e.g., c("CVXR", "SCS")). The expectation is that optimized_method is a character vector of length 1. However, if the user includes an optimizer, it becomes a character vector of length 2.
Example code:
library(PortfolioAnalytics)
library(CVXR)
library(data.table)
library(xts)
data(edhec)
# Use edhec for a returns objectret_edhec<- tail(edhec, 60)
colnames(ret_edhec) <- c("CA", "CTAG", "DS", "EM", "EMN", "ED", "FIA",
"GM", "LSE", "MA", "RV", "SS", "FF")
print(head(ret_edhec, 5))
fund_edhec<- colnames(ret_edhec)
# Create portfolio objectpspec_maxret<- portfolio.spec(assets=fund_edhec)
# Add constraints to the portfolio objectpspec_maxret<- add.constraint(pspec_maxret, type="full_investment")
pspec_maxret<- add.constraint(portfolio=pspec_maxret, type="box",
min= rep(0.02, 13),
max= c(rep(0.6, 4), rep(0.2, 9)))
# Add objective to the portfolio objectpspec_maxret<- add.objective(portfolio=pspec_maxret,
type="risk", name="StdDev")
pspec_maxret<- add.objective(portfolio=pspec_maxret,
type="return", name="mean")
pspec_maxret# Run the optimization with default solveropt_maxret<- optimize.portfolio(R=ret_edhec, portfolio=pspec_maxret,
optimize_method=c("CVXR", "SCS"), trace=TRUE,MaxSR=TRUE)
opt_maxretbt_maxret<- optimize.portfolio.rebalancing(R=ret_edhec, portfolio=pspec_maxret,
optimize_method=c("CVXR", "SCS"),
rebalance_on="quarters",
training_period=36, trace=TRUE, MaxSR=TRUE)
The text was updated successfully, but these errors were encountered:
goodnewz
added a commit
to goodnewz/PortfolioAnalytics
that referenced
this issue
Jan 9, 2023
The new CVXR method introduced a bug when reading the
optimize_method
user input. This happens if the uses CVXR and defines an optimizer (e.g.,c("CVXR", "SCS")
). The expectation is thatoptimized_method
is a character vector of length 1. However, if the user includes an optimizer, it becomes a character vector of length 2.Example code:
The text was updated successfully, but these errors were encountered: