# Portfolio optimization subject to transaction costs

Mean-Variance portfolio optimization attracted lots of attention in this forum so far. I am interested in the effect of incorporating transaction costs into the decision framework and I would like to obtain 'optimal' portfolios. In other words, approaches which are still capable of being solved using quadratic programing by constraining maximum turnover are not what I am looking for. Just recently, this question was solved with the help of the community in order to obtain optimal portfolios if we consider quadratic transaction costs. However, what happens if we come up with transaction costs in a V-shape, which means we pay a fee proportionally to the sum of absolute rebalancing: $$TC(\omega_\text{new}) \propto ||\omega_\text{new}-\omega_\text{old}||.$$ This (rather old) paper by Atsushi Yoshimoto handles exactly the optimization problem I want to solve: $$\omega_\text{new} = \arg\max {\omega'\mu - \sum_{i=1}^N c_i -\lambda \omega'\Sigma\omega} \\ \text{s.t.} c_i = k(d^+ _{i,t} + d^- _{i,t}), \forall i \\ \omega_{i}-\omega_{old} = d_{i} ^+ - d_{i} ^-, \forall i \\ d_i ^+ d_i ^- =0, \forall i \\ d_i ^+, d_i ^- \geq 0 \forall i \\\omega'\iota=1$$ Intuitively speaking the optimization is doing the following: Given estimates of future returns $\mu$ and volatility $\Sigma$, we search for $\omega$ which maximizes our Certainty equivalent. This value is decreased with total transaction costs $\sum c$. Transaction costs occur if we rebalance our portfolio: Given we increase the share of wealth in one asset $i$, this affects $d_i ^+$ and, vice versa, if we decrease the share of wealth in one asset, this increases $d_i ^-$. Total rebalancing in asset $i$ is therefore $d_i ^+ +d_i ^-$. The constraint $d_i ^+ d_i ^- = 0$ ensures, that one cannot buy and sell simultaneously one asset (which should be clear). The last constraint requires that our new portfolio weights $\omega$ sum up to 1, therefore we are investing all the money into the available assets (I did not incorporate an additional short sell constraint here, opposed to Yoshimoto).

I would love to implement this optimization in R, Matlab, Python, whatever, but I do not understand the structure explained in this paper: All which is explained is that a nonlinear optimizer called GAMS/MINOS was used. I think, 20 Years after publishing there should certainly be a publicly available approach to to this, therefore I ask (i) does an implementation already exist? (ii) If not, how to do this properly?

EDIT: To show my first approach I worked out this small example for R. Hereby I neglect the estimation of the mean but only consider volatility timing:

library(alabama)
library(quantmod)

symbols <- c("MSFT","AAPL","MMM")
getSymbols(symbols,src='yahoo',from = '1995-01-01')
N <- length(symbols)

MSFT <-  to.monthly(MSFT)
AAPL <-  to.monthly(AAPL)
MMM <-  to.monthly(MMM)
returns <- data.frame(MSFT=diff(log(MSFT$MSFT.Adjusted)), AAPL=diff(log(AAPL$AAPL.Adjusted)),
MMM=diff(log(MMM$MMM.Adjusted))) returns <- na.omit(returns) names(returns) <- symbols mu <- rep(1,N) sigma <- cov(returns) lambda <- 4 costpara <- 50/10000 wold <- rep(1/N,N) fn <- function(w) -w%*%mu + costpara*sum(abs(w- wold))+lambda*t(w)%*%sigma%*%w heq <- function(w) return(sum(w)-1) out <- constrOptim.nl(par=wold, fn=fn,heq=heq) rbind(out$par,wold)

wnew 0.3333233 0.08347908 0.5831977
wold 0.3333333 0.33333333 0.3333333


However, I am not too familiar with numerical optimization, so can anyone confirm this approach is correct, or point out ways to improve the optimization?

What you do looks ok. But in practice how would you set costpara? This coud have a huge impact on your optimization.
So I would do something different. Define the buys $b_i>0$ and the sells $s_i>0$ then you have $$w_i = wold_i + b_i - s_i$$ or in other terms: $$w_i-wold_i - b_i + s_i = 0.$$ This is a linear equality that you cas use in your heq. Then you add a constraint $$\sum_{i=1}^n b_i + s_i \le T$$ for some turnover limit $T$. Then you make sure that the problem is optimized under a turnover constraint. Multipliying this $T$ by your cost of one percent sold or bought gives you control over transaction costs.