<html><head></head><body><div style="font-family: Verdana;font-size: 12.0px;"><div>Hello everyone,</div>

<div> </div>

<div>I am currently trying to run an out-of-sample-optimization with the PortfolioAnalytics package, where the quadratic utility function of the investor also penalizes transaction costs (40bps) through the numeric solver. The vignette states that this can be implemented via a constraint that is supported for quadratic utility maximization using the ROI solver. However, this does not work for me. I have the following exemplary code:</div>

<div> </div>

<div>
<div>library(xts)<br/>
library(PortfolioAnalytics)<br/>
library(ROI)<br/>
library(quadprog)<br/>
options(scipen = 999)</div>

<div> </div>

<div>data("edhec")<br/>
returns = edhec[, 1:3]<br/>
colnames(returns) = c("CA", "CTAG", "DS")</div>

<div> </div>

<div>port <- portfolio.spec(assets = colnames(returns))<br/>
port <- add.constraint(port, "long_only")<br/>
port <- add.constraint(port, "weight_sum", min_weight = 1, max_weight = 1)<br/>
port <- add.constraint(port, "transaction_cost", ptc = 0.004)<br/>
port <- add.objective(port, type = "risk", name = "var", risk_aversion = 10)<br/>
port <- add.objective(port, type = "return", name = "mean")</div>

<div> </div>

<div>opt_TC = optimize.portfolio.rebalancing(R = returns, portfolio = port, optimize_method = "ROI", rebalance_on = "months", training_period = 100, rolling_window = NULL)</div>

<div> </div>

<div>rr_TC = Return.portfolio(returns, weights = extractWeights(opt_TC))<br/>
charts.PerformanceSummary(rr_TC)<br/>
chart.Weights(opt_TC)</div>

<div> </div>

<div> </div>

<div>When I run this code without the transaction cost constraint it works fully as intended. However, if I run it with the TC constraint, I suddenly receive the following error messages:</div>

<div>> charts.PerformanceSummary(rr_TC)<br/>
Error in `[.xts`(x, start.row, 1) : subscript out of bounds<br/>
> chart.Weights(opt_TC)<br/>
Error in plot.window(xlim, ylim, log = log, ...) : <br/>
  need finite 'ylim' values</div>

<div> </div>

<div>It does work with the "DEoptim" solver (although the solutions somehow look strange to me), but I would want to run it using the ROI solver, which should be possible as I understand it. Has someone had a similar problem and was able to fix it?</div>

<div> </div>

<div>Kind regards, <br/>
Jarno</div>

<div> </div>
</div></div></body></html>