Efficient Computation of Optimal Trading Strategies
Efficient Computation of Optimal Trading Strategies
Abstract
Given the return series for a set of instruments, a trading strategy is a switching function
that transfers wealth from one instrument to another at specified times. We present efficient
algorithms for constructing (ex-post) trading strategies that are optimal with respect to the total
return, the Sterling ratio and the Sharpe ratio. Such optimal strategies are useful as benchmarks,
and for identifying the optimal trades that can be used to to teach (ex-ante) predictors within
a learning framework.
1 Introduction
A trader has in mind the task of developing a trading system that optimizes some profit criterion,
the simplest being the total return. A more conservative approach is to optimize a risk adjusted
return. Widely followed measures of risk adjusted returns are the Sterling Ratio and Sharpe Ratio.
In an enviroment where markets exhibit frequent crashes and portfolios encounter sustained periods
of losses, the Sterling ratio and the Sharpe ratio have emerged as the leading performance measures
used in the industry. Given a set of instruments, a trading strategy is a switching function that
transfers the wealth from one instrument to another. In this paper, we consider the problem of
finding optimal trading strategies, i.e., trading strategies that maximize a given optimality criterion.
In particular, we consider optimal strategies with respect to the total cumulative return, as well
as with respect to various risk adjusted measures of return (the Sterling ratio and variants of the
Sharpe ratio). A brute force approach to obtaining such optimal trading strategies would search
through the space of all possible trading strategies, keeping only the one satisfying the optimality
1
criterion. Since the number of possible trading strategies grows exponentially with time, the brute
force approach leads to an exponential time algorithm1 , which for all practical purposes is infeasible
– even given the pace at which computing power grows. The contribution in this work is to give
efficient (polynomial time) algorithms to compute the optimal trading strategy for various profit
objectives, and under constraints on the number of trades that can ber made.
Our motivations for constructing such optimal strategies are: (i) Knowing what the optimal
trades are, one can one can try to learn to predict good trading opportunities by using market
and/or technical indicators as features on which to base the prediction. A host of such activity
goes under the name of financial engineering. (ii) The optimal performance modulo certain trading
constraints can be used as a benchmark for real trading systems. For example, how good is a trading
system that makes ten trades with a Sterling ratio of 4 over a given time period? One natural
comparison is to benchmark this trading strategy against a Sterling-optimal trading strategy that
makes at most ten trades over the same time period. (iii) Optimal trading strategies (with or
without constraints) can be used to quantitatively rank various markets (and time scales) with
respect to their profitability according to a given criterion. So for example, one could determine
the optimal time scale on which to trade a particular market, or given a set of markets, which is the
most (risk adjusted) profit-friendly. (iv) Given a model for the behavior of a pair of instruments,
one can use the efficient algorithms presented here to construct optimal strategies using simulation.
In order to make the preceeding discussion more precise and to more accurately state our results,
lets introduce a few definitions. Assume that we have two instruments, for concreteness, a stock S
and a bond B with price histories {S0 , . . . , Sn } and {B0 , . . . , Bn } over n consecutive time periods,
ti , i ∈ {1, . . . , n}. Thus, for example, over time period ti , the price of stock moved from Si−1 to Si .
We denote the return sequence for the two instruments by {s1 , . . . , sn } and {b1 , . . . , bn } respectively:
si = log SSi−1
i
, and correspondingly, bi = log Bi
Bi−1 . We assume that one of the instruments is the
benchmark instrument, and that all the equity is held in the benchmark instrument at the begining
and end of trading. The bond is usually considered the benchmark instrument, and for illustration,
we will follow this convention. The trivial trading strategy is to simply hold onto bond for the
entire duration of the trading period. It is useful to define the excess return sequence for the stock,
ŝi = si − bi . When the benchmark instrument is the bond, the excess return as we defined it is the
conventionally used one. However, one may want to measure performances of a trading strategy
with respect to the S&P 500 as benchmark instrument, in which case the excess return would be
determined relative to the S&P 500 return sequence. The excess return sequence for the bond
is just the sequence of zeros, b̂i = 0. Conventionally, the performance of a strategy is measured
1
The asymptotic running time of an algorithm is measured in terms of the input size n. If the input is a time
sequence of n price data points, then polynomial time algorithms have run time that is bounded by some polynomial
in n. Exponential time algorithms have running time greater than some exponentially growing function in n [7].
2
relative to some trivial strategy, so the excess return sequence will be the basis of most of our
performance measures.
Definition 1.1 (Trading Strategy) A trading strategy T is a boolean n-dimensional vector in-
dicating where the money is at the end of time period ti :
1 if money is in stock at the end of ti ,
T [i] =
0 if money is in bond at the end of ti .
We assume that T [0] = T [n] = 0, i.e., all the money begins and ends in bond. A trade is entered
at time ti if T [i] = 0 and T [i + 1] = 1. A trade is exited at time ti if T [i] = 1 and T [i + 1] = 0.
The number of trades made by a trading strategy is equal to the number of trades that are entered.
ET [i]
rT [i] = log − bi . (1)
ET [i − 1]
If we ignore the bid-ask spread, then the excess return in time period ti is given by
The bid-ask spread affects the return, reducing it by an amount depending on T [i − 1]. Denoting
3
this transactions cost attributable to T [i] by ∆[i], we have that
where fˆS = log(1+fS ) and fˆB = log(1+fB ). Thus, the bid-ask spread can be viewed as introducing
an instantaneous return of −fˆB or −fˆS whenever the position is switched. To exactly which time
period this transactions cost is applied may depend on the nature of the market, i.e., it may be
applied to rT [i], rT [i − 1] or rT [i + 1]. The nature of the results will not change significantly
for either of these options, so in our algorithms, we will generally make the choice that offers the
greatest technical simplicity. For a trading strategy T , we define the total return µ(T ), the sum of
the squared returns s2 (T ), the sum of squared deviations of the returns σ 2 (T ) and the maximum
drawdown M DD(T ) as follows,
n
X
µ(T ) = rT [i], (4)
i=1
Xn
s2 (T ) = rT [i]2 , (5)
i=1
n 2
2
X 1 1
σ (T ) = rT [i] − µ(T ) = s2 (T ) − µ2 (T ), (6)
n n
i=1
l
X
M DD(T ) = max − rT [i]. (7)
1≤k≤l≤n
i=k
When it is clear from the context what trading strategy we are talking about, we will generally
suppress the explicit dependence on T . The performance measures that we consider in this paper
are derived from these statistics. In particular, we are interested in the total return µ, the Sterling
ratio Strl, and variants of the Sharpe ratio, Shrp1 and Shrp2 :
Shrp1 is the conventionally used Sharpe ratio. Shrp2 is a more risk averse performance measure, as
it is more sensitive to the variance in the returns. Often, Strl as we have defined it is refered to as
the Calmar ratio in the literature [11], and the Sterling ratio adds a constant (for example 10%) to
the M DD in the denominator [1]. Such a constant can easily be accomodated by our algorithms,
and so we will maintain this simpler definition for the Sterling ratio.
The contribution of this paper is efficient algorithms for computing optimal trading strategies.
We will use standard O() notation in stating our results: let n be the length of the returns sequences;
we say that the run time of an algorithm is O(f (n)) if, for some constant C, the runtime is ≤ Cf (n)
4
for any possible return sequences. If f (n) is linear (quadratic), we say that the runtime is linear
(quadratic). We will establish the following results.
Theorem 1.2 (Return Optimal Trading Strategies) A total return optimal trading strategy
can be computed in linear time. Specifically,
i. Unconstrained Trading. A trading strategy Tµ can be computed in O(n) such that for any
other strategy T , µ(Tµ ) ≥ µ(T ).
ii. Constrained Trading. A trading strategy TµK making at most K trades can be computed in
O(K · n) such that for any other strategy T K making at most K trades, µ(TµK ) ≥ µ(T K ).
Theorem 1.3 (Sterling Optimal Trading Strategies) A Sterling optimal trading strategy can
be computed in near linear time. Specifically,
i. Unconstrained Trading. A trading strategy TStrl can be computed in O(n log n) such that
for any other strategy T , Strl(TStrl ) ≥ Strl(T ).
Theorem 1.4 (Sharpe Optimal Trading Strategies) A Sharpe optimal trading strategy can
be computed in near quadratic time. Specifically, trading strategies TShrp1 and TShrp2 can be found in
O(n2 log n) such that for any other strategy T , Strl1 (TShrp1 ) ≥ Strl1 (T ) and Strl2 (TShrp2 ) ≥ Strl2 (T )
In all cases, our proofs are constructive, and so immediately give the algorithms for performing the
desired computations. Next, we discuss the existing related work, followed by a detailed discussion
of the algorithms, along with all necessary proofs.
Related Work
The body of literature on optimal trading is so enormous that we only mention here some represen-
tative papers. All the reasearch on optimal trading falls into two broad categories. The first group
is on the more theoretical side where researchers assume that stock prices satisfy some particular
model, for example the prices are driven by a stochastic process of known form; the goal is to
5
derive closed-form solutions for the optimal trading strategy, or a set of equations that the optimal
strategy must follow. We highlight some of this research below.
Lobo et al. in [16] consider the problem of single-period portfolio optimization. They consider
the maximization of the expected return subject to different types of constraints on the portfolio
(margin, diversification, budget constraints and limits on variance or shortfall risk). Under the
assumption that the return on asset i at the end of period is the random variable ai and both first
and second moments of the joint distribution of the random variables are known, this optimization
problem can be represented as a convex optimization problem and thus can be efficiently solved by
a numerical methods (eq. by Karmarkar’s interior-point method [14]).
Thompson in [24] considered the problem of maximizing the (expected) total cumulative return
of a trading strategy under the assumption that the asset price satisfies a stochastic differential
equation of the form dSt = dBt + h(Xt )dt, where Bt is a Brownian motion, h is a known function
and Xi is a Markov Chain independent of the Brownian motion. In this work, he assumes fixed
transaction costs and imposes assumptions A1, A2, A4 on the trading. He also imposes a stricter
version of our assumption A3: at any time, trader can have only 0 or 1 unit of stock. He proves that
the optimal trading strategy is the solution of a free-boundary problem, gives explicit solutions for
several functions h and provides bounds on the transaction cost above which it is optimal never to
buy the asset at all.
Pliska et al. in [4] considered the problem of an optimal investment for a continuous-time
market consisting of the usual bank account, a rolling horizon bond and a discount bond whose
maturity coincides with the planning horizon. They assume interest rates to be stochastic (driven
by a stochastic differential equation) and derive an equation satisfied by the trading strategy that
maximizes the HARA utility wealth function.
Bielecki in [3] considered the problem of maximizing the risk sensitive expected exponential
growth rate of the investor’s portfolio in a economy model consisting of a bank account and a risky
security (stock) with a stochastic interest rate. The optimal trading strategy is characterized in
terms of a nonlinear quasi-variational inequality and he developed a numerical approach to solving
this equation.
Berkelaar and Kouwenberg in [2] considered asset allocation in a mean versus downside-risk
framework. Downside-risk measures penalize only negative returns relative to a given benchmark.
Investors have a trade-off between mean and downside-risk. Closed-form solutions for the optimal
asset allocation are derived for the case where asset prices follow geometric Brownian motions with
constant interest rate.
The main drawbacks of such theoretical approaches is that their prescriptions can only be useful
to the extent that the assumed models are correct. Our work does not make any assumptions about
the price dynamics to construct ex-post optimal trading strategies. The second group of research
6
which is more on the practical side is focused on exploring learning methods for the prediction
of future stock prices moves. Intelligent agents are designed by training on past data and their
performance is compared with some benchmark strategies. Our results furnish (i) optimal strategies
on which to train intelligent agents and (ii) benchmarks with which to compare their performance.
Liu in [15] consider the optimal investment policy of a constant absolute risk aversion (CARA)
investor who faces fixed and proportional transaction costs when trading multiple risky assets. He
show that when asset returns are uncorrelated, the optimal investment policy is to keep the dollar
amount invested in each risky asset between two constant levels and upon reaching either of these
thresholds, to trade to the corresponding optimal targets.
Zakamouline in [27] studies the optimal portfolio selection problem for a constant relative risk
averse investor who faces fixed and proportional transaction costs and maximizes expected utility
of the investor’s end-of-period wealth. The author applies the method of the Markov chain approxi-
mation to numerically solve for the optimal trading strategy. The numerical solution indicates that
the portfolio space is divided into three disjoint regions (Buy, Sell and No-Transaction), and four
boundaries describe the optimal strategy. If a portfolio lies in the Buy region, the optimal strategy
is to buy the risky asset until the portfolio reaches the lower (Buy) target boundary. Similarly, if
a portfolio lies in the Sell region, the optimal strategy is to sell the risky asset until the portfo-
lio reaches the upper (Sell) target boundary. All these boundaries are functions of the investor’s
horizon and the composition of the investor’s wealth.
Choi and Liu in [20] considered trading tasks faced by an autonomous trading agent. An au-
tonomous trading agent works as follows. First, it observes the state of the environment. According
to the environment state, the agent responds with an action, which in turn influences the current
environment state. In the next time step, the agent receives a feedback (reward or penalty) from
the environment and then perceives the next environment state. The optimal trading strategy for
the agent was constructed in terms of the agent’s expected utility (expected accumulated reward).
Cuoco et al. in [9] considered Value at Risk as a tool to measure and control the risk of the
trading portfolio. The problem of a dynamically consistent optimal porfolio choice subject to the
Value at Risk limits was formulated and they proved that the risk exposure of a trader subject to
a Value at Risk limit is always lower than that of an unconstrained trader and that the probability
of extreme losses is also decreased. They also prove that another risk measure - Tail Conditional
Expectation - is equivalent to the Value at Risk. In particular, they showed that in a dynamic
setting it is always possible to transform any given Tail Conditional Expectation limit into an
equivalent Value at Risk limit and conversely.
Dammon and Spatt in [19] explored the optimal trading and pricing of taxable securities with
asymmetric capital gains taxes and transaction costs. Under current U.S. tax law, gains on capital
assets are not taxed until the investor sells the asset and the tax rate that applies to capital gains
7
and losses may be a function of the investor’s holding period. These features give investors the
incentive to time their asset sales so as to minimize the tax burden of owning taxable securities.
In this work the optimal trading strategy is derived in the presence of capital gains taxes and
transaction costs and the implications of the optimal trading strategy for asset pricing is explored.
Mihatsch and Neuneier in [17] considered problem of optimization of a risk-sensitive expected
return of a Markov Decision Problem. Based on an extended set of optimality equations, risk-
sensitive versions of various well-known reinforcement learning algorithms were formulated and
they showed that these algorithms converge with probability one under reasonable conditions.
The Sharpe ratio was introduced in [21], [22] and since then became a popular and widespread
risk-sensitive measure of a portfolio performance. Faugere et al. in [6] used Sharpe ratio as one of
performance measures to compare effectiveness of different decision-making criteria. Pedersen et al.
in [18] performed empirical comparison of many performance measurement methodologies for the
global financial services sector and documented strong evidence in support of using Sharp-Ratio
based measures. It was also pointed out that correlation of the Sterling ratio with other measures
is usually small and dips below 5% in some instances.
A number of authors associated with BARRA (a major supplier of analytic tools and databases)
have used the terms information ratio [10] or Appraisal ratio instead [25]. Goodwin in [10] considers
the relationship between the Sharpe ratio and other performance measures, compares four methods
of annualizing an information ratio, and presents the empirical evidence on the distribution of
information ratios by style, which provides a context in which to examine manager performance.
Surprisingly, there is little previous research on portfolio optimization with respect to the Sharpe
ratio or Sterling ratio, partially because of the intristic difficulty of these non-linear optimization
criteria.
Moody and Saffell in [13] presented methods for optimizing portfolios, asset allocations and
trading systems based on a direct reinforcement approach. In this approach, investment decision
making is viewed as a stochastic control problem and the need to build forecasting models is elim-
inated. An adaptive algorithm called recurrent reinforcement learning for discovering investment
policies was proposed and they demonstrated how it can be used to optimize risk-adjusted invest-
ment returns like the Sterling Ratio or Sharpe Ratio, while accounting for the effects of transaction
costs.
Liu et al. in [26] proposed a learning-based trading strategy for portfolio management, which
aims at maximizing the Sharpe Ratio by actively reallocating wealth among assets. The trading
decision is formulated as a non-linear function of the latest realized asset returns, and the function
cam be approximated by a neural network. In order to train the neural network, one requires a
Sharpe-Optimal trading strategy to provide the supervised learning method with target values. In
this work they used heuristic methods to obtain a locally Sharp-optimal trading strategy. The
8
transaction cost was not taken into consideration. Our methods can be considerably useful in the
determination of target trading strategies fot such approaches.
Tasche and Tibiletti in [23] explored ways to speed up the online computation of the Sharpe
ratio of a current portfolio and how the Sharpe ratio will change if a candidate new asset will be
incorporated into the portfolio. Approximation formulae were derived that are based on certain
derivatives of the Value-at-Risk.
Hellstrom in [12] formulates an alternative formulation of the stock prediction problem based
on a statistical investigation of the stock’s ranks. In this work a single perceptron neural network
is trained to find the parameter vector that maximizes the Sharpe ratio. Due to the lack of the
Sharpe-optimal trading decisions that can be supplied as target values, a special technique for
optimization without derivatives is utilized [8].
First we give the main definitions that we will need in the dynamic programming algorithm to
compute the optimal strategy. Consider a return-optimal strategy for the first m time periods,
[t1 , tm ]. Define S[m, 0] (S[m, 1]) to be a return-optimal strategy over the first m periods ending
in bond (stock) at time tm . For ℓ ∈ {0, 1}, let µ[m, ℓ] denote the return of S[m, ℓ] over [t1 , tm ],
i.e., µ[m, ℓ] = µ(S[m, ℓ]). Let Prev[m, ℓ] denote the penultimate position of the optimal strategy
S[m, ℓ] just before the final time period tm .
The optimal strategy S[m, ℓ] must pass through either bond or stock at time period m − 1.
Thus, S[m, ℓ] must be the extension of one of the optimal strategies {S[m − 1, 0], S[m − 1, 1]} by
adding the position ℓ at time period tm . More specifically, S[m, ℓ] will be the extension that yields
the greatest total return. Using (2) and (3), we have that
9
Since µ[m, ℓ] is the maximum of these two values, we have the following recursion,
n o
µ[m, ℓ] = max µ[m − 1, 0] + ŝm ℓ − fˆS ℓ, µ[m − 1, 1] + ŝm ℓ − fˆB (1 − ℓ) .
The position of the optimal strategy S[m, ℓ] just before time period m is given by the ending
position of the strategy that was extended. Thus,
0 if µ[m − 1, 0] + ŝm ℓ − fˆS ℓ ≥ µ[m − 1, 1] + ŝm ℓ − fˆB (1 − ℓ),
Prev[m, ℓ] =
1 otherwise.
If we already know µ[m − 1, 0] and µ[m − 1, 1], then we can compute µ[m, ℓ] and Prev[m, ℓ] for
ℓ ∈ {0, 1} in constant time. Further, we have that µ[1, 0] = 0 and µ[1, 1] = ŝ1 − fˆS , and so, by a
straight forward induction, we can prove the following lemma.
Lemma 2.1 Prev[m, ℓ] for all ℓ ∈ {0, 1} and m ≤ n can be computed in O(n).
The optimal strategy Tµ is exactly S[n, 0]. Prev[n, 0] gives the position at tn−1 , and the optimal
way to reach Prev[n, 0] at tn−1 is given by optimal strategy S[n − 1, Prev[n, 0]]. Continuing
backward in this fashion, it is easy to verify that we can reconstruct the full strategy Tµ using the
following backward recursion:
Tµ [n] = 0,
Tµ [m] = Prev[m + 1, Tµ [m + 1]], for 1 ≤ m < n.
Thus, a single backward scan is all that is required to compute Tµ [i] for all i ∈ {1, . . . , n}, which
is linear time, and so we have proved the first part of Theorem 1.2. Further, it is clear that the
algorithm requires memory that is linear in n to store Prev[m, ℓ]. While we have assumed that
the algorithm works with excess returns, the optimal strategy does not depend on this assumption,
thus the algorithm works correctly even with the actual return sequences. The generalization of
this algorithm to N > 2 instruments is straightforward by suitably generalizing a trading strategy.
S[m, ℓ] retains its definition, except now ℓ ∈ {0, . . . , N − 1}. To compute µ[m, ℓ] will need to take a
maximum over N terms depending on µ[m − 1, ℓ′ ], and so the algirithm will have runtime O(N n).
One concern with the unconstrained optimal strategy is that it may make too many trades. It
is thus useful to compute the optimal strategy that makes at most a given number of trades. We
discuss this next.
10
2.2 Constrained Return-Optimal Strategies
We suppose that the number of trades is constrained to be at most K. It is more convenient to
consider the number of jumps k, which we define as the sum of the number of trades entered and
the number exited. For a valid trading strategy, the number of trades entered equals the number
of trades exited, so k = 2K. Analogous to S[m, ℓ] in the previous section, we define S[m, k, ℓ] to be
the optimal trading strategy to time period tm that makes at most k jumps ending in instrument
ℓ. Let µ[m, k, ℓ] be the return of strategy S[m, k, ℓ], and let Prev[m, k, l] store the pair (k′ , ℓ′ ),
where ℓ′ is the penultimate position of S[m, k, ℓ] at tm−1 that leads to the end position ℓ, and k′
is the number of jumps made by the optimal strategy to time period tm−1 that was extended to
S[m, k, ℓ].
The algorithm once again follows from the observation that the the optimal strategy S[m, k, ℓ]
must pass through either bond or stock at tm−1 . A complication is that if the penultimate position
is bond and ℓ = 0, then at most k jumps can be used to get to thhe penultimate position, however,
if ℓ = 1, then only at most k − 1 jumps may be used. Similarily if the penultimate position is stock.
We thus get the following recursion,
n o
µ[m, k, 0] = max µ[m − 1, k, 0], µ[m − 1, k − 1, 1] − fˆB ,
n o
µ[m, k, 1] = max µ[m − 1, k − 1, 0] + ŝm − fˆS , µ[m − 1, k, 1] + ŝm .
This recursion is initialized with µ[m, 0, 0] = 0 and µ[m, 0, 1] = NULL for 1 ≤ m ≤ n. Once µ[m, k, ℓ]
is computed for all m, ℓ, then the above recursion allows us to compute µ[m, k + 1, ℓ] is computed
for all m, ℓ. Thus, the computation of µ[m, k, ℓ] for 1 ≤ m ≤ n, 0 ≤ k ≤ 2K and ℓ ∈ {0, 1} can be
accomplished in O(nK). Once again, the strategy that was extended gives Prev[m, k, ℓ],
(k, 0) if µ[m − 1, k, 0] > µ[m − 1, k − 1, 1] − fˆB ,
Prev[m, k, 0] =
(k − 1, 1) otherwise.
(k − 1, 0) if µ[m − 1, k − 1, 0] + ŝm − fˆS > µ[m − 1, k, 1] + ŝm ,
Prev[m, k, 1] =
(k, 1) otherwise.
Since computing µ[m, k, ℓ] immediately gives Prev[m, k, ℓ], we have the following lemma,
Lemma 2.2 Prev[m, k, ℓ] for all ℓ ∈ {0, 1}, m ≤ n and k ≤ 2K can be computed in O(nK).
TµK is given by S[n, 2K, 0], and the full strategy can be reconstructed in a single backward scan
11
using the following backward recursion (we introduce an auxilliary vector κ),
TµK [n] = 0,
(κ[n − 1], TµK [n − 1]) = Prev[n, 2K, TµK [n]),
(κ[m], TµK [m]) = Prev[m + 1, κ[m + 1], TµK [m + 1]), for 1 ≤ m < n − 1.
Since the algorithm needs to store Prev[m, k, ℓ] for all m, k, the memory requirement is O(nK).
Once again, it is not hard to generalize this algorithm to work with N instruments, and the resulting
run time will be O(nN K).
First, we will upper bound M DD(Tµ ), because this in turn serves as an upper bound for the
M DD of the Sterling-optimal strategy,
Since the cost (in terms of the cumulative return) of entering and exiting a trade is −(fˆS + fˆB ), no
segment of the optimal trading strategy Tµ should lose more than this in return.
Lemma 3.2 For any i < j, CTµ [j] − CTµ [i] ≥ −(fˆS + fˆB ).
Proof: Suppose, for contradiction, that for some i < j, CTµ [j] − CTµ [i] < −(fˆS + fˆB ). By setting
Tµ [i + 1], . . . , Tµ [j] to be all equal to 0, it is easy to verify that the cumulative return of the strategy
must increase, which contradicts the optimality of Tµ .
For technical convenience, we will assume that the transactions cost when entering a trade is
assigned to the time period prior to the entry, and the transactions cost when exiting a trade is
assigned to the time period after the trade. Note that just prior to entering, the position is 0 and
12
so it will now have a return of −fˆS , and just after exiting, the position is 0, and will now have a
return of −fˆB .
Let fsp = fˆS + fˆB . From Lemma 3.2, no segment of the optimal strategy can lose more than fsp ,
and so this immediately gives an upper bound on M DD(Tµ ). For the trivial strategy that makes
no trades, the M DD is 0. If a strategy makes exactly one trade, then there is a drawdown of at
least fˆS at the begining, and of at least fˆB at the end. If at least two trades are made, then there
is a drawdown of at least fsp between the exit of one trade and the entry of another, and since
the drawdown cannot exceed fsp , the M DD must therefore equal fsp. We thus have the following
lemma.
note that if we relax assumption A1, then by legging into a trade, it may be possible to decrease
the drawdown, in which case Lemma 3.3 would no longer be valid. We are now ready to discuss
the O(n log n) algorithms to obtain Sterling-optimal trading strategies. First we will consider
unconstrained Sterling optimal strategies, and then we will require number of trades ≤ K.
For a degenerate trading system with all returns equal to zero, we define its Sterling ratio as 1. The
only trading system with a M DD of 0 is a degenerate trading system, so with this definition, the
Sterling ratio is defined for all possible trading systems. The computation of the Sterling-optimal
trading system breaks down into three cases, according to the number of trades its makes:
Sterling-optimal that makes one trade. The trading strategy contains a single interval of 1’s.
Sterling-optimal that makes at least two trades. Any trading system that makes at least
two trades has an M DD ≥ fsp . Since M DD(Tµ ) ≤ fsp (Lemma 3.3), Tµ has the smallest
M DD among all such systems. Since it also has the highest total return, we conclude that if
the Sterling-optimal system makes at least two trades, then TStrl = Tµ .
The first case is trivially computed. The third case, i.e., the Sterling optimal strategy that makes
at least two trades can be computed in linear time using the dynamic programming algorithm to
compute Tµ . If we also compute the Sterling-optimal system that makes exactly one trade, then, we
solve our problem by taking the case with the maximum Sterling ratio. We now focus on finding
the trading strategy that makes only one trade and has greatest Sterling Ratio among all such
strategies.
13
Let T be a strategy that makes exactly one trade. The trade interval is the interval of time
periods, [ti , tj ] on which T = 1, i.e., the trade interval is an interval of 1’s in the trading strategy.
An elementary algorithm that considers all the O(n2 ) possible trade intervals, picking the best is
a quadratic time algorithm. The remainder of this section is devoted to providing an algorithm
which computes such a strategy in O(n log n) time, which will complete the proof of the first part
of Theorem 1.3. In fact the algorithm that we present is a much more general algorithm that
computes the single interval that optimizes a general class of optimality criteria. This algorithm
will be useful when we discuss the Sharpe-optimal strategy.
Consider a consecutive sequence of time periods ti , ti+1 , . . . , ti+k where k ≥ 1, with all the excess
returns non-negative and the last one positive, i.e., ŝi ≥ 0, ŝi+1 ≥ 0, . . . , ŝi+k > 0.
Lemma 3.4 Either the optimal single trade interval does not intersect these time periods, or an
optimal single interval can be chosen to contain this interval.
Proof: Suppose that T [i + j] = 1 and T [i + j + 1] = 0 for some 0 ≤ j < k. Extend the trading
interval by setting T [i + j + 1] = 1, . . . , T [i + k] = 1, which adds positive return, without increasing
the M DD, contradicting the optimality of the original interval. On the other hand, suppose that
T [i + j] = 1 and T [i + j − 1] = 0 for some 0 < j ≤ k. Once again, by extending the trading interval,
setting T [i] = 1, . . . , T [i + j] = 1, we add non-negative returns, without increasing the M DD hence
this new interval is at least as good as the previous interval.
A similar result holds for a sequence of consecutive negative time periods, ti , ti+1 , . . . , ti+k where
k ≥ 1, with ŝi ≤ 0, ŝi+1 ≤ 0, . . . , ŝi+k < 0. If an optimal trading interval only intersects part of
these time periods, this intersection can be removed without decreasing the Sterling ratio. Thus,
by Lemma 3.4, any sequence of time periods with all returns non-negative (non-positive) can be
condensed into a single time period, t′i = ti + · · · + ti+k , with ŝ′i = ŝi + · · · + ŝi+k . Further, this
operation can be performed in linear time on the entire excess return sequence, so from now on
we assume without loss of generality that the excess return sequence consists of alternating time
periods of strictly positive and negative excess returns. If ŝi < 0, then ti cannot be the first 1 of
a trade, since by entering one time period later, we exclude only this negative return and do not
increase the M DD. Similarily, it cannot be the last 1 of a trade.
Lemma 3.5 The first 1 and the last 1 of the optimal trade interval must occus at time periods tf
and tl for which ŝf > 0 and ŝl > 0.
The pictorial illustration of this lemma is given below where we show the cumulative return curve.
The time instants ai are the possible entry points, and the time instants bi are the possible exit
points.
14
b4 b6
Cumulative Return
b3 b5
b1
b2
a4
a5 a6
a2
a1 a3
Time
Let the alternating sequence of entry and exit points be {a1 , b1 , a2 , b2 , . . . , ak , bk } (ai are the entry
points, and bi are the exit points). Note that after the preprocessing into alternating intervals,
k ≤ ⌈ n/2 ⌉. Notice that without loss of generality, we can throw away the first interval if it has a
negative return, as it can never be an entry point, and the last interval if it has a negative return,
for a similar reason. The optimal trade interval will be of the form (at , bt+r ), r ≥ 0.
Our algorithm for finding the Sterling-optimal interval will be to consider every possible starting
point ai , and find the Sterling-optimal interval with this point as starting point (i.e. we have to
find the end point of this interval). As the algorithm proceeds, we keep track of the best entry
point (and its corresponding exit point). The entry points at are processed from right to left.
After processing a new entry point at , we will modify the alternating sequence to facilitate faster
processing of the remaining points. More specifically, we will delete the processed entry point and
add a weight to the edge between bt−1 and bt to preserve all the necessary information – we cannot
simply delete the entry point at , since we have to keep track of maximum MDD that occurs in our
activity interval. Since between bt−1 and at we have a drawdown of bt−1 − at , we need to keep this
information in an edge weight connecting bt−1 to bt . Please note that at any stage of algorithm
edge weight connecting bt−1 to bt will be equal to the MDD of the interval [bt−1 , bt ] and this MDD
is realized on prefix of [bt−1 , bt ], i.e. M DD([bt−1 , bt ]) = C(bt−1 ) − C(x), for some x ∈ [bt−1 , bt ] -
Invariant (*). We will show this weight attached to bt in parentheses, (wt )bt , where the value of
wt appearing in parentheses indicates the weight.
We start our backward scan at the last entry point, ak , for which there is only one pos-
sible interval (ak , bk ). We update the weight wk ← bk−1 − ak , store the current best interval
(ak , bk , Strlk ), and delete the possible start point ak from the sequence to give the processed se-
quence {a1 , b1 , ..., ak−1 , bk−1 , (wk )bk }. Note that (ak , bk , Strlk ) is a one-step trade, but we keep it
here for simplicity. We now proceed to ak−1 and so on.
In the general case, suppose we have processed (backwards) all the entry points up to (including)
the entry point at+1 , and are currently processing entry point at . The weighted exit sequence is
{a1 , b1 , ..., at , bt , (wt+1 )bt+1 , . . . , (wt+m )bt+m }. bt , . . . , bt+m are the possible exit points – note that
t + m may not equal k due to possible deletion of points which we discuss below. Assume that
{bt+1 < . . . < bt+m }: this is true after we have processed the first start point (since the sequence
consists only of one point), and we will maintain this condition by induction. If bt < bt+1 , then the
15
entire sequence of exit points is monotonically increasing. On the other hand, if bt ≥ bt+1 , bt+1 need
not be considered as an exit point for any optimal interval with entry point at or earlier, because
by stopping earlier at bt , we do not decrease the cumulative return, nor increase the M DD. Hence,
we can delete the possible exit point bt+1 . However, we must now update the weight in (wt+2 )bt+2
to store the new drawdown between bt and bt+2 as follows wt+2 ← max{wt+1 , wt+2 + bt − bt+1 }.
at , bt , (wt+1 )bt+1 , . . . , (wt+m )bt+m → at , bt , (max{wt+1 , wt+2 + bt − bt+1 })bt+2 , . . . , (wt+m )bt+m
The correctness of the weight updating rule above follows from the Invariant (*). Please note that
the transformation above preserves the Invariant (*).
This process is continued until the next exit point after bt is either above bt or there are no
remaining exit points after bt . In either event, the new sequence of exit points available for at is
strictly monotonically increasing (by the induction hypothesis). Observe that any deletion of a
possible exit point is a constant time operation. Further, since each deletion drops a point from the
set {b1 , . . . , bk }, there can be at most k − 1 such deletions during the course of the entire algorithm.
We thus have the following lemma.
Lemma 3.7 When at is processed by the algorithm, the exit points bt < bt+1 < · · · are monotoni-
cally increasing. The cost of maintaining this condition for the entire algorithm is O(k) operations.
When processing at , the weighted exit sequence is {a1 , b1 , ..., at , bt , (wt+1 )bt+1 , . . . , (wt+m )bt+m }.
Suppose that wt+2 < wt+3 < . . . < wt+m . Initially this sequence is the empty sequence and so this
condition holds, and once again, by induction we will ensure that this condition will always hold. If
wt+1 ≥ wt+2 , then no optimal interval can have entry point at or earlier, and exit at bt+1 , because
otherwise by exiting at bt+2 , since bt+2 > bt+1 (Lemma 3.4), the M DD is not increased, however
the total return is increased. Thus if wt+1 ≥ wt+2 , we can remove the possible exit point bt+1 from
the weighted exit sequence and update wt+2 ← wt+1 . Please note that this transformation also
preserves the Invariant (*).
Lemma 3.8 If wt+1 ≥ wt+2 , the weighted exit sequence is updated as follows:
We continue removing exit points in this way until either there is only one weight left in the weighted
exit sequence, or all the weights are strictly monotonically increasing (by induction).
Suppose that wt+1 ≤ f . In this case, we observe that bt cannot be the exit of an optimal interval
with entry at−r , where r ≥ 0. To see this note that if bt − at−r − fˆS < 0, then the return of this
16
interval is negative and this interval cannot be an optimal interval. If bt − at−r − fˆS ≥ 0 then since
the interval already has M DD of at least f , so by continuing to bt+1 , we do not increase the M DD
but strictly increase the return, hence it cannot be optimal to exit at bt .
be the weighted exit sequence and let T ∈ [t, . . . , t + m] be such an index that wT < f and wT1 ≥ f .
Then no Sterling-optimal interval that starts at at or earlier can exit at {bt , . . . , bT −1 }.
Lemma 3.10 When at is processed by the algorithm, the weights wt+1 are monotonically increas-
ing. The cost of mainitaining this condition for the entire algorithm is O(k) operations.
We thus assume from now on that when processing entry point at , the weighted exit sequence
{a1 , b1 , ..., at , bt , (wt+1 )bt+1 , . . . , (wt+m )bt+m } with m ≥ 0 satisfies the conditions of Lemmas 3.7 and
3.10. The first available exit gives the trade interval (at , bT ). If bT − at − fsp ≤ 0, i.e., if the return
is not positive, then this cannot possibly be an optimal interval. Otherwise, the Sterling Ratio is
bT − at − fsp
Strlt = ,
f
where fsp = fˆS + fˆB and f = max{fˆS , fˆB }. Now consider the exit points bT +r , r > 0, and suppose
that bT − wT +1 < at . No trade with entry at at , exiting at bT +r with r > 0 can possibly be optimal,
since we could always enter later at bT −wT +1 , exit at bT +r , and strictly increase the return without
increasing the drawdown. We are thus done with processing the entry point at , and we can proceed
bT −at −fsp
to at−1 after updating weight wt and comparing f with the current champion. Similarly,
if bt̄ − wt̄+1 < at for some t̄ ∈ [t, . . . , T − 1], we are done with the starting point at , and we can
proceed to at−1 after updating weight wt . We assume that at any stage of the algorithm we keep
the value of mint̄∈[t,...,T −1] bt̄ − wt̄+1 and thus this check can be done in constant time for any given
point at . Thus, without loss of generality, we can assume that bT − wT +1 ≥ at and bt̄ − wt̄+1 ≥ at
for all t̄ ∈ [t, . . . , T − 1]. Since wT +1 ≥ f , we conclude that bT − at ≥ f . A trade, entering at at
and exiting at bT +r , r > 0 has total return bT +r − at − fsp . The next lemma gives the M DD.
Lemma 3.11 Assume that bT − wT +1 ≥ at and bt̄ − wt̄+1 ≥ at for all t̄ ∈ [t, . . . , T − 1]. The trade
(at , bT +r ), r > 0, has M DD = wT +r .
Proof: The local maxima of the cumulative return sequence for this trade are {0, bt − at −
fˆS , , . . . , bT − at − fˆS , . . . , bT +r − at − fˆS }. Since bt̄ − wt̄+1 − at ≥ 0 ∀t̄ ∈ [t, . . . , T − 1], M DD of the
interval [at , bT ] is equal to fˆS .
17
Since bT − at − fˆS ≥ 0 and since the sequence of exit points is strictly increasing,
M DD([at , bT +r ]) = max(M DD([at , bT ]), M DD([bT , bT +r ])) = max(fˆS , M DD([bT , bT +r )), fˆB )
where fˆB is the draw down after the last point bT +r .
Since the drawdown at any time in a trade is given by the the diffenence between the previous
maximum and the current cumulative return, M DD([bT , bT +r )) is at most maxi∈[1,r] wt+i . Since
the weights are monotonically increasing, we see that this drawdown ≤ wt+r , which is achieved in
the interval (bt+r−1 , bt+r ). Since wt+r ≥ f = max(fˆS , fˆB ) ∀r > 0, we conclude M DD([at , bT +r ]) =
wt+r .
Summary: For entry point at , the sequence of exit points bT +r , r ∈ [0, m] have cumulative
returns cr = bT +r − at − fsp and M DD’s dr = wT +r for r > 0 and d0 = f . The task is to maximize
cr /dr with respect to r. The sequences {cr } and {dr } are both strictly increasing. We now describe
a general algorithm for performing such a maximization.
cr
3.1.1 Maximizing
dr
′ = {(d , c )}m . Let p′ = (0, 0). Then
On the two dimensional plane, consider the set of points Pm r r r=0
the slope of the line joining p to (dr , cr ) is exactly the Sterling ratio of the trade (at , bt+r ). Thus,
finding the optimal trade is equivalent to finding the upper-touching point from p to the convex
′ (see illustration below). We call p the source point.
hull of the set of points Pm
cr
p′ dr
18
be able to compute the upper tangent line efficiently. First we recall that the dr are monotonically
increasing. Assume that each point (dr , cr ) stores all the necessary forward and backward pointers.
We also assume that the point (dr , cr ) stores the pointer to the point nxt(r), which is the next point
in the convex hull if all the points d0 , . . . , dr−1 were removed – note that in this case, dr becomes
leftmost, and so must be in the convex hull. We will see that these assumptions are maintained
inductively. Note that the initial convex hull with all the points is given by (d0 , c0 ) followed by the
points pointed to by nxt(0), nxt(nxt(0)), . . .. We would like to perform the following operations on
our points and still be able to compute the upper tangent point efficiently:
Proof: Let A = O(m) be the size of the current convex hull. For (1), we do not change the points at
all, we simply compute the new tangent point for p′ = p+v, which can be accomplished in O(log A).
(2) is equivalent to shifting p by −v. To prove (3), notice that if we remove (d0 , c0 ), then the new
leftmost point becomes (d1 , c1 ) and we immediately have the new convex hull nxt(1), nxt(nxt(1)), . . ..
Thus we can find the new upper tangent point in O(log A′ ) = O(log m), where A′ is the size of
the new convex hull. Further, deleting (d0 , c0 ) requires first deleting the backward pointers of the
points that it points to O(log A), and then deleting the point itself, and its forward pointers (it
has no backward pointers), O(log A). To prove (4), note that when we add (d−1 , c−1 ), nxt(−1)
is exactly the upper tangent point from p′ = (d−1 , c−1 ) to the current convex hull. This can be
computed in O(log A). We now need to add all the necessary pointers into the data structure. For
each forward pointer we add, we will add the coresponding backward pointer as well. We need a
pointer at position 2j in the convex hull of (d−1 , c−1 ). But this is exactly the point at position 2j −1
in the convex hull of point nxt(−1). Since nxt(−1) maintains a pointer to point 2j in its convex
hull, and this point will have a backward pointer by one step of this same convex hull, we can
construct the forward an backward pointer for point 2j in the convex hull of (d−1 , c−1 ) in constant
time, requiring total time O(log A′ ) = O(log m) to construct all the new forward and backward
pointers, where A′ is the size of the new convex hull. We now construct the new upper tangent
point from p to the new convex hull of (d−1 , c−1 ) in O(log A′ ) time. The entire process is therefore
O(log m).
19
The algorithm that we have just described is a general purpose algorithm for efficiently maintaining
the upper tangent point to any set of points, as long as only a limited set of operations is allowed
on the set of points and the source point. We will now see that these limited operations are all
that is needed for maximizing the Sterling ratio.
Suppose that point at has been processed in the algorithm – i.e., the upper tangent point
(optimal trade with entry at at ) from pt = (0, at +fsp) to Pm = {(dr , bT +r )}m
r=0 has been computed.
Now consider the addition at−1 to construct the new weighted exit sequence. Delete the leftmost
point (d0 , bT ) from the convex hull. Lets consider all posible operations that may take place. There
are several possibilities.
i. bt−1 ≥ bt . We remove (leftmost) points bt+i , i ≥ 0, until bt−1 < bt+i+1 , and the new weight
′
wt+i+1 may have increased (Lemma 3.6). Deleting of points bt + i from the weighted exit
sequence doesn’t implies changes of the convex hull until t + i ≥ T . After this point, deleting
one point bT + i, i ≥ 0 from the weighted exit sequence followed by deletion of corresponding
leftmost point of the convex hull. At the very end of the sequence of deletions, we have to
′
update the MDD of point bt+i+1 from wt+i+1 to wt+i+1 , this can be done by deletion of the
′
point (wt+i+1 , bt+i+1 ) and addition of new point (wt+i+1 , bt+i+1 ). The total number of such
removals during the entire algorithm is at most n − 1. When condition bt−1 < bt is satisfied,
proceed to the next stage.
ii.1. wt+1 ≤ wt . We remove (leftmost) points bt+i , i ≥ 0, until wt < wt+i+1 . Deleting of
points bt + i from the weighted exit sequence doesn’t implies changes of the convex hull
until t + i ≥ T . After this point, deleting one point bT + i, i ≥ 0 from the weighted
exit sequence followed by deletion of corresponding leftmost point of the convex hull. By
Lemma 3.10, the total number of such removals cannot exceed n − 1 over the course of
the entire algorithm. When condition wt < wt+1 is satisfied, proceed to the next stage.
ii.2. bt−1 < bt and wt < wt+1 .
(a) f > wt . Add to the convex hull point (f, bT ).
(b) f < wt . Add to the convex hull points (wt , bt ) and (f, bt−1 ).
The new source point is pt−1 = (0, at−1 + fsp ), which just corresponds to a shift of pt , and so
once the new convex hull for the new weighted exit sequence is computed, an additional O(log n)
operations are needed to find the new upper tangent point.
The total number of removals in the entire algorithm is O(n). For each new entry point, we
have at most a constant number of additions, and since the number of entry points is O(n), we see
that the total number of additions is O(n). By Lemma 3.12, we have that each operation takes
20
O(log n) in the worst case, thus the total run time is O(n log n). Collecting all the results together,
we can find the Sterling-optimal strategies making zero, one or more than one trade in O(n log n)
time, completing the proof of the first part of Theorem 1.3.
Note that by only maintaining exit points with weight at most some given constant, M DD0 , i.e.,
by truncating some region of the points to the right, this algorithm is easily extended to computing
the Sterling-optimal strategy that uses exactly one trade and has an M DD ≤ M DD0 .
Proposition 3.13 Given M DD0 , a Sterling-optimal strategy that uses exactly one trade and has
M DD ≤ M DD0 can be computed in O(n log n) time.
Lemma 3.14 A maximal return-optimal strategy Tµ∗ can be computed in linear time.
If any trade interval of a maximal return-optimal strategy is extended in either direction, then
the total return must strictly decrease. In the previous section, we gave a O(n log n) algorithm for
computing the Sterling-optimal strategy with exactly 1 trade. We also saw that if the unconstrained
Sterling-optimal strategy contains more than 1 trade, then it is Tµ∗ . Fix K, and let the number of
trades that Tµ∗ makes be K0 ≤ K. In this case TStrl
K = T ∗ , and we are done. Thus we only need
µ
to consider the case that 1 < K < K0 . Some important properties of Tµ∗ are summarized below.
Pi
When it is clear, We also use Tµ∗ to refer to the set of trading intervals {Ir }K
r=1 . Let Ci =
0
j=1 ŝj
denote the cumulative return sequence of the excess returns.
21
ii. Suppose I does not intersect with any interval in Tµ∗ and let the return of I ( jk=i ŝk ) be µ(I).
P
Then, µ(I) ≤ fsp. If I is adjacent to some interval of Tµ∗ , then µ(I) < 0. If I is adjacent to
two intervals in Tµ∗ , then µ(I) < −fsp.
iii. Let [tl , tr ] and [tl′ , tr′ ] be two consecutive trade intervals in Tµ∗ , l ≤ r < l′ ≤ r ′ . Then,
Cr − Cl′ > fsp, and for all r < q < l′ , Cl′ < Cq < Cr .
Let {(ai , bi )} denote the local minima and maxima of {Ci }, as in the previous section. Any trade
of Tµ∗ or TStrl
K must enter (exit) at a local minimum (maximum). Further, the entry (exit) point
must be a minimum (maximum) in the trade, otherwise we can shrink the trade, strictly increasing
the return without increasing the M DD.
K .
We now give an important inclusion property of the TStrl
Proposition 3.17 Let Tµ∗ be a maximal return-optimal trading strategy. There exists a K-Sterling-
K , K > 1, with the following property: if I = [t , t ] is any trading interval in
optimal strategy TStrl l r
K , then a prefix of I and a suffix of I are trades in the maximal return-optimal strategy T ∗ .
TStrl µ
Proof: First we show that for every trading interval I ∗ = [ta , tb ] in Tµ∗ with I ∩ I ∗ 6= ∅, one can
K such that I ∗ ⊆ I. Suppose to the contrary, that for some I ∗ , either t < t and t ≥ t or
pick TStrl a l b l
K so that I ∗ ⊆ I.
ta ≤ tr and tb > tr . We will extend I without decreasing the Sterling ratio of TStrl
Suppose ta < tl and tb ≥ tl (a similar argument holds for ta ≤ tr and tb > tr ). There are two cases:
ii. I ∗ intersects with the previous trading interval of strategy TStrl K : ∃I ′ = [t ′ , t ′ ] ∈ T K such that
l r Strl
∗
Pl−1
ta ≤ tr′ < tl . Since [tr′ +1 , tl−1 ] is a subinterval of I , j=r′ +1 ŝj ≥ −fsp (Lemma 3.15). If we
merge I and I ′ by adding the interval [tr′ +1 , tl−1 ] into TStrl
K , we save on the transaction cost
of fsp, and so the total return will not decrease. We show that the M DD has not increased.
Since Cr′ is a maximum in [tl′ , tr′ ], the drawdown for all points in [tr′ +1 , tl ] is at most fsp . Since
Cl is a minimum in [tl , tr ], we conclude that the drawdown for any point in [tl , tr ] is at most
K ) ≥ f , we conclude that this merger does not increase
max{fsp , M DD(I)}. Since M DD(TStrl sp
the M DD.
22
K by removing I, without increasing the
Note that µ(I) ≥ 0 otherwise we improve the return of TStrl
K cannot possibly be optimal. Thus, without loss of generality, we assume that
M DD, ans so TStrl
the return of I is positive. Suppose that I ∩ Tµ∗ = ∅. Then, by adding I to Tµ∗ , we strictly increase
the return, a contradiction on the optimality of Tµ∗ . Thus, every interval of TStrl
K contains at least
one interval of Tµ∗ . Now consider the maximal prefix Pmax of I that does not overlap with any
interval of Tµ∗ . Since we know that I contains some interval of Tµ∗ , we conclude that this maximal
prefix must be adjacent to some interval of Tµ∗ . By Lemma 3.15, this interval has strictly negative
K , without increasing its M DD.
return, so removing it from I strictly increase the return of TStrl
K , thus, P
This contradicts the optimality of TStrl max must be empty. Similarily, the maximal suffix
of I that is non-intersecting with Tµ∗ must be empty, concluding the proof.
As a result of Proposition 3.17, we assume from now on that every interval of the sterling optimal
K is prefixed and suffixed by (not necessarily distinct) intervals from a maximal return-
strategy TStrl
optimal strategy that makes K0 trades.
K can be chosen to make exactly K trades.
Lemma 3.18 If 1 < K ≤ K0 then TStrl
Proof: If K = K0 , then Tµ∗ itself is K-Sterling-optimal. If K < K0 , we show that if the number
of trades made is less than K, we can always add one more interval without decreasing the Sterling
K cannot contain all the intervals of T ∗ , as otherwise (by
ratio of the strategy. First, note that TStrl µ
K contains two consecutive intervals
the pigeonhole principle) at least one interval I = [tl , tr ] of TStrl
I1 = [tl1 , tr1 ] and I1 = [tl2 , tr2 ] of Tµ∗ . The region between these two intervals has return less than
−fsp (Lemma 3.15), so breaking up I into the two intervals [tl , tr1 ] and [tl2 , tr ] will strictly increase
K . If T K does not
the return, without increasing the M DD, contradicting the optimality of TStrl Strl
contain some interval of Tµ∗ , then by adding this interval, we do not decrease the return or the
M DD (Lemma 3.15), since the M DD is already ≥ fsp .
K can be constructed: start with all the intervals of a maxi-
Lemmas 3.17 and 3.18 indicate how TStrl
mal return-optimal strategy Tµ∗ and then merge some neighbouring intervals, keeping the merging
sequence that gave the best strategy. The number of possible merging sequences is exponential,
however, we will now show that an efficient greedy merging algorithm gives the correct result.
Given two consecutive non-adjacent intervals I1 = [tl1 , tr1 ], I2 = [tl2 , tr2 ], where I1 preceeds
I2 , define the bridge B(I1 , I2 ) = [tr1 , tl2 ] to be interval connecting I1 with I2 . If I1 and I2 are
intervals in a maximal return optimal strategy, then by Lemma 3.15, the M DD of the bridge
is Cr1 − Cl2 . Since Cr1 is a maximum over the interval [tl1 , tl2 ], and Cl2 is a minimum over the
interval [tr1 , tr2 ], we have that the M DD of the union of these three intervals, [tl1 , tr2 ] is given by
max{M DD(I1 ), Cr1 − Cl2 , M DD(I2 )}.
For every bridge B(I1 , I2 ), define the closure Cl(B(I1 , I2 )) to be the smallest interval J = [tl , tr ],
in the return sequence, satisfying the following three properties.
23
Cl1 . Cl ≤ Cm ≤ Cr for l ≤ m ≤ r, i.e., Cl is a minimum and Cr is a maximum in [tl , tr ].
Cl3 . J is prefixed and suffixed by intervals from a maximal return-optimal strategy Tµ∗ .
Note that a bridge may not have closure. For example, if the two last intervals Il−1 , Il in Tµ∗ are
such that such that the end point Il is below the end point of Il−1 , then B(Il−1 , Il ) doesn’t have a
closure. The next lemma shows that if the closure J for a bridge exists, then not only is it unique,
but any other interval satisfying Cl1 - Cl3 contains J.
Lemma 3.19 For two intervals I1 , I2 , if Cl(B(I1 , I2 )) exists, then it is unique. Moreover, for any
other interval I satisfying Cl1 - Cl3 , Cl(B(I1 , I2 )) ⊆ I.
Proof: Let J1 = [tl1 , tr1 ] and J2 = [tl2 , tr2 ] satisfy Cl1 - Cl3 . Without loss of generality, assume
that tl1 ≤ tl2 < tr1 ≤ tr2 . By construction, J1 ∩J2 = [tl2 , tr1 ] satisfies Cl1 - Cl3 . Now let Cl(B(I1 , I2 ))
be the intersection of all intervals that satisfy Cl 1 - Cl3 , concluding the proof.
Suppose that bridge B and B ′ are bridges in Tµ∗ and that Cl(B) contains B ′ . Then Cl(B) satisfies
Cl1 - Cl 3 with respect to B ′ and hence Cl(B) also contains Cl(B ′ ).
Lemma 3.20 Let B and B ′ be bridges in Tµ∗ . If B ′ ⊂ Cl(B), then Cl(B ′ ) ⊂ Cl(B).
i. If B ⊂ I, then Cl(B) ⊂ I.
ii. If B does not have a closure, then no K-Sterling-optimal strategy can contain B.
iii. A K-Sterling-optimal strategy with more than one trading interval and no bridges of Tµ∗ has
M DD = fsp . If it contains one or more bridges Bi of Tµ∗ , then M DD = maxi M DD(Cl(Bi )).
iv. The M DD of a K-Sterling-optimal strategy with more than one trading interval can be one of
at most T + 1 possible values where T is the number of bridges between the intervals of Tµ∗ .
Proof: (i) and (ii) are immediate. (iv) follows from (iii), thus we only need to prove (iii). Let
K contain the consecutive bridges B , . . . , B , and hence their closures. From (i), it is
I ∈ TStrl 1 K
clear that M DD(I) ≥ maxi M DD(Cl(Bi )). It is also clear that I = ∪K
i Cl(Bi ). We show, by
strong induction on K, a more general statement than we need: suppose that I = ∪K
i Cl(Bi ), then
24
M DD(I) ≤ maxi M DD(Cl(Bi )). If K = 1 then I = Cl(B1 ) and the result is trivial; suppose
it is true for up to K − 1 consecutive bridges, K > 1, and suppose that I is the union of K
closures of consecutive bridges. Consider the first closure Cl(B1 ). Let I = [tl , tr ] and Cl(B1 ) =
[tl , tr′ ], tr′ ≤ tr . By definition of Cl(B1 ), Cr′ is a maximum over [tl , tr′ ]. Thus, M DD(I) =
max{M DD(Cl(B1 )), M DD([tr′ , tr ])}. If r = r ′ , then I = Cl(B1 ) and we are done. If r < r ′ ,
then tr′ +1 is the begining of some bridge Bκ . Let I ′ = ∪K ′
i=κ Cl(Bi ). Then, [tr ′ , tr ] ⊆ I and so
M DD([tr′ , tr ]) ≤ M DD(I ′ ). But I ′ is the union of at most K − 1 closures, so by the induction
hypothesis, M DD(I ′ ) ≤ maxi≥κ M DD(Cl(Bi )), concluding the proof.
We will distinguish between four types of bridges. Let I1 = [tl1 , tr1 ], I2 = [tl2 , tr2 ] be consecutive
intervals in Tµ∗ . The bridge B = B(I1 , I2 ) can be one of four types:
regular. Cl1 ≤ Cl2 and Cr1 ≤ Cr2 , i.e., Cl(B) = [l1 , r2 ].
right irregular. Cl1 ≤ Cl2 and Cr1 > Cr2 , i.e., Cl(B) contains the next bridge.
left irregular. Cl1 > Cl2 and Cr1 ≤ Cr2 , i.e., Cl(B) contains the previous bridge.
irregular. Cr1 > Cr2 and Cl1 > Cl2 , i.e., Cl(B) contains both the next and previous bridges.
We define the weight of the bridge W (B(I1 , I2 )) as follows:
Cr1 − Cl2 if B(I1 , I2 ) is regular,
Cr − C
if B(I1 , I2 ) is left irregular and the previous bridge is right irregular.
1 l2
W (B(I1 , I2 )) =
C − C if B(I1 , I2 ) is left irregular and the previous bridge is irregular.
r1 l2
+∞ otherwise.
The general idea behind our algorithm is to start with a maximal return-optimal strategy and
greedily merge pairs of intervals or pair of bridges according to the bridge weight, keeping track
of the best K intervals each time. When no more merging can occur, because we are down to K
intervals or all the bridge weights are ∞, we return the best K intervals we have seen so far. More
precisely, let Tµ∗ = {I1 , . . . , IK0 } be a maximal return-optimal trading strategy making K0 trades.
We denote this pool of trade intervals by P0 , the base pool. From pool Pi , we obtain pool Pi+1 by a
single merge according to the following rule. Let B = B(I1 , I2 ) be the bridge with smallest weight.
If B = ∞, stop (pool Pi+1 does not exist). Otherwise, there are two cases.
i. Regular merge: if B is regular, merge B with I1 and I2 to get a larger interval Inew = [tl1 , tr2 ].
We now update the status (type and weight) of any neighboring bridges as follows:
• Previous bridge changes from right-irregular to regular (update type and weight).
• Previous bridge B ′ changes irregular to left-irregular (update type). If the bridge previous
to B ′ is right-irregular or irregular then update weight.
25
• Next bridge changes from irregular to right-irregular (update type).
• Next bridge changes from left-irregular to to regular (update type and weight).
ii. Irregular merge: if B is left irregular, denoting the previous bridge B ∗ , merge the two bridges
and the interval between them into one bigger bridge Bnew = B ∗ ∪ I1 ∪ B. The status of bridges
other than B have not changed. The status and weight of B may need updating.
Intervals are formed only by regular merges, so it is easy to see that intervals resulting from this
merging procedure begin at a minimum and end at a maximum. New bridges are formed by
irregular merges, and the resulting bridge must begin at a maximum and end at a minimum. The
only bridge weights that could change are those that had weights of ∞. In such an event the weight
will drop, but not below the weight of the original bridge used in the merge that led to the update.
Lemma 3.22 Let bridge B with weight w be involved in a merge, and suppose that the weight of
bridge B ′ is updated in the process from ∞ to u. Then, w < u.
i. The bridge involved in the merge was regular, i.e., two consecutive intervals I1 = [tl1 , tr1 ]
and I2 = [tl2 , tr2 ] are merged with their bridge B12 = B(I1 , I2 ) with W (B12 ) = w. Let the
preceeding interval be I0 = [tl0 , tr0 ] and the following interval be I3 = [tl3 , tr3 ] , and let the
preceeding and following bridges be B01 and B23 respectively. If B01 obtained finite weight, it
cannot be left irregular, as it would remain left irregular after the merge, and hence its weight
would still be ∞. Thus, we need only consider B01 right irregular or irregular (i.e., Cr0 > Cr1 ).
Its weight becomes u = Cr0 − Cl1 > Cr1 − Cl1 . Since B12 is regular, w = Cr1 − Cl2 < Cr1 − Cl1
and so w < u. If B23 obtained finite weight, then it could not be right regular or irregular as
it could not become regular or left irregular after the merge. Thus, we need only consider B23
left irregular (Cl2 > Cl3 ). Its weight becomes u = Cr2 − Cl3 > Cr2 − Cl2 . Since B12 is regular,
Cr1 ≤ Cr2 , and so u > Cr1 − Cl2 = w.
ii. The bridge involved in the merge was left-irregular, i.e., B12 = [tr1 , tl2 ] is left irregular, and
B01 = [tr0 , tl1 ] is either right-irregular or irregular (in both cases, Cr0 > Cr1 ). Let w = Cr1 −Cl2
be the weight of B12 . The merged bridge is B = B01 I1 B12 . If B has finite weight (i.e. it is
either regular or left-irregular), then its new weight is u = Cr0 − Cl2 > Cr1 − Cl2 = w. If
B is left-irregular or irregular, then it does not change the weight of any other bridge. If,
on the other hand, B became right-irregular or irregular, then it could affect the weight of
the following bridge B23 , if B23 was left-irregular (Cl2 > Cl3 ). In this case, the weight of
B23 = [tr2 , tl3 ] becomes v = Cr2 − Cl3 > Cr2 − Cl2 . But since B12 was left-irregular, Cr2 ≥ Cr1 ,
and so v > Cr1 − Cl2 = w.
26
The next lemma shows that if all the bridge weights become ∞, any further merged pairs of intervals
can never be part of a K-Sterling-optimal strategy.
Lemma 3.23 If all the bridge weights in a pool of intervals are ∞, then any further merged pairs
of intervals from this pool can never be part of a K-Sterling-optimal strategy.
Proof: (Lemma 3.23). Let Pr be pool obtained from P0 by some sequence of merging intervals with
bridges of finite weight, and suppose that all the bridges in Pr have infinite weight. In particular,
this means that none of the bridges in Pr are regular. Denote the bridges by B1 , . . . , Bm , and
consider bridge Bk . If Bk is right irregular or irregular, then all following bridges are either right
irregular or irregular since all bridges have finite weight. If a trading interval contains Bk , it must
contain Bk+1 (since Bk is right irregular or irregular), and so by induction, it must contain all the
following bridges (and their closures). But, the last bridge does not have a closure (as it is right
irregular or irregular), a contradiction. If on the other hand, Bk is left irregular, then all preceeding
bridges are left irregular as all bridges have infinite weight. If a trading interval contains Bk , it must
contain Bk−1 (since Bk is left irregular), and so by induction, it must contain all the preceeding
bridges (and their closures). But, the first bridge does not have a closure (as it is left irregular), a
contradiction. We conclude that Bk cannot be in any trading interval.
Each merge decreases the number of intervals and number of bridges by one. If we merge down
K can be chosen to be
to pool PK0 −K , we are left with exactly K intervals. We will show that TStrl
the best K trades (with respect to total return) in one of these pools. Specifically, define TjK to
be the K intervals in Pj with the highest total return. We say that a strategy is coarser than pool
Pi if the strategy can be obtained by a sequence of merges of some (or all) of the intervals in Pi .
Clearly, ∀i, Pi+1 is coarser than Pi , as Pi+1 is obtained from Pi after a single merge. Note that for
a strategy to be coarser than Pi , it need not contain every trade in Pi , however if it contains part
of any trade in Pi , then it contains the entire trade. Next, we show that after a merge, the M DD
of the remaining intervals is equal to the weight of the bridge involved in the merging.
Lemma 3.24 If pool Pi , i ≥ 1, was obtained from Pi−1 by a merge involving a bridge of weight w,
then the M DD of any interval in Pi is at most w. If the merge created a new interval (i.e., the
bridge was regular), then the M DD of the new interval is equal to w.
Proof: In pool P0 , since any bridge is adjacent to two intervals of Tµ∗ , its weight is at least fsp
(Lemma 3.15). Consider sequence of pools P0 , P1 , . . . , Pr , where bridge Bi with weight W (Bi ) was
the minimum weight bridge involved in the merge that resulted in pool Pi from from Pi−1 . By
Lemma 3.22 bridges weights are non-decreasing, i.e., W (Bi ) ≤ W (Bi+1 ).
27
We now use induction on the index i. For i = 1, from Lemma 3.15, every interval in P0 has
M DD at most fsp . If P1 was obtained from P0 by an irregular merge, then all intervals of P1 are
intervals of P0 , with M DD at most fsp . Since W (B1 ) ≥ fsp , the claim holds. If the merge was
regular, then the M DD is W (B1 ) ≥ fsp and the M DD of all other intervals is at most fsp . Thus,
the claim holds for P1 .
Suppose the claim holds for all j < i and consider pool Pi which was obtained from Pi−1 using
a merge involving Bi . By the induction hypethesis, the M DD of any interval from Pi−1 is at
most W (Bi−1 ) ≤ W (Bi ). If Pi that was obtained by an irregular merge, every interval of Pi is an
interval of Pi−1 and thus has M DD at most W (Bi−1 ) ≤ W (Bi ). Suppose that Pi was obtained by
a regular merge – all intervals except the merged interval are intervals of Pi−1 . Consider the M DD
of the new interval, which is obtained by the regular merge I1 ∪ Bi ∪ I2 . Since new intervals are
created only through regular merges, it is easy to see by induction that property Cl1 holds for all
the intervals in Pi−1 , in particular it holds for I1 and I2 . Since Bi was regular, the M DD of the new
interval is max(M DD(I1 ), W (Bi ), M DD(I2 )). By the induction hypothesis, M DD(I1 ) ≤ W (Bi−1 )
and M DD(I2 ) ≤ W (Bi−1 ), thus, max(M DD(I1 ), W (Bi ), M DD(I2 )) = W (Bi ).
First, we show that if a K-Sterling-optimal strategy makes K trades, all of which are contained in
intervals of one of the pools Pi , then a K-Sterling-optimal strategy exists which is composed of the
K intervals with highest return in some pool Pj with j ≤ i.
Lemma 3.25 If K subintervals of the intervals of pool Pi are a K-Sterling-optimal strategy, then
for some j ≤ i, the K intervals with highest return of pool Pj are a K-Sterling-optimal strategy.
Proof: If Pi = P0 , then the claim is trivial. Suppose that i > 0, and let T = {I1 , . . . , IK } be the
K-Sterling-optimal strategy whose trades are all subintervals of intervals in Pi . Consider the set
B of all bridges in Tµ∗ that are contained in T , B = {Bi }ri=1 . We can assume that B is not empty
because if it were, then T is composed of intervals in Tµ∗ , in which case the top K intervals (with
respect to return) in Tµ∗ are clearly optimal. Since Pi contains all the intervals in T , Pi contains
all the bridges in B. Thus, there must exist j ≤ i such that Pj contains all the bridges in B and
no pool Pk , with k < j has this property, i.e., Pj was obtained from the previous pool by a regular
merge involving a bridge B ∗ which must contain some bridge Bl ∈ B. Let I be the interval in T
that contains Bl . Then, I must contain the whole bridge B ∗ , since if B ∗ is the result of irregular
merges, one of which involved bridge Bl , then B ∗ ⊂ Cl(Bl ), and Cl(Bl ) ⊆ I (Proposition 3.21).
Since B ⊂ I, M DD(T ) ≥ M DD(I) ≥ W (B ∗ ). By Lemma 3.24, since B ∗ was the last bridge
involved in a merge, the M DD of every interval in Pj is at most W (B ∗ ). Since every interval of
T is a subinterval of some interval in Pj , we conclude that T is contained in at most K intervals
of Pj . Let TjK be the top K intervals in Pj . Then, the return of T is at most the return of TjK .
Further, M DD(TjK ) ≤ W (B ∗ ) ≤ M DD(T ), and so Strl(TjK ) ≥ Strl(T ), concluding the proof.
28
We are now ready to prove the main result, which will lead to the greedy algorithm for constructing
a K-Sterling optimal strategy.
Proof: Let S0K be a K-Sterling-optimal strategy that makes K trades – by Lemma 3.18, such a
strategy must exist. If S0K has the same Sterling ratio as the trading strategy composed of the K
most profitable trades in P0 , then we are done. If not, then we know from Proposition 3.17 that
S0K is coarser than P0 . We prove the following statement for all k ≥ 1
K
Q(k): Suppose there exists a K-Sterling-optimal strategy Sk−1 that makes K trades
K is composed of K intervals of P , or there
and is coarser than Pk−1 . Then either Sk−1 k
exists a K-Sterling-optimal strategy SkK that makes K trades and is coarser than Pk .
We know that Q(1) is true. Suppose that Q(k) is true for all k ≥ 1, we then prove the proposition
K are composed of K intervals in
as follows. By an easy induction, we have that if none of the Sj−1
K making exactly K trades that is
Pj for all j ≤ m, then there is a K-Sterling-optimal strategy Sm
coarser than Pm . Suppose that we can construct a total of κ + 1 pools, Pi for 0 ≤ i ≤ κ ≤ K0 − K.
If κ < K0 − K then all the bridge weights in Pκ are infinite. If κ = K0 − K, then any further
merging leads to fewer than K intervals. In both cases, there cannot exist a K-Sterling-optimal
strategy that is coarser than Pκ . Therefore, for some j ∗ ≤ κ, the K-Sterling-optimal strategy SjK∗ −1
K that
is composed of K intervals of Pj ∗ . By Lemma 3.25, there is a K-Sterling-optimal strategy TStrl
is composed of the top K intervals of some pool Pl , where l ≤ j ∗ .
K
What remains is to show that Q(k) is true for all k ≥ 1. Suppose that Sk−1 is coarser than
Pk−1 and is not composed of K intervals in Pk . We show that there exists SkK that is coarser than
K
Pk . Since Sk−1 is coarser than Pk−1 , it contains at least one bridge B in Pk−1 with finite weight
(because if it contains an infinite weight bridge, then it either contains the preceeding or following
bridge; this argument continues analogously to the proof of Lemma 3.23 until we include a bridge
K
of finite weight). Let I be the interval of Sk−1 that contains B, and let Il and Ir be intervals in
Pk−1 (which are subintervals of I) connected by B. Let B ∗ be the bridge in Pk−1 with minimum
weight that was involved in the merge to get Pk from Pk−1 , and let Il∗ and Ir∗ be the intervals in
Pk−1 connected by B ∗ . If B ∗ = B then Sk−1
K is also coarser than P and we are done, so suppose
k
B ∗ 6= B. There are two possibilities:
has as a suffix Il∗ . Suppose we construct SkK by replacing interval I ′ by interval I ′ ∪ B ∗ ∪ Ir∗ .
SkK is then coarser than Pk . Since B ∗ is regular, the return of I ′ ∪ B ∗ ∪ Ir∗ is at least
29
as big as the return of I ′ . Ir∗ is either an interval of P0 or was obtained by merging some
intervals of P0 through bridges with weight at most W (B ∗ ) (Lemma 3.24), and so M DD(Ir∗ ) ≤
W (B ∗ ). Since the maximum cumulative return for I ′ is attained at its right endpoint (Lemma
3.16) and the left endpoint of Ir∗ is a minimum in Ir∗ , we have that M DD(I ′ ∪ B ∗ ∪ Ir∗ ) =
max{M DD(I ′ ), W (B ∗ ), M DD(Ir∗ )} = max{M DD(I ′ ), W (B ∗ )}. Since W (B ∗ ) ≤ W (B), we
K ), and thus Strl(S K ) ≥ Strl(S K ), which means that
conclude that M DD(SkK ) ≤ M DD(Sk−1 k k−1
K
SkK is also K-Sterling-Optimal. Finally, suppose that Sk−1 contains both Il∗ and Ir∗ , and
K
consider the strategy SkK obtained from Sk−1 by removing bridge B and adding bridge B ∗ .
K ) + W (B) − W (B ∗ ) ≥ µ(S K ). Since W (B) ≥ W (B ∗ ), the M DD cannot
µ(SkK ) = µ(Sk−1 k−1
have increased, and so SkK is K-Sterling-Optimal and coarser than Pk .
(ii) B ∗ is an irregular bridge. Since B ∗ = B(Il∗ , Ir∗ ) has finite weight, we can conclude that B ∗ is
∗ , I ∗ ) is right-irregular or irregular. Since
left-irregular and the previous bridge B− = B(Il−1 l
K does not contain B ∗ , by Lemma 3.16, there are two possibilities: S K does not contain
Sk−1 k−1
Il∗ , in which case it also does not contain bridge B− and so B− and B ∗ can be merged into one
K , i.e., S K is also more coarse than P ; or, S K
bridge without influencing Sk−1 ∗
k−1 k k−1 contains Il
as one of its intervals. In this case, since B ∗ is left-irregular, µ(Il∗ ) < W (B ∗ ) ≤ W (B), and so
by dropping Il∗ from Sk−1
K and breaking I into two subintervals by removing B from I results
in a profit increase of W (B) − µ(Il∗ ) > 0. Further, the M DD cannot increase, so the new
K , which contradicts
strategy makes K trades and has strictly greater Sterling ratio than Sk−1
K . Thus, S K cannot contain I ∗ as one of its intervals.
optimality of Sk−1 k−1 l
We are now ready to give the O(n log n) algorithm that establishes Theorem 1.3. First, we can
compute the optimal strategy that makes only one trade in O(n log n) (Section 3.1), and compare
this with the trivial strategy that makes no trades. It remains to compute the K-Sterling-optimal
strategy and pick the best. We show how to do this in O(n log n) time.
First we obtain Tµ∗ in linear time. Suppose Tµ∗ makes K0 > K trades (as otherwise Tµ∗ is our
solution). By Theorem 3.26, we only need to construct the pools P0 , P1 , . . ., maintaining the pool
with the optimal Sterling ratio for its top K trades, as explained in the following algorithm.
1: Set i = 0; Sort (in decreasing order) the intervals from P0 according to profit; Sort all the
bridges with finite weight in increasing order. Let Bi be the minimum weight bridge in Pi ; Let
strategy Si consist of the top K intervals, and let Strlopt = Strl(Si );
2: while Pi contains at least K intervals and at least one finite weight bridge do
3: if Bi = B(Il , Ir ) is regular then
4: Regular merge to obtain Pi+1 : remove Il , Ir , Bi from the interval and bridge orderings, and
add back I = Il ∪ Bi ∪ Ir into the interval ordering; compute µ(I) and M DD(I);
30
5: Update neighboring bridge weigths and re-insert them back into the bridge ordering.
6: else if Bi = B(Il , Ir ) is left-regular then
7: Irregular merge to obtain Pi+1 : Let B− be the bridge left of Bi ; remove Il , B− , Bi from the
interval and bridge orderings. Create the new bridge B = B− ∪ Il ∪ Bi , compute W (B)
and insert B into the bridge ordering (note that W (B) may be ∞).
8: end if
9: i ← i + 1; update Strli ; if Strlopt < Strli , then Strlopt ← Strli .
10: end while
The correctness of the algorithm follows from Theorem 3.26. We now analyse the run time of
an efficient implementation of the algorithm. P0 contains at most n intervals and bridges. Each
execution of the while loop reduces loop number of bridges and intervals by 1 each, so the while
loop is executed at most n/2 times. Merging two intervals is a constant time operation. The profit
of a new interval is the profit of the merged intervals minus the weight of the merging bridge (also
computable in constant time). The M DD of a new interval is the maximum of the M DD of the
merged intervals and the weight of the merging bridge (also computable in constant time). The
weight of a new bridge takes constant time to compute, and updating the weights of the neighbour
bridges is a constant time operation provided that pointers are maintained to them. These pointers
can be updated in constant time as well. Thus the run time within the while loop is dominated by
inserting into the bridge or interval orderings. At most a constant number of such such inserts into
a sorted list need to be done, and each is an O(log n) operation [7]. To efficiently implement step
9, we maintain two sorted lists of the top K intervals in the algorithm, sorted according to return
and M DD. These can be maintained in O(log K) operations. The first allows us to update the
total return of the top K intervals in constant time, and the second allows us to update the M DD
of the top K intervals (by taking the interval with largest M DD) in constant time. Thus the total
running time of the while loop is O(n log n + n log K) = O(n log n) The preprocessing (step 1) is
O(n), and so does not contribute to the asymptotic run time.
µ(T ) µ(T )
Shrp1 (T ) = , Shrp2 (T ) = . (9)
σ(T ) σ 2 (T )
31
Note that Shrp2 is more conservative in that it penalizes large variances more heavily. We introduce
a simplified Sharpe ratio (SSR) S that will be instrumental to finding the optimal strategies,
µ
S= .
s2
µ2
It is easy to check that maximizing Shrp1 is equivalent to maximizing s2
, and that Shrp2 is given
r̄
by 1 2
s −r̄ 2
, where r̄ is the mean return. We will relate the maximization of Shrp1 and Shrp2 to the
n
maximization of S.
Let T be a trading strategy that makes K trades, with trading intervals I1 , . . . , IK . Each trade
contributes a transactions cost of −fsp to the return sequence. In general, a trade contributes
fˆ2 + fˆ2 to s2 . However, we will assume that fsp ≪ 1 and so we will ignore the contribution of the
S B
transactions cost to s2 . Alternatively, we can justify this by assuming that the transactions cost is
spread finely over many time intervals. The sum over these small time intervals is finite, equal to
−fsp , however, the sum of squares over these small time intervals can be made arbitrarily small.
Define the total return and sum of squared returns for each trading interval,
X X
µi = µ(Ii ) = r[j], s2i = s2 (Ii ) = r[j]2 .
j∈Ii j∈Ii
We define Ai as the contribution of trade i to the mean return, and Bi as the contribution of trade
i to the mean squared return (ignoring the effect of the transactions cost), i.e., Ai = n1 (µi − fsp )
and Bi = n1 s2i . We define A(T ) = K
P PK
k=1 Ai (note that r̄ = A(T )) and B(T ) = k=1 Bi (note that
1 2
ns = B(T )).
We will need the following technical lemma, which can be proved by an easy induction.
Lemma 4.1 Let F = { ab11 , ab22 , . . . , abkk } be any set of fractions satisfying bi > 0 and c
d ≤ ai
bi ≤ a
b,
c a1 +a2 +...+ak
for all i, where b, d > 0. Then, d ≤ ≤ ab . The upper (resp. lower) bound is strict if at
b1 +b2 +...+bk
least one of the fractions in F is strictly upper (resp. lower) bounded by ab resp dc .
Ai
Lemma 4.2 Bi is a constant for every interval i, i.e., every trade is equivalent.
32
Ai Aj
Proof: Suppose that mini Bi < Bj for some j (strict inequality), and without loss of generality,
assume that the minimum is attained for interval I1 . By Lemma 4.1, if we remove I1 , we get that
PK PK
i=1 Ai i=2 Ai
S(I1 ∪ · · · ∪ IK ) = PK < PK = S(I2 ∪ · · · ∪ IK ),
i=1 Bi i=2 Bi
Ai Aj
which contradicts the optimality of T ∗ implying that mini Bi = Bj for all j.
Proposition 4.4 An SSR-optimal strategy making one trade can be found in O(n log n) time.
Proof: By Corollary 4.3, we are guaranteed the existence of such a strategy. It suffices to find
the single interval I maximizing i∈I r[i]/ i∈I r[i]2 . Consider all intervals starting at position i
P P
and define ck = kj=i r[j] and dk = kj=i r[j]2 . We wish to find k to maximize ck /dk . If we have
P P
done this for position i, we now consider position i − 1. We show that the algorithm in Section
3.1.1 can be used. Trade intervals starting at i − 1 correspond to shifting all the ck by r[i − 1],
and all the dk by r[i − 1]2 . Both these operations simply correspond to shifting the origin point p
to p′ = p − (r[i − 1], r[i − 1]2 ). We then add a new leftmost point at p. Since each update takes
O(log n), and the optimal interval for the new points can be found in O(log n), the entire algorithm
runs in O(n log n).
Ignoring the fsp 2 term in the denominator changes the denominator slightly, so we introduce the
slightly different quantity Shrp2 . Specifically,
A(T ) A(T )
Shrp2 (T ) = 2
, Shrp2 (T ) = ,
d
n fsp + B(T ) − A2 (T ) B(T ) − A2 (T )
where d is the number of trades in T . By the Cauchy-Schwarz inequality, for any trading strategy,
r[i]2 ≥ n1 ( i r[i])2 . Since we are only interested in strategies for which A(T ) ≥ 0, we have
P P
We will show that maximizing Shrp2 is closely related to a constrained optimization of the SSR,
and that maximizing Shrp2 is not too far from maximizing Shrp2 .
Let Tµ∗ be return optimal, with return µ(Tµ∗ ) = µ∗ . For any 0 ≤ α ≤ µ∗ , we define the
constrained SSR-optimal strategy Tα as the strategy with maximum SSR among all strategies with
return at least α, i.e., A(Tα ) ≥ α and for all strategies T with A(T ≥ α), S(Tα ) ≥ S(T ). Note that
while an SSR-optimal strategy can be chosen with one trading interval, a constrained SSR-optimal
33
strategy may require more than one trading interval. We show that for some appropriate threshold
α, the constrained SSR-optimal strategy is a Shrp2 -optimal strategy.
Proposition 4.6 ∃0 ≤ α ≤ µ∗ such that the constrained SSR-optimal strategy Tα is Shrp2 -optimal.
Proof: Let T be any Shrp2 -optimal strategy, and let α∗ = A(T ). Let Tα∗ be any constrained
SSR-optimal strategy. Then A(Tα∗ ) ≥ A(T ) and since S(Tα∗ ) ≥ S(T ), we have that
0 ≤ A(Tα∗ )B(T ) − A(T )B(Tα∗ ) < A(Tα∗ )A(T ) · (A(T ) − A(Tα∗ )).
Both A(Tα∗ ) and A(T ) are > 0, otherwise both strategies are inferior to Tµ∗ ; thus A(T ) > A(Tα∗ ),
which is a contradiction. Therefore Shrp2 (Tα∗ ) ≥ Shrp2 (T ) and so Tα∗ is Shrp2 -optimal.
Proof: If J is a prefix or suffix of I and µ(J) ≤ 0, then deleting J from I gives at least as much
return, with smaller sum of squared returns, contradicting the SSR-optimality of I. Suppose that
µ(J)+µ(R) −fsp +µ(L)
I = L ∪ J ∪ R where L and R are nonempty subintervals of I. If s2 (J)+s2 (R)
< s2 (L)
, then by
Lemma 4.1,
−fsp + µ(L) + µ(J) + µ(R) −fsp + µ(L)
S(I) = 2 2 2
< = S(L) (*)
s (L) + s (J) + s (R) s2 (L)
This contradicts the optimality of I, so we have
Now, suppose that µ(J) < −fsp . Using (*) and Lemma 4.1, we find that
We show that adding an SSR-optimal interval to any trading strategy can only improve the strategy.
34
Proposition 4.8 Let I0 be any SSR-optimal interval, and let T be any trading strategy. Let
T ′ = I0 ∪ T . Then A(T ′ ) ≥ A(T ) and S(T ′ ) ≥ S(T )
Proof: If I0 is contained in some interval of T , then there is nothing to prove, so suppose that
T ∪ I0 6= T , and that T contains d ≥ 1 trades I1 , . . . , Id . Note that S(T ) = A(T )/B(T ). If I0 and
T do not intersect, then T ′ = I0 ∪ T = {I0 , I1 , . . . , Id }. A(T ′ ) = A(T ) + A(I0 ) ≥ A(T ), because
A(I0 ) A(T )
A(I0 ) ≥ 0. Since I0 is SSR-optimal, S(I0 ) = B(I0 ) ≥ B(T ) = S(T ), so by lemma 4.1,
Suppose that T ∩ I0 6= ∅. We can decompose T into four parts (each part could be empty):
T = S1 ∪ S2 ∪ Il ∪ Ir , where S1 contains intervals that do not intersect with I0 , S2 contains intervals
that are contained in I0 , Il is not contained in I0 but overlaps I0 on the left, and Ir is not contained
in I0 but overlaps I0 on the right. T ′ = I0 ∪ T = S1 ∪ Il ∪ I0 ∪ Ir , i.e., adding I0 combines all
the trades in {S2 , Il , Ir } into one trade. Since the internal regions of I0 have return at least −fsp
and any prefix and suffix of I0 has positive return (Proposition 4.7), we see that merging any two
consecutive trades overlapping I0 decreases the number of trades by one, hence increases the return
by fsp and the added interval loses at most fsp , hence this merge can only increase A(T ). If either
Il or Ir are empty, then we are addionally adding a prefix or suffix of I0 without changing the
number of trades, which also increases A(T ), thus we see that A(T ′ ) ≥ A(T ).
Let’s introduce the following definitions,
1
A1 = A(S1 ) + (µ(Il ∩ I0 ) + µ(Ir ∩ I0 ))
n
1
A2 = A(S2 ) + (µ(Il ∩ I0 ) − fsp + µ(Ir ∩ I0 ) − fsp )
n
1
B1 = B(S1 ) + (s2 (Il ∩ I0 ) + s2 (Ir ∩ I0 ))
n
1
B2 = B(S2 ) + (s2 (Il ∩ I0 ) + s2 (Ir ∩ I0 )),
n
A1 + A2 A1 + A0
S(T ) = , and S(T ′ ) = .
B1 + B2 B1 + B0
A2 A2 A0
Note that S(S2 ∪ (Il ∩ I0 ) ∪ (Ir ∩ I0 )) = B2 , so by the optimality of I0 , B2 ≤ B0 . We show that
1 1
n µ(Il ∩ I0 ) A0 n µ(Ir ∩ I0 ) A0
1 2
≤ , and 1 2
≤ . (**)
n s (Il ∩ I0 )
B0 n s (Ir ∩ I0 )
B0
35
1
µ(Il ∩I0 ) A0
If not, then suppose (for example) that n
1 2
s (Il ∩I0 )
> B0 . Then,
n
A0 + n1 µ(Il ∩ I0 ) A0
S(I0 ∪ Il ) = 1 2
> = S(I0 )
B0 + n s (Il ∩ I0 ) B0
A(S1 ) A0
contradicting the SSR-optimality of I0 . Again, by the optimality of I0 , S(S1 ) = B(S2 ) ≤ B0 =
S(I0 ). it also has to be sharper than strategy S1 . Thus, using (**) and Lemma 4.1 we have that
A1 A0
B1 ≤ B0 . Because A2 is obtained from the returns of a collection of subintervals of I0 , it follows
from Proposition 4.7 that A2 ≤ A0 . Now suppose that S(T ) > S(T ′ ), i.e.,
Since A2 ≤ A0 , it follows that B2 ≤ B0 . Rearranging terms in the equation above, we have that
A2 B1 − A1 B2 A0 A1 + A2
> − ,
B0 (B1 + B2 ) B0 B1 + B2
A2 A1 + A2 A2 B1 − A1 B2
≥ − = .
B2 B1 + B2 B2 (B1 + B2 )
Since S(I0 ) ≥ S(T ), the first inequality shows that A2 B1 − A1 B2 > 0. The second inequality then
implies that B2 > B0 , a contradiction.
We can now give the intuition behind our algorithm. The starting point is Proposition 4.6, which
says that it suffices to look for constrained SSR-optimal strategies. So the natural first choice is
an unconstrained SSR-optimal interval T0 . Either this will be Shrp2 optimal or not. If not, it
is because it has too small a return. So our next step is to add to this interval an new interval
(possibly adjacent) with the property that the interval increases the return with smallest possible
decrease in SSR, resulting in strategy T1 . We repeat this process, constructing a sequence of trading
strategies T0 , T1 , . . . with the property that A(Ti ) > A(Ti−1 ), and among all other strategies T such
that A(T ) > A(Ti−1 ), S(Ti ) ≥ S(T ). We then pick the strategy Ti∗ with maximum Shrp2 ratio
among these strategies, which will be globally sharpe optimal.
Suppose that we have a current strategy, Ti . We need to determine the next piece to add to
this so that we increase the return, with smallest possible decrease in SSR. Let Ti be composed of
the intervals I0 , I1 , . . . , Id . We replace each of these intervals by a special symbol, $, to signify that
these regions are already included in the strategy. We thus obtain a generalized returns sequence,
one in which some intervals are replaced by the $ symbol. A generalized trading strategy on the
generalized return sequence must be composed of trades that do not contain the $ symbol. However
trades may be adjacent to the $ symbol. A trade interval I in a generalized trading strategy can be
isolated (not adjacent to any $ symbol), extending (adjacent to one $ symbol), or bridging (adjacent
36
to two $ symbols). In order to correctly account for the transactions cost, we need to change how
we compute A(I), so we introduce the new function Ā(I):
A(I) I is isolated
fsp
Ā(I) = A(I) + n I is extending
A(I) + 2fsp
n I is bridging
The generalized simplified Sharp ratio (GSSR) for generalized strategy T = {I1 , . . . , Id } is
P
Ā(Ii )
S̄(T ) = P i=1...d
i=1...d B(Ii )
Similar to the notion of a maximal return optimal strategy, we introduce the notion of a maxi-
mal SSR-optimal (or GSSR-optimal) interval as one which cannot be extended in either direction
without decreasing the SSR (or GSSR).
We now define generalized return sequences {R0 , R1 , . . .} as follows. R0 is just the original
returns sequence. Let Ii be a maximal GSSR-optimal interval for Ri . We obtain the generalized
sequence Ri+1 by replacing Ii ⊂ Ri with the symbol $. We define any set of generalized sequences
obtained in this way as monotone. We also refer to a member of a monotone set as monotone.
Let R0 , R1 , . . . , Rk be a monotone sequence of gerenalized returns sequences, and let I0 , I1 , . . . , Ik
be the maximal GSSR-optimal intervals corresponding to each sequence. By construction, Ii is a
maximal GSSR-optimal interval for Ri . We have defined Ā so that the SSR of the union of these
intervals in R0 is given by
Pd
ĀRi (Ii )
SR0 (I0 ∪ I1 ∪ · · · ∪ Ik ) = Pi=1
d
,
i=1 B(Ii )
where the subscript Ri indicates on which generalized return sequence the quantity is computed.
Proof: Suppose that S̄Ri (Ii ) < S̄Ri+1 (Ii+1 ), and let $i be the symbol that replaced Ii in Ri to
obtain Ri+1 . If Ii+1 is not adjacent with $i , then Ii is not GSSR-optimal in Ri , a contradiction. If
Ii+1 is adjacent with $i , then Ii ∪ Ii+1 has higher GSSR (by Lemma 4.1), so once again Ii is not
GSSR-optimal in Ri .
37
Analogous to Propositions 4.4, 4.7, 4.8, we have the following three propositions. Their proofs are
almost identical, so we omit them.
Proposition 4.11 A GSSR-optimal strategy making one trade exists, and all maximal GSSR-
optimal trades can be found in O(N logN ) time.
Proposition 4.12 Let J be a subinterval of any GSSR-optimal interval I. Then µ(J) ≥ −fsp . If
J is a prefix or suffix of I that is not adjacent with the symbol ”$”, then µ(J) > 0.
Proposition 4.13 Let I0 be any GSSR-optimal interval, and let T be any generalized trading
strategy. Let T ′ = I0 ∪ T . Then, Ā(T ′ ) ≥ Ā(T ) and S̄(T ′ ) ≥ S̄(T ).
We now give the main result that will lead to the final algorithm to obtain the Shrp2 -optimal strat-
egy. Its essential content is that given a monotone set of generalized returns sequences, R0 , R1 , . . .,
with corresponding GSSR-optimal intervals I0 , I1 , . . ., for some k, T = I0 ∪ I1 ∪ · · · ∪ Ik is Shrp2
optimal. We will need some preliminary results.
Proposition 4.14 For some k, T ∗ = I0 ∪ I1 ∪ · · · ∪ Ik is Shrp2 -optimal., where Ii are the GSSR-
optimal intervals corresponding to a monotone set of generalized returns sequences.
Proof: First we show that there exists a Shrp2 -optimal strategy T0 that contains I0 . Indeed,
let T be any Shrp2 -optimal strategy, and consider T0 = I0 ∪ T . By the Proposition 4.8, we have
S(T0 ) ≥ S(T ) and A(T0 ) ≥ A(T ) ≥ 0. Then,
From now on, we will drop the Rk+1 subscript. Let A = A(I0 ∪ . . . ∪ Ik ), B = B(I0 ∪ . . . ∪ Ik ),
A′ = Ā(T ′ ), B ′ = B(T ′ ), A′′ = Ā(T ′′ ) and B ′′ = B(T ′′ ). Let Shrp2 = Shrp2 (I0 ∪ . . . ∪ Ik ),
38
′ ′′
Shrp2 = Shrp2 (I0 ∪ . . . ∪ Ik ∪ T ′ ) and Shrp2 = Shrp2 (I0 ∪ . . . ∪ Ik ∪ T ′′ ). Thus,
A ′ A + A′ ′′ A + A′′
Shrp2 = , Shrp2 = , and Shrp2 = .
B − A2 B + B ′ − (A + A′ )2 B + B ′′ − (A + A′′ )2
Let A′′ = α′′ A and A′ = α′ A, where α′′ ≥ α′ > 0. Then, by direct computation, one obtains
′ A ′′ A
Shrp2 = α′ B′
, and Shrp2 = α′′ B ′′
,
B+ A2 + 1+α′ ( α′ −B− A2 ) B+ A2 + 1+α′′ ( α′′ − B − A2 )
′ B′ 2
Since Shrp2 > Shrp2 , we conclude that α′ − B − A < 0. Since S̄(T ′′ ) ≥ S̄(T ′ ), we have that
B′ B ′′ α′′ α′
α′ ≥ α′′ , and since α′′ ≥ α′ > 0, 1+α′′ ≥ 1+α′ > 0, therefore
α′′ B ′′ α′ B′
− B − A2 ≤ − B − A2 < 0,
1 + α′′ α′′ 1 + α′ α′
′′ ′
and so Shrp2 ≥ Shrp2 , concluding the proof.
By Proposition 4.14, a Shrp2 -optimal trading strategy can be obtained by constructing the strategies
Tk , and then picking the one with the maximum value for Shrp2 . The next proposition shows that
this can be done in O(N 2 logN ) time.
Proposition 4.15 A Shrp2 -optimal trading strategy can be found in time O(n2 logn).
Proof: Ii can be obtained in O(n log n) time (Proposition 4.11). Since there are at most n such
intervals (since each must be non-empty), obtaining all the intervals is in O(n2 log n).
Given the intervals, a single scan can be used to obtain the k for which Tk is Shrp2 -optimal.
One can improve the runtime to O(n2 ) if O(n2 ) memory is available, however, we do not discuss
the details.
We have given an algorithm that obtains a Shrp2 -optimal strategy. A modification to the algorithm
constructs the hierarchy Ti and pick the one with the highest one with value of Shrp2 . Suppose we
have a Shrp2 -optimal strategy T and let T ∗ be a Shrp2 -optimal strategy. Then by Proposition 4.6,
it must be that A(T ∗ ) > A(T ) and that S(T ∗ ) ≤ S(T ). Since Shrp2 (T ) ≥ Shrp2 (T ∗ ), we have that
A∗ (B − A2 ) − A(B ∗ − A∗ 2 ) ≤ 0, where A = A(T ), A∗ = A(T ∗ ), B = B(T ), B ∗ = B(T ∗ ). We can
evaluate Shrp2 (T ∗ ) − Shrp2 (T ) to obtain
d 2
n fsp
0 ≤ Shrp2 (T ∗ ) − Shrp2 (T ) ≤ Shrp∗2 · d 2
n fsp + B − A2
39
When B − A2 = O(1), which is usually the case, we see that this is a very accurate approximation
(since fsp ≪ 1).
A(T ) A(T )
Shrp1 (T ) = q , Shrp1 (T ) = p .
d 2
+ B(T ) − A2 (T ) B(T ) − A2 (T )
n fsp
2
We will optimize Shrp1 (T ). Since maximizing Shrp1 (T ) is equivalent to minimizing 1/Shrp1 (T ) the
problem reduces to maximizing
A2 (T )
Q(T ) =
B(T )
The entire algorithm is analogous to that for maximizing Shrp2 in the previous section, we only
need to prove the analogs of Propositions 4.6 and 4.14.
Proof: Let T be Shrp1 -optimal, and let α∗ = A(T ). Let Tα∗ be a corresponding constrained
A(Tα∗ ) A(T )
SSR-optimal strategy. A(Tα∗ ) ≥ A(T ) and B(Tα∗ ) ≥ B(T ) . Multiplying these two inequalities gives
A2 (Tα∗ ) A2 (T)
that B(Tα∗ ) ≥ B(T ) , i.e. Tα∗ is also Q-optimal.
Proposition 4.17 For some k, T ∗ = I0 ∪I1 ∪· · ·∪Ik is Q-optimal., where Ii are the GSSR-optimal
intervals corresponding to a monotone set of generalized returns sequences.
Proof: The proof is very similar to tho proof of Proposition 4.14. Let T be Q-optimal, and let
T0 = I0 ∪ T . Then A(T0 ) ≥ A(T ) and S(T0 ) ≥ S(T ). Multiplying these two inequalities give that
Q(T0 ) ≥ Q(T ), or that T0 is also Q-optimal.
Let Tk be a Q-optimal strategy that contains I0 ∪ · · · ∪ Ik . Introduce T ′ , T ′′ = Ik+1 ∪ T ′
as in the proof of Proposition 4.14. Let Q = Q(I0 ∪ . . . ∪ Ik ), Q′ = Q(I0 ∪ . . . ∪ Ik ∪ T ′ ) and
Q′′ = Q(I0 ∪ . . . ∪ Ik ∪ T ′′ ),
A2 (A + A′ )2 (A + A′′ )2
Q= , Q′ = , and Q′′ = .
B B + B′ B + B ′′
Following exactly the same logic as in the proof to Proposition 4.14, we only need to show that
A′′ A′ B ′′ B′
Q′′ ≥ Q′ . Let A′′ = α′′ A and A′ = α′ A, where α′′ ≥ α′ > 0. B ′′ ≥ B′ implies that α′′ ≤ α′ , and so
40
B ′′ B′
α′′ (α′′ +2) ≤ α′ (α′ +1) . By direct computation, one obtains
A2 A2
Q′ = , Q′′ = .
1 B′ 1 B ′′
B+ 1− (1+α′ )2 α′ (α′ +2) −B B+ 1− (1+α′′ )2 α′′ (α′′ +2) −B
B′ 1 1
Since Q′ > Q, it must be that α′ (α′ +2) − B < 0. Since α′′ ≥ α′ , 1 − (1+α′′ )2
≥ 1− (1+α′ )2
, so we
have that
B ′′ B′
1 1
1− −B ≤ 1− −B < 0,
(1 + α′′ )2 α′ (α′′ + 2) (1 + α′ )2 α′ (α′ + 2)
Once again, a modification to the algorithm constructs the hierarchy Ti and picks the one with
the highest one with value of Shrp1 . Suppose we have a Shrp1 -optimal strategy T and let T ∗ be a
Shrp1 -optimal strategy. By direct computation, and using the fact that Shrp1 (T ) ≥ Shrp1 (T ∗ ) =⇒
A∗2 B − A2 B ∗ ≤ 0, we get
dfsp 2
0≤ Shrp21 (T ∗ ) − Shrp21 (T )≤ 2 ∗
Shrp1 (T ) n
dfsp 2
n + B
q
which gives an approximation ratio of 1 − O(fsp 2 ) when B = O(1).
5 Discusion
Our main goal was to provide the theoretical basis for the computation of a posteriori optimal
trading strategies, with respect to various criteria. The highlights of our contributions are that
return and M DD-optimal strategies can be computed very efficiently, even with constraints on
the number of trades. Sharpe optimal strategies prove to be much tougher to compute. However,
for slightly modified notions of the Sharpe ratio, where one ignores the impact of bid-ask spread
squared we can compute the optimal strategy efficiently. This is a reasonable approach since in
most cases, the bid-ask spread is ∼ 10−4 . We also show that this modified optimal strategy is not
far from optimal with respect to the unmodified Sharpe ratio.
We have introduced a new technique for optimizing quotients over intervals of a sequence.
This technique is based on relating the problem to convex set operations, and for our purposes
has direct application to optimizing the M DD, the simplified Sharpe ratio (SSR), which is an
41
integral component in optimizing the Sharpe ratio, and the Downside Deviation Ratio (DDR).
This technique may be of more general use in optimizing other financially important criteria.
A natural open problem is whether Sharpe optimal strategies can be computed under constraints
on the number of trades. We suspect that the monotone hierarchy we created with respect to the
SSR has an important role to play, but the result has been elusive. Other directions of future
research include the implementation of the algorithms in various markets to obtain, compare and
learn from the optimal trading strategy.
References
[1] Online encyclopedia of financial terms. http://www.investopedia.com, 2004.
[2] Arjan Berkelaar and Roy Kouwenberg. Dynamic asset allocation and downside-risk aversion.
citeseer.ist.psu.edu/berkelaar00dynamic.html.
[3] Tomasz R. Bielecki, Jean-Philippe Chancelier, Stanley Pliska, and Agnes Sulem. Risk sensitive
portfolio optimization with transaction costs. To appear, 2004.
[4] Tomasz R. Bielecki, Stanley Pliska, and Jiongmin Yong. Optimal investment decisions for a
portfolio with a rolling horizon bond and a discount bond. To appear, 2004.
[5] Timothy M. Chan. Output-sensitive results on convex hulls, extreme points, and related
problems. In Proc. 11th Symposium on Computational Geometry, pages 10 – 19, 1995.
[6] David M. Smith Christophe Faugere, Hany A. Shawky. Sell discipline and institutional money
management. Journal of Portfolio Management, 30(3), 2004.
[7] Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. Introduction
to Algorithms. Mcgraw-Hill, 2001.
[8] C.D. Perttunen D. Jones and B.E. Stuckman. Lipschitzian optimization without the lipschitz
constant. Journal of Optimization Theory and Application, 79:157–181, 1993.
[9] Sergei Issaenko. Domenico Cuoco, Hua He. Optimal dynamic trading strategies with risk
limits. SSRN Electronic Paper Collection, 2001.
[10] Thomas H. Goodwin. The information ratio. Financial Analysis Journal, 54(4):43–43, 1998.
[11] Bhaswar Gupta and Manolis Chatiras. The interdependence of managed futures risk measures.
pages 203–220. Center for International Securities and Derivatives Markets, October 2003.
42
[12] Thomas Hellstrom. Optimizing the sharpe ratio for a rank based trading system. In Portuguese
Conference on Artificial Intelligence, pages 130–141, 2001.
[13] Matthew Saffell. John Moody. Learning to trade via direct reinforcement. IEEE Transactions
on Neural Networks, 12(4):875–889, 2001.
[15] Hong Liu. Optimal consumption and investment with transaction costs and multiple risky
assets. The Journal of Finance, 59(1):289, 2004.
[16] Stephen Boyd. Miguel Sousa Lobo, Maryam Fazel. Portfolio optimization with linear and fixed
transaction costs. Operations Research, to appear, 2002.
[17] Oliver Mihatsch and Ralph Neuneier. Risk-sensitive reinforcement learning. Mach. Learn.,
49(2-3):267–290, 2002.
[19] Chester S. Spatt. Robert M. Dammon. The optimal trading and pricing of securities with asym-
metric capital gains taxes and transaction costs. The Review of Financial Studies, 9(3):921–
952, 1996.
[20] Jiming Liu. Samuel P. M. Choi. Optimal time-constrained trading strategies for autonomous
agents. In Proceedings of International ICSC Symposium on Multi-agents and Mobile Agents
in Virtual Organizations and E-Commerce (MAMA 2000), 2000.
[21] William F. Sharpe. Mutual fund performance. Journal of Business, pages 119–138, January
1966.
[22] William F. Sharpe. Adjusting for risk in portfolio performance measurement. Journal of
Portfolio Management, pages 29–34, 1975.
43
[25] Fischer Black. Treynor, Jack L. How to use security analysis to improve portfolio selection.
Journal of Business, pages 66–85, January 1973.
[26] Jiqing Han. Yang Liu, Xiaohui Yu. Sharp ratio-oriented active trading: A learning approach.
SSRN Electronic Paper Collection, 2001.
[27] Valeri I. Zakamouline. Optimal portfolio selection with both fixed and proportional transaction
costs for a crra investor with finite horizon. Norwegian School of Economics and Business
Administration, 2002.
44