You are on page 1of 8

J Comb Optim (2012) 23:159–166

DOI 10.1007/s10878-010-9344-4

Optimal algorithms for online time series search and


one-way trading with interrelated prices

Wenming Zhang · Yinfeng Xu · Feifeng Zheng ·


Yucheng Dong

Published online: 3 August 2010


© Springer Science+Business Media, LLC 2010

Abstract The basic models of online time series search and one-way trading are
introduced by El-Yaniv et al. in Algorithmica 30(1), 101–139 (2001) where it is as-
sumed that the prices are bounded within interval [m, M] (0 < m < M). In this paper,
we consider another case where every two consecutive prices are interrelated, that is,
the variation range of each price depends on its preceding price. We present optimal
deterministic online algorithms for the two problems, respectively. According to one
conclusion in Algorithmica 30(1), 101–139 (2001), we further point out that for the
case we considered, an optimal deterministic algorithm for the one-way trading prob-
lem can be regarded as an optimal randomized one for the time series search problem,
and randomization is useless for the one-way trading problem.

Keywords Time series search · One-way trading · Online algorithm · Competitive


ratio

1 Introduction

The basic models of online time series search and one-way trading are introduced
by El-Yaniv et al. (2001). In the time series search problem, a player has one asset
for sale and he observes a series of prices sequentially in order to sell the asset in
the highest price, i.e., aiming to obtain the best revenue. Each price expires before
the next one is presented and on the observation of each price, the player has to

The work is supported by NSF grant of China, no. 60736027 and 70702030.
W. Zhang () · Y. Xu · F. Zheng · Y. Dong
School of Management, Xi’an JiaoTong University, Xi’an, 710049, China
e-mail: wenming.zhang.xjtu@gmail.com

W. Zhang · Y. Xu · F. Zheng · Y. Dong


State Key Lab for Manufacturing Systems Engineering, Xi’an, 710049, China
160 J Comb Optim (2012) 23:159–166

decide immediately whether to accept the price and sell the asset without knowledge
of future prices. The game ends either a price is accepted or the last period is met.
El-Yaniv et al. (2001) prove that if the prices are bounded within interval [m, M] (0 <
√ < M), an optimal deterministic√algorithm is to accept the first price no less than
m
Mm and its competitive ratio is M/m. In the one-way trading problem, the story
is a bit different. There is some initial currency, which is planned to be exchanged into
some foreign currency. At each period, the player observes a foreign exchange rate
or simply called price, and shall decide immediately whether to exchange a part of
the initial currency into foreign currency with the price. The objective is to maximize
the amount of foreign currency in the end. The difference between the above two
problems lies in that whether the asset is divisible. In the former problem, the asset
shall be wholly sold at one time while in the latter one, the asset may be divided into
parts and handled independently.
For the time series search problem, Lorenz et al. (2009) extend the basic model to
the k-search problem, i.e., searching for the k highest or lowest prices in one series.
They adopt the approach in El-Yaniv et al. (2001) and present optimal deterministic
and randomized algorithms for both maximum and minimum objectives. Damaschke
et al. (2009) study some different search models where the variation range of price
varies over time. They give two models based on natural problems. For the first model
where the upper and lower bounds of price have decay speeds, they present an optimal
deterministic algorithm and a nearly-optimal randomized algorithm. For the second
model where the upper bound decreases in time while the lower bound is constant,
they propose an optimal randomized algorithm. Xu et al. (2009) extend the model in
El-Yaniv et al. (2001) by introducing so-called general profit functions which increase
in price for each fixed period while decrease in time for any given price. They give
optimal deterministic algorithms for both cases where the duration is either known or
unknown beforehand.
For the one-way trading problem, there are some works following El-Yaniv et al.
(2001). Fujiwara et al. (2009) study the problem via average-case competitive analy-
sis. They present optimal strategies for different optimization measures respectively.
Kakade et al. (2004) study another one-way trading model in stock market, called
the price-volume trading problem, in which a player has a fixed amount of shares of
a given stock at the beginning and his task is to sell all the shares to maximize the
average selling price, i.e., the total revenue over the amount of shares. To measure
the performance of an online algorithm, they compare the average selling price of the
online algorithm to a so-called volume-weighted average price (abbr. VWAP). For
the details on VWAP, please refer to Kakade et al. (2004).
In this paper, we consider another case of the above two problems such that in
every two consecutive periods, the variation range of the latter price depends on the
former price. This case is motivated by the stock market in China mainland where for
the price of each stock, both increment and decrement in a day are bounded by 10%
of the closing price in the preceding day.

1.1 Related work

There is much literature related on either the time series search problem or the one-
way trading problem. Two related ones are the optimal stopping and the secretary
J Comb Optim (2012) 23:159–166 161

problems, which both have received considerable attention in mathematical eco-


nomics and operations research since 1960’s. In the optimal stopping problem, the
distribution of prices is known to the player and the aim is to maximize (or minimize)
the expectation of the accepted price. Peskir and Shiryaev (2006) give a detailed in-
troduction on the optimal stopping problem and its applications in mathematical fi-
nance. Abdelaziz and Krichen present a review of the optimal stopping problem with
more than one single decision maker (see Abdelaziz and Krichen 2007). The secre-
tary problem is a special case of the optimal stopping problem with relative rank (see
Lorenzen 1981). Ferguson (1989) proposes a review of the secretary problem, and
Babaioff et al. (2008) give a framework of generalized secretary problems. Note that
most of these work follows Bayesian approach and the algorithms are developed un-
der an assumption that prices in different periods are generated by some distribution,
which is known beforehand.

1.2 Competitive ratio

Sleator and Tarjan (1985) propose to evaluate the performance of online algorithms
by competitive ratio. Translated into our problem terminology, for an arbitrary price
sequence σ , let ALG(σ ) be the revenue of an online algorithm ALG and OPT(σ )
be that of an offline optimal algorithm OPT which knows all the prices in advance,
respectively. We say ALG is α-competitive if for any σ ,
OPT(σ )
≤ α.
ALG(σ )
α is also called the competitive ratio of ALG algorithm. Given that there are no on-
line algorithms with competitive ratios less than α, ALG is called an optimal online
algorithm.
The rest of this paper is organized as follows. Section 2 models the online se-
ries search and online one-way trading problems considering price interrelation. We
present optimal online algorithms for the two problems in Sects. 3 and 4, respec-
tively. We further make some discussion on randomization in Sect. 5. Finally, Sect. 6
concludes this paper.

2 Problem description

We describe formally the online time series search and one-way trading problems
with price interrelation as follows. A player has one unit of asset to be sold within
n periods where n (> 0) is known to the player beforehand. At each period i (1 ≤
i ≤ n), the player observes one price pi > 0 and decides whether to sell some or all
of the asset with pi without knowledge of further prices. The decision on selling is
irrecoverable and pi expires before the next period. The objective is to maximize the
revenue for selling the unit of asset. We assume that the player has knowledge that
for each pi (1 ≤ i ≤ n − 1), pi+1 ∈ [θ1 pi , θ2 pi ] where 0 < θ1 ≤ θ2 . The online time
series search problem, denoted by P1, and one-way trading problem, denoted by P2,
are defined below.
162 J Comb Optim (2012) 23:159–166

P1: Online Time Series Search with Interrelated Prices. The player accepts exactly
one price during the n periods and sells the unit of asset with the accepted price. The
objective of maximizing the selling revenue is equivalent to maximizing the price
selected.
P2: Online One-Way Trading with Interrelated Prices. The player may divide the
unit of asset into parts and sell each part in different periods. The total revenue is the
sum of that of the parts.
We make some basic observation on the values of θ1 and θ2 . If 1 ≤ θ1 or θ2 ≤ 1,
implying that the price sequence is monotonously increasing or decreasing respec-
tively, the solution can be obtained by selecting the last or first price for problems P1
and P2 , respectively. Thus, we focus on the case where 0 < θ1 < 1 < θ2 in the rest of
this paper.

3 Optimal deterministic algorithm for P1

1−j n−j
Let αj = max{θ1 , θ2 }, α = min1≤j ≤n {αj } and J = arg min1≤j ≤n {αj } where ties
are broken by selecting the smallest one. Note that α = max{θ11−J , θ2n−J }.

Algorithm UND Sell the unit of asset at the J th period, that is pJ .

Theorem 1 UND has a competitive ratio of α for P1.

Proof If the player accepts the J th price with revenue pJ , then the worst-case se-
quence is
σ = θ11−J pJ , . . . , θ1−1 pJ , pJ , θ2 pJ , . . . , θ2n−J pJ
where the prices are decreasing from period 1 to period J and increasing from period
J to period n. Obviously, OPT(σ ) = max{θ11−J pJ , θ2n−J pJ } while UND(σ ) = pJ .
Remember that α = max{θ11−J , θ2n−J }. We have

OPT(σ ) max{θ11−J pJ , θ2n−J pJ }


= = α.
UND(σ ) pJ
The theorem follows. 

Theorem 2 For P1, no deterministic algorithm has a competitive ratio less than α.

Proof Let alg be any deterministic algorithm for P1. We construct a price sequence
σ̂ = p̂1 , p̂2 , . . . , p̂n such that alg cannot achieve a competitive ratio less than α.
The sequence is constructed in periods as follows. At period 1, we arbitrarily
present price p̂1 > 0 to alg. If alg accepts p̂1 , we further present the rest n − 1 prices
by formula p̂i+1 = θ2 p̂i (1 ≤ i ≤ n − 1); otherwise if alg rejects p̂1 , we present
p̂2 = θ1 p̂1 and go to the next period. Similarly, at period 2, if alg accepts p̂2 , then
we further present the rest n − 2 prices by formula p̂i+1 = θ2 p̂i (2 ≤ i ≤ n − 1); oth-
erwise we present p̂3 = θ1 p̂2 and go to the next period. Repeat the above procedure
J Comb Optim (2012) 23:159–166 163

until period n. Note that if alg rejects all the previous n − 1 prices, then it has to
accept pn according to the problem description.
Assume that alg accepts p̂j at some period j (1 ≤ j ≤ n). By the construction of
1−j n−j
σ̂ , we have p̂1 = θ1 p̂j and p̂n = θ2 p̂j implying alg’s competitive ratio is no less
1−j n−j
than max{θ1 , θ2 } = αj since the OPT may either accept p̂1 or p̂n . Remember
that α = min1≤j ≤n {αj }. The theorem follows. 

By Theorems 1 and 2, UND is an optimal deterministic algorithm for P1.

4 Optimal deterministic algorithm for P2

We denote s1
+ s2
+ · · · + si−1
θ2 + si + si+1 θ1 + · · · + sn θ1
n−i
by Fi (s1 , s2 , . . . , sn ).
θ2i−1 θ2i−2
Before presenting the algorithm, we investigate one programming problem with vari-
ables {r, s1 , s2 , . . . , sn } below.

min r

⎨Fi (s1 , s2 , . . . , sn ) ≥ r i = 1, 2, . . . , n
1

⎩s1 + s2 + · · · + sn ≤ 1
s.t.
si ≥ 0 i = 1, 2, . . . , n

We discuss this programming problem in the following two lemmas.

Lemma 1 The solution space is not empty for the above programming problem.

Proof It suffices to prove that there exist {r  , s1 , s2 , . . . , sn } such that Fi (s1 , s2 , . . . , sn )
≥ r1 and si ≥ 0 for i = 1, 2, . . . , n, and s1 + s2 + · · · + sn ≤ 1.
By solving

Fi (s1 , s2 , . . . , sn ) = r1 i = 1, 2, . . . , n
s1 + s2 + · · · + sn = 1
(n−2)(1−θ1 )(θ2 −1) θ2 −1
we get a solution where r  = (1−θ1 )θ2
θ2 −θ1 + θ2 −θ1 + θ2 −θ1 and



(1−θ1 )θ2
i=1
⎪ r  (θ2 −θ1 )

(1−θ1 )(θ2 −1)
si = r  (θ2 −θ1 ) i = 2, 3, . . . , n − 1



⎩ θ2 −1
r  (θ2 −θ1 ) i=n

Note that si > 0 for i = 1, 2, . . . , n. The lemma follows. 

Lemma 2 The above programming problem is equivalent to a linear programming


problem. It implies that the above programming problem is solvable in polynomial
time.
164 J Comb Optim (2012) 23:159–166

Proof Let u = 1/r. From si ≥ 0 and 0 < θ1 < 1 < θ2 , we have that 0 ≤ Fi (s1 , s2 , . . . ,
sn ) ≤ s1 + s2 + · · · + sn = 1, implying r ≥ 1/Fi (s1 , s2 , . . . , sn ) ≥ 1. So, minimizing
1/r is equivalent to maximizing u. The above programming problem is equivalent to

max u

⎨Fi (s1 , s2 , . . . , sn ) ≥ u i = 1, 2, . . . , n
s.t. s + s2 + · · · + sn ≤ 1
⎩1
si ≥ 0 i = 1, 2, . . . , n

which is a linear programming problem. The lemma follows. 

From Lemmas 1 and 2, we know that there exist an optimal solution for the pro-
gramming problem and the solution can be obtained by solving the equivalent linear
programming problem in polynomial time. Let {r ∗ , s1∗ , s2∗ , . . . , sn∗ } be the solution.
We are now ready to present an algorithm for P2.

Algorithm DIV Sell si∗ (1 ≤ i ≤ n) units of the asset at period i.

Theorem 3 DIV has a competitive ratio of r ∗ for P2.

Proof Given an arbitrary price sequence σ = p1 , p2 , . . . , pn . Without loss of gen-


assume that the highest price in σ is pi . Then, OPT(σ ) = pi while
erality, we
DIV(σ ) = nj=1 sj∗ pj . Since pj +1 ∈ [θ1 pj , θ2 pj ] (1 ≤ j ≤ n − 1), we have
 pi
i−j i = 1, 2, . . . , i
pj ≥ θ2
j −i
θ 1 pi j = i + 1, i + 2, . . . , n

So,
OPT(σ ) pi
= n ∗
DIV(σ ) j =1 sj pj

1
≤ ∗
s1∗ s2∗ si−1
+ + ··· + + si∗ + si+1
∗ θ + · · · + s ∗ θ n−i
1 n 1
θ2i−1 θ2i−2 θ2

1
=
Fi (s1∗ , s2∗ , . . . , sn∗ )

≤r .

The theorem follows. 

Theorem 4 For P2, no deterministic algorithm has a competitive ratio less than r ∗ .

Proof Let ALG be any deterministic algorithm for P2. We construct n special se-
quences σ̂1 , σ̂2 , . . . , σ̂n where σ̂i = i−1
1 1
, i−2 , . . . , θ12 , 1, θ1 , θ12 , . . . , θ1n−i . Without
θ2 θ2
J Comb Optim (2012) 23:159–166 165


loss of generality, we assume that si (where 1 ≤ i ≤ n and nj=1 sj ≤ 1) units of the
asset is sold by ALG at period i. We show that there exists at least one sequence σ̂j
(1 ≤ j ≤ n), such that OPT(σ̂j )/ALG(σ̂j ) ≥ r ∗ . Otherwise if OPT(σ̂j )/ALG(σ̂j ) <
r ∗ for all j , we deduce a contradiction in the following.

s1 s2 si−1
It is obvious that OPT(σ̂j ) = 1 while ALG(σ̂j ) = + + ··· + + si +
θ2i−1 θ2i−2 θ2
 θ + · · · + s  θ n−i = F (s  , s  , . . . , s  ). By OPT(σ̂ )/ALG(σ̂ ) < r ∗ , we have
si+1 1 n 1 j 1 2 n j j
that Fj (s1 , s2 , . . . , sn ) > 1/r ∗ , where j = 1, 2, . . . , n. So, we claim that there exists
an r  < r ∗ such that for all j , Fj (s1 , s2 , . . . , sn ) ≥ 1/r  , contradicting to the definition
of r ∗ . The theorem follows. 

By Theorems 3 and 4, DIV is an optimal deterministic algorithm for P2.

5 Further discussion on randomization

In this section, we discuss randomized algorithms for P1 and P2. We resort to one
conclusion on the relationship between the online search problem and one-way trad-
ing problem, proved in El-Yaniv et al. (2001). We restate the conclusion below.

Theorem 5 (Corollary 2 in El-Yaniv et al. 2001) A (competitive) optimal determinis-


tic one-way trading algorithm has the same return as an optimal randomized search
algorithm. This implies that randomization cannot improve the competitive perfor-
mance in one-way trading.

It is assumed that pj ∈ [m, M] for the search problem and one-way trading prob-
lem in El-Yaniv et al. (2001) while pj +1 ∈ [θ1 pj , θ2 pj ] in P1 and P2. We claim
that Theorem 5 still holds for problems P1 and P2 with similar proof for Theorem 5
in El-Yaniv et al. (2001). So, we have the following two corollaries on randomized
algorithms for P1 and P2.

Corollary 1 An optimal randomized algorithm for P1 is to sell the asset at period i


with probability si∗ , and its competitive ratio is r ∗ .

Corollary 2 Randomization can not improve the competitive performance in P2, i.e.,
no randomized algorithm can achieve a competitive ratio less than r ∗ for P2.

6 Conclusion

In this paper, we propose and investigate the online time series search and one-way
trading problems with interrelated prices. We present optimal deterministic online
algorithms for the two problems, respectively. Moreover, we give an optimal ran-
domized online algorithm for the search problem and state that randomization can
not improve the competitive performance for the one-way trading problem.
166 J Comb Optim (2012) 23:159–166

References

Abdelaziz FB, Krichen S (2007) Optimal stopping problems by two or more decision makers: a survey.
Comput Manag Sci 4(2):89–111
Babaioff M, Immorlica N, Kempe D, Kleinberg R (2008) Online auctions and generalized secretary prob-
lems. ACM SIGecom Exch 7(2):1–11
Damaschke P, Ha PH, Tsigas P (2009) Online search with time-varying price bounds. Algorithmica
55(4):619–642
El-Yaniv R, Fiat A, Karp RM, Turpin G (2001) Optimal search and one-way trading online algorithms.
Algorithmica 30(1):101–139
Ferguson TS (1989) Who solved the secretary problem? Stat Sci 4(3):282–296
Fujiwara H, Iwama K, Sekiguchi Y (2009) Average-case competitive analyses for one-way trading. J Comb
Optim. doi:10.1007/s10878-009-9239-4
Kakade SM, Kearns M, Mansour Y, Ortiz LE (2004) Competitive algorithms for VWAP and limit order
trading. In: Proceedings of the 5th ACM conference on electronic commerce, New York, USA, vol 7,
pp 189–198
Lorenz J, Panagiotou K, Steger A (2009) Optimal algorithms for k-search with application in option pric-
ing. Algorithmica 55(2):311–328
Lorenzen TJ (1981) Optimal stopping with sampling cost: the secretary problem. Ann Probab 9(1):167–
172
Peskir G, Shiryaev A (2006) Optimal stopping and free-boundary problems. Birkhäuser, Basel
Sleator DD, Tarjan RE (1985) Amortized efficiency of list update and paging rules. Commun ACM
28:202–208
Xu YF, Zhang WM, Zheng FF (2009) Optimal algorithms for the online time series search problem. Theor
Comput Sci. doi:10.1016/j.tcs.2009.09.026

You might also like