Trade Cost Optimisation

8 May 2019  |  Dr. Malte Kurz
title pic trade cost opt bars
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(,)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][0,1] (see Section 3 for a formal definition). In the following, we will use TO(x0,x~)δTO(
bm{x}_0,
tilde{
bm{x}})
leq
delta
as the trading trigger. This means that we trigger a trading event whenever the distance of the current weight, x0
bm{x}_0
, to the ideal weight, x~
tilde{
bm{x}}
, is larger than δ(0,1)
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, x~
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 x
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 γ(0,δ)
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.,

minxC(x0,x)subject toTO(x,x~)γ,
min
limits_{
bm{x}} C(
bm{x}_0,
bm{x})

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

where C(x0,x)C(
bm{x}_0,
bm{x})
are the costs to trade from x0
bm{x}_0
to x
bm{x}
and TO(x,x~)TO(
bm{x},
tilde{
bm{x}})
is the turnover distance of the post-trade weights, x
bm{x}
, to the ideal weights, x~
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

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:


Figure 2: Visualization of the Trade Cost Optimisation

Figure 2: Visualisation of the 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

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 γ=0
gamma=0
enforces the trade cost optimisation to fully trade towards the ideal weights and, e.g., γ=0.5δ
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 (γ=0
gamma = 0
, δ=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 γ=0.025
gamma = 0.025
, δ=0.1
delta=0.1
and γ=0.05
gamma = 0.05
, δ=0.15
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 γ=0.025
gamma = 0.025
, δ=0.1
delta=0.1
the distance is 5.94% while it is 9.59% for γ=0.05
gamma = 0.05
, δ=0.15
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 γ=0.025
gamma = 0.025
, δ=0.1
delta=0.1
(γ=0.05
gamma = 0.05
, δ=0.15
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 nn assets. Our hypothetical investor intends to switch from one portfolio weight vector x0:=(x0,1,,x0,n)
bm{x}_0 {:=} (x_{0,1},
ldots, x_{0,n})'
to another weight vector x~:=(x~1,,x~n)
tilde{
bm{x}} {:=} (
tilde{x}_1,
ldots,
tilde{x}_n)'
in a trade-cost-efficient manner.

Measuring the Distance Between Weight Vectors

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

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

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

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

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

  1. Turnover TO(,)TO(
    cdot,
    cdot)

TO(x,x~):=12i=1nxix~i=12TV(x,x~)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 x0
bm{x}_0
to x
bm{x}
comes at a cost. W.l.o.g. let the cash asset have index i=1i=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 cfixc_{fix} per trade in an asset:

Cfix(x0,x)=cfixi=2n1{xix0,i>0}=cfixTC1(x0,x).
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 cvarc_{var} per traded volume:

Cvar(x0,x)=PPFcvari=2nxix0,i=PPFcvarTV1(x0,x)=PPF2cvarTO1(x0,x),
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 PPFP_{PF} denotes the total value of the portfolio.
3. Total costs

C(x0,x)=Cfix(x0,x)+Cvar(x0,x)=cfixTC1(x0,x)+PPF2cvarTO1(x0,x).
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 ii is given by Pi>0P_i > 0 and the number of volumes invested in asset ii by ViR0+{V_i
in
mathbb{R}^{+}_{0}}
, the total value of the portfolio can be computed as

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

and the portfolio weight for asset ii is given by xi=ViPiPPFx_i = V_i
cdot
frac{P_i}{P_{PF}}
. If fractional dealing is allowed, we have ViR0+{V_i
in
mathbb{R}^{+}_{0}}
, whereas with no-fractional-dealing condition ViN0{V_i
in
mathbb{N}_{0}}
applies for all assets except cash (i=2,,ni=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(x0,x~)>δ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(x0,x~)=Cfix(x0,x~)+Cvar(x0,x~)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, x
bm{x}
, with minimum trading costs, but sufficiently close to the ideal weight vector (the maximum allowed distance is TO(x,x~)=γTO(
bm{x},
tilde{
bm{x}}) =
gamma
, with γ(0,δ)
gamma
in (0,
delta)
).

In mathematical terms, the optimisation problem can be written as

minxCfix(x0,x)+Cvar(x0,x)s.t.{i=1nxi=10nx1nTO(x,x~)γ,
min
limits_{
bm{x}} C_{fix}(
bm{x}_0,
bm{x}) + C_{var}(
bm{x}_0,
bm{x})

qquad
text{s.t.}
qquad

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 0n
bm{0}_n
and 1n
bm{1}_n
for (n×1)(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 Cvar(,)C_{var}(
cdot,
cdot)
and TO(,)TO(
cdot,
cdot)
contain the absolute value function and Cfix(,)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,,ni=1,
ldots,n
let x0,ix_{0,i} be the current weight invested in asset ii and xix_i be the future, i.e., after-optimisation weight of asset ii. By introducing appropriate auxiliary variables xi+0x_i^+
geq 0
and xi0x_i^-
geq 0
for each asset respectively, we can obtain

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

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

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

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

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

Cvar(x0,x)=PPF2cvarTO1(x0,x)=PPF2cvari=2nxix0,i=PPF2cvari=2n(xi++xi).
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 x
bm{x}
and x~
tilde{
bm{x}}
by enforcing the identity

xi=x~i+x~i+x~i,x_i =
tilde{x}_i +
tilde{x}_i^{+} -
tilde{x}_i^-,

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

xix~i=x~i++x~i.|x_i -
tilde{x}_i| =
tilde{x}_i^+ +
tilde{x}_i^-.

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

TO(x,x~)γ12i=1nx~i++x~iγ.TO(
bm{x},
tilde{
bm{x}})
leq
gamma

quad
Leftrightarrow
quad

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 zi{0,1}z_i
in
{0,1
}
, for 2in2
leq i
leq n
. Via inequality constraints, we will force the binary variable ziz_i to be an indicator variable which is equal to one if and only if we trade asset ii. Let α0=105
alpha_0 = 10^{-5}
, α1=1
alpha_1 = 1
and consider the inequality

ziα0xix0,iziα1,i=2,,n.
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 zi=0z_i = 0 when xix0,i=0|x_i - x_{0,i}| = 0 and zi=1z_i=1 when xix0,iα0|x_i - x_{0,i}|
geq
alpha_{0}
. Like the variable costs, we can re-write these constraints in terms of x+
bm{x}^+
and x
bm{x}^-
as linear functions. Moreover, we can now also write the fixed costs as a linear function in z:=(z2,,zn)
bm{z} {:=} (z_2,
ldots, z_n)'

Cfix(x0,x)=cfixTC1(x0,x)=cfixi=2n1{xix0,i>0}=()cfixi=2n1{xix0,iα0}=cfixi=2n1{zi>0}=cfixi=2nzi.
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 α0=105
alpha_0 = 10^{-5}
such that ()(
star)
holds, i.e., either xix0,iα0|x_i - x_{0,i}|
geq
alpha_0
or xix0,i=0|x_i - x_{0,i}| = 0.

Putting things together, we obtain the optimisation problem

miny  cfixi=2nzi+PPFcvari=2n(xi++xi)s.t.{i=1nxi=1x=x0+x+xx=x~+x~+x~x+x=0nx~+x~=0n0nx,x+,x1n12i=1nx~i++x~iγxi++xiα0zi,2inxi++xiα1zi,2inz{0,1}n1,
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.}
qquad

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},
quad 2
leq i
leq n


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



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

end{cases},

end{aligned}

where y:=(x+,x,x~+,x~,z)
bm{y} {:=} ({
bm{x}^+}', {
bm{x}^-}', {
tilde{
bm{x}}^+}', {
tilde{
bm{x}}^-}',
bm{z}')'
is a ((5n1)×1)((5
cdot n - 1)
times 1)
vector and
odot
denotes the Hadamard product.

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

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

j{1,,n}:xj+xj0xj+xj>0xj+>0xj>0.
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
quad
wedge
quad x_j^- > 0.

end{aligned}

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

yi+:={xi+xi,xi+xi0,xi+xiandyi:={xixi+,xixi+0,xixi+.
begin{aligned}
y_i^+ {:=}
begin{cases}
x_i^+ - x_i^-, & x_i^+
geq x_i^-


0, & x_i^+
leq x_i^-

end{cases}

quad
text{and}
quad
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

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


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

end{aligned}

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

i=1nyix~i=i=1ny~i++y~i=i=1n{x~i+x~i,x~i+x~i0x~ix~i+,x~ix~i+0i=1nx~i++x~i2γ,
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., (y+,y,y~+,y~,z)({
bm{y}^+}', {
bm{y}^-}', {
tilde{
bm{y}}^+}', {
tilde{
bm{y}}^-}',
bm{z}')'
solves the original problem, including the non-linear constraints yi+yi=0y_i^+
cdot y_i^- = 0
and y~i+y~i=0
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

miny  fys.t.{AybGy=hz{0,1}n1,
min
limits_{
bm{y}}
;

bm{f}'
bm{y}

qquad
text{s.t.}
qquad

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 f
bm{f}
, A
bm{A}
, b
bm{b}
, G
bm{G}
and h
bm{h}
.

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

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

Vi=PPFPixi=PPFPix0,i+PPFPixi+PPFPixi=:V0,i+Vi+Vi.
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 y~:=(V+,V,y~+,y~,z)
tilde{
bm{y}} {:=} ({
bm{V}^+}', {
bm{V}^-}', {
tilde{
bm{y}}^+}', {
tilde{
bm{y}}^-}',
bm{z}')'
and P~:=(P1PPF,,PnPPF)
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

miny~  f~y~s.t.{A~y~bG~y~=hz{0,1}n1Vi+,ViN0,2in,
min
limits_{
tilde{
bm{y}}}
;

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

qquad
text{s.t.}
qquad

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},
quad 2
leq i
leq n

end{cases},

where A~:=(1rAQ)A
tilde{
bm{A}} {:=} (
bm{1}_{r_{
bm{A}}}
otimes
bm{Q}')
odot
bm{A}
and G~:=(1rGQ)G
tilde{
bm{G}} {:=} (
bm{1}_{r_{
bm{G}}}
otimes
bm{Q}')
odot
bm{G}
, with Q:=(P~,P~,13n1)
bm{Q} {:=} (
tilde{
bm{P}}',
tilde{
bm{P}}',
bm{1}_{3
cdot n-1}')'
. Moreover, rAr_{
bm{A}}
, rGr_{
bm{G}}
denote the number of rows of A
bm{A}
and G
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 No trade cost optimisation 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, 0)

(0.025,0.1)(0.025, 0.1)

(0.025,0.1)(0.025, 0.1)

(0.05,0.15)(0.05, 0.15)

(0.05,0.15)(0.05, 0.15)

Average TO(x,x~)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

Annualised trade count

1422.25

40.33

51.75

23.67

27.42

Table 1: Relative Strength Momentum Strategy with Trade Cost Optimisation

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.

Turquoise Line

References


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


Hoffstein, C., Sibears, J. and Faber, N. (2018), Rebalance Timing Luck: The Difference Between Hired and Fired, Journal of Portfolio Management (forthcoming), Available at SSRN: http://dx.doi.org/10.2139/ssrn.3319045.


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 https://blog.thinknewfound.com/2018/01/quantifying-timing-luck/ for a discussion of timing luck.
4: We use the notation TC1(,)TC_{1}(
cdot,
cdot)
and TV1(,)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 Warning – With investment comes risk. The value of your investment can go down as well as up and you may get back less than you invest. Past performance or future projections are not indicative of future performance. We do not provide any investment, legal and/or tax advice. If this website contains information regarding capital markets, financial instruments and/or other topics relevant for investments of assets, the exclusive purpose of this information is to give general guidance on investment management services provided by members of our group. Please note our Risk Warning and the Website Terms.

team-malte-kurz-de
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.