Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

Physica A 461 (2016) 498–508

Contents lists available at ScienceDirect

Physica A
journal homepage: www.elsevier.com/locate/physa

Trading strategy based on dynamic mode decomposition:


Tested in Chinese stock market
Ling-xiao Cui, Wen Long ∗
Research Center On Fictitious Economy & Data Science, Chinese Academy of Sciences, Beijing, 100190, China
School of Economics and Management, University of Chinese Academy of Sciences, Beijing 100190, China
Key Laboratory of Big Data Mining and Knowledge Management, Chinese Academy of Sciences, Beijing, 100190, China

highlights
• DMD can capture Chinese stock market dynamical patterns well especially in sideways market.
• The spatial information from spatial–temporal coherent structure of DMD modes can improve trading strategy remarkably.
• The SPA tests further prove that DMD can model the behavior of stock market well in a choppy market period with no clear trend.

article info abstract


Article history: Dynamic mode decomposition (DMD) is an effective method to capture the intrinsic
Received 15 February 2016 dynamical modes of complex system. In this work, we adopt DMD method to discover the
Received in revised form 13 May 2016 evolutionary patterns in stock market and apply it to Chinese A-share stock market. We
Available online 11 June 2016
design two strategies based on DMD algorithm. The strategy which considers only timing
problem can make reliable profits in a choppy market with no prominent trend while
Keywords:
fails to beat the benchmark moving-average strategy in bull market. After considering the
Dynamic mode decomposition
Technical analysis
spatial information from spatial–temporal coherent structure of DMD modes, we improved
Trading strategy the trading strategy remarkably. Then the DMD strategies profitability is quantitatively
Superior predictive ability evaluated by performing SPA test to correct the data-snooping effect. The results further
prove that DMD algorithm can model the market patterns well in sideways market.
© 2016 Elsevier B.V. All rights reserved.

1. Introduction

The efficient market hypothesis was widely accepted in academia, which suggests that current prices of securities have
already reflected all the information in current time and one cannot use technical analysis or even fundamental analysis to
achieve excess profits. Many early studies used traditional statistical tests to show the invalidation of technical strategy [1,
2]. However in recent decades many scholars began to believe that human psychological and behavioral factors have played
an important role in securities price determination [3,4] and the stock price movement can be partially predicted by using
the past information. Therefore technical analysis has attracted more and more attention both in practical and theoretical
field of finance. Currently most of technical trading strategies try to capture the price trend of the near future and profit
from it [5–9]. Although the actual profitability of technical analysis is still controversial [10–15], technical strategies are of
growing importance in modern financial investment especially with the advent of automated trading.
Technical analysts usually believe that the past price time series can provide indicators of future price variations. In
Refs. [16–18], the profitability of technical trading strategies have been tested in Chinese A-share stock market. Results

∗ Corresponding author at: Research Center On Fictitious Economy & Data Science, Chinese Academy of Sciences, Beijing, 100190, China.
E-mail address: longwen@ucas.ac.cn (W. Long).

http://dx.doi.org/10.1016/j.physa.2016.06.046
0378-4371/© 2016 Elsevier B.V. All rights reserved.
L.-x. Cui, W. Long / Physica A 461 (2016) 498–508 499

show that Chinese stock market is not efficient in the weak form and some technical trading strategies can offer significant
profitability. The profitability of technical strategies can be understood that they detect patterns or features of a less efficient
market. In this work, we adopt the dynamic mode decomposition (DMD) [19–22] method to capture the intrinsic dynamics in
stock market and apply it to Chinese A-share stock market to test its profitability. Unlike most of the model-driven methods
which need to impose assumptions, the DMD is a data-driven method that any postulations about the underlying dynamical
information is not needed. Compared with traditional time series analysis method, the most novel feature of DMD is that
it combines features of the power spectral analysis in temporal component and the principal components analysis (PCA) in
spatial component simultaneously. The DMD method has been originally used in the field of fluid dynamics for experimental
or simulative data mining. In fluid mechanics, fluid flows are infinite-dimensional nonlinear systems. The DMD method
produces a least-square regression to reduce the high-dimensional system to a lower linear dynamical system in the form
of DMD modes and corresponding eigenvalues. The DMD modes are coherent spatial structure of the fluid flows and the
eigenvalues show the systems’ evolving behavior. Note that in fluid dynamics community there are other technics to extract
coherent structures. For example, the proper orthogonal decomposition (POD) modes [23], global eigenmodes, frequential
modes [24]. Both POD and DMD are snapshot-based post-processing algorithms. POD modes are spatial orthogonal with
multi-frequential temporal component while DMD modes are non-orthogonal but each of them possesses a single temporal
frequency. This non-orthogonal property of DMD is essential when capturing important dynamical effects in systems with
non-normal dynamical generators [25]. Recently many improved DMD algorithm have also been proposed. The multi-
resolution DMD has been introduced in Ref. [26] and a sparsity-promoting variant of the standard DMD can be found in
Ref. [27].
Many research have showed that some dynamical behaviors of economic systems resemble the features of complex
systems, such as multi-scale phenomenon, power-law distribution and critical behavior [28–31]. The basic assumption in
this paper is that the stock market is a complex dynamical system. In stock market, stock prices are interactive and can
be regarded as the measurements of such complex systems. As an equation-free technique, DMD method allows one to
focus his attention exclusively on historical data to discover the dynamical properties of financial system. More specifically,
the time series of stocks’ price data provide the series of snapshots of DMD. By extracting the dynamical pattern, one can
make prediction about the near future states. In Ref. [32], DMD algorithm has been used to develop trading strategies in US
stock market. By extracting key temporal coherent structures, DMD trading scheme can inform buy/sell/hold investment
decisions. The results in different sectors show that DMD trading strategies can easily beat the benchmark. In this work, we
will further show that the spatial–temporal coherent structures in DMD modes can be used to make not only market timing
strategies but also portfolio selection strategies. Our results show that the strategy with only timing decision part can barely
beat some simple technical strategy, while the strategy with both timing and portfolio selection parts will be improved
significantly. The most noticeable aspect for implementation of DMD in finance is that financial market is an open complex
adaptive system, unlike the fluid flows or other physical systems, the dynamical patterns in financial market are changing all
the time. This leads to the difficulty of deciding the time scales in DMD. In this work, we use the same learning algorithm as
showed in Ref. [32] to dynamically choose the best time scales. Also the original DMD cannot model the exogenous influences
on stock market. One can take into account other exogenous variable by adopting the DMD algorithm with external signal
which can be found in Ref. [33]. In this work, we adopt the Superior Predictive Ability (SPA) test [34] to quantitatively
evaluate the DMD algorithm’s predictive ability in Chinese A-share stock market. The SPA test was proposed to eliminate
the data-snooping effects which occurs when the same historical data is used more than once for model selection. There is
high possibility that the best fitted model is chosen by luck rather than its actual forecasting ability.
The paper is arranged as follow: In Section 2, we briefly introduce the DMD method. In Section 3, we design two trading
strategies based on DMD and back test it in Chinese A-share stock market. In Section 4, we adopt the SPA test to quantitatively
evaluate the forecasting ability of these two strategies. The conclusion and the discussion of future improvement can be
found in Section 5.

2. Dynamic mode decomposition method

The dynamic mode decomposition is a data processing algorithm that extracts spatial–temporal coherent structures
in a given complex system. It is an equation-free, data-driven method that can capture important dynamical effects even
without knowing fully, or partially, the underlying governing equations. DMD has been wildly used in the fluid dynamics
communities and atmospheric science. Here we briefly outline the key structures of DMD.
Consider n data or measurements collected at time ti from a given nonlinear system, assume that the data are equispaced
in time, with a time step 1t and the collection time starts from t1 to tm . These m snapshots can be arranged into an n × m
matrix.
 
X = x1 , x2 , x3 , . . . , xm (1)

where the vector xi is the data collected at time ti . The purpose of DMD is to extract important dynamical information from
matrix X . We can define two matrices from X as follow:
 
X1 = x1 , x2 , x3 , . . . , xm−1 (2)
500 L.-x. Cui, W. Long / Physica A 461 (2016) 498–508

 
X2 = x2 , x3 , x4 , . . . , xm . (3)

Postulate that these snapshots are generated by a time-invariant system that the Koopman operator A maps the snapshot
at time ti to the data at time ti+1 , xi+1 = Axi . Using the Koopman operator A, the matrices X1 and X2 can be linked as
 
X2 = x2 , x3 , x4 , . . . , xm
 
= Ax1 , Ax2 , Ax3 , . . . , Axm−1
= AX1 . (4)
In DMD, it is assumed that the set {x1 , x2 , . . . , xm } does not span the entire vector space especially if the Koopman
operator A has low-rank structure. When number of snapshots m increases, the new added snapshot xm will not further
improve the vector space spanned by X1 . Namely the vectors xm can be expressed in a linear combination of the previous,
linearly independent vector X1 .
m−1

xm = ai x i + r (5)
i =1

where the vector r is the residual and should be minimized in DMD procedure. Using Eqs. (4) and (5), we have:

X2 = X1 S + re∗m−1 (6)
where ∗ denotes the conjugate transpose and em−1 is the (m − 1)th unit vector. S is a n × m matrix and has the form,

0 0 ··· 0 a1
 
1 0 ··· 0 a2 
0
S = 1 ··· 0 a3 
. (7)
 ... .. .. .. .. 
 
. . . .
0 0 ··· 1 am−1
Notice that AX1 = X2 ≈ X1 S, the eigenvalues of A can be approximated by the eigenvalues of S. From (5), its least-squares
solution for a full-rank matrix X1 is given by

a = R −1 Q ∗ xm (8)
with QR = X1 as the QR-decomposition of matrix X1 . However this mathematically correct formulation can lead to an ill-
conditioned algorithm which is often not capable of extracting more than the first or first two dominant dynamic modes [20].
In practice, a more robust implementation is adopted by replacing S by its similar matrix S̃. Note that the singular value
decomposition (SVD) of the matrix X1 can provide low-dimensional reduction of such system. X1 = U 6V ∗ , where U ∈ Cn×r
is an unitary matrix, 6 ∈ Cr ×r is a diagonal matrix and V ∈ C(m−1)×r is unitary. The parameter r is chosen to keep only the
r largest singular values in 6 so that the dominant modes can be captured. Substituting the singular value decomposition
of X1 into Eq. (6), we obtain

X2 ≈ U 6V ∗ S
(9)
S ≈ V 6−1 U ∗ X2 .

After the similarity transform, S̃ can be derived,

S̃ ≈ U ∗ X2 V 6−1 . (10)

The DMD eigenvalues can be approximated by solving the eigenvalue problem of matrix S̃:

S̃vj = λj vj , j = 1, 2, . . . , r . (11)

In fact, S̃ ∈ Cr ×r is a least-square sense optimal low-dimensional representation of the original dynamical mapping A on
the subspace spanned by the proper orthogonal modes(POD) of X1 [19]. Using Eqs. (10) and (4), we can also approximate
the eigenvectors of A since:

AU ≈ U 6V ∗ S (6V ∗ )−1 = U S̃ = UP 3P −1
(12)
A(UP ) ≈ (UP )3

where the eigendecomposition of S̃ is S̃ = P 3P −1 . The matrix of POD modes U can map the eigenvectors of S̃ into the higher
dimensional space of A. The jth eigenvector of Koopman operator A can be shown as:
φj = Uvj . (13)
L.-x. Cui, W. Long / Physica A 461 (2016) 498–508 501

For convenience the DMD eigenvalues can be converted to Fourier modes by rewriting ωj = ln(λj )/1t. Therefore even
when we do not know the governing equation which drives the system, with the eigenvalues and eigenvectors of the
Koopman operator A, we can reconstruct the approximate dynamics of data set X .
r
bj φj eωj t = 8 diag(eωt )b

XDMD (t ) = (14)
j=1

where 8 is the matrix whose columns are the eigenvector φj and b is the vectors of coefficients bj which can be determined
by the initial condition. We simply choose the first snapshot of data x1 as time zero which gives b = 8−1 x1 . Notice that 8
is not a square matrix and we use a Moore–Penrose pseudo-inverse instead.
It should be mentioned that the original DMD algorithm is used widely in large fluid flow fields, where the numbers of
measurements or observables are much larger than the number of snapshots, that is, n ≫ m. When DMD method is applied
to other fields, the problem of rank mismatch has always been found. If n is too small, the DMD modes extracted are often
too few to capture the dominant dynamics of the whole m snapshots.

3. Application of DMD in stock market

The DMD method captures the underlying dominant evolution modes to reconstruct an approximate dynamic of a given
complex system. It combines the merits of time-series analysis and PCA analysis and it can extract key spatial–temporal
coherent structures. Financial markets can be regard as complex systems which consist of crowds of traders and are
constantly evolving. In this section, we try to apply the DMD technic to Chinese A-share stock market.

3.1. DMD in finance

The snapshots in DMD are collected at regularly spaced intervals of time. In stock market, we use daily closing prices of
stocks as the snapshots series. To avoid the rank mismatch problem, we take into account all the stocks in China’s A-share
market except the ST (specially treated) stocks and suspended stocks. Thus the DMD modes contain information from all
industry sectors. The total sample data includes nearly 2500 A-Share stocks.
A demonstration of DMD analysis in a given time period is shown in Fig. 1. We consider 20 trading days from Mar 6,
2015 to Apr 3, 2015 during which the market is in a bullish mood. The distribution of DMD eigenvalues λ can be put on the
complex plane with unit circle as shown in top left panel of Fig. 1. The eigenvalues which lie inside of the unit circle are
decaying modes. The amplitude of these modes decrease as time goes on. Eigenvalues exactly on the unit circle are stable
modes. The most important modes to us are those that lie outside of the unit circle. The influence of these modes can be
magnified as time goes on. Notice that the red point outside of the unit circle at 1% level in top left panel of Fig. 1 has no
imaginary part which represents an exponentially growing solution. To characterize the significance of each DMD mode, we
calculate the average amplitude of each mode from Eq. (14), which is Σi φij  /N. N is the total number of stocks. The results
 
are shown in top right panel of Fig. 1. It can be seen that the average amplitude of the first mode which represents the fastest
growing mode have significant larger amplitude than other modes and it is the dominant mode in this time period. We then
calculate all stocks’ decompositions on this mode using Eq. (13) which is demonstrated in bottom left panel of Fig. 1. It can
be learned that all stocks have positive coefficient which implies that all stocks’ prices are rising. In this time period, China’s
A-share market was in a bull market duration and nearly every stock price is growing. Note that some stocks’ weighting
factors are much larger than the average level. These stocks should get more attention for their strong rising trend. Finally
we demonstrate decomposition of one stock (stock code: 300252) on DMD modes in bottom right panel of Fig. 1. It can be
seen that the dominant mode which represents the fast growing mode has the largest coefficient.
We also demonstrate the DMD eigenvalues’ distributions in both declining bearish market and a sideways market in
Fig. 2. The left part shows eigenvalues in a 60-trading-days window period. The first four leading modes with larger average
amplitudes are coded in red color which indicates four exponentially decreasing mode. All stocks in A-share market in this
period are going downward. While the right part of Fig. 2 shows that, in a sideways movement period when trading volumes
shrink sharply and stock prices oscillate without a clear trend, all four leading modes are all nearly in the unit circle within
the condition | |ω| − 1| < 0.01, which represents that they are all stable oscillating modes.

3.2. Trading strategy based on DMD

Now we will build our trading strategy based on DMD. The first thing should be reminded is that DMD only capture
the system’s intrinsic underlying dynamics while external influences are not taken into account. Stock market is an open
complex system with many exogenous variables. The original DMD cannot produce such an input–output model. So the
DMD model cannot be expected to be suitable for every time period in stock market. The DMD algorithm with external
signal can be found in Ref. [33]. In this work, we do not consider exogenous influences to stock market.
The DMD method looks back upon a historic time period and makes prediction using DMD modes as shown in Eq. (14).
Assume that short selling is not allowed, if the DMD solution shows a growing mode, we open long positions and if the
502 L.-x. Cui, W. Long / Physica A 461 (2016) 498–508

Fig. 1. DMD analysis in a 20-trading-days window period from Mar 6, 2015 to Apr 3, 2015. The top left panel shows DMD eigenvalues λ in a complex
plane with unit circle. The solid point indicates the dominant rising mode. The top right panel shows the average amplitude of each DMD mode and the
diamond shaped point is the dominant mode. The bottom left panel shows all stocks’ decompositions on the dominant rising mode. The red points with
bigger size represent the top seven stocks with larger weighting factors. The bottom right panel demonstrates the decomposition of one stock (stock code:
300252) on DMD modes. (For interpretation of the references to color in this figure legend, the reader is referred to the web version of this article.)

Fig. 2. The demonstration of DMD eigenvalues’ distributions in both declining bear market and a sideways market. The left part shows eigenvalues in a
60-trading-days window period in bearish market. The right part shows eigenvalues in a sideways market. The red solid points in both part represent the
four leading modes. (For interpretation of the references to color in this figure legend, the reader is referred to the web version of this article.)

solution shows the price is going down, we close the long positions. The main problem is to determine the numbers of
previous days l which the DMD algorithm take as input. Like other technical indexes, long-term input windows always
L.-x. Cui, W. Long / Physica A 461 (2016) 498–508 503

Fig. 3. The performances (cumulative return) of two DMD strategies as well as two benchmarks from 2002 to 2015.

capture mean reversion effects while short-term windows indicate the momentum effects. We search for the best length
of input window by the success rate of their prediction. This learning process has been also used in Ref. [32]. We set the
limit that l = 3, 4, 5, . . . , 100 for our searching which covers most of the region considered in other technical strategies.
Our trading algorithm looks over the sliding window of previous 120 days and search the best input window length with
the highest success rate. Then we use the input data to predict the future moving trend. If the highest success rate is less
than 50%, it probably means that some external information has affected the market so that the DMD model cannot capture
current market activity. In this situation we simply hold our positions and make no prediction. To avoid the interference of
short-term fluctuation, a buy (sell) signal is generated only when there are two continuous rising (falling) prediction appear.
The DMD modes reveal the spatial–temporal coherent pattern in current stock market. The temporal content provides
information that can be used to make market timing strategy as shown in last paragraph. The spatial content, which gives
each stock the amplitudes of DMD modes as shown in Fig. 1, is useful in portfolio selection. Therefore we design two trading
strategies to test these two aspect of information from DMD. The DMD strategy 1 only considers the market timing signal.
When a buy signal appears, it equally invest in all stocks without selection. While the DMD strategy 2 considers both timing
and portfolio selection problems. From Eq. (14), we can see that for an arbitrary stock xi , its DMD modes can be expressed
as,
r
bij φij eωj t .

xi (t ) = (15)
j =1

Those ωj with Im(ωj ) = 0 are modes with rapid rising or declining trend. According to the amplitude of those rising modes
we can determine the trend of a stock. In DMD strategy 2, we select the top ten stocks with the largest amplitude of the
rising mode. Finally using our trading strategies we perform back test on 300 companies of CSI300 components in Chinese
stock market.
To check the performance of our DMD trading strategies, we make three basic assumptions: (1) Transaction costs is 0.1%
for both buy and sell. This is a conservative estimate in Chinese stock market. (2) All stocks in our portfolio are evenly invested
in. (3) The gains will be re-invested. For the purpose of comparison, we also choose two benchmark strategies. One is Buy-
And-Hold (BAH) strategy, which completely reproduces the CSI300. The other is Moving-Average (MA) strategy, which is
a very popular technical strategy. In Ref. [17] 7846 trading rules have been tested in Chinese stock market and the highest
annualized return is generated by moving averages strategies. Usually the short-term moving average price crossing the
long-term average price from below (above) indicates an upward (downward) trend and it is the signal to buy (sell). There
are two important parameters in MA-strategy: the short-term days s and long-term days l to calculate the corresponding
moving average. We globally search the best performance of different combinations of MA(s, l) strategy to be our benchmark
index. The result shows that MA(5100) has the best performance in the time range of Jan. 4, 2002 to Jun. 2, 2015.
The performances (cumulative return) of DMD strategies as well as two benchmarks have been showed in Fig. 3. The
results show that if we only focus on the market timing part, the DMD algorithm is quite a conservative strategy as DMD
strategy 1 shows. From the results it can be seen that market timing strategy based on DMD can make reliable profits
when market is moving sideways. In Fig. 3 we see that from Aug. 2009 to Oct. 2014 the stock prices have no obvious
rising or declining trajectories. It is difficult for MA-strategy or BAH-strategy to make profits, while DMD strategy 1 can
still achieve 15.7% annualized return in these five years. At the same time period, MA-strategy and BAH-strategy get only
5.7% and −12.9% annualized return respectively. Yet during the bull market time period, DMD strategy 1 fails to beat the
two benchmarks. For example, from Jul. 2006 to Oct. 2007, three strategies DMD 1, MA and BAH achieve 183%, 414% and
584% annualized return respectively. However, when considering both timing and portfolio selection, the DMD strategy
2 shows a great improvement compared with DMD strategy 1. From the performance results, it has completely beat the
other two benchmarks and DMD strategy 1. Again we find that DMD strategy 2 works even better in oscillating market
mode than in a bull market period. From Aug. 2009 to Oct. 2014, DMD strategy 2 achieves annual abnormal return 31.4%
504 L.-x. Cui, W. Long / Physica A 461 (2016) 498–508

Table 1
Performance measures of strategies including annualized return, Sharpe ratio, max drawdown, Alpha, Beta and volatility to
evaluate strategies. The benchmark is CSI 300.
Strategy Annualized return Sharpe ratio Max drawdown Alpha Beta Volatility

DMD 1 24.8% 0.334 17.2% 0.093 0.383 0.00332


DMD 2 30.2% 0.306 25.0% 0.104 0.397 0.00402
Moving-average 24.2% 0.260 26.8% 0.086 0.543 0.00429
CSI 300 12.0% 0.075 70.8% 0.000 1.000 0.006295

Fig. 4. The performances (cumulative return) of two DMD strategies as well as mutual funds from 2009 to 2015. The left part is in bearish region from Jan.
2009 to Jan. 2014. The right part is in bullish region from Jan. 2014 to Jun. 2015.

compared with CSI300, while in bull market period 2006–2007 the abnormal return is −30.1%. Finally we calculate six
performance measures which include annualized return, Sharpe ratio, max drawdown, Alpha, Beta and volatility. The results
are shown in Table 1. It can be seen that two DMD strategies’ Sharpe ratio and Alpha are higher than MA and CSI 300. The
max drawdown of CSI 300 is 70.8% which is mainly given rise to the stock market crash in the time period of Oct. 2007 to
Nov. 2008. DMD strategies have successfully reduce the loss to 25.0% or lower. Comparing with two DMD strategies, we find
that after considering the stocks selection problem, DMD 2 have obvious higher Alpha than DMD 1. However the volatility
have also been slightly increased.
We further compare performances of DMD strategies with realistic performances of mutual funds in Chinese A-share
stock market. Considering that there are not enough data of mutual funds before 2009, we only compare the performances
after 2009. We choose mutual funds that invest in large-cap stocks or stock index which have the same scope of investments.
The fund codes and the cumulative returns of mutual funds and DMD strategies can be seen in Fig. 4. We investigate bearish
and bullish market separately. The performances of bearish region from Jan. 2009 to Jan. 2014 are in the left part of Fig. 4.
The right part is in bullish region from Jan. 2014 to Jun. 2015. Once again we find DMD strategies can beat these mutual
funds in bearish market while lose ground in bullish market. The six measures of performances in time range Jan. 2009
to Jun. 2015 are shown in Table 2. Although DMD strategies have fail to beat some mutual funds, the sharpe ratio and max
drawdown of DMD strategies show more stable performance. Focusing on the spatial information in DMD modes, we see that
DMD 2 can offer more Alpha return than DMD 1. The portfolio selection strategy we adopt is very similar to the traditional
momentum or contrarian strategy [6–8,35]. The differences is that we use each stock’s amplitude of the rising modes to
decide the selection group. In a sideways market, the dominant moving modes are nearly an oscillation mode. The stocks
which locate in the ‘‘trough’’ have larger rising coefficient while the stocks in the ‘‘peak’’ have larger declining coefficient.
This is much alike the contrarian strategies which have been tested to be profitable in Chinese stock market in Ref. [16]. And
this may explain the excess return of DMD 2 compared with timing-decision strategy DMD 1. Thus from all the results, we
conjecture that DMD algorithm can make reliable profits in a choppy market with no prominent trend which is opposite to
other technical analysis methods such as moving-average strategy. In next section we will quantitatively evaluate the DMD
strategies’ predictive ability using Superior Predictive Ability test.

4. Superior predictive ability test

The DMD trading strategies have been back tested on historic data. Even DMD strategy 1 gives the return of 24.8%
annualized over 13 years which is better than the benchmark index CSI300 and MA-strategy. However in our strategy,
we have selected the best performance parameter l in every sliding window. There is high possibility that this good model
is chosen by luck rather than its actual forecasting ability, which is also called the data-snooping effect. To further check
our strategies’ practicability and their capacity to predict, we consider applying the most popular testing method Superior
Predictive Ability test [34] to our trading strategies for statistical tests.
L.-x. Cui, W. Long / Physica A 461 (2016) 498–508 505

Table 2
Six performance measures of DMD strategies and mutual funds in Chinese A-share market. The benchmark
of Alpha and Beta is CSI 300.
Strategy Annualized return Sharpe ratio Max drawdown Alpha Beta Volatility

Time range: Jan. 2009–Jun. 2015


DMD 1 26.5% 0.303 11.56% 0.076 0.453 0.00311
DMD 2 30.4% 0.286 11.80% 0.089 0.464 0.00377
000011 23.5% 0.069 32.09% 0.062 0.773 0.01348
519110 32.18% 0.079 36.66% 0.093 0.767 0.01552
519668 33.47% 0.088 26.14% 0.101 0.609 0.01416

4.1. SPA test

In SPA test, a benchmark strategy is chosen to show whether the performance of our strategies could beat the benchmark.
In this work, we choose MA(5100) MA-strategy and BAH strategy as two benchmarks.
First, the performance statistic can be defined as follow,
n −1
1
⟨f ⟩ = f t +1 , (16)
n t =1

where n is the total number of trading days in a given time period. ft +1 is the performance of our trading strategy when
compared with the benchmark at time t + 1, which is defined as,

ft +1 = ln(1 + rt +1 It +1 ) − ln(1 + rt +1 Ib,t +1 ), (17)

where rt +1 is the return at time t + 1, rt +1 = (pt +1 − pt )/pt . It +1 is the indicator to show our positions in the market. If we
have long positions at time t + 1, then It +1 = 1, otherwise It +1 = 0. Ib,t +1 is the indicator of the benchmark strategy at time
t + 1.
The null hypothesis in SPA test is that the performance of DMD trading strategy is not better than the benchmark, which
can be expressed as follow,

H0 : ⟨f ⟩ ≤ 0. (18)

We adopt the stationary bootstrap method [36] to test this null hypothesis. The stationary bootstrap is based on the
pseudo time-series of the original data. Let f ∗ be the resampled data. Giving the smoothing parameter q in the range of
[0, 1] and the block size is 1/q. The resampling procedure is as follow: with probability q, the tth data ft∗ is chosen uniformly
on f1,...,n where n is the length of the original time series, and with probability 1 − q, the tth data is chosen to be the data
which follow ft −1 , if t − 1 = n, then set ft∗ = f1 .
Following [34], the SPA test statistic is defined as follow:
√ 
n⟨f ⟩
TSPA = max ,0 , (19)
ω


ω is a consistent estimator of the variance var( n⟨f ⟩), the explicit form is shown as follow:
where 

n−1

ω2 = 
 γ0 + 2 κ(n, t )
γt , (20)
t =1

where γi are the empirical covariances.

n−i
1
γi =
 (fj − ⟨f ⟩)(fi+j − ⟨f ⟩), i = 0, 1, . . . , n − 1. (21)
n j =1

The kernel weights are given by the following form [36],


n−t t
κ(n, t ) = (1 − q)t + (1 − q)n−t , (22)
n n
where q is the parameter in the stationary bootstrap procedure.
For each bootstrap sample ft∗ , we need to calculate the statistics as follow,
 
n1/2 Z

TSPA = max ,0 , (23)
ω

506 L.-x. Cui, W. Long / Physica A 461 (2016) 498–508

Table 3
The p-values of SPA tests in different time period. The upper part is the results of DMD strategy 1 and the
bottom part is the results of DMD strategy 2.
Time period p-value
q = 0.01 0.05 0.1 0.2 0.5 1

DMD strategy 1; Benchmark: MA-strategy


20020626–20050606 0.00*** 0.00*** 0.00*** 0.00*** 0.00*** 0.00***
20050606–20071016 0.16 0.23 0.19 0.20 0.18 0.27
20071016–20081105 0.00*** 0.00*** 0.00*** 0.00*** 0.00*** 0.00***
20050606–20081105 0.02** 0.00*** 0.00*** 0.00*** 0.00*** 0.00***
20081105–20090807 0.01*** 0.06** 0.11 0.12 0.23 0.29
20081105–20140725 0.00*** 0.00*** 0.00*** 0.00*** 0.00*** 0.00***
20090807–20140725 0.00*** 0.00*** 0.00*** 0.00*** 0.00*** 0.00***
20140725–20150602 0.00*** 0.01*** 0.03** 0.08** 0.13 0.15
DMD strategy 2; Benchmark: MA-strategy
20020626–20050606 0.00*** 0.00*** 0.00*** 0.00*** 0.00*** 0.00***
20050606–20071016 0.00*** 0.02** 0.01*** 0.07* 0.08* 0.02**
20071016–20081105 0.00*** 0.00*** 0.01*** 0.00*** 0.00*** 0.00***
20050606–20081105 0.00*** 0.00*** 0.00*** 0.00*** 0.00*** 0.00***
20081105–20090807 0.00*** 0.01*** 0.00*** 0.02** 0.00*** 0.00***
20081105–20140725 0.00*** 0.00*** 0.00*** 0.00*** 0.00*** 0.00***
20090807–20140725 0.00*** 0.00*** 0.00*** 0.00*** 0.00*** 0.00***
20140725–20150602 0.01*** 0.00*** 0.04** 0.08* 0.13 0.10*
*
Represent the significance level of 10%.
**
Represent the significance level of 5%.
***
Represent the significance level of 1%.

where Z is the average of the recentered bootstrap variables,


n

Z = 1/n Zt , (24)
t =1

with
Zt = ft∗ − g (⟨f ⟩) , (25)
1/2

where the function g is defined as g (x) = x · U n ω 2 ln ln(n) and U (x) is the unit step function which gives 1 if
 
x+
x ≥ 0 and 0 for x ≤ 0.
Let N be the total times of the bootstrap procedure. In this paper, we adopt N = 1000 to make sure the final results are
robust. The bootstrap p value can be obtained,

U (TSPA − TSPA )
N
 ∗
p= . (26)
i=1
N

4.2. SPA test on DMD strategy

To eliminate the data-snooping effect, we use SPA test on the two DMD strategies to evaluate their predictive abilities.
We perform the test on different time periods as shown in Table 3. Here we only demonstrate the results of MA-strategy
benchmark, in as much as both DMD strategies have rejected the null hypothesis at 1% significance level when choosing
BAH-strategy as benchmark. The upper part of Table 3 shows that compared with the MA-strategy, DMD strategy 1 cannot
reject the null hypothesis at the 10% significance level for different block length parameter q mainly in the time period of
2005–2008. During this time period, Chinese stock market is in bull market mood. CSI300 rose from 866 to 5891 in only
two years. From 2014 to mid-2015, another bubble in Chinese stock market is forming. The SPA test in this time range with
q = 0.5 and 1 fails to reject the null hypothesis. For DMD strategy 2 in the lower part of Table 3, the results shows that
even in bull market region of 2007, DMD strategy 2 has rejected the null hypothesis at 10% significance level. However at
5% level again we find some value of q could not reject the null hypothesis. Also it can be noticed that both DMD strategies
have passed the test even at 1% significance level from 2009 to 2014 during which the CSI300 of Chinese stock market shows
sideways trend.
To see more details of their performances, we perform SPA test in sliding windows of 60 days as showed in Fig. 5. One can
see that CSI300 in the time regions where p-values are above 0.1 all has prominent rising or declining trends, while in the
region where the market has gone sideways, both DMD strategies have rejected the null hypothesis at 5% significance level.
This further proves our conjecture that DMD algorithm could model the behavior of stock market well in a choppy market
period with no clear trend. This could be explained by the nature of DMD method. The original DMD cannot model the
influences external to the system. For example, the government’s policies may play an important role in promoting bubble
L.-x. Cui, W. Long / Physica A 461 (2016) 498–508 507

Fig. 5. The p-values of SPA test in sliding windows of 60 days.

in Chinese stock market. External impacts like these can corrupt the dynamical modes in market system and the DMD
algorithm fail to capture the influences. Further more in Ref. [17], fixed technical strategies have been tested in Chinese
A-share stock market using SPA test. Our DMD 1 strategy can hardly beat the MA-strategy may be due to the dynamical
update of the learning algorithm, which need to be further investigated. However focusing on the portfolio selection feature
of DMD, the comparison in Fig. 5 shows that the spatial information in DMD modes really brings remarkable improvement.
This is an unique advantage compared with other time-domain analysis such as empirical mode decomposition (EMD) [37].

5. Conclusion and outlook

In this paper, we apply DMD [19–22] method to Chinese stock market and investigate its profitability. Then we
quantitatively evaluate the DMD strategies’ predictive ability by performing SPA test [34] to correct the data-snooping effect.
Results show that the DMD strategies can make reliable profits in a choppy market with no apparent trend while fail to beat
the benchmark moving-average strategy in bull market. After considering the spatial information from spatial–temporal
coherent structure of DMD modes, the trading strategy is remarkably improved. We conclude that the original DMD
algorithm can capture the dynamical patterns of stock market only when there is no lasting exogenous influences such
as government’s policies. One can make improvement by constructing the input–output DMD model [33] to model the
exogenous variables in stock market.

Acknowledgments

This research was supported by National Natural Science Foundation of China (No. 71101146) and University of Chinese
Academy of Sciences (No. Y55202KY00).

References

[1] E.-F. Fama, M.-E. Blume, Filter rules and stock-market trading, J. Bus. 39 (1) (1966) 226–241.
[2] R. Levy, Random walks: Reality or myth, Financ. Anal. J. 23 (6) (1967) 69–77.
[3] D. Kahneman, Tversdy, prospect theory: an analysis of decision making under risk, Econometrica 47 (1979) 263–291.
[4] D. Kahneman, M.W. Riepe, Aspects of investor psychology, J. Portf. Manag. 24 (4) (1998) 52–65.
[5] M.W. Covel, Trend Following (Updated Edition): Learn to Make Millions in Up or Down Markets, Pearson Education, New Jersey, 2009.
[6] K.-C.-L. Chan, N. Jegadeesh, J. Lakonishok, Momentum strategies, J. Finance 51 (5) (1996) 1681–1713.
[7] C.-S. Asness, T.-J. Moskowitz, L.-H. Pedersen, Value and momentum everywhere, J. Finance 68 (3) (2013) 929–985.
[8] J. Lewellen, Momentum and autocorrelation in stock returns, Rev. Financ. Stud. 15 (2) (2002) 533–564.
[9] Moskowitz, J. Tobias, Yao Hua Ooi, L.-H. Pedersen, Time series momentum, J. Financ. Econ. 104 (2) (2012) 228–250.
[10] W. Brock, J. Lakonishok, B. Lebaron, Simple technical trading rules and the stochastic properties of stock returns, J. Finance 47 (1992) 1731–1764.
[11] H. Bessembinder, K. Chan, The profitability of technical trading rules in the Asian stock markets, Pac.-Basin Finance J. 3 (1995) 257–284.
[12] R. Hudson, M. Dempsey, K. Keasey, A note on the weak form efficiency of capital markets: The application of simple technical trading rules to UK stock
prices 1935-1994, J. Bank. Financ. 20 (1996) 1121–1132.
[13] A. Ito, Profits on technical trading rules and time-varying expected returns: Evidence from Pacific-Basin equity markets, Pac.-Basin Finance J. 7 (1999)
283–330.
[14] M.-M. Lai, K.-G. Balachandher, F.-M. Nor, An examination of the random walk model and technical trading rules in the Malaysian stock market, Quart.
J. Bus. Econ. 41 (1–2) (2002) 81–104.
[15] D. Vasiliou, N. Eriotis, S. Papathanasiou, How rewarding is technical analysis? Evidence from Athens stock exchange, Oper. Res. 6 (2) (2006) 85–102.
[16] H.-L. Shi, Z.-Q. Jiang, W.-X. Zhou, Profitability of contrarian strategies in the Chinese stock market, PLoS One 10 (9) (2015) e0137892.
[17] S. Wang, Z.-Q. Jiang, S.-P. Li, W.-X. Zhou, Testing the performance of technical trading rules in the Chinese market, Physica A 439 (2015) 114–123.
[18] H. Zhu, Z.-Q. Jiang, S.-P. Li, W.-X. Zhou, Profitability of simple technical trading rules of Chinese stock exchange indexes, Physica A 439 (2015) 75–84.
[19] J.N. Kutz, Data-Driven Modeling and Scientific Computing: Methods for Integrating Dynamics of Complex Systems and Big Data, Oxford Press, 2013.
[20] P. Schmid, Dynamic mode decomposition of numerical and experimental data, J. Fluid Mech. 656 (2010) 5–28.
[21] C. Rowley, I. Mezic, S. Bagheri, P. Schlatter, D. Henningson, Spectral analysis of nonlinear flows, J. Fluid Mech. 641 (2009) 115–127.
508 L.-x. Cui, W. Long / Physica A 461 (2016) 498–508

[22] P. Schmid, L. Li, M. Juniper, O. Pust, Applications of the dynamic mode decomposition, Theor. Comput. Fluid Dyn. 25 (1–4) (2011) 249–259.
[23] L. Sirovich, Turbulence and the dynamics of coherent structures. Part I: Coherent structures, Quart. Appl. Math. 45 (3) (1987) 561–571.
[24] D. Sipp, O. Marquet, P. Meliga, A. Barbagallo, Dynamics and control of global instabilities in open flows: a linearized approach, Appl. Mech. Rev. 63
(2010) 030801.
[25] P.J. Schmid, Nonmodal stability theory, Annu. Rev. Fluid Mech. 39 (2001) 129–162.
[26] J.N. Kutz, X. Fu, S.L. Brunton, Multi-resolution dynamic mode decomposition, 2015. arXiv:1506.00564.
[27] M.-R. Jovanović, P.J. Schmid, J.W. Nichols, Sparsity-promoting dynamic mode decomposition, Phys. Fluids 26 (2) (2014) 024103.
[28] S. Ghashghaie, W. Breymann, J. Peinke, P. Talkner, Y. Dodge, Turbulent cascades in foreign exchange markets, Nature 381 (1996) 767–770.
[29] K. Matia, Y. Ashkenazy, H.E. Stanley, Multifractal properties of price fluctuations of stock and commodities, Europhys. Lett. 61 (2003) 422–428.
[30] A. Turiel, C.J. Perez-Vicente, Multifractal geometry in stock market time series, Physica A 322 (2003) 629–649.
[31] A. Bershadskii, Multifractal diffusion in NASDAQ, J. Phys. A 34 (2001) L127–L130.
[32] J. Mann, J.N. Kutz, Dynamic Mode Decomposition for Financial Trading Strategies, 2015. ArXiv Preprint arXiv:1508.04487.
[33] J.L. Proctor, S.L. Brunton, J.N. Kutz, Dynamic mode decomposition with control, 2014. ArXiv Preprint arXiv:1409.6358.
[34] P.-R. Hansen, A test for superior predictive ability, J. Bus. Econom. Statist. 23 (4) (2005) 365–380.
[35] N. Jegadeesh, S. Titman, Returns to buying winners and selling losers: Implications for stock market efficiency, J. Finance 48 (1993) 65–91.
[36] D.-N. Politis, J.-P. Romano, The stationary bootstrap, J. Amer. Statist. Assoc. 89 (1994) 1303–1313.
[37] N.E. Huang, Z. Shen, S.R. Long, M.C. Wu, H.H. Shih, Q. Zheng, N.-C. Yen, C.C. Tung, H.H. Liu, The empirical mode decomposition and the hilbert spectrum
for nonlinear and non-stationary time series analysis, Proc. R. Soc. Lond. Ser. A 454 (1998) 903–995.

You might also like