arxiv:1709.07527v2 [q-fin.pm] 25 apr 2018 · a posteriori multi-stage optimal trading under...

25
A posteriori multi-stage optimal trading under transaction costs and a diversification constraint Mogens Graf Plessen * and Alberto BemporadIMT School for Advanced Studies Lucca, Piazza S. Francesco 19, 55100 Lucca, Italy This paper presents a simple method for a posteriori (historical) multi-variate multi-stage optimal trading under transaction costs and a diversification constraint. Starting from a given amount of money in some currency, we analyze the stage-wise optimal allocation over a time horizon with potential investments in multiple currencies and various assets. Three variants are discussed, including unconstrained trading frequency, a fixed number of total admissable trades, and the waiting of a specific time-period after every executed trade until the next trade. The developed methods are based on efficient graph generation and consequent graph search, and are evaluated quantitatively on real-world data. The fundamental motiva- tion of this work is preparatory labeling of financial time-series data for supervised machine learning. Keywords : A posteriori optimal trading, Transaction costs, Diversification constraint, Multi-variate trading, Multi-stage trading, Labeling of financial time-series data. 1. Introduction Algorithmic assistance to traders and portfolio managers has become standard practice. It can be distinguished between algorithmic trading, i.e., fully automated high- or low-frequency trading, and algorithmic screening or semi-automated high- or low-frequency trading with computer pro- grams providing recommendations to the human trader. Both algorithmic trading and screening are fundamentally based on predictions of future developments. Predictions may be made based on, for example, financial accountancy, technical chart analysis, global macroeconomic analysis, news, sentiments and combinations thereof. There exists a plethora of literature on financial times-series forecasting. For methods based on support vector machines, see, for example, Tay, F.E. and Cao * Corresponding author. Email: [email protected] 1 arXiv:1709.07527v2 [q-fin.PM] 25 Apr 2018

Upload: others

Post on 24-Jul-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: arXiv:1709.07527v2 [q-fin.PM] 25 Apr 2018 · A posteriori multi-stage optimal trading under transaction costs and a diversi cation constraint ... we analyze the stage-wise optimal

A posteriori multi-stage optimal trading under

transaction costs and a diversification constraint

Mogens Graf Plessen∗† and Alberto Bemporad†

†IMT School for Advanced Studies Lucca, Piazza S. Francesco 19, 55100 Lucca, Italy

This paper presents a simple method for a posteriori (historical) multi-variate multi-stage optimal trading

under transaction costs and a diversification constraint. Starting from a given amount of money in some

currency, we analyze the stage-wise optimal allocation over a time horizon with potential investments

in multiple currencies and various assets. Three variants are discussed, including unconstrained trading

frequency, a fixed number of total admissable trades, and the waiting of a specific time-period after every

executed trade until the next trade. The developed methods are based on efficient graph generation and

consequent graph search, and are evaluated quantitatively on real-world data. The fundamental motiva-

tion of this work is preparatory labeling of financial time-series data for supervised machine learning.

Keywords: A posteriori optimal trading, Transaction costs, Diversification constraint, Multi-variate

trading, Multi-stage trading, Labeling of financial time-series data.

1. Introduction

Algorithmic assistance to traders and portfolio managers has become standard practice. It can

be distinguished between algorithmic trading, i.e., fully automated high- or low-frequency trading,

and algorithmic screening or semi-automated high- or low-frequency trading with computer pro-

grams providing recommendations to the human trader. Both algorithmic trading and screening

are fundamentally based on predictions of future developments. Predictions may be made based on,

for example, financial accountancy, technical chart analysis, global macroeconomic analysis, news,

sentiments and combinations thereof. There exists a plethora of literature on financial times-series

forecasting. For methods based on support vector machines, see, for example, Tay, F.E. and Cao

∗Corresponding author. Email: [email protected]

arX

iv:1

709.

0752

7v2

[q-

fin.

PM]

25

Apr

201

8

Page 2: arXiv:1709.07527v2 [q-fin.PM] 25 Apr 2018 · A posteriori multi-stage optimal trading under transaction costs and a diversi cation constraint ... we analyze the stage-wise optimal

[2001], Kim, K. [2003], Van Gestel, T. et al. [2001], and Chowdhury et al. [2018]. In general, in-

fluential factors on trading decisions are trading frequency, targeted time horizons, performance

expectations, asset choices, foreign exchange rates, transaction costs and risk-management, for ex-

ample, in the form of investment diversification. Our paper belongs to the class of technical chart

analysis. The data on which the analysis is based are daily adjusted closing-prices of various curren-

cies and assets. Short-selling, borrowing of money, and the trading of derivatives are not treated,

eventhough the presented methodologies can be extended to include them.

The motivation and contribution of this paper is threefold: i) the development of a simple al-

gorithm for a posteriori (historical) multi-variate multi-stage optimal trading under transaction

costs and a diversification constraint, including the discussion of unconstrained trading frequency,

a fixed number of total admissable trades, and the waiting of a specific time-period after every

executed trade until the next trade; ii) the quantification of the effects of transaction costs on a

posteriori optimal trading evaluated on real-world data; and finally iii) the preparatory labeling of

financial time-series data for supervised machine learning.

This paper is related most closely to the work of Boyarshinov, V. and Magdon-Ismail [2010], who

discuss a dynamic programming solution to the optimal investment in either one stock or one bond

under consideration of unconstrained trading frequency, and a bound on the admissable number

of trades. Additionally, a method for optimization of Sterling and Sharpe ratio are presented. No

real-world data analysis is conducted though. Additional differences are our discussion of a diversi-

fication constraint, the constraint of introducing a waiting period after every executed trade until

the next trade, and a synchronous trading constraint. Furthermore, we introduce a heuristic for

each of the constrained optimal investment problems (with a bound on the admissable number

of trades and a waiting period constraint), thereby reducing the computational complexity of the

methods while not compromising optimality of the resulting solution. For an overview of measures

to reduce risk by the introduction of various constraints, for example, on the drawdown probability

or shortselling, see Lobo, M.S. et al. [2007] where one-step ahead optimization is conducted, impor-

tantly, based on estimates of one-step ahead returns and covariance matrices of a set of risky assets.

In contrast this papers is concerned about multi-stage optimization and historical optimal trading

with hindsight. The mathematical approaches therefore differ significantly (convex optimization

vs. graph search). Optimal trading based on stochastic models, usually stochastic differential equa-

tions (SDEs), and the consideration of fixed and/or proportional transaction costs is treated, for

example, in Altarovici, A. et al. [2015], Lo, A.W. et al. [2001], Morton, A.J. and Pliska [1995]

and Korn, R. [1998]. In contrast, this paper is data-based only, i.e., without consideration of any

2

Page 3: arXiv:1709.07527v2 [q-fin.PM] 25 Apr 2018 · A posteriori multi-stage optimal trading under transaction costs and a diversi cation constraint ... we analyze the stage-wise optimal

mathematical model explaining the generation of this data. For a discussion about the existence

of trends in financial time series, see Fliess, M. and Join [2009]. For the general discussion of tran-

scation cost analysis (TCA), see Gomes and Waelbroeck [2010], and further Kissell [2013], Kissell

[2008] and Kissell [2006] for a discussion about how TCA can be used by portfolio managers to

improve performance and the development of a framework for pre-, intra- and post-trade analysis.

The remainder of this paper is organized as follows. Section 2 discusses transition dynamics

modeling and introduces notation. Multi-stage optimization without a diversification constraint

is treated in Section 3, whereas Section 4 includes a diversification constraint. Section 5 presents

numerical examples based on real-world data, before concluding with Section 6.

2. One-stage modeling of transition dynamics

2.1. Notation

Let time index t ∈ Z+ be associated with the trading period Ts, such that trading instants are

described as tTs, whereby Ts may typically be, for example, one week, one day, or less (for intraday

trading). The system state zt at time t is defined as an eight-dimensional vector of mixed integer

and real-valued quantities,

zt =[it kt jt m

ctt nt w

0t dt ct

], (1)

where it ∈ I = (INc∪ INa

) denotes investment identification numbers partitioned into Nc

currencies and Na different risky non-currency assets, such that INc= {0, 1, . . . , Nc − 1} and

INa= {Nc, . . . , Nc + Na − 1}. For ease of reference, in the following, we lump currencies and

non-currency assets in the term asset and only distinguish when context-necessary. The integer

number of conducted trades along an investment trajectory shall be denoted by kt ∈ Z, whereby

an investment trajectory is here defined as a sequence of states zt, t = 0, 1, . . . , Nt, where Nt is the

time horizon length. Let jt denote the investment identification number preceding it at time t− 1

(parent node), i.e., jt = it−1. We define mctt ∈ R+ as the real-valued and positive cash position

(liquidity) held in the currency identified by ct ∈ INc. The number nt ∈ Z+ indicates the number of

non-currency assets held. The current wealth, composed of cash position and non-currency asset,

is denoted by w0t and shall always be in monetary units EUR. Euro is considered as our reference

currency and shall throughout this paper be identified by it = 0. The integer number of time sam-

ples since the last trade is defined by dt ∈ Z+. The (unitless) foreign exchange (fx) rate xc1,c2t for

two currencies c1 ∈ INcand c2 ∈ INc

is defined as xc1,c2t such that mc2t = mc1

t xc1,c2t . Thus, mc1

t and

3

Page 4: arXiv:1709.07527v2 [q-fin.PM] 25 Apr 2018 · A posteriori multi-stage optimal trading under transaction costs and a diversi cation constraint ... we analyze the stage-wise optimal

mc2t have numerical values, however, with units identified by c1 ∈ INc

and c2 ∈ INc, respectively.

Non-currency asset prices are denoted by pct,at , whereby ct identifies the price unit and a ∈ INa

the asset. We treat foreign exchange rates and asset prices as time-varying parameters obtained

from data. In the sequel, various sets of admissable system states are defined. For brevity, we

therefore use a shorthand notation. For example, we define a set as Zt = {zt : it = 10}, implying

Zt = {zt : it = 10, and it associated with zt according (1)}.

2.2. Transaction costs

For the modeling of transaction costs, we follow the notion of Lobo, M.S. et al. [2007], modeling

transaction costs as non-convex with a fixed charge for any nonzero trade (fixed transaction costs)

and a linear term scaling with the quantity traded (proportional transaction costs). Thus, for a

foreign exchange at time t − 1, we model mctt = m

ct−1

t−1 xct−1,ctt−1 (1 − εct−1,ct

fx ) − βct−1,ctfx , where ε

ct−1,ctfx

and βct−1,ctfx denote the linear term and the fixed charge, respectively. Similarly, transaction costs

for transactions from currency to non-currency asset, between assets of different currencies and the

like can be defined. We can further differentiate between linear terms for buying and selling. To

fully introduce notation for transaction costs (εitbuy, βitbuy ≥ 0), we state the transaction from a cash

position towards an asset investment and vice versa. For a transaction of buying nt−1 of asset it−1

at time t− 1, we obtain

mctt = m

ct−1

t−1 xct−1,ctt−1 (1− εct−1,ct

fx )− βct−1,ctfx − nt−1pct,itt−1 (1 + εitbuy)− βitbuy.

For a transaction of selling nt−1 of asset it−1 and transforming to currency ct, we obtain

mctt =

(mct−1

t−1 + nt−1pct−1,it−1

t−1 (1− εit−1

sell )− βit−1

sell

)xct−1,ctt−1 (1− εct−1,ct

fx )− βct−1,ctfx .

Finally, note that transaction costs may vary dependent on the assets involved.

2.3. Transition dynamics

Given our assumption of being able to invest in currencies and non-currency assets, there are six

general types of transitions dependent on the investment at time t−1. For an introduction to Markov

Decision Processes (MDP), see Puterman, M. [2005]. We initialize z0 =[0 0 0 m0

0 0 m00 0 0

]. Then,

4

Page 5: arXiv:1709.07527v2 [q-fin.PM] 25 Apr 2018 · A posteriori multi-stage optimal trading under transaction costs and a diversi cation constraint ... we analyze the stage-wise optimal

the transition dynamics are

zt =

z(1)t , if {it : it = it−1, zt−1 with it−1 ∈ INc

},

z(2)t , if {it : it ∈ INc

\{it−1}, zt−1 with it−1 ∈ INc},

z(3)t , if {it : it ∈ INa

, zt−1 with it−1 ∈ INc},

z(4)t , if {it : it = it−1, zt−1 with it−1 ∈ INa

},

z(5)t , if {it : it ∈ INc

, zt−1 with it−1 ∈ INa},

z(6)t , if {it : it ∈ INa

\{it−1}, zt−1 with it−1 ∈ INa},

(2)

where z(j)t , ∀j = 1, . . . , 6, is defined next, and our control variable ut−1 is the targeted investment

identified by variable it, i.e., ut−1 = it. We have

z(1)t =

[it−1 kt−1 jt−1 m

ct−1

t−1 0 w0t−1 dt ct−1

],

z(2)t =

[it kt−1 + 1 jt−1 ϕ(mct

t ) 0 mctt x

ct,0t dt it

],

z(3)t =

[it kt−1 + 1 jt−1 m

ctt nt w

0t dt c(it)

],

with c(it) denoting the currency of asset it and with

dt =

dt−1 + 1, if dt−1 < D − 1,

0 otherwise,

ϕ(mctt ) = m

ct−1

t−1 xct−1,ctt−1 (1− εct−1,ct

fx )− βct−1,ctfx ,

and where variable D determines an overflow in dt and will become relevant when later discussing

the constraint of waiting a specific amount of time until the next admissable trade. Furthermore,

mctt and nt are obtained from solving

maxm

ctt ≥0

{nt : nt =

mct−1

t−1 xct−1,ctt−1 (1− εct−1,ct

fx )− βct−1,ctfx − βitbuy −mct

t

pct,itt−1 (1 + εitbuy), nt ∈ Z+

}, (3)

with mctt denoting the optimizer and nt the corresponding optimal objective function value. Thus,

given mct−1

t−1 , we find the largest possible positive integer number of assets we can purchase under

the consideration of transaction costs. The (small) cash residual is then mctt ≥ 0. Therefore, for

5

Page 6: arXiv:1709.07527v2 [q-fin.PM] 25 Apr 2018 · A posteriori multi-stage optimal trading under transaction costs and a diversi cation constraint ... we analyze the stage-wise optimal

the portfolio wealth at time t in currency EUR, we obtain w0t = (mct

t + ntpct,itt )xct,0t . Furthermore,

z(4)t =

[it−1 kt−1 jt−1 m

ct−1

t−1 nt−1 w0t−1 dt ct−1

],

z(5)t =

[it kt−1 + 1 jt−1 φ(mct

t ) 0 mctt x

ct,0t dt it

],

z(6)t =

[it kt−1 + 1 jt−1 m

ctt nt w

0t dt c(it)

],

with

φ(mctt ) =

(mct−1

t−1 + nt−1pct−1,it−1

t−1 (1− εit−1

sell )− βit−1

sell

)xct−1,ctt−1 (1− εct−1,ct

fx )− βct−1,ctfx ,

and where mctt and nt are obtained from solving

maxm

ctt ≥0

{nt : nt =

φ(mctt )− βitbuy −mct

t

pct,itt−1 (1 + εitbuy), nt ∈ Z+

}, (4)

with mctt denoting the optimizer and nt the corresponding optimal objective function value. Then,

for the portfolio wealth at time t in EUR, we obtain w0t = (mct

t + ntpct,itt )xct,0t .

The solution to (3) and (4) can be easily computed by setting mctt initially zero, then rounding

the corresponding real-valued nt to the largest smaller integer, before then computing the cash

residuals, respectively. The methodology of preserving a cash residual is implemented in order to

enforce an integer-valued number of shares in assets.

2.4. Remarks about optimality and transition dynamics modeling

An investment trajectory is defined as a sequence of states zt, t = 0, 1, . . . , Nt. We wish to find an

optimal (in the sense of wealth-maximizing) investment trajectory. Several remarks about above

problem formulation and transition dynamics modeling can be made.

First, suppose all of the initial money m00 is fully allocated to the optimal investment trajectory,

then there is no diversification present, and, defining the final return as rNt= (w0

Nt− m0

0)/m00,

the optimal investment trajectory never returns less than rNt< 0%. This is since one feasible

investment trajectory is to remain invested in the initial reference currency (EUR) for all t =

0, 1, . . . , Nt. This can be taken into account as a heuristic for transition graph generation.

Second, above transition dynamics modeling naturally results in cash residuals when investing

in non-currency assets. According to our modeling, the cash residuals are enforced to be in the

currency of the purchased asset. This may be suboptimal when the non-currency asset in which

6

Page 7: arXiv:1709.07527v2 [q-fin.PM] 25 Apr 2018 · A posteriori multi-stage optimal trading under transaction costs and a diversi cation constraint ... we analyze the stage-wise optimal

we invest is extremely expensive (e.g., worth thousands of EUR), since the resulting cash-residuals

may then be very large. Then, in general it may be worthwhile to invest the cash residual into

another asset which is more profitable than the “enforced” residual currency. Two comments are

made. On the one hand, assets with such prices are rare in practice. On the other hand, and more

importantly, in order to admit free investing of cash residuals, an extension of the state space

(beyond 8 variables) would be required such that any cash residual could be invested in any of the

Nc+Na−1 assets. Then, Nc+Na−1 additional branches would need to be added to the transition

graph, which, in the most general case, would also need further branching at subsequent stages.

This considerably complicates the tracking of states and is therefore not applied in the following.

Third, transition dynamics (2) indicate an all-or-nothing strategy. At every time t, the investment

at that time is maintained or, alternatively, reallocated to exactly one–the most profitable–currency

or asset, whereby cash residuals are accounted for as described in the previous paragraph.

Fourth, let us briefly discuss the effect of absence of transaction costs on optimal trading fre-

quency. For simplicity let us consider the case of being able to invest in an asset of variable value

(such as a stock) and holding of cash in the currency in which the risky asset is traded. Relevant

discrete-time dynamics can then be written as

wt = mt + ntpt, and mt = mt−1 − ntpt−1, (5)

with mt the cash position, nt the number of shares in the risky asset, pt the price of the asset and

wt the wealth at time t. At every time t a decision about a reallocation of investments is made.

For a final time period t = 0, 1, . . . , Nt, we wish to maximize wNt−w0, which can be expanded as

wNt− w0 =

Nt∑t=1

wt − wt−1. (6)

To maximize (6), we thus have to maximize the increments. Combining (5), we write wt −wt−1 =

nt(pt − pt−1)− nt−1pt−1, which therefore motivates the following optimal trading strategy, imple-

mented at every t−1. If pt > pt−1, maximize nt and set nt−1 = 0 (i.e., allocate maximal ressources

towards the asset), and if pt ≤ pt−1, set nt = 0 and minimize nt−1 (i.e., sell the asset if held at t−1

and allocate maximal ressources towards the cash position). We profit on a price increase of the

asset, and maintain our wealth on a price decrease1. Thus, it is optimal to trade upon any change

of sign of ∆pt = pt − pt−1. This is visualized Figure 1 and summarized in the following remark.

1We here assume a long-only strategy. By the use of derivative contracts, we can increase wealth on a price decrease as well.

7

Page 8: arXiv:1709.07527v2 [q-fin.PM] 25 Apr 2018 · A posteriori multi-stage optimal trading under transaction costs and a diversi cation constraint ... we analyze the stage-wise optimal

cash assetif ∆pt ≤ 0

if ∆pt > 0

if ∆pt ≤ 0

if ∆pt > 0

Figure 1. Visualization of the Markov decision process when optimally trading only cash and an asset in the absence

of transaction costs. The optimal trading strategy is to trade upon any change of ∆pt-sign, i.e., even if this is

minimally small (∆pt → 0).

Remark 1 In absence of transaction costs, trading upon any change in sign of ∆pt = pt − pt−1 is

the optimal trading policy.

Remark 1 implies that in the absence of transaction costs high-frequency trading (Aldridge [2013],

Bowen et al. [2010]) is always the optimal trading policy. Furthermore, note that ∆wt = wt−wt−1 ≥0, ∀t = 1, 2, . . . , Nt. Thus, in the absence of transaction costs, at every time step there is at least

no incremental decrease in wealth when employing the optimal trading policy. Naturally, when

including non-zero transaction costs, this is in general not the case anymore and we may (at

least temporarily) have ∆wt < 0. In addition, the optimal trading frequency will be non-trivially

affected. Quantitative examples for optimal trading frequencies under transaction costs are given

in Section 5.

Fifth, motivated by the previous paragraph and under the consideration of transaction costs, a

valid question to address is when to sell and rebuy a non-currency asset given a long-term trend

but temporary dip in price. Selling and rebuying may optimize profit. The typical minimal decrease

in price required for the strategy of selling and rebuying being optimal is approximately twice the

proportional transaction cost level. Twice because of selling and rebuying. Approximately because

of cash residuals due to the integer-valued number of assets and fixed transaction costs that need

to be accounted for.

3. Multi-stage optimization without diversification constraints

3.1. Multi-stage optimization

Multi-stage transition dynamics can be modeled in form of a transition graph. We therefore assign

a set Zt of admissable states to every time stage t. For investment trajectory optimization without

a diversification constraint, we employ one transition graph. For investment trajectory optimiza-

tion with a diversification constraint, multiple transition graphs and Z(q)t , ∀q = 0, 1, . . . , Q − 1,

8

Page 9: arXiv:1709.07527v2 [q-fin.PM] 25 Apr 2018 · A posteriori multi-stage optimal trading under transaction costs and a diversi cation constraint ... we analyze the stage-wise optimal

are defined and discussed in Section 4. In contrast, for the remainder of this section we dismiss

superscript “(q)” and focus on optimization without a diversification constrain. We define the initial

set Z0 ={z0 : z0 =

[0 0 0 m0

0 0 m00 0 0

]}. In the following, three constraints are discussed that

affect transition graph generation.

3.2. Case 1: Unconstrained trading frequency

Remark 2 Suppose that following a particular investment trajectory, at time τ an investment state

zτ is reached with a particular iτ , w0τ and jτ = iτ−1. Suppose further that there exists another

investment trajectory resulting in the same asset, i.e., iτ = iτ , but in contrast with w0τ > w0

τ and

jτ 6= jτ . Then, the former investment trajectory can be dismissed from being a possible candidate

segment for the optimal investment trajectory. This is because any trajectory continuing the latter

investment trajectory will always outperform a continuation of the former investment trajectory

for all t > τ .

Remark 2 motivates a simple but efficient transition graph generation: first, branch from every

state zt−1 ∈ Zt−1 to all possible states zt at time t according transition dynamics (2), whereby we

summarize the set of states at time t− 1 from which zt can be reached as J ztt−1; second, select the

optimal transitions and thus determine Zt according to

Zt =

{zt : max

jt∈J ztt−1

{w0t }, ∀it ∈ I

}, (7)

recalling the definition jt = it−1, and thereby selecting the solutions with highest value w0t , ∀it ∈

I = {0, 1, . . . , Nc +Na− 1}. The resulting transition graph holds a total of Nz(t) = 1 + (Nc +Na)t

states up to time t ≥ 0. For a time horizon Nt, the optimal investment strategy, here denoted by

superscript “?”, can then be reconstructed by proceeding backwards as

z?Nt

=

{zNt

: i?Nt= max

iNt

{w0Nt}, iNt

∈ I},

z?t−1 = {zt−1 : it−1 = j?t } , ∀t = Nt, Nt − 1, . . . , 1.

(8)

The resulting investment trajectory is optimal since by construction of the transition graph as

outlined, starting from z0, there exists exactly one wealth maximizing trajectory to every invest-

ment it = 0, 1, . . . , Nc +Na − 1 for every time t = 0, 1, . . . , Nt. By iterating backwards the optimal

investment decisions at every time stage are determined.

9

Page 10: arXiv:1709.07527v2 [q-fin.PM] 25 Apr 2018 · A posteriori multi-stage optimal trading under transaction costs and a diversi cation constraint ... we analyze the stage-wise optimal

3.3. Case 2: Bound on the admissable number of trades

We constrain the investment trajectory to include at most K ∈ Z+ trades during t = 0, 1, . . . , Nt,

whereby we define a trade as any reallocation of an investment resulting in a change of the asset

identification number it. A transition according it = it−1 is consequently no trade. The set of

admissable states is generated as

Zt =

{zt : max

jt∈J ztt−1

{w0t }, ∀kt < K and unique, and ∀it ∈ I

}. (9)

Consequently, the resulting transition graph holds a total of Nz(t) = 1 +∑t

l=1(Nc +Na)min(l,K)

states. The reconstruction of optimal investment decisions is similar to (8).

Note that the total number of states,Nz(t), quickly reaches large numbers. We therefore introduce

a heuristic to reduce Nz(t) while not compromising optimality of the solution.

Proposition 3.1 While not compromising the finding of an optimal investment trajectory, the

set of admissable states Zt of (9) can be shrunken to Zt according to the following heuristic:

1: Initialize: Zt = Zt.2: For every it ∈ I such that the corresponding zt ∈ Zt of (9):

3: Compute: koptt (it) ={kt : w0,opt

t (it) = max{w0t } s.t. corresponding zt ∈ Zt of (9)

}.

4: Shrink: Zt = Zt\{zt : kt > koptt (it)

}.

5: End For

Proof. W.l.o.g., suppose that for a given it = i ∈ I we have determined koptt (it). Let the associated

state vector be denoted by zoptt (it). Then, we can discard all zt with it = i and kt > koptt (it), since

w0,optt+τ (it) ≥ w0

t+τ , ∀τ ≥ 0, and the admissable set for state zoptt (it) is thus larger by at least the

option of one additional trade, in comparison to the admissable set corresponding to all zt ∈ Zt of

(9) with it = i and kt > koptt (it).

Note that the total number of states, Nz(Nt), cannot be predicted precisely as before. It is now

data-dependent instead. Quantitative implications are reported in Section 5.

10

Page 11: arXiv:1709.07527v2 [q-fin.PM] 25 Apr 2018 · A posteriori multi-stage optimal trading under transaction costs and a diversi cation constraint ... we analyze the stage-wise optimal

3.4. Case 3: Waiting period after every trade until the next trade

We constrain the investment trajectory to waiting of at least a specific time period D after every

executed trade until the next trade. The set of admissable states is consequently generated as

Zt =

{zt : max

jt∈J ztt−1

{w0t }, ∀dt < D and unique, and ∀it =∈ I

}. (10)

As a result, the resulting transition graph holds a total of Nz(t) = 1+∑t

l=1(Nc+Na−1)min(l,D)+

1+min (max(0, l −D), D − 1) states. The reconstruction of optimal investment decisions is similar

to (8).

Similarly to Section 3.3, the total number of states, Nz(t), quickly reaches large numbers. We

therefore also introduce a heuristic to reduce Nz(t) while not compromising optimality of the

solution.

Proposition 3.2 While not compromising the finding of an optimal investment trajectory, the

set of admissable states Zt of (10) can be shrunken to Zt according to the following heuristic:

1: Initialize: Zt = Zt.2: For every it ∈ I such that the corresponding zt ∈ Zt of (10):

3: Compute: doptt (it) ={dt : w0,opt

t (it) := max{w0t } s.t. corresponding zt ∈ Zt of (10)

}.

4: Shrink: Zt = Zt\{zt : 0 < dt < doptt (it)

}.

5: End For

Proof. W.l.o.g., suppose for a given it = i ∈ I we have determined doptt (it). Let the associated

state vector be denoted by zoptt (it). Then, we can discard all zt with it = i and 0 < dt < doptt (it),

since w0,optt+τ (it) ≥ w0

t+τ , ∀τ ≥ 0, and the admissable set for state zoptt (it) is larger by being closer

to a potential next trade by at least one trading sampling time, in comparison to the admissable

set corresponding to all zt ∈ Zt of (10) with it = i and 0 < dt < doptt (it).

Similarly to Section 3.3, the total number of states, Nz(Nt), cannot be predicted precisely since

it is data-dependent. Quantitative results are reported in Section 5. This heuristic significantly

reduces computational complexity in practice.

11

Page 12: arXiv:1709.07527v2 [q-fin.PM] 25 Apr 2018 · A posteriori multi-stage optimal trading under transaction costs and a diversi cation constraint ... we analyze the stage-wise optimal

4. Multi-stage transition dynamics optimization with a diversification constraint

In portfolio optimization the introduction of diversification constraints is regarded as a measure

to reduce drawdown risk. For our purpose of analysis of historical optimal trading we first divide

the initial wealth m0 into Q parts of equal proportion. Then, we impose constraints on each of

the corresponding Q investment trajectories. In the unconstrained case, all Q trajectories would

coincide. In the constrained case, we distinguish between i) constraints between multiple invest-

ment trajectories: diversification at only the initial time, diversification permitted at all times,

asynchronous trading and synchronous trading, and ii) constraints along any specific investment

trajectory: unconstrained trading frequency, at most K trades along the investment trajectory, and

the enforcement of a waiting period after each executed trade.

We define a diversification constraint at a specific time t such that each of the states of the Q-

trajectories, zt ∈ Z(q)t , ∀q = 0, . . . , Q−1, must be invested differently. Thus, each asset identification

number i(q)t must be different ∀t = 0, 1, . . . , Nt, ∀q = 0, 1, . . . , Q− 1.

We define the sets of admissable states Z(q)t , ∀t = 0, 1, . . . , Nt and ∀q = 0, 1, . . . , Q−1, sequentially

and ordered according to optimality. Thus, Z(1)t , ∀t = 0, 1, . . . , Nt is constructed accounting only

for the optimal investment trajectory associated with Z(0)t , i.e., the set Z(0),?

t , ∀t = 0, 1, . . . , Nt,

whereas Z(q)t is constructed accounting for all of the optimal investment trajectories associated

with Z(0),?t , Z(1),?

t , . . . ,Z(q−1),?t . Here, Z(q),?

t , ∀q = 0, 1, . . . , Q − 1 denotes the set of states at

each time t that result from the reconstruction of optimal investment decisions along the optimal

investment trajectory according to (8). Thus, our methodology aims at being maximally invested

in the investment trajectories ordered according to optimality.

4.1. Q trajectories, diversification for a subset of times and asynchronous trading

We define the subset of trading sampling times as T (q) ⊆ {0, 1, . . . , Nt}, ∀q = 0, 1, . . . , Q− 1. For

enforcement of diversification in form of Q trajectories, diversification for any subset of trading

times and asynchronous trading, the sets of admissable states are initialized as

Z(q)0 =

{z0 : z0 =

[0 0 0 m0,q

0 0 m0,q0 0 0

]}, ∀q = 0, 1, . . . , Q− 1. (11)

For unconstrained trading frequency along an investment trajectory and t > 0, the sets of

12

Page 13: arXiv:1709.07527v2 [q-fin.PM] 25 Apr 2018 · A posteriori multi-stage optimal trading under transaction costs and a diversi cation constraint ... we analyze the stage-wise optimal

admissable states are thus generated according to

Z(q)t =

{zt : max

jt∈J ztt−1

{w0t }, ∀it ∈ I if t /∈ T (q), or ...

∀it ∈ I\(∪{it : it = i

(r),?t , z

(r),?t ∈ Z(r),?

t

}q−1r=0

)if t ∈ T (q)

},

(12)

with q = 0, 1, . . . , Q − 1, and where z(r),?t ∈ Z(r)

t denotes the optimal state at time t associated

with investment trajectory r.

For the case of at most K admissable trades along any investment trajectory and t > 0, the sets

of admissable states are generated according to

Z(q)t =

{zt : max

jt∈J ztt−1

{w0t }, ∀kt < K and unique, and ∀it ∈ I if t /∈ T (q), or ...

∀kt < K and unique, and ∀it ∈ I\(∪{it : it = i

(r),?t , z

(r),?t ∈ Z(r),?

t

}q−1r=0

)if t ∈ T (q)

},

(13)

with q = 0, 1, . . . , Q− 1.

For the case of enforcing a waiting period after each executed trade along any investment tra-

jectory and t > 0, the sets of admissable states are generated according to

Z(q)t =

{zt : max

jt∈J ztt−1

{w0t }, ∀dt < D and unique, and ∀it ∈ I if t /∈ T (q), or ...

∀dt < D and unique, and ∀it ∈ I\(∪{it : it = i

(r),?t , z

(r),?t ∈ Z(r),?

t

}q−1r=0

)if t ∈ T (q)

},

(14)

with q = 0, 1, . . . , Q− 1.

4.2. Q trajectories, diversification for all times and synchronous trading

Let us define a subset of trading sampling times as T ⊆ {0, 1, . . . , Nt}. This subset may, for

example, indicate the sampling times at which trades were executed along the optimal investment

trajectory associated with Z(0),?t :

T = {t : i(0),?t 6= j

(0),?t , z

(0),?t ∈ Z(0),?

t , ∀t = 1, . . . , Nt}.

The set of a admissable states is initialized as in (11). Then, for an unconstrained trading

frequency along an investment trajectory and t > 0, the sets of admissable states are generated

13

Page 14: arXiv:1709.07527v2 [q-fin.PM] 25 Apr 2018 · A posteriori multi-stage optimal trading under transaction costs and a diversi cation constraint ... we analyze the stage-wise optimal

according to

Z(q)t =

{zt : zt = zt−1 if t /∈ T , or . . .

zt s.t. maxjt∈J zt

t−1

{w0t }, ∀it ∈ I\

(∪{it : it = i

(r),?t , z

(r),?t ∈ Z(r),?

t

}q−1r=0

)if t ∈ T

},

(15)

with q = 0, 1, . . . , Q− 1.

The case of at most K admissable trades along any investment trajectory as well as the case of

enforcing a waiting period after each executed trade along any investment trajectory can then be

defined analogously.

4.3. Remarks and relevant quantities for interpretation

Note that the presented framework can also be extended to analyze alternative optimization cri-

teria such as, for example, determining a worst-case investment trajectory (pessimization), or the

tracking of a target return reference trajectory (index tracking).

In order to interpret quantiative results in the following Section 5, we define the total return

(measured in percent) as rtot,(q)Nt

= 100w0

Nt−w0

0

w00

, ∀q ∈ Q. Similarly, we define the return at time t

as rtot,(q)t , ∀q ∈ Q. We further report the total number of conducted trades as Ktot

Nt. The minimal

time-span between any two trades within time-frame t ∈ Nt = {0, 1, . . . , Nt} shall be denoted by

DminNt

. In addition, the average, minimal and maximal percentage gain per conducted non-currency

asset-trade is of our interest. Stating the quantities with respect to our reference currency (EUR),

we therefore first define the set

∆G(q) =

{100

w0τ − w0

η

w0η

: with τ s.t. τ = t− 1, i ∈ INa, it−1 6= i, it = i,

with η s.t. η = t, i ∈ INa, it = i, it+1 6= i, and τ > η, zt ∈ Z(q),?

t , ∀t ∈ Nt, ∀q ∈ Q},

whereby i identifies an asset of interest. The average, minimum and maximum shall then be de-

noted by avg(∆G(q)), min(∆G(q)) and max(∆G(q)), respectively. The associated trading times are

summarized in

∆T (q) =

{τ − η : with τ s.t. τ = t− 1, i ∈ INa

, it−1 6= i, it = i,

with η s.t. η = t, i ∈ INa, it = i, it+1 6= i, and τ > η, zt ∈ Z(q),?

t , ∀t ∈ Nt, ∀q ∈ Q},

14

Page 15: arXiv:1709.07527v2 [q-fin.PM] 25 Apr 2018 · A posteriori multi-stage optimal trading under transaction costs and a diversi cation constraint ... we analyze the stage-wise optimal

Table 1. Example 1, see Section 5.1. Identification of the currencies and asset under consideration. The currency in

which asset i is traded is denoted by c(i). The reference currency of Nasdaq-100 is USD.

i finance.yahoo-symbol Interpretation c(i)

0 – EUR 0

1 EURUSD=x USD 1

2 ^ NDX Nasdaq-100 1

with corresponding avg(∆T (q)), min(∆T (q)) and max(∆T (q)) defined accordingly.

Then, we can partition quantities of interest into two groups: overall performance measures

and, secondly, quantities associated with non-currency asset holdings along an investment-optimal

q-trajectory. We therefore compactly summarize results in evaluation vectors and matrices

e(q) =[rtot,(q)Nt

Ktot,(q)Nt

Dmin,(q)Nt

], ∀q ∈ Q, (16)

E(q) =

avg(∆G(q)) min(∆G(q)) max(∆G(q))avg(∆T (q)) min(∆T (q)) max(∆T (q))

, ∀q ∈ Q. (17)

5. Numerical examples

To quantitatively evaluate results, three numerical examples are reported. For all examples, a

time horizon of one year is chosen. The sampling time is selected as one day. Adjusted closing

prices of both foreign exchange rates and stock indices are retrieved from finance.yahoo.com.

As a preprocessing step all non-currency assets are normalized to value 100 in their corresponding

currency at time t = 0.

The first example treats optimal trading of EUR, USD and the Nasdaq-100. This scenario is

selected mainly to analyze currency effects. No diversification constraint is enforced such that we

have Q = 1. The second example treats optimal trading of 16 different currencies and 15 different

non-currency assets. A diversification constraint is employed with Q = 3. The third example

compares the results for an exemplary downtrending and an uptrending stock.

This section illustrates the effects of i) different transaction cost levels, and ii) various constraints

on a posteriori optimal trading performance.

5.1. Example 1: EUR, USD and Nasdaq-100

The results for numerical example 1 are summarized in Table 2. Different levels of transaction costs

with variable proportional cost but constant fixed cost are considered. In Table 2 the evaluation

15

Page 16: arXiv:1709.07527v2 [q-fin.PM] 25 Apr 2018 · A posteriori multi-stage optimal trading under transaction costs and a diversi cation constraint ... we analyze the stage-wise optimal

Table 2. Summary of quantitative results of Example 1 from Section 5.1.

ε = 0 ε = 0.5 ε = 1 ε = 2

Buy-and-Hold[−0.2 1 250

] [−1.2 1 250

] [−2.2 1 250

] [−4.2 1 250

]Unconstrained

[330.0 165 1

][2.0 0.1 11.01.8 1 5

][134.6 59 1

][3.9 0.9 11.85.5 1 21

][86.2 31 1

][5.9 0.4 16.612.2 1 45

][50.1 14 1

][8.2 3.1 15.520.0 3 45

]

≤ 12 trades

[106.8 12 6

][11.9 7.1 17.823.7 11 45

][87.9 12 6

][11.0 6.6 17.223.7 11 45

][72.5 12 5

][10.1 5.8 16.623.8 11 45

][49.6 12 1

][9.2 5.0 15.523.7 11 45

]

≥ 10 days waiting

[114.2 18 10

][9.1 2.7 16.615.3 10 21

][84.8 17 10

][9.2 2.7 16.016.1 11 21

][68.4 13 10

][9.8 6.0 15.422.3 11 45

][46.5 10 11

][9.3 5.9 15.525.4 12 45

]

quantities e(0) and E(0) are reported for the different trading strategies. For the Buy-and-Hold

strategy, only e(0) is reported. We assume proportional costs (indicated in %) to be the same for

buying and selling for both foreign exchange and asset trading, i.e., ε = εbuy = εsell. For ε = 0,

we also set β = 0. For all other cases, we set β = 50. Total returns (rtot,(q)Nt

) are printed bold for

emphasis. The time-span of interest is August 5, 2015 until August 3, 2016, and comprises 251

potential trading days.

Several observations can be made with respect to the results of Table 2. First, eventhough

only two currencies, EUR and USD, i.e., i ∈ INc= {0, 1}, and one non-currency asset, i.e.,

i ∈ INa= {2}, are traded long-only, remarkable profits can be earned when optimally trading

a posteriori. Even in case of (high) transaction costs with a proportional rate of 2%, the profits

significantly outperform a one-year Buy-and-Hold strategy. Second, the influence of different levels

of transaction costs is impressive. This holds specifically for unconstrained trading with respect

to returns, optimal trading frequency and percentage gains (average, minimum and maximum)

upon which the non-currency asset is traded. Third, while the total return drops with increasing

transaction cost levels, the remaining evaluation quantities remain approximately constant for the

K-trades strategy (here K = 12, i.e., 12 trades per year or one per month). Fourth, the results

associated with the percentage gains upon which the non-currency asset is traded were unexpected.

Intuitively, they were thought to be higher. The same holds for optimal time periods between any

two trades. Results from Example 1 encourage frequent trading. For example, for the case with a

waiting constraint, trading is encouraged upon percentage gains of on average slightly less than

10% for all four levels of transaction costs.

Figure 2 further visualizes results. In order to compactly display multiple foreign exchange rates,

we normalize w.r.t. the initial value at t = 0, see the subplot with label ∆xnormt . For reference

16

Page 17: arXiv:1709.07527v2 [q-fin.PM] 25 Apr 2018 · A posteriori multi-stage optimal trading under transaction costs and a diversi cation constraint ... we analyze the stage-wise optimal

0

1

2i t

0

5

∆xnorm

t[%

]

−20

−10

0

10

∆pnorm

t,EUR

[%]

0 20 40 60 80 100 120 140 160 180 200 220 2400

100

200

300

t [days]

rtot

t[%

]

Figure 2. Example 1, the unconstrained trading case in the absence of any transaction costs. See also Table 2.

currency EUR, we set ∆xnormt = 0, ∀t = 0, 1, . . . , Nt. Analogously, we normalize non-currency

prices and additionally take currency effects into account by first converting prices to currency

EUR, see the subplot with label ∆pnormt,EUR. For a specific optimal investment trajectory, at every

time t, an investment in exactly one currency or non-currency asset is taken. Being invested in a non-

currency asset is indicated by the red balls in Figure 2. Since non-currency assets are associated

with a specific currency we also label them accordingly with red balls. In contrast, an explicit

investment in a currency is emphasized by blue balls.

It is striking that despite an absence of clear trends in both the EURUSD-foreign exchange

rate and the Nasdaq-100 stock index, significant profits can be made when optimally trading–even

when employing a long-only strategy. The largest increases in return rates in currency EUR are

achieved when the asset is increasing in value while the foreign exchange rate with reference Euro is

17

Page 18: arXiv:1709.07527v2 [q-fin.PM] 25 Apr 2018 · A posteriori multi-stage optimal trading under transaction costs and a diversi cation constraint ... we analyze the stage-wise optimal

Table 3. Example 2, see Section 5.2. Identification of 16 currencies and 15 assets. Each currency is associated with

a foreign exchange rate with respect to EUR. The currency in which an asset i is traded is denoted by c(i).

i finance.yahoo-symbol Interpretation c(i)

0 – EUR 0

1 EURUSD=x USD 1

2 EURJPY=x JPY 2

3 EURGBP=x GBP 3

4 EURCHF=x CHF 4

5 EURCNY=x CNY 5

6 EURDKK=x DKK 6

7 EURHKD=x HKD 7

8 EURNOK=x NOK 8

9 EURRUB=x RUB 9

10 EURBRL=x BRL 10

11 EURAUD=x AUD 11

12 EURCAD=x CAD 12

13 EURTRY=x TRY 13

14 EURZAR=x ZAR 14

15 EURINR=x INR 15

16 ^ GDAXI DAX (GER) 0

17 FTSEMIB.MI FTSEMIB (ITA) 0

18 ^ OSEAX OSEAX (NOR) 8

19 CSSMI.SW SMI (SUI) 4

20 ^ NDX Nasdaq-100 (USA) 1

21 ^ GSPC S&P 500 (USA) 1

22 ^ N225 NIKKEI 225 (JPN) 2

23 ^ HSI Hang-Seng (HKG) 7

24 ^ BVSP IBOVESPA (BRA) 10

25 ^ AORD All Ordinaries (AUS) 11

26 ^ GSPTSE S&P/TSX (CAN) 12

27 AFS.PA FTSE/JSE (RSA) 14

28 RUS.PA Dow Jones Russia (RUS) 0

29 INR.PA MSCI India (IND) 0

30 TUR.PA Dow Jones Turkey (TUR) 0

decreasing. Investments in USD are optimal when the EURUSD-foreign exchange rate is trending

down and the Nasdaq-100 is decreasing likewise. Investments in EUR are in general optimal when

the EURUSD-foreign exchange rate is trending up and the Nasdaq-100 is trending down.

5.2. Example 2: Global investing and including a diversification constraint

We consider 16 currencies and 15 non-currency assets. Real-world data is obtained according to

Table 3. We consider the time horizon August 5, 2015 until August 3, 2016. Because of different

trading holidays in the different countries, a total of 199 trading days could be determined common

to all assets. We diversify in three assets at every trading time t, i.e., we set Q = 3.

18

Page 19: arXiv:1709.07527v2 [q-fin.PM] 25 Apr 2018 · A posteriori multi-stage optimal trading under transaction costs and a diversi cation constraint ... we analyze the stage-wise optimal

Table 4. Summary of quantitative results of Example 2 for the first case: time-asynchronous trading with

diversification for all times.

ε = 0 ε = 0.5 ε = 1 ε = 2q=

0

Buy-and-Hold[18.2 1 199

] [17.0 1 199

] [15.9 1 199

] [13.6 1 199

]Unconstrained

[17450.5 184 1

][3.3 0.1 19.51.1 1 3

][3092.0 126 1

][4.3 0.2 21.91.7 1 5

][1099.5 95 1

][5.9 0.7 24.72.7 1 8

][354.5 50 1

][8.6 1.8 26.25.0 1 21

]

≤ 12 trades

[453.9 12 3

][19.0 5.6 56.713.8 3 55

][377.9 12 3

][12.0 7.2 17.822.5 11 45

][326.4 12 2

][20.8 5.4 5418.4 3 49

][258.7 12 2

][22.3 5.4 50.119.0 3 46

]

≥ 10 days waiting

[440.8 17 10

][12.9 3.8 33.511.7 5 16

][341.2 16 10

][11.5 2.1 31.411.7 5 16

][269.3 15 10

][11.1 1.8 29.512.4 5 16

][186.6 12 10

][17.9 12.1 26.718.5 11 36

]

q=

1

Buy-and-Hold[3.3 1 199

] [2.8 1 199

] [2.3 1 199

] [1.3 1 199

]Unconstrained

[3671.6 190 1

][2.4 0.02 7.51.0 1 2

][769.0 123 1

][3.3 0.4 9.01.8 1 6

][378.5 76 1

][4.8 1.2 9.03.3 1 9

][173.2 38 1

][8.0 2.8 22.57.0 2 19

]

≤ 12 trades

[227.0 12 1

][12.8 0.5 36.015.5 1 43

][212.3 12 1

][14.5 2.6 34.516.2 1 43

][173.0 12 4

][13.8 2.6 33.218.3 7 43

][129.6 12 3

][18.7 9.5 30.523.7 7 43

]

≥ 10 days waiting

[267.5 17 10

][10.4 2.0 18.411.2 1 15

][200.5 17 10

][9.8 3.8 17.211.5 10 14

][153.2 17 10

][9.2 1.5 14.511.0 8 14

][113.3 15 10

][9.1 1.2 22.114.3 6 33

]

q=

2

Buy-and-Hold[1.7 1 199

] [0.6 1 199

] [−0.4 1 199

] [−2.4 1 199

]Unconstrained

[1882.1 191 1

][2.0 2e− 14 6.91.0 1 3

][459.7 113 1

][3.0 0.1 11.42.0 1 8

][229.3 66 1

][4.9 1.2 12.03.7 1 10

][102.9 37 1

][6.4 2.9 10.06.7 1 16

]

≤ 12 trades

[186.3 12 1

][12.9 7.2 31.816.6 1 67

][158.0 12 1

][11.8 5.8 30.615.3 1 49

][137.9 12 1

][11.9 7.5 24.618.0 5 37

][89.0 12 3

][10.7 5.9 18.318.0 8 36

]

≥ 10 days waiting

[215.2 18 10

][9.2 3.3 13.910.8 9 14

][164.1 18 10

][7.5 2.5 12.410.6 8 14

][116.2 15 10

][9.0 4.9 12.313.3 10 20

][70.7 11 10

][9.7 5.8 18.317.6 10 29

]

Summary Buy-and-Hold 23.2 20.4 17.8 12.5

Unconstrained 23004.2 4320.7 1707.3 630.6

≤ 12 trades 867.2 748.2 637.3 477.3

≥ 10 days waiting 923.5 705.8 538.7 370.6

We distinguish between two cases: synchronous and asynchronous trading. Quantitative results

are summarized in Tables 4 and 5, respectively. The results for all Q trajectories are reported. The

“Summary”-section in Tables 4 and 5 reports the sum of returns of all Q trajectories. Exemplary,

results are further visualized in Figure 3. The black-dashed horizontal line in the corresponding

top subplots denotes Nc = 16 to distinguish currency and non-currency asset investments.

For performance comparison, we consider a Buy-and-Hold strategy, whereby an asset is bought

19

Page 20: arXiv:1709.07527v2 [q-fin.PM] 25 Apr 2018 · A posteriori multi-stage optimal trading under transaction costs and a diversi cation constraint ... we analyze the stage-wise optimal

Table 5. Summary of quantitative results of Example 2 for the second case: time-synchronized trading with

diversification for all times.

ε = 0 ε = 0.5 ε = 1 ε = 2q=

0

Buy-and-Hold[18.2 1 199

] [17.0 1 199

] [15.9 1 199

] [13.6 1 199

]Unconstrained

[17450.5 184 1

][3.3 0.1 19.51.1 1 3

][3092.0 126 1

][4.3 0.2 21.91.7 1 5

][1099.5 95 1

][5.9 0.7 24.72.7 1 8

][354.5 50 1

][8.6 1.8 26.25.0 1 21

]

≤ 12 trades

[454.3 12 2

][19.0 7.0 56.713.8 2 55

][377.9 12 3

][19.0 5.4 54.315.3 3 55

][326.4 12 2

][20.8 5.4 54.018.4 3 49

][258.7 12 2

][22.3 5.4 50.119.0 3 46

]

≥ 10 days waiting

[440.8 17 10

][12.9 3.8 33.511.7 5 16

][341.2 16 10

][11.5 2.1 31.411.7 5 16

][269.3 15 10

][11.1 1.8 29.512.4 5 16

][186.6 12 10

][17.9 12.1 26.718.5 11 36

]

q=

1

Buy-and-Hold[1.7 1 199

] [0.6 1 199

] [−0.4 1 199

] [−2.4 1 199

]Unconstrained

[3009.4 177 1

][2.4 0.02 7.81.1 1 3

][523.5 89 1

][3.6 0.4 13.02.5 1 8

][259.9 46 1

][6.1 0.6 18.65.8 1 17

][137.8 24 1

][9.1 2.9 25.910.3 2 23

]

≤ 12 trades

[142.8 12 2

][8.9 5.0 18.011.3 2 55

][112.7 12 3

][8.2 0.8 16.813.5 4 55

][87.7 12 2

][9.8 5.4 19.714.8 4 49

][67.3 12 2

][11.1 3.9 22.415.3 4 46

]

≥ 10 days waiting

[179.1 17 10

][7.6 0.7 15.711.7 5 16

][135.9 14 10

][8.1 0.8 15.112.8 5 24

][116.0 12 10

][9.0 2.1 23.416.6 10 41

][73.2 9 10

][11.3 6.0 14.819.8 11 32

]

q=

2

Buy-and-Hold[3.3 1 250

] [2.1 1 250

] [1.1 1 250

] [−0.9 1 250

]Unconstrained

[1640.8 177 1

][2.1 0.02 10.61.1 1 4

][342.9 91 1

][3.2 0.1 9.52.4 1 6

][170.3 45 1

][5.8 0.4 11.46.1 1 21

][87.9 20 1

][7.9 3.9 11.711.0 3 22

]

≤ 12 trades

[114.8 12 2

][8.2 4.6 14.611.6 2 55

][92.2 11 3

][9.4 0.6 24.615.7 3 59

][74.4 11 2

][10.3 1.8 28.218.3 3 53

][50.0 7 6

][15.9 3.8 25.636.0 6 53

]

≥ 10 days waiting

[134.2 16 10

][6.4 0.3 11.712.4 10 16

][102.9 13 10

][8.4 0.5 12.217.3 11 33

][87.8 12 11

][7.3 4.5 10.114.7 13 21

][52.8 7 10

][13.9 8.1 19.326.7 25 32

]

Summary Buy-and-Hold 23.2 20.4 17.8 12.5

Unconstrained 22100.7 3958.4 1529.7 580.2

≤ 12 trades 711.9 582.8 488.5 376.0

≥ 10 days waiting 754.1 580.0 473.1 312.6

initially and then held. The most performant non-currency assets from Table 3 for the time frame

of interest were, in order, the IBOVESPA (BRA), the Dow Jones Russia GDR (RUS) and the S&P

500 (USA). Associated returns are reported in Table 4 and 5, where we attribute the IBOVESPA

to q = 0 and the other two assets to q = 1 and q = 2, respectively.

Interpretation of results is in line with Section 5.1. In particular, the influence of transaction costs

and the encouragement of frequent trading upon relatively small percentage gains is recurrent.

20

Page 21: arXiv:1709.07527v2 [q-fin.PM] 25 Apr 2018 · A posteriori multi-stage optimal trading under transaction costs and a diversi cation constraint ... we analyze the stage-wise optimal

Table 6. Summary of quantitative results of Example 3. Comparison of a downtrending and an uptrending stock

for the time period between August 10, 2015 and August 8, 2016. The exemplary downtrending stock is of

Deutsche Bank AG (finance.yahoo-symbol: DBK.DE). The exemplary uptrending stock is of Adidas AG

(finance.yahoo-symbol: ADS.DE). See Section 5.3 for interpretation.

DKB.DE ε = 1

Buy-and-Hold[−61.4 1 260

]Unconstrained

[382.8 51 1

][7.5 1.5 21.84.2 1 11

]

ADS.DE ε = 1

Buy-and-Hold[95.6 1 260

]Unconstrained

[249.4 43 1

][7.0 1.0 20.17.8 2 24

]

A remark about computational complexity needs to be made. The total number of states, Nz(Nt),

without consideration of any heuristics is 6139, 71611 and 59905 for the three cases (unconstrained,

constraint of at most K = 12 trades, and constraint of waiting at least D = 10 days between any

two trades). These numbers can be computed according to the formulas stated in Section 3. Then,

applying the heuristics from Section 3.3 and 3.4 to the given finance.yahoo-data trajectories, we

measured (to give one example) Nz(Nt) = 65238 and Nz(Nt) = 33161 for the latter two cases,

q = 0 and ε = 0. Similar results are obtained for the other transaction cost levels and the other

q-trajectories, resulting in overall computation times (for all q = 0, 1, 2) in the tens of minutes.

In contrast, for the unconstrained case, overall computation times for the generation of all Q = 3

transition graphs were on average only slightly more than 10 seconds, thereby making the uncon-

strained case much more suitable for fast analysis of sets of multiple assets and foreign exchange

rate trajectories. Secondly, the trajectories for q = 0 are identical for both time-asynchronous and

-synchronous trading. However, for the remaining investment trajectories with q > 0, the number

of states is much lower for time-synchronous trading in comparison to the asynchronous case. For

time-synchronous trading, Q = 3 and a bound on the total admissable number of trades, the total

number of states is 63803 for q = 0, but 39713 and 23549 for q = 1 and q = 2, respectively. All

numerical experiments throughout this paper were conducted on a laptop running Ubuntu 14.04

equipped with an Intel Core i7 CPU @ 2.80GHz×8, 15.6 GB of memory, and using Python 2.7.

5.3. Example 3: A downtrending and an uptrending stock

The ultimate example compares achievable performances for an examplary downtrending and an

an uptrending stock. The exemplary downtrending stock is of Deutsche Bank AG (finance.yahoo-

symbol: DKB.DE). The exemplary uptrending stock is of Adidas AG (finance.yahoo-symbol:

ADS.DE). Both stocks are listed in the German stock index (DAX). The time-frame considered

21

Page 22: arXiv:1709.07527v2 [q-fin.PM] 25 Apr 2018 · A posteriori multi-stage optimal trading under transaction costs and a diversi cation constraint ... we analyze the stage-wise optimal

August 7, 2016 Quantitative Finance paperV1

...

............0 .

10

.

20

.

30

.

i t

..

............−20 .

−10

.

0

.

10

.

20

.

30

.

40

.

∆x

norm

t[%

]

..

............−40 .

−30

.

−20

.

−10

.

0

.

10

.

20

.

∆p

norm

t,E

UR

[%]

..

..0.

20.

40.

60.

80.

100.

120.

140.

160.

180.0 .

100

.

200

.

300

.

t [days]

.

rtot

t[%

]

Figure 12. Example 2. The results for q = 0, at most K = 12 admissable trades and transaction cost level ϵ = 1.For q = 0, the results for asynchronous and synchronous trading are identical. See Section 5.2 for interpretation.

21

Figure 3. Example 2. The results for q = 0, at most K = 12 admissable trades and transaction cost level ε = 1. For

q = 0, the results for asynchronous and synchronous trading are identical. See Section 5.2 for interpretation.

22

Page 23: arXiv:1709.07527v2 [q-fin.PM] 25 Apr 2018 · A posteriori multi-stage optimal trading under transaction costs and a diversi cation constraint ... we analyze the stage-wise optimal

0

1i t

−60

−40

−20

0

∆pnorm

t,EUR

[%]

0 20 40 60 80 100 120 140 160 180 200 220 2400

100

200

300

400

t [days]

rtot

t[%

]

Figure 4. The downtrending stock of Example 3 for the unconstrained trading case in case of proportional transaction

costs of 1%, see Section 5.3. The exemplary downtrending stock is of Deutsche Bank AG (finance.yahoo-symbol:

DKB.DE). See also Table 6.

is August 10, 2015 until August 8, 2016. There are 260 potential trading days. Both stocks are

traded in currency EUR. We thus find optimal investment trajectories when i) trading DKB.DE and

EUR, and ii) trading ADS.DE and EUR. We assume propotional costs of 1% identical for buying

and selling, i.e., ε = εbuy = εsell. We set β = 50. Results are summarized in Table 6 and Figure 4.

Unexpectedly and remarkably, the yearly return associated with the optimal investment tra-

jectory of the downtrending stock is higher than its uptrending counterpart: 382.8% vs. 249.2%.

Importantly, note that the corresponding Buy-and-Hold returns are −61.4% and 95.6%, respec-

tively. While overall downtrending, the price of DKB.DE indicates temporary steep price increases.

Furthermore, these occur mostly towards the second half of the time-period of interest, and thus

imply stronger return growth due to the already compounded portfolio wealth that is available for

investing at that time (instead of the initial m0). Naturally, without a posteriori knowledge of price

evolutions, an uptrending stock such as ADS.DE offers the advantage that missing the right selling

dates is less important. Interestingly, both downtrending and uptrending are traded optimally upon

similar short-term average price increases: 7.5% and 7%. Similarly, the optimal holding periods of

the stocks are short with on average 4.2 and 7.8 days, respectively.

23

Page 24: arXiv:1709.07527v2 [q-fin.PM] 25 Apr 2018 · A posteriori multi-stage optimal trading under transaction costs and a diversi cation constraint ... we analyze the stage-wise optimal

6. Conclusion

We developed a simple graph-based method for a posteriori (historical) multi-variate multi-stage

optimal trading under transaction costs and a diversification constraint. Three variants were dis-

cussed, including unconstrained trading frequency, a fixed number of total admissable trades, and

the waiting of a specific time-period after every executed trade until the next trade. Findings were

evaluated quantitatively on real-world data.

It was illustrated that transaction cost levels are decisive for achievable performance and signif-

icantly influence optimal trading frequency. Quantitative results further indicated optimal trading

upon occasion rather than on fixed trading intervals, and, dependent on transaction cost levels,

upon single- to low double-digit percentage gains with respect to the reference currency, and exploit-

ing short-term trends. Achievable returns for optimized trading are uncomparably outperforming

Buy-and-Hold strategies. Naturally, these returns are very difficult to achieve in practice without

knowledge of future price and foreign exchange rate evolutions.

The fundamental motivation and possibly best application of this work is to use it for i) the

preparatory and automated labeling of financial time-series data, which is almost unlimitedly avail-

able, and where transaction cost level ε can then be regarded as a hyperparameter for the desired

tuning of labeled data, before ii) developing supervised machine learning applications for algorith-

mic trading and screening systems. This is subject of ongoing work.

Bibliography

Tay, F.E. and L. Cao. Application of support vector machines in financial time series forecasting. Omega,

29(4):309–317, 2001.

Kim, K. Financial time series forecasting using support vector machines. Neurocomputing, 55(1):307–319,

2003.

Van Gestel, T., J.A. Suykens, D.E. Baestaens, A. Lambrechts, G. Lanckriet, B. Vandaele, B. De Moor, and

J. Vandewalle. Financial time series prediction using least squares support vector machines within the

evidence framework. IEEE Transactions on Neural Networks, 12(4):809–821, 2001.

Utpala Nanda Chowdhury, Sanjoy Kumar Chakravarty, and Md Tanvir Hossain. Short-term financial time

series forecasting integrating principal component analysis and independent component analysis with

support vector regression. Journal of Computer and Communications, 6(03):51, 2018.

Boyarshinov, V. and M. Magdon-Ismail. Efficient computation of optimal trading strategies. arXiv preprint

arXiv:1009.4683, 2010.

Lobo, M.S., M. Fazel, and S. Boyd. Portfolio optimization with linear and fixed transaction costs. Annals

24

Page 25: arXiv:1709.07527v2 [q-fin.PM] 25 Apr 2018 · A posteriori multi-stage optimal trading under transaction costs and a diversi cation constraint ... we analyze the stage-wise optimal

of Operations Research, 152(1):341–365, 2007.

Altarovici, A., J. Muhle-Karbe, and H. M. Soner. Asymptotics for fixed transaction costs. Finance and

Stochastics, 19(2):363–414, 2015.

Lo, A.W., H. Mamaysky, and J. Wang. Asset prices and trading volume under fixed transactions costs.

Technical report, National Bureau of Economic Research, 2001.

Morton, A.J. and S.R. Pliska. Optimal portfolio management with fixed transaction costs. Mathematical

Finance, 5(4):337–356, 1995.

Korn, R. Portfolio optimisation with strictly positive transaction costs and impulse control. Finance and

Stochastics, 2(2):85–114, 1998.

Fliess, M. and C. Join. A mathematical proof of the existence of trends in financial time series. Systems

Theory: Modelling, Analysis and Control, pages 43–62, 2009.

Carla Gomes and Henri Waelbroeck. Transaction cost analysis to optimize trading strategies. The Journal

of Trading, 5(4):29–38, 2010.

Robert Kissell. The science of algorithmic trading and portfolio management. Academic Press, 2013.

Robert Kissell. Transaction cost analysis: A practical framework to measure costs and evaluate performance.

The Journal of Trading, 3(2):29–37, 2008.

Robert Kissell. The expanded implementation shortfall: Understanding transaction cost components. The

Journal of Trading, 1(3):6–16, 2006.

Puterman, M. Markov decision processes: discrete stochastic dynamic programming. Monographs on Tech-

nical Aspects. John Wiley & Sons, 2005.

Irene Aldridge. High-frequency trading: a practical guide to algorithmic strategies and trading systems,

volume 604. John Wiley & Sons, 2013.

David Bowen, Mark Hutchinson, and Niall O’Sullivan. High frequency equity pairs trading: transaction

costs, speed of execution and patterns in returns. 2010.

25