May 8, 2019  | Minimising trading costs and enforcing a no-fractional-dealing condition are two major challenges when implementing dynamic portfolio strategies. We present a flexible and efficient trade cost optimisation algorithm utilising a classical mixed integer linear program (MILP).

DisclaimerThe views and opinions expressed in this blog are those of the author and do not necessarily reflect the views of Scalable Capital GmbH or its subsidiaries. Further information can be found at the end of this article.

### Summary

• We discuss two major challenges when implementing a dynamic portfolio strategy in practice: Minimising trading costs and enforcing a no-fractional-dealing condition.
• To master these challenges, we present a flexible and efficient trade cost optimisation algorithm that can be combined with a wide variety of portfolio optimisation approaches.
• We explain what characterises a trade cost optimisation and illustrate the mechanism behind it.
• The trade cost optimisation allows us to implement a relative strength momentum strategy with annual turnover of 200% over the past ten years, using on average only 24 trades per year.
• Mathematical derivations are provided such that the trade cost optimisation problem can be written as a mixed integer linear program (MILP). This way it can be implemented using standard software packages for numerical optimisation.
• Investors often face a no-fractional-dealing condition and we show how it can be integrated into the trade cost optimisation with only a negligible decrease in efficiency.

### 1. What is Trade Cost Optimisation?

Investors usually face a multi-objective optimisation problem. The main objective is to find the optimal portfolio for investing. Besides that, a second objective is to implement this optimal portfolio allocation in a cost-efficient manner.

Let us assume that we always trigger trading if the distance of our current portfolio from a given ideal portfolio is too large1. One way to measure distance between portfolios is turnover, $TO($
cdot,
cdot)
, which is defined as the sum of the absolute distances of the portfolio weights of each asset scaled by one-half to obtain a measure in $[0,1]$ (see Section 3 for a formal definition). In the following, we will use $TO($
bm{x}_0,
tilde{
bm{x}}) >
delta
as the trading trigger. This means that we trigger a trading event whenever the distance of the current weight, 
bm{x}_0
, to the ideal weight, 
tilde{
bm{x}}
, is larger than 
delta
in (0,1)
. A trade cost optimisation is used to determine new portfolio weights which are closer to the ideal portfolio weights than the current weights, but cheaper to accomplish than a full rebalancing to the ideal portfolio. Quite generally speaking, two implementation strategies are possible. First, the portfolio optimisation and the trade cost optimisation could be done in a joint optimisation step (see for example Mansini, Ogryczak and Speranza (2014) for a literature overview). And second, a two-step approach where the portfolio optimisation delivering an ideal weight vector, 
tilde{
bm{x}}
, for the portfolio is done in a first step, while trade costs are optimised only in a second step. The original ideal weight vector hence will be adapted by the trade cost optimisation, leading to a slightly different weight vector 
bm{x}
. We will focus on the second approach as it comes with two advantages. From a mathematical point of view it is much easier to implement. In addition to that, having trade cost optimisation and portfolio optimisation independent from each other allows one to combine the trade cost optimisation flexibly with any potential portfolio strategy. Whether the ideal weights are decided by an investment committee or obtained from a dynamic portfolio optimisation strategy, the trade cost optimisation approach can be applied in both cases.

Any trade cost optimisation needs to deal with a trade-off between cost efficiency and optimality of the new portfolio. One way to balance this trade-off is by defining a maximum acceptable distance 
gamma
in (0,
delta)
to the ideal portfolio weights. This way only portfolio weight vectors with a distance less than the threshold become valid solutions in the optimisation problem. The closer this threshold is to zero, the less freedom the trade cost optimisation gets. Portfolio weights will be closer to the original target and hence "more optimal", but with less reductions in trading costs. Using such a threshold, a trade cost optimisation can be achieved by minimising the costs while keeping the distance to the ideal portfolio within bounds, i.e.,


min
limits_{
bm{x}} C(
bm{x}_0,
bm{x})

text{subject to}
TO(
bm{x},
tilde{
bm{x}})
leq
gamma,

where $C($
bm{x}_0,
bm{x})
are the costs to trade from 
bm{x}_0
to 
bm{x}
and $TO($
bm{x},
tilde{
bm{x}})
is the turnover distance of the post-trade weights, 
bm{x}
, to the ideal weights, 
tilde{
bm{x}}
. An illustration of this approach is shown in Figure 1. While distances are actually measured in terms of portfolio weights, individual portfolios are represented in terms of risk and return in a 
mu
-
sigma
-chart. The star represents the ideal weight of a hypothetical portfolio strategy and the outer circle around it visualises the area in which no trading is triggered. Only portfolios outside of this area exceed the threshold and need to be traded. The arrow represents the trading to the new weights instead of trading to the ideal weights (dashed arrow). Moreover, the inner circle represents the area into which the trade cost optimisation has to move in a trade-cost-efficient manner. ###### Figure 1: Illustration of a Trade Cost Optimisation

A second animated graphic (Figure 2) gives a visual impression of the trading behaviour of such a trade cost optimisation: The more reduction of the distance to the ideal weight is enforced (represented as a bar in the lower left plot), the more trades need to be executed. The increase in trading costs is shown as a bar in the lower right plot of Figure 2, where the orange part represents fixed costs and the dark blue part variable costs. Fixed costs are for example fees which are charged per traded asset and variable costs can either be explicit fees per traded volume or implicit costs, like bid-ask-spreads, that are proportional to the traded volume. A typical fee structure for a retail investor using an online broker could be a fixed amount per executed order of $5.00 and a variable cost depending on the trade volume, e.g., 0.25% of the traded volume. This exemplary cost structure will be assumed in the following. Moreover, the central part of Figure 2 shows in which assets buys (green) and sells (red) are proposed by the trade cost optimisation. The light green and light red part represent the weight distances from the ideal weights that the trade cost optimisation decided not to trade. The frames show the final post-trade-cost-optimisation portfolio weights. ### 2. Applications: The Cost-Efficient Implementation of a Relative Strength Momentum Strategy To demonstrate the benefits of trade cost optimisation we now show achievable cost reductions for an exemplary systematic portfolio strategy. The strategy is taken from Portfolio Visualizer2, where the relative strength momentum strategy (Faber 2010) is applied for a US investor rotating across asset classes using the following ETFs: SHY, TLT, RWR, IWM, IWB, GLD, EFA, EEM, DBC. We use total return data from Bloomberg for the ETFs and for simplicity assume that all ETFs are accumulating their distributions so that there is no need to manually re-invest cash-flows in between. On a daily basis, we compute yearly returns (252 trading days) for every asset and invest into the top 5 performing assets equally weighted. In addition, we apply a regularisation step on daily ideal portfolio weights in order to reduce noise and to be less sensitive to effects like timing luck3. This regularisation step simply applies a moving-window (21 trading days) sample mean to daily portfolio weights from relative strength momentum indicators. This way portfolio weights cannot dramatically change from one day to the next anymore and hence become more smooth over time. The trade cost optimisation in use relies on two key tuning parameters: ###### Figure 3: Relative Strength Momentum Strategy with Trade Cost Optimisation The turnover distance  delta which needs to be exceeded such that we trigger a trading event and the turnover distance  gamma which is accepted directly after trading. The second parameter  gamma basically determines the tolerance in which the trade cost optimisation is allowed to operate. It controls the precision to which the optimal portfolio weights will be achieved after application of the trade cost optimisation. Setting  gamma=0 enforces the trade cost optimisation to fully trade towards the ideal weights and, e.g.,  gamma = 0.5 cdot delta means that the trade cost optimisation has to reduce the turnover distance to the ideal weight until it is smaller or equal to half the turnover trigger. The trade cost optimisation is doing this in a cost-efficient way. A graphical illustration of the trade cost optimisation mechanism was already presented in Figure 2 for an example trade event. In Figure 3, we present the results for a backtest from Jan-2008 to Dec-2018 with an initial portfolio value of$25,000. Three different implementation strategies are considered: As benchmark case we consider the strategy without any trade cost optimisation (
gamma = 0
, 
delta=0
), i.e., we trade on a daily basis to the ideal weights. The two other strategies use the trade cost optimisation with parameter settings 
gamma = 0.025
, 
delta=0.1
and 
gamma = 0.05
, 
delta=0.15
. In all three cases we assume that fractional dealing is allowed. Results under a no-fractional-dealing condition are presented in Section 3.4.

In the top plot of Figure 3 we can see that the performance of the three settings is almost indistinguishable. Looking at the middle plot in Figure 3 for the cumulative turnover and the lower plot for the cumulative trade count it becomes clear that the trade cost optimisation can reduce trading costs to a huge extent. In particular, aggregate trade count, i.e. the number of executed trades, can be reduced significantly, but trading volume measured in terms of turnover is also reduced. At the same time the overall performance of the portfolio strategy does not change significantly and there is no systematic bias visible. Measured in terms of average daily turnover distance to the ideal weights for 
gamma = 0.025
, 
delta=0.1
the distance is 5.94% while it is 9.59% for 
gamma = 0.05
, 
delta=0.15
. This explains why it is almost impossible to visually distinguish the three cumulative performance graphs shown in the top plot of Figure 3.

The reductions in trading costs are indeed remarkable: The annualised turnover is reduced from 1.96 by 52.64% to 0.93 (by 61.92% to 0.75) for 
gamma = 0.025
, 
delta=0.1
(
gamma = 0.05
, 
delta=0.15
). The cost-efficiency gain is even more pronounced for the annualised trade count, which is reduced from 1,422 to 40 (24) trades per year, i.e., by 97.16% and 98.34% respectively. This means that the studied momentum strategy, which in the backtest has a turnover of almost 200% per year, can be implemented with an average of only 24 trades per year and the resulting portfolio allocations, and hence also the performance, is almost the same as the original strategy.

### 3. Efficient Implementation of a Trade Cost Optimisation

In the following, we will present technical details and mathematical derivations necessary to implement the trade cost optimisation. Readers not interested in those technical details are encouraged to directly jump to either Section 3.4, which contains the backtest results with a no-fractional-dealing condition, or to continue reading with the concluding remarks in Section 4.

Section 3 is organised as follows. In Section 3.1 we introduce measures for the distance of two portfolio weight vectors and explain the relation of those distances to different types of transaction costs. Moreover, we give a mathematical formulation of a no-fractional-dealing condition. Section 3.2 contains the mathematical formulation of the trade cost optimisation problem and in Section 3.3 we provide derivations in order to transform the trade cost optimisation problem into a mixed integer linear program (MILP) for which standard solvers exist. Finally, in Section 3.4 we show simulation results for the previously studied momentum strategy but under consideration of a no-fractional-dealing condition.

### 3.1. Portfolio Weights, Distance Measures, Transaction Costs and Fractional Dealing

For simplicity, we restrict ourselves to the case of an existing portfolio with no deposits and $n$ assets. Our hypothetical investor intends to switch from one portfolio weight vector 
bm{x}_0 {:=} (x_{0,1},
ldots, x_{0,n})'
to another weight vector 
tilde{
bm{x}} {:=} (
tilde{x}_1,
ldots,
tilde{x}_n)'

Measuring the Distance Between Weight Vectors

The distance between two portfolio weight vectors 
bm{x} {:=} (x_1,
ldots,x_n)'
and 
tilde{
bm{x}}
can be measured with different metrics:

1. Trade count ${TC}($
cdot,
cdot)

$TC($
bm{x},
tilde{
bm{x}})
{:=}
sum_{i=1}^{n} 1_{
lbrace |x_i -
tilde{x}_i| > 0
rbrace},

where $1_{A}$ is the indicator function which is equal to one if $A$ is true and zero otherwise.
2. Trading volume $TV($
cdot,
cdot)

$TV($
bm{x},
tilde{
bm{x}}) {:=}
sum_{i=1}^{n} |x_i -
tilde{x}_i|.

1. Turnover $TO($
cdot,
cdot)

$TO($
bm{x},
tilde{
bm{x}}) {:=}
frac{1}{2}
sum_{i=1}^{n} |x_i -
tilde{x}_i|
=
frac{1}{2} TV(
bm{x},
tilde{
bm{x}})

Note that all three distances are symmetric.

Measuring Transaction Costs

Trading from 
bm{x}_0
to 
bm{x}
comes at a cost. W.l.o.g. let the cash asset have index $i=1$. It is used as a residual asset with target weight zero. Different types of costs can be represented in terms of weight distances4.

1. Fixed costs of $c_{fix}$ per trade in an asset:


begin{aligned}
C_{fix}(
bm{x}_0,
bm{x})
&= c_{fix}
sum_{i=2}^{n} 1_{
lbrace |x_i - x_{0,i}| > 0
rbrace}

&= c_{fix}
cdot TC_{1}(
bm{x}_0,
bm{x}).

end{aligned}

1. Variable costs of $c_{var}$ per traded volume:


begin{aligned}
C_{var}(
bm{x}_0,
bm{x})
&= P_{PF}
cdot c_{var}
sum_{i=2}^{n} |x_i - x_{0,i}|

&= P_{PF}
cdot c_{var}
cdot TV_{1}(
bm{x}_0,
bm{x})

&= P_{PF}
cdot 2
cdot c_{var}
cdot TO_{1}(
bm{x}_0,
bm{x}),

end{aligned}

where $P_{PF}$ denotes the total value of the portfolio.
3. Total costs


begin{aligned}
C(
bm{x}_0,
bm{x})
&= C_{fix}(
bm{x}_0,
bm{x}) + C_{var}(
bm{x}_0,
bm{x})

&= c_{fix}
cdot TC_{1}(
bm{x}_0,
bm{x}) +
P_{PF}
cdot 2
cdot c_{var}
cdot TO_{1}(
bm{x}_0,
bm{x}).

end{aligned}

Portfolio Volumes, Weights and Fractional Dealing

For retail investors fractional dealing is often not possible. This implies that trade-cost efficient implementations need to handle integer constraints. If the price of asset $i$ is given by $P_i > 0$ and the number of volumes invested in asset $i$ by ${V_i$
in
mathbb{R}^{+}_{0}}
, the total value of the portfolio can be computed as

$P_{PF} =$
sum_{i=1}^{n} V_{i}
cdot P_{i}

and the portfolio weight for asset $i$ is given by $x_i = V_i$
cdot
frac{P_i}{P_{PF}}
. If fractional dealing is allowed, we have ${V_i$
in
mathbb{R}^{+}_{0}}
, whereas with no-fractional-dealing condition ${V_i$
in
mathbb{N}_{0}}
applies for all assets except cash ($i=2,$
ldots,n
).

### 3.2. The Optimisation Problem: Minimising Transaction Costs

As explained in Section 1, a straightforward setup for a trade cost optimisation is to minimise the total costs under some constraint on the distance to the ideal portfolio weight. A trade event is triggered whenever $TO($
bm{x}_0,
tilde{
bm{x}}) >
delta
. However, if the trading trigger 
delta
is reached, we do not want to fully trade to our ideal weight and spend costs $C($
bm{x}_0,
tilde{
bm{x}}) = C_{fix}(
bm{x}_0,
tilde{
bm{x}}) + C_{var}(
bm{x}_0,
tilde{
bm{x}})
. Instead, the trade cost optimisation should deliver a new weight vector, 
bm{x}
, with minimum trading costs, but sufficiently close to the ideal weight vector (the maximum allowed distance is $TO($
bm{x},
tilde{
bm{x}}) =
gamma
, with 
gamma
in (0,
delta)
).

In mathematical terms, the optimisation problem can be written as


min
limits_{
bm{x}} C_{fix}(
bm{x}_0,
bm{x}) + C_{var}(
bm{x}_0,
bm{x})

text{s.t.}

begin{cases}

sum_{i=1}^{n} x_i = 1

bm{0}_n
leq
bm{x}
leq
bm{1}_n

TO(
bm{x},
tilde{
bm{x}})
leq
gamma

end{cases},

where we use the notation 
bm{0}_n
and 
bm{1}_n
for $(n$
times 1)
column vectors of zeros and ones, respectively. Besides the already discussed turnover restriction, we added the standard portfolio budget constraint and a no-short-selling restriction. For simplicity, we also assume that trading costs are not directly deducted from the portfolio but externally charged, for example on a monthly basis from a reference bank account.

Standard solvers for convex problems are not well suited for such a problem as the $C_{var}($
cdot,
cdot)
and $TO($
cdot,
cdot)
contain the absolute value function and $C_{fix}($
cdot,
cdot)
even the absolute value function within the indicator function. Therefore, we will now show how the optimisation problem can be linearised using an augmentation technique to obtain a mixed integer linear program (MILP) which can be easily solved using standard software packages for numerical optimisation (see for example Roncalli (2013) where such an augmentation is also applied for quadratic programs).

### 3.3. Augmentation of Optimisation Problems to Linearise Distances Measured with the Turnover Metric

For $i=1,$
ldots,n
let $x_{0,i}$ be the current weight invested in asset $i$ and $x_i$ be the future, i.e., after-optimisation weight of asset $i$. By introducing appropriate auxiliary variables $x_i^+$
geq 0
and $x_i^-$
geq 0
for each asset respectively, we can obtain

$x_i = x_{0,i} + x_i^+ - x_i^-.$

Without further constraints, we could find infinitely many combinations of $x_i^+$ and $x_i^-$ that fulfil this equation. However, if we impose the additional constraint $x_i^+$
cdot x_i^- = 0
, i.e., at least one of the variables $x_i^+$ or $x_i^-$ is necessarily equal to zero, $x_i^+$ and $x_i^-$ are uniquely defined and we can write

$|x_i - x_{0,i}| = |x_i^+ - x_i^-| = x_i^+ + x_i^-.$

$x_{i}^{+}$ can then be interpreted as the excess weight of the final weight $x_i$ with regards to the initial portfolio weight $x_{0,i}$. In other words: It measures how much the individual asset weight is increased. Similarly, $x_{i}^{-}$ represents a decrease in the weight of asset $i$.

We can now re-write the variable costs as a linear function in the vectors ${$
bm{x}^+} {:=} (x_1^{+},
ldots, x_n^{+})'
and ${$
bm{x}^-} {:=} (x_1^{-},
ldots, x_n^{-})'
as


begin{aligned}
C_{var}(
bm{x}_0,
bm{x})
&= P_{PF}
cdot 2
cdot c_{var}
cdot TO_{1}(
bm{x}_0,
bm{x})

&= P_{PF}
cdot 2
cdot c_{var}
sum_{i=2}^{n} |x_i - x_{0,i}|

&= P_{PF}
cdot 2
cdot c_{var}

sum_{i=2}^{n} (x_i^+ + x_i^-).

end{aligned}

In a similar way, we also linearise the turnover distance between 
bm{x}
and 
tilde{
bm{x}}
by enforcing the identity

$x_i =$
tilde{x}_i +
tilde{x}_i^{+} -
tilde{x}_i^-,

with the auxiliary variables 
tilde{x}_i^+
geq 0
and 
tilde{x}_i^-
geq 0
. Under the condition 
tilde{x}_i^+
cdot
tilde{x}_i^- = 0
, we get

$|x_i -$
tilde{x}_i| =
tilde{x}_i^+ +
tilde{x}_i^-.

We can now re-write the optimisation constraint $TO($
bm{x},
tilde{
bm{x}})
leq
gamma
as a linear constraint in the vectors ${$
tilde{
bm{x}}^+} {:=} (
tilde{x}_1^{+},
ldots,
tilde{x}_n^{+})'
and ${$
tilde{
bm{x}}^-} {:=} (
tilde{x}_1^{-},
ldots,
tilde{x}_n^{-})'

$TO($
bm{x},
tilde{
bm{x}})
leq
gamma

Leftrightarrow

frac{1}{2}
sum_{i=1}^{n}
tilde{x}_i^+ +
tilde{x}_i^-
leq
gamma.

The fixed costs additionally contain an indicator function. Therefore, we need to add further binary auxiliary variables $z_i$
in
{0,1
}
, for $2$
leq i
leq n
. Via inequality constraints, we will force the binary variable $z_i$ to be an indicator variable which is equal to one if and only if we trade asset $i$. Let 
alpha_0 = 10^{-5}
, 
alpha_1 = 1
and consider the inequality


begin{aligned}
z_i
cdot
alpha_0
leq |x_i - x_{0,i}|
leq z_i
cdot
alpha_1,
&&i=2,
ldots,n.

end{aligned}

If the inequality is fulfilled, it guarantees that $z_i = 0$ when $|x_i - x_{0,i}| = 0$ and $z_i=1$ when $|x_i - x_{0,i}|$
geq
alpha_{0}
. Like the variable costs, we can re-write these constraints in terms of 
bm{x}^+
and 
bm{x}^-
as linear functions. Moreover, we can now also write the fixed costs as a linear function in 
bm{z} {:=} (z_2,
ldots, z_n)'


begin{aligned}
C_{fix}(
bm{x}_0,
bm{x})
&= c_{fix}
cdot TC_{1}(
bm{x}_0,
bm{x})
= c_{fix}
sum_{i=2}^{n} 1_{
lbrace |x_i - x_{0,i}| > 0
rbrace}

&
stackrel{(
star)}{=} c_{fix}
sum_{i=2}^{n} 1_{
lbrace |x_i - x_{0,i}|
geq
alpha_0
rbrace}
= c_{fix}
sum_{i=2}^{n} 1_{
lbrace z_{i} > 0
rbrace}
= c_{fix}
sum_{i=2}^{n} z_i.

end{aligned}

Note that, due to technical reasons, we have to assume a minimum trade size per asset of 
alpha_0 = 10^{-5}
such that $($
star)
holds, i.e., either $|x_i - x_{0,i}|$
geq
alpha_0
or $|x_i - x_{0,i}| = 0$.

Putting things together, we obtain the optimisation problem


begin{aligned}
&
min
limits_{
bm{y}}
;
c_{fix}
sum_{i=2}^{n} z_i
+ P_{PF}
cdot c_{var}
sum_{i=2}^{n} (x_i^+ + x_i^-)

&
text{s.t.}

begin{cases}

sum_{i=1}^{n} x_i = 1

bm{x} =
bm{x}_0 +
bm{x}^+ -
bm{x}^-

bm{x} =
tilde{
bm{x}} +
tilde{
bm{x}}^+ -
tilde{
bm{x}}^-

bm{x}^+
odot
bm{x}^- =
bm{0}_n

tilde{
bm{x}}^+
odot
tilde{
bm{x}}^- =
bm{0}_n

bm{0}_n
leq
bm{x},
bm{x}^+,
bm{x}^-
leq
bm{1}_n

frac{1}{2}
sum_{i=1}^{n}
tilde{x}_i^+ +
tilde{x}_i^-
leq
gamma

x_{i}^{+} + x_{i}^{-}
geq
alpha_{0}
cdot z_{i},
leq i
leq n

x_{i}^{+} + x_{i}^{-}
leq
alpha_{1}
cdot z_{i},
leq i
leq n

bm{z}
in
{0,1
}^{n-1}

end{cases},

end{aligned}

where 
bm{y} {:=} ({
bm{x}^+}', {
bm{x}^-}', {
tilde{
bm{x}}^+}', {
tilde{
bm{x}}^-}',
bm{z}')'
is a $((5$
cdot n - 1)
times 1)
vector and 
odot

The Non-Linear Constraints $x_i^+$
cdot x_i^- = 0
and 
tilde{x}_i^+
cdot
tilde{x}_i^- = 0

The non-linear constraints $x_i^+$
cdot x_i^- = 0
and 
tilde{x}_i^+
cdot
tilde{x}_i^- = 0
can be indirectly integrated. Lets skip the non-linear constraints for a moment. Assume $({$
bm{x}^+}', {
bm{x}^-}', {
tilde{
bm{x}}^+}', {
tilde{
bm{x}}^-}',
bm{z}')'
solves the new (without ${x_i^+$
cdot x_i^-} = 0
and ${$
tilde{x}_i^+
cdot
tilde{x}_i^-} = 0
constraints) optimisation problem. Then w.l.o.g.


begin{aligned}
&
exists j
in
lbrace 1,
ldots,n
rbrace: x_j^+
cdot x_j^-
neq 0

&
Rightarrow x_j^+
cdot x_j^- > 0

&
Rightarrow x_j^+ > 0
wedge

end{aligned}

Define the new variables (for $i$
in
lbrace 1,
ldots, n
rbrace
):


begin{aligned}
y_i^+ {:=}
begin{cases}
x_i^+ - x_i^-, & x_i^+
geq x_i^-

0, & x_i^+
leq x_i^-

end{cases}

text{and}
y_i^- {:=}
begin{cases}
x_i^- - x_i^+, & x_i^-
geq x_i^+

0, & x_i^-
leq x_i^+

end{cases}.

end{aligned}

It holds


begin{aligned}
y_i &{:=} x_{0,i} + y_i^+ - y_i^-

&= x_{0,i} + x_i^+ - x_i^- = x_i,

end{aligned}

with $y_i^+$
cdot y_i^- = 0
for $1$
leq i
leq n
. Similarly, we can construct variables 
tilde{y}_i^+
and 
tilde{y}_i^-
with $y_i {:=}$
tilde{x}_i +
tilde{y}_i^+ -
tilde{y}_i^- =
tilde{x}_i +
tilde{x}_i^+ -
tilde{x}_i^- = x_i
and 
tilde{y}_i^+
cdot
tilde{y}_i^- = 0
. At the same time it holds


begin{aligned}

sum_{i=1}^{n} |y_i -
tilde{x}_{i}| &=

sum_{i=1}^{n}
tilde{y}_i^+ +
tilde{y}_i^-

&=
sum_{i=1}^{n}
begin{cases}

tilde{x}_i^+ -
tilde{x}_i^-, &
tilde{x}_i^+ -
tilde{x}_i^-
geq 0

tilde{x}_i^- -
tilde{x}_i^+, &
tilde{x}_i^- -
tilde{x}_i^+
geq 0

end{cases}

&
leq
sum_{i=1}^{n}
tilde{x}_i^+ +
tilde{x}_i^-

leq 2
cdot
gamma,

end{aligned}

i.e., $({$
bm{y}^+}', {
bm{y}^-}', {
tilde{
bm{y}}^+}', {
tilde{
bm{y}}^-}',
bm{z}')'
solves the original problem, including the non-linear constraints $y_i^+$
cdot y_i^- = 0
and 
tilde{y}_i^+
cdot
tilde{y}_i^- = 0
as well as the turnover maximum constraint.

The Trade Cost Optimisation Problem as Mixed Integer Linear Program (MILP)

Having shown how to get rid of the non-linear constraint, we can write our optimisation problem as a mixed integer linear program (MILP) with linear (in-)equality constraints


min
limits_{
bm{y}}
;

bm{f}'
bm{y}

text{s.t.}

begin{cases}

bm{A}
bm{y}
leq
bm{b}

bm{G}
bm{y} =
bm{h}

bm{z}
in
{0,1
}^{n-1}

end{cases},

with appropriately selected matrices and vectors 
bm{f}
, 
bm{A}
, 
bm{b}
, 
bm{G}
and 
bm{h}
.

Integrating a No-Fractional-Dealing Condition into the Trade Cost Optimisation Problem

Using the identity $x_i = V_i$
cdot
frac{P_i}{P_{PF}}
, we can obtain post-trade volumes and corresponding buy and sell volumes as


begin{aligned}
V_i &=
frac{P_{PF}}{P_i}
cdot x_i

&=
frac{P_{PF}}{P_i} x_{0,i} +
frac{P_{PF}}{P_i} x_i^+ -
frac{P_{PF}}{P_i} x_i^-

&=: V_{0,i} + V_i^+ - V_i^-.

end{aligned}

Defining 
tilde{
bm{y}} {:=} ({
bm{V}^+}', {
bm{V}^-}', {
tilde{
bm{y}}^+}', {
tilde{
bm{y}}^-}',
bm{z}')'
and 
tilde{
bm{P}} {:=} (
frac{P_1}{P_{PF}},
ldots,
frac{P_n}{P_{PF}})'
, we obtain the trade cost optimisation with no-fractional-dealing condition as


min
limits_{
tilde{
bm{y}}}
;

tilde{
bm{f}}'
tilde{
bm{y}}

text{s.t.}

begin{cases}

tilde{
bm{A}}
tilde{
bm{y}}
leq
bm{b}

tilde{
bm{G}}
tilde{
bm{y}} =
bm{h}

bm{z}
in
{0,1
}^{n-1}

V_i^+, V_i^-
in
mathbb{N}_{0},
leq i
leq n

end{cases},

where 
tilde{
bm{A}} {:=} (
bm{1}_{r_{
bm{A}}}
otimes
bm{Q}')
odot
bm{A}
and 
tilde{
bm{G}} {:=} (
bm{1}_{r_{
bm{G}}}
otimes
bm{Q}')
odot
bm{G}
, with 
bm{Q} {:=} (
tilde{
bm{P}}',
tilde{
bm{P}}',
bm{1}_{3
cdot n-1}')'
. Moreover, $r_{$
bm{A}}
, $r_{$
bm{G}}
denote the number of rows of 
bm{A}
and 
bm{G}
, respectively and 
otimes
denotes the Kronecker product.

### 3.4. The Momentum Strategy with a No-Fractional-Dealing Condition

We rerun our momentum strategy backtest to see the impact of a no-fractional-dealing condition applied to all nine ETFs. Table 1 summarises the results. We can see that, even with a no-fractional-dealing condition, the trade cost optimisation is capable of keeping the average daily turnover distances to the ideal portfolio on a similar level. At the same time the annual turnovers are almost unchanged, but we observe mildly increasing trade costs in terms of an increase in the annual trade counts. This means that even under the more complex integer constraint of a no-fractional-dealing condition, the trade cost optimisation approach allows us to implement the momentum strategy in a cost-efficient way while keeping the distance to the ideal portfolio within certain bounds.

Parameters & metrics

Setting 1 with fractional dealing

Setting 1 without fractional dealing

Setting 2 with fractional dealing

Setting 2 without fractional dealing

$($
gamma,
delta)

$(0, 0)$

$(0.025, 0.1)$

$(0.025, 0.1)$

$(0.05, 0.15)$

$(0.05, 0.15)$

Average $TO($
bm{x},
tilde{
bm{x}})
in %

0.00

5.94

6.01

9.59

9.37

Annualised turnover

1.96

0.93

0.98

0.75

0.73

1422.25

40.33

51.75

23.67

27.42

### 4. Concluding Remarks

In this blog article we introduced an efficient and flexible trade cost optimisation approach. It can be combined with every portfolio optimisation strategy in a two-step setup. Tuning of the optimisation parameters allows customisation of the trade cost optimisation to individual cost structures and requirements with regards to proximity of realised weights to ideal weights.

We demonstrated the benefits of the presented trade cost optimisation approach in a backtest by showing that a momentum strategy with a yearly turnover of 200% can be implemented with an average of only 24 trades per year. The main challenge in the technical implementation of the trade cost optimisation is the reformulation of the optimisation problem as a mixed integer linear program (MILP). Our derivation of a MILP representation allows a straightforward implementation in every standard software package for numerical optimisation. ### References

Faber, M. (2010), Relative Strength Strategies for Investing, Available at SSRN: http://dx.doi.org/10.2139/ssrn.1585517.

Hoffstein, C., Sibears, D. J. and Faber, N. (2019), Rebalance Timing Luck: The Difference Between Hired and Fired, The Journal of Index Investing, https://doi.org/10.3905/jii.2019.1.070.

Mansini, R., Ogryczak, W. and Speranza, M. G. (2014), Twenty years of linear programming based portfolio optimization, European Journal of Operational Research, 234 (2), pp. 518-535.

Roncalli, T. (2013), Introduction to Risk Parity and Budgeting, Chapman & Hall/CRC Financial Mathematics Series.

1: As an alternative, we could also use a calendar-based trading trigger, like monthly or weekly.
2: https://www.portfoliovisualizer.com/examples
3: See Hoffstein, Sibears and Faber (2019) and https://blog.thinknewfound.com/2018/01/quantifying-timing-luck/ for a discussion of timing luck.
4: We use the notation $TC_{1}($
cdot,
cdot)
and $TV_{1}($
cdot,
cdot)
, etc., if the first index (w.l.o.g. cash) is skipped in the distance measure.

Disclaimer – The views and opinions expressed in this blog are those of the author and do not necessarily reflect the views of Scalable Capital GmbH, its subsidiaries or its employees ("Scalable Capital", "we"). The content is provided to you solely for informational purposes and does not constitute, and should not be construed as, an offer or a solicitation of an offer, advice or recommendation to purchase any securities or other financial instruments. Any representation is for illustrative purposes only and is not representative of any Scalable Capital product or investment strategy. The academic concepts set forth herein are derived from sources believed by the author and Scalable Capital to be reliable and have no connection with the financial services offered by Scalable Capital. Past performance and forward-looking statements are not reliable indicators of future performance. The return may rise or fall as a result of currency fluctuations. Please refer to our risk information.

Risk Disclaimer – There are risks associated with investing. The value of your investment may fall or rise. Losses of the capital invested may occur. Past performance, simulations or forecasts are not a reliable indicator of future performance. We do not provide investment, legal and/or tax advice. Should this website contain information on the capital market, financial instruments and/or other topics relevant to investment, this information is intended solely as a general explanation of the investment services provided by companies in our group. Please also read our risk information and terms of use. Dr. Malte Kurz
QUANTITATIVE STRATEGIST
Malte works as Quantitative Researcher at Scalable Capital and is a Research Fellow of the Center for Quantitative Risk Analysis at the Ludwig-Maximilians-Universität (LMU) Munich. He studied Mathematical Finance at the University of Konstanz and Statistics at the LMU. He previously worked as a research and teaching assistant at the Chair of Financial Econometrics (LMU). In his PhD thesis he developed and analyzed methods for high-dimensional dependence modelling with applications in financial econometrics. Malte has published peer-reviewed research articles and regularly serves as a referee for academic journals.