Soft Comput DOI 10.1007/s00500-016-2162-6

FOCUS

Using trading mechanisms to investigate large futures data and their implications to market trends

Mu-En Wu1 · Chia-Hung Wang2 · Wei-Ho Chung3

© Springer-Verlag Berlin Heidelberg 2016

Abstract Market trends have been one of the highly debated the existence of the momentum effect via applying these two phenomena in the financial industries and academia. Prior new trading strategies. Besides, we analyze the market trends works show the profitability in exploiting transactions via through the repeated simulations of random trades with the market trend quantification; on the other hand, traders’ stop-loss and stop-profit mechanisms. Our numerical results behaviors and effects on the market trends can be better reveal that there exist momentum effects in TAIEX Futures, understood by market trend studies. In general, the trading which verifies the market inefficiency and the market prof- strategies on the market trend include trend following strate- itability in exploiting the market inefficiency. In addition, gies and contrarian strategies. Following the trend, trading the techniques of random trades are also applied to the other strategies exploit the momentum effects. The momentum commodities, such as AAPL in , IBM, GOOG in strategies profit in a long position with the rising market NYSE, and, TSMC in TPE, and so on. Surprisingly, not all the prices, as well as in a short position with the decreasing mar- stocks have the momentum effects. Our experimental results ket prices. On the contrary, the view of contrarian trading show that some stocks or markets are more suitable for the strategy is based on the mean-reversion property, i.e., a long mean-reverse strategy. Finally, we propose a technique to position is taken when the price moves down and a short posi- quantify the momentum effect of a financial market by using tion is taken when the price moves up. In this paper, we apply Jensen–Shannon divergence. the stop-loss and stop-profit mechanisms to verify the market trends based on two new simple strategies, i.e., the BuyOp. strategy and the BuyHi.SellLo. strategy. We back-test these 1 Introduction two strategies on the Capitalization Weighted Stock Index Futures (TAIEX Futures) during the The trend of financial prices has been one of the most con- period from May 25, 2010 to August 19, 2015. We compare cerned phenomena for many investors and in academia. the numerical results of its profits and losses through vari- Researchers develop profitable trading strategies through ous stop-loss thresholds and stop-profit thresholds, and verify exploiting market behaviors, technical analysis (Park and Irwin 2007; Schulmeister 2009; Holmberg et al. 2012; Borda Communicated by C.-H. Chen. et al. 2011; Cekirdekci 2010) and commodity pricing model, etc. However, the market is often conjectured to be unpre- B Wei-Ho Chung dictable, which conforms to the observation where only [email protected] few transaction strategies are profitable in practice. Besides, losses in transactions are usual for most investors in finan- 1 Department of Mathematics, Soochow University, , Taiwan cial markets. Hence, in this paper, we investigate the price behavior and market trends. 2 College of Information Science and Engineering, Fujian University of Technology, Fuzhou, Fujian, One model to describe the price behavior in stock markets People’s Republic of China is to use the random walk to explain unpredictability (Basu 3 Research Center for Information Technology Innovation, 1977; Brown 1971). In 1970, Fama (1970) proposed the , Taipei, Taiwan efficient-market hypothesis (EMH, Fama 1970), which con- 123 M.-E. Wu et al. sists of three types: strong form, semi-strong form, and weak In this paper, we investigate the profitability of trading form. These three forms differ in whether or not the public strategies in the studied market, and the impact of the stop- information, non-public information, or historical informa- loss and stop-profit mechanisms on the profit and loss to ver- tion have been reflected in the fluctuations of the stock price. ify whether there exist the momentum effects in the studied Even though EMH (Fama 1970) has been studied widely, financial market. Here, the Taiwan Stock Exchange Capi- there are many evidences reveling that certain financial mar- talization Weighted Stock Index Futures (TAIEX Futures) kets do not conform to market efficiency, such as Hung et al. is used as the case study for the simplicity. Other financial (2014). On the other hand, other research works show the markets can be studied via a similar approach; this can be market efficiency in some financial markets (Brown 1971; considered for a future work. We back-test the real intra-day Hung et al. 2014; Fama 1970), where the strategies are unable data during the period between May 25, 2010 and August to make consistent profits in certain financial markets. How- 19, 2015, by 1-min time frame data, including the opening ever, many research works show the market may not be price (Op.), closing price, the highest price (Hi.), and the efficient in the stock markets (Holmberg et al. 2012; Borda lowest price (Lo.). In the numerical experiments, day trading et al. 2011; Cekirdekci 2010; Ansari and Khan 2012; Tsai strategy is adopted. First, a simple strategy is used, BuyOp.: et al. 2014). Park and Irwin (2007) made a survey and found long, a position at the open price for daily trading; and close, a rapid increase in the amount of literature in studying tech- the position at the end of the market, to observe the changes nical analysis. Schulmeister (2009) studied the momentum in the profit–loss curve through back-testing various stop- and reversal effects in the S&P 500 spot and futures mar- loss points and stop-profit points. Secondly, another simple ket by using technical trading systems. These works show strategy used, BuyHi.SellLo., is conceptually more aligned the existence of market inefficiency and its resulting prof- with the momentum effects. BuyHi.SellLo. is to long\short itability. In the following, we introduce two types of trading a position at open if the open price is higher\lower than the strategies: momentum trading strategy and mean-reversion close price of the previous trading day, and then close the strategy. positions at the end of the market for the daily trading. To The trend following trading strategy assumes that the avoid influences of a specific strategy on the profit and loss, movement of market price is driven by the momentum, i.e., we propose the concept of random trades to test the exis- the market price moves in the direction of the momentum. tence of a momentum effect in the market. The technique Typically, the characteristic of momentum trading strategy of random trade is to BUY or SELL at daily open price with is to long a position upon the price rising up to a prede- 50 % probability. The experiments are conducted by simulat- fined price threshold. On the contrary, the mean-reversion ing 10,000 rounds to observe the profit–loss distribution via strategy is to shor a position upon the price dropping below a different stop-loss and stop-profit points. If the momentum predefined price threshold. The trend following trading strat- effect exists in the market, the profit distribution with stop- egy is based on the momentum effect proposed by Jegadeesh loss and no stop-profit should smoothly move to the profitable and Titman (1993). The momentum effect represents that the side. This phenomenon also appears on the other markets, prices of commodities will continue the trend in its direction such as NASDAQ, NYSE, TPE, TYO, and so on. Finally, of movement, i.e., the trend of the commodity price will con- we use the method of random trades to define an index of tinue in time. Based on the momentum effect, it is possible momentum effect, which is expected to serve as one of the to develop profitable momentum trading strategies through standard measures of momentum effect for general financial buying stocks with increasing prices and selling decreasing markets. Note that the money managements (Tharp 2008; stocks. There are many aspects on momentum trading strate- Vince 2012; Vince and Zhu 2013b; MacLean and Ziemba gies, one of which is the effect of fat tails. Many studies have 2006) are also crucial in the investment outcomes. To avoid shown that there exist fat tails in the financial markets (Park ambiguity and simplify the interpretation of the numerical and Irwin 2007; Borda et al. 2011; Tsai et al. 2014). The results, the money management technique is not adopted in chances of rally or crash often exceed the level of belief in our back-testing strategies. The purpose of this work is to ver- most investors. ify and classify the market trends via well-calibrated trading On the other hand, the contrarian trading strategy is the strategies. The technique of money management (Zhu et al. reverse of the momentum trading strategy. The contrarian 2012; Vince and Zhu 2013a; Zhu 2007; de Prado et al. 2013) trading strategy is based on the mean-reversion theory. That can be considered as future works to be applied to the basic is, if the current price continues to increase and is already strategies. higher than the average price above a threshold, there is a The organization of this paper is shown as follows. In Sect. great chance that the price will fall back to the average. Sim- 2, we show the preliminaries in this work, including the two ilarly, if the current price continues to decline and is lower types of trading strategies, and the financial market for the than the average below a threshold, there is a great probability back-testing and the device for the experiments. In Sect. 3,we that there will be a rebound to the average price. provide two simple trading strategies to show the existence 123 Using trading mechanisms to investigate large future data and their… of moment effect by using various points of stop-loss and stop-profit. In Sect. 4 we propose a novel and neutral method called “random trade” to avoid the possible bias of specific strategies on observations of momentum effects. In Sect. 5, we apply the random trade technique to the other financial stocks and markets. In Sect. 6, we further investigate the index of momentum effect, which can serve as one of the standard measures of momentum effects for general financial markets. Finally, the conclusion is given in Sect. 7.

2 The related work and preliminaries

Fig. 1 The stock price of Apple Inc. and its Bollinger Band Generally, there are two types of trading strategies. The first type is the mean-reversion strategy, and the second type is the trend following strategy, or called the momentum strat- kind of strategy long (short) a position , while the market egy. The trading strategies are explained individually in the price breaks the highest (lowest) points in a predefined time following. interval. Another common strategy is to long or short a posi- tion when the market price breaks a threshold set by prior 2.1 Mean-reversion strategy and momentum strategy price fluctuation ranges, i.e., trend following action is taken if the current price moves higher than a certain target price The mean-reversion strategy is to pursue the property where based on the past volatility metric. the price fluctuates around the average price over a period of time even if there are excessive fluctuations in the price trend. Once the price moves up (down) to a certain level, 2.2 The device for back-testing and the symbol of we short (long)a position. The intuition of mean-reversion strategies strategy complies with the martingale central limit theorem (Brown 1971). In this paper, we take the Taiwan Stock Exchange Capi- Bollinger Bands, one of the well-known technical indices talization Weighted Stock Index Futures (TAIEX Futures) used for mean-reversion strategies, was proposed by Bollinger as the back-testing target during the period between May (2001). This tool is used to measure the security’s volatility 25, 2010 and August 19, 2015. We use R language soft- and price trend over a period of time. Usually, we take 20 MA ware with the package “Quantmod” to back-test the actual as the trending line of the stock price and 20 MA ±2 stan- intra-day data points by 1-min time frame data, including dard deviations as the “highness” and “lowness” of the price the opening price, closing price, highest price, lowest price, relative to previous trades. The following Fig. 1 is taken as an and volume. The computing device we used for back-testing example, which shows the stock price of Apple Inc. between is Intel((R) Core(TM) i7-4790 CPU @ 3.60 GHz 3.60 GHz 2015.03 and 2016.02. The red dotted lines in the figure rep- with 32.0 GB RAM. Table 1 shows the type of basic trading resent the upper bound and lower bound of the Bollinger strategies studied in the paper. Four kinds of trading strategies Bands. It can be observed that the fluctuations of the prices with various stop-loss and stop-profit points are back-tested are almost contained in the band. Thus, as the prices reach the on TAIEX Futures and some stocks in NASDAQ NYSE, and upper bound of the Bollinger Band, a short position is taken, TPE Exchanges. in the hope that the price will go down to the 20 MA, which is the middle line of the Bollinger Band. Similarly, as the prices touch the lower bound of the Bollinger Band, a long 3 Trading mechanisms of stop-loss and stop-profit position is taken, in the hope that the price will rise up to the 20 MA. There are many trading strategies designed based on 3.1 Rationales of using the stop-loss and stop-profit the rationale of Bollinger Band, which are considered typical mechanisms mean-reversion strategies. In contrast to the mean-reversion strategy, the momentum In designing a trading strategy, the focus is on the conditions strategies possess opposite views. There are several kinds to buy, sell, add position, and stop-loss/stop-profit. Through of momentum strategies. The open range breakout is one of a trading strategy, the quantity of positions can be determined the well-known momentum strategies (Holmberg et al. 2012; at any time point. In the market, if a position is closed in the Borda et al. 2011; Cekirdekci 2010; Tsai et al. 2014). This profitable status, this action is called the stop-profit. On the 123 M.-E. Wu et al.

Table 1 Basic trading strategies including the open price, the highest price, the lowest price Types of strategies Trading mechanisms and the close price in each 1 min. First, we consider a simple day-trade strategy, i.e., buy/sell at the day’s first open, and BuyOp. Make a position long at the open price; close the close the position at the day’s final close. With the strategy of position at the end of the market if no stop-loss buy at first open and sell at the final close, Fig. 2 illustrates the and no stop-profit triggered cumulative profits and losses per trading day and its profit- SellOp. Make a position short at the open price; close the position at the end of the market if no stop-loss loss distribution. On the left side of Fig. 2, the horizontal axis and no stop-profit are triggered represents each trading day. The upper half of the vertical axis BuyHi.SellLo. long\short a position at open if the open price is represents accumulated profit (indicated by orange color), higher\lower than the close price of the last and the lower half represents the cumulative loss (indicated trading day; close the position at the end of the by green color). The red symbol “x” represents a new high market if no stop-loss and no stop-profit is triggered profit. On the right side of Fig. 2, it illustrates the distribution RT.Op. Random trade a position at the open price; close of profits for this trading strategy BuyOp., which is approx- the position at the end if no stop-loss and no imately a symmetric bell-shaped distribution. It represents stop-profit is triggered that the probability of making money is almost the same as the probability of losing money and the earned/losing points is symmetric. other hand, if we close a position in the losing status, this Table 2 summarizes the performance for the strategy of action is called the stop-loss. buy at open and sell at close, including the win rate, average The rationale of the stop-profit mechanism is in contrast earning, average loss, profit factor, and maximum drawdown. to the market momentum effect where the market prices con- The profit factor is defined as the absolute value of the ratio tinue the trend. Therefore, the stop-profit mechanism is the of cumulative profit divided by cumulative loss. The max- reverse action to the past trend of making profits via utilizing imum drawdown denotes the maximal value of cumulative the momentum effect. loss during the back-testing period. Here, for the strategy of buy at open and sell at close, the maximum drawdown is 3.2 Buy/sell at the opening 1958. Because this strategy is not determined by any techni- In this paper, we take a day-trade strategy to verify whether cal index, it will not have an overfitting problem. Although there exists a momentum effect in the TAIEX Future. For a this strategy seems to be unprofitable, we use the two basic day-trade strategy, a new position is opened and then closed trading mechanisms, stop-loss and stop-profit, to observe the on the same day. In other words, no remaining positions are characteristics of market price trends. We consider the fol- kept after the day close, and there exist no risks in inter-day lowing trading strategy: set a stop-loss point and a stop-profit price fluctuations. point after buying a position at opening. For example, given We back-test the intra-day data of 1-min time frame in 30 stop-loss points and 60 stop-profit points, and we close the TAIEX futures from May 25, 2010 to August 19, 2015, position bought at opening as soon as the price encounters

Fig. 2 The cumulative profit and loss (left) and profit distribution (right)ofBuyOp. (color figure online)

123 Using trading mechanisms to investigate large future data and their…

Table 2 The performance of Profit/loss Win rate Average earning Average loss Profit factor Maximum drawdown the BuyOp. strategy −428 50.51 % 43.99064 −45.5828 0.9850486 1958

Table 3 The profit and loss with various stop-loss and stop-profit points of BuyOp. BuyOp. 30 stop-profit points 40 stop-profit points 50 stop-profit points 60 stop-profit points No stop-profit

No stop-loss −1511 −1177 −637 −911 −428 60 stop-loss points −209 231 553 383 686 50 stop-loss points −168 409 588 487 965 40 stop-loss points −203 350 584 555 1163 30 stop-loss points 697 1172 1376 1516 2089

Table 4 The profit and loss with various stop-loss and stop-profit points of SellOp. SellOp. 30 stop-profit points 40 stop-profit points 50 stop-profit points 60 stop-profit points No stop-profit

No stop-loss −2089 −1163 −965 −686 428 60 stop-loss points −1516 −555 −487 −383 911 50 stop-loss points −1376 −584 −588 −553 637 40 stop-loss points −1173 −350 −409 −231 1177 30 stop-loss points −697 203 168 209 1511

either 30 stop-loss points or 60 stop-profit points. Otherwise, loss points. It reveals that there exist the momentum effects if the price meets neither 30 stop-loss points nor 60 stop-profit in TAIEX Futures. Similarly, Table 4 summarizes the profit points, then we close the position at the day’s final closing and loss for sell at open with various stop-loss points and price. We determine whether different stop-loss and stop- stop-profit points. profit points have a significant impact on the changes in profit. Given fixed 30 stop-loss points, Fig. 3 illustrates the cumu- Table 2 summarizes the profits and losses for buy at open lative profit with respect to various stop-profit points for buy with various stop-loss points and stop-profit points, includ- at open. The stop-profit points range from 30 stop-profit ing 30 stop-profit/stop-loss points, 40 stop-profit/stop-loss points up to 300 stop-profit points, which increase evenly points, 50 stop-profit/stop-loss points, 60 stop-profit/stop- by five points. It can be observed that it reaches the peak loss points, and no stop-profit/stop-loss points. profit when setting 235 stop-profit points, which results in From observing the longitudinal direction of Table 3, a total gain of 2381 points. The above-mentioned numerical we find that this strategy makes better profit with smaller results reflect the momentum effect of market price, even for stop-loss points. Because the stop-loss belongs to the trend such a simple trading strategy with different stop-loss and following the trading mechanism, it reflects the greater stop-profit points. momentum effect if the performance gets better with the smaller stop-loss points. On the contrary, it reflects the 3.3 The BuyHi.SellLo. strategy smaller momentum effect if the performance gets worse with the smaller stop-loss points. Next, we test another trading strategy, the BuyHi.SellLo. On the other hand, with the higher stop-profit points, the strategy, since the momentum effect seems to exist in the performance gets better. It gets the highest performance with TAIEX Futures. Compared with the above two strategies closing the position at the day’s close. Because the stop-profit (buy at open and sell at open), this BuyHi.SellLo. strategy belongs to the contrarian trading mechanism, it reflects the possesses stronger trend following the nature of the transac- greater momentum effect if the performance gets better with tion. According to the momentum effect, if today’s opening the higher stop-profit points; otherwise, it reflects the smaller price is higher than yesterday’s closing price, the price gets momentum effect if the performance gets worse with the greater opportunity to continue to rise. In this case, we long a higher stop-profit points. From observing the results in Table position at open. On the other hand, if today’s opening price 3, the performance gets better when moving to the lower right is lower than yesterday’s closing price, the price gets greater corner, i.e., the higher stop-profit points and the smaller stop- opportunity to continue to fall. In this case, we short a posi- 123 M.-E. Wu et al.

worse than BuyOp. in this case. The reason is that the per- formance is very good in 30 stop-loss points regardless of using BuyHi.SellLo. or BuyOp.. So we cannot observe the significant difference. The above two types of strategies reflect that the momen- tum strategies are more suitable for the TAIEX Futures market with either stop-loss or stop-profit mechanism. To check whether this characteristic results from the strategy, rather than the stop-loss or stop-profit mechanism, we inves- tigate the random trade strategy in the next section.

4 Random trade strategy

Fig. 3 The profit with various stop-profit and 30 stop-loss points of In this work, we attempt to verify the existence of momen- BuyOp. tum effect in the intra-day price fluctuations in TAIEX futures market through the stop-loss and stop-profit mechanisms. To tion at open. In the following, we observe the performance maintain generality and avoid influences of specific trading for this strategy. mechanisms, we consider the following method. We use ran- When setting various stop-loss points and stop-profit dom trade to decide the transaction at each day’s open. Before points, the results in Table 5 show that the performance gets opening, a fair coin is thrown and a long position is taken if better with the higher stop-profit points and with the smaller the head appears; otherwise, we short a position if the oppo- stop-loss points. This experiment reveals that there exist the site appears. This strategy is called random trade (short for momentum effects in TAIEX Futures, which is similar to the RT.Op.). Clearly, the results of the random trade would not be phenomenon obtained from the buy at open strategy. the same for each back-testing experiment. We aim to verify Besides, it can be observed that BuyHi.SellLo. strategy whether the stop-loss and stop-profit mechanisms are useful always gets better performance than buy at open strategy. in improving the trading performance, so we take the average For example, we compare the performance for these two of repeated 10,000 times back-testing results as a baseline. strategies with the same 60 stop-loss points. Tables 6 and Table 8 summarizes the average profit and its standard 7 summarize the performance for BuyOp. and BuyHi.SellLo. derivation of RT.Op. with various stop-loss points and stop- strategies with 60 stop-loss points and 60 stop-profit points, profit points. It should be noted that each tabular value in respectively. Table 8 is obtained through averaging 10,000 times back- Note that the performance of BuyHi.SellLo. in Table 7 are testing experimental results. With various stop-loss points totally better than those of BuyOp. in Table 6. This is because and stop-profit points, the average and the standard deviation BuyHi.SellLo. possesses stronger trend following nature than of profit for random trade are listed below. BuyOp. strategy. If there exists a momentum effect in the Through back-testing 10,000 rounds, Fig. 5 illustrates the market, the performance of BuyHi.SellLo. should be better distribution of profit/loss for random trade with no stop-loss than BuyOp. at any stop-loss points and stop-profit points. and no stop-profit. Here, we long a new position at day open, The numerical results of Tables 2 and 4 are compared in Fig. and close that position at day close. The statistics of 10,000 4 as shown below. simulation rounds for random trade transactions are sum- In Fig. 4., there is only one exception in setting 30 stop- marized below: the average profit/loss is −13.0964, and the loss points, that is, the profit of BuyHi.SellLo. is slightly standard deviation is 2148.252. The distribution for profit

Table 5 The profit and loss with various stop-loss and stop-profit points of BuyHi.SellLo. BuyHi.SellLo. 30 stop-profit points 40 stop-profit points 50 stop-profit points 60 stop-profit points No stop-profit

No stop-loss −475 786 1279 1630 2448 60 stop-loss points −38 1170 1472 2065 3227 50 stop-loss points −383 670 766 1406 2281 40 stop-loss points −156 830 845 1494 3136 30 stop-loss points 321 1219 1161 1687 3125

123 Using trading mechanisms to investigate large future data and their…

Table 6 The profit of BuyOp. with 60 stop-loss points and various stop-profit points BuyOp. with 60 stop-loss points 30 stop-profit points 40 stop-profit points 50 stop-profit points 60 stop-profit points No stop-profit

−209 231 553 383 686

Table 7 The profit of BuyHi.SellLo. strategy with 60 stop-loss points and various stop-profit points BuyHi.SellLo. with 60 stop-loss points 30 stop-profit points 40 stop-profit points 50 stop-profit points 60 stop-profit points No stop-profit

−38 1170 1472 2065 3227

Fig. 4 The comparison between BuyOp. and BuyHi.SellLo. with vari- Fig. 5 The profit distribution of RT.Op. with no stop-loss and no stop- ous stop-loss points and stop-profit points in Tables 2 and 4 profit and loss is almost perfectly symmetrical, which presents a Finally, with 30 stop-loss points, we consider no stop- bell-shaped distribution. profit points and close the position at close. The statics of Next, with 30 stop-loss points and 30 stop-profit points, 10,000 simulation rounds for random trade transactions are we consider the strategy of longing a new position at day open illustrated in Fig. 8. The average earning is 1876.874, and and closing that position at day close. The statistics of 10,000 the standard deviation is 1346.058. simulations for random trade transactions are illustrated in From the above four distribution graphs (Figs. 5, 6, 7, 8), it Fig. 6. can be observed that all of them are bell-shaped distributions, Next, with 30 stop-loss points and 60 stop-profit points, and the averages are gradually enlarged with varying the pairs we consider the strategy of longing a new position at day of stop-loss points and stop-profit points. Figures 9, 10, and open and closing that position at day close. The statistics of 11 depict a total of 26 statistical distributions with different 10,000 simulation rounds for random trade transactions are stop-loss and stop-profit mechanisms. We consider the fol- illustrated in Fig. 7. The average earning is 866.252, and the lowing stop-loss and stop-profit mechanisms: (1) no stop-loss standard deviation is 1174.588. points and 30 stop-profit points (−no, +30); (2) 150 stop-

Table 8 The profits and its standard derivation of RT.Op. with various stop-loss points and stop-profit points RT.Op. 30 stop-profit points 40 stop-profit points 50 stop-profit points 60 stop-profit points No stop-profit

No stop-loss −1855.0887 (1363.366) −1222.4635 (1514.576) −841.9535 (1656.478) −817.9889 (1787.797) −23.8568 (2163.488) 60 stop-loss points −894.4057 (1184.918) −166.1117 (1350.646) 36.1903 (1490.297) −13.8502 (1614.635) 839.4461 (1761.362) 50 stop−loss points −779.7591 (1167.041) −123.2132 (1324.465) −19.5156 (1476.792) −24.4287 (1515.319) 852.1089 (1682.152) 40 stop-loss points −685.7710 (1081.217) −3.7826 (1269.204) 82.5973 (1331.652) 190.9596 (1363.784) 1232.4100 (1523.159) 30 stop-loss points −27.6268 (1015.721) 690.1276 (1102.077) 777.2399 (1143.381) 904.5415 (1180.896) 1864.5938 (1362.451)

123 M.-E. Wu et al.

loss points and 35 stop-profit points (−150, +35); (3) 145 stop-loss points and 40 stop-profit points (−145, +40); (4) 140 stop-loss points and 45 stop-profit points (−140, +45); …; (5) 35 stop-loss points and 150 stop-profit points; (6) 30 stop-loss points and no stop-profit points (−30, +no). A total of 26 pairs of stop-loss and stop-profit mecha- nisms are mentioned above. With no stop-loss points at the beginning, we set stop-loss points in the decreasing order, and we set stop-profit points at the increasing order till no stop-profit points. Figure 9 depicts the changes of empiri- cal probability density functions in the first 12 stop-loss and stop-profit mechanisms. Figure 10 illustrates the changes of empirical probability density functions in the last 12 stop- loss and stop-profit mechanisms. Finally, Fig. 11 shows the empirical probability density functions for a total of 26 stop- Fig. 6 The profit distribution of RT.Op. with 30 stop-loss and 30 stop- loss and stop-profit mechanisms. From Figs. 9, 10, and 11,it profit points can be observed that the profit distribution gradually shifts to the right, which represents that the average profit gets better. The similar trends occur when varying the stop-profit points. The profit distribution slightly shifts to the right with the increase of stop-profit points from 30 stop-profit points to no stop-profit. Note that these statistics are obtained from 10,000 simulation rounds for random trade transactions. Obviously, the profit distribution at the lower right corner of the graph performs the best, which represents the random trade strategy with 30 stop-loss points and no stop-profit mechanism. It is obvious that TR.Op. types of strategies are not prof- itable in the real transactions. However, in the experiments, we intend to verify whether the distribution of profit would be affected by different stop-loss or stop-profit mechanisms. These experimental results confirm the conjecture and are consistent with the viewpoint of momentum strategy. That is, the trend following trading strategy makes better profits with the smaller stop-loss points and the higher stop-profit points. Fig. 7 The profit distribution of RT.Op. with 30 stop-loss and 60 stop- profit points

5 Momentum effects on the other stocks

In this section, we apply the method of random trade to verify the momentum effect of the stocks in other financial markets. We take some stocks of exchanges for example, including NASDAQ, NYSE, and TPE. Note that in the pre- vious cases, we use the absolute losing or profit points to measure the momentum effect, such as stop-loss (or stop- profit) of 30 points, 45 points, and so on. This is not fair for other stocks, because the volatility of each security is differ- ent. Consequently, we use the 1 % of stop-loss or stop-profit as a normalized scale. First, we apply the technique of ran- dom trade to the stock of Apple Inc. from 2007 to 2016. The experimental results are shown in Fig. 12. The left of Fig. 12 shows the profit distribution of random trade at daily open price by 10,000 simulation rounds. The green curve (RT.Op. Fig. 8 The profit distribution of RT.Op. with 30 stop-loss points Stop +1 %) means to buy or sell (by random trade) at daily 123 Using trading mechanisms to investigate large future data and their…

Fig. 9 The empirical PDF of profit of RT.Op. (no stop-loss, +30), ∼(−95, +80), (−100, +85) open price, but exit when earning 1 % profit (stop-profit), no In Fig. 14, we consider the profit distribution of random stop-loss and exit at the market close. The red curve (RT.Op. trade for the stock of IBM (NYSE Exchange). Different from Stop −1 %) means the distribution of random trade at daily the previous results, we observe no momentum effect in open price, but exit when suffering 1 % loss (stop-loss). As the IBM stock, but also observe totally the opposite of the can be seen in the left of Fig. 12,theRT.Op. Stop −1% momentum effect. Note that the red curve in Fig. 14 moves is better than RT.Op. Stop +1 % obviously. The profit dis- to the left side compared to the green curve. The profit dis- tribution moves to the right side significantly. On the other tribution of RT.Op Stop −1 % is worse than that of RT.Op hand, the corresponding distribution of win rate is shown in Stop +1 %. However, the distributions of win rate still fol- the right of Fig. 12. Although the mechanism of stop-profit low the phenomenon mentioned previously. That is, the win +1 % increases the win rate, it is still not a good method rate distribution of stop-loss (red histogram) is still in the according to the result of profit distribution for APPL stock. left side of that of stop-profit (green histogram). Moreover, In Fig. 13, we show the method of random trade applying we can observe the same syndrome in the stock of Microsoft to “GOOG”, which is the stock of Alphabet Inc. in NAS- Corporation (MSFT) (see Fig. 15). DAQ. Surprisingly, it is quite different from the distribution For the case of stock in TPE exchanges, we consider one compared with the stock of Apple. Inc. The red curve and of the major companies, Taiwan Semiconductor Mfg. Co. the green curve almost coincide (see the left of Fig. 13). This Ltd (TSMC), in Taiwan. Applying the method of random means the stock of GOOG is not suitable for momentum trade in TSMC, the momentum effect is strong by 10,000 strategy. One interesting observation is that the distributions simulations. The profit and win rate distributions are shown of win rates for RT.Op. Stop −1 % and RT.Op. Stop −1% in Fig. 16. Since the momentum effect is significant, we may are still separated faraway. That means the mechanism of claim that the momentum strategy is more suitable for the stop-loss actually decreases the win rate, and stop-profit can day trading of TSMC than using mean-reverse strategy. increase the win rate. This property is independent of the According to the above experiments, we can categorize profit distribution with different trading styles (momentum stocks into two groups. The first is suitable for using the or mean reverse). momentum strategies. The other is suitable for using the

123 M.-E. Wu et al.

Fig. 10 The empirical PDF of profit of RT.Op.. (−95, +90), ∼(−100, +80), (−35, +150)

ing strategies. However, for the cases of IBM and MSFT, the mean reversion serves as a better principle in devel- oping the trading strategies. The above experiment results also show the practicability of our proposed random trade method.

6 The measurement of momentum effect

According to the concept of random trades, the back-testing strategies with different stop-loss and stop-profit points result in different distributions of profit and losses. Meanwhile, from the above experiments, it can be observed that these distributions of profit/loss could be significantly different. So, we can propose a method to quantify the momentum effect as follows.

Fig. 11 The total 26 empirical PDF of profit of RT.Op. (no stop-loss, Step 1 Choose the metric of stop-loss and stop-profit, such + ∼ − 30) ( 30, no stop-profit) as 1 %, or fixed points (e.g., 30 points) for the trading com- modity. mean-reversion strategy. For example, the momentum effects in AAPL and TSMC (see Figs. 12, 16) are stronger than Step 2 Back-test for the commodity by running the random the momentum effect in GOOG, MSFT, IBM, and MSFT. trade algorithm. Random trade algorithm is shown in the For the case of GOOG, since the red curve coincides with following. In this case, we take fixed 30 points of stop-loss the green curves, this stock is neutral in terms of the trad- and stop-profit on TAIEX Futures for example. 123 Using trading mechanisms to investigate large future data and their…

Fig. 12 The momentum effect of APPL (Apple Inc.) and the corresponding distribution of win rate (color figure online)

Fig. 13 The momentum effect of GOOG (Alphabet Inc.) and the corresponding distribution of win rate (color figure online)

Fig. 14 The momentum effect of IBM Inc. and the corresponding distribution of win rate (color figure online)

123 M.-E. Wu et al.

Fig. 15 The momentum effect of Microsoft Inc. and the corresponding distribution of win rate (color figure online)

Fig. 16 The momentum effect of TSMC Inc. and the corresponding distribution of win rate (color figure online)

Algorithms of RT.Op. −30 (RT.OP.+30) Step 5 Calculate Jensen–Shannon divergence of PDF (RT.Op. −30) and PDF(RT.Op. −30), that is, JSD (PDF(RT.Op. −30) 1. Toss a fair coin with 50 % probability of head and tail. If || PDF(RT.Op. +30)). the head comes up, then long (buy) a position. If the tail Let P = PDF(RT.Op. −30) and Q = PDF(RT.Op. +30), = 1 ( ) ( || ) = 1 ( || ) + comes up, then short (sell) a position. and M 2 P+Q .WehaveJSDP Q 2 KL P M 1 ( || ) (·||·) 2. After starting a new position at daily open price, set the 2 KL Q M , where KL is the Kullback–Leibler diver- points of stop-loss (stop-profit). Once the event of stop- ( || ) = ∫∞ ( ) ( A(x) ) gence. That is, KL A B −∞ A x log B(x) dx,for loss (stop-profit) is triggered, close the position and there some probability density functions A and B (Wikipedia is no more trades for the today. 2016a). 3. If there are stop-loss (stop-profit) events, the position is The value of this Jensen–Shannon divergence (Wikipedia closed at the end of market close. 2016b) is defined as the metric of the momentum effect in the studied market. The left side of Fig. 12 illustrates the dis- Step 3 Repeat Step 2 for n rounds of simulations and record tribution of profit/loss for random trades with 30 stop-profit the profit and win rate of each round. Note that n should be points and no stop-loss points. The right side of Fig. 12 illus- large enough (e.g., n ≥ 10,000) for statistical significance. trates the distribution of profit/loss for random trades with 30 stop-loss points and no stop-profit points. The statistics Step 4 Convert two profit distributions of RT.Op. −30 are obtained through averaging 10,000 rounds back-testing and RT.Op. +30 into continuous probability distributions, experimental results. The blue dotted line indicates the break- denoted as PDF(RT.Op. −30) and PDF(RT.Op. +30) 123 Using trading mechanisms to investigate large future data and their…

Fig. 17 The profit distribution moves to the right side with more profit with higher probability

profit mechanisms do improve the trading performance. It also verifies the phenomenon of momentum effect in TAIEX Futures. Finally, to observe the changes in market prices and investors’ trading behaviors, we develop a quantitative indi- cator describing the strength of a market momentum effect. In the future, we would like to investigate the properties of the proposed index of momentum effect and attempt to extend the studies to cover the global financial markets.

Acknowledgments The work of Mu-En Wu was funded by the Min- istry of Science and Technology, Taiwan (MOST-104-2221-E-031 -004). The work of Wei-Ho Chung was funded by the Ministry of Sci- ence and Technology, Taiwan (MOST-104-2221-E-001-008-MY3).

Compliance with ethical standards

Conflict of interest Mu-En Wu declares that he has no conflict of inter- est. Chia-Hung Wang declares that he has no conflict of interest. Wei-Ho Chung declares that he has no conflict of interest. Fig. 18 The metric of the momentum effect is defined as the Jensen– Shannon divergence of two probability density functions Ethical approval This article does not contain any studies with human participants or animals performed by any of the authors. even points. It is noted that the profit\loss distributions move to the right side when changing the mechanism of stop-profit 30 points to stop-loss 30 points. This property verifies the existence of the momentum effect, but also indicates that the References action of running the profit and cutting the loss gains more profit with higher probability (Figs. 17, 18). Ansari VA, Khan S (2012) Momentum anomaly: evidence from India. Manag Financ 38(2):206–223 Basu S (1977) Investment performance of common stocks in relation to 7 Conclusions and future works their priceearnings ratios: a test of the efficient market hypothesis. J Financ 32(3):663–682 Borda M, Nistor I, Gherman M (2011) Opening range trading strategies In this paper, we verify the market trends with stop-loss and applied on daily and intraday data: the case of BET index. Rev Econ stop-profit mechanisms, and determine the suitability to take Stud Res Virgil Madgearu 2:79–96 trend following strategies or contrarian strategies in the stud- Brown BM (1971) Martingale central limit theorems. Ann Math Stat 42(1):157–170 ied markets. According to our back-testing results of TAIEX Bollinger J (2001) Bollinger on bollinger bands. McGraw Hill, New Futures, it shows that the appropriate stop-loss and stop- York, NY, USA. ISBN 0-07-137368-3 123 M.-E. Wu et al.

Cekirdekci ME (2010) Trading system development: trading the open- Tsai YC, Wu ME, Lei CL, Wu CS, Ho JM (2014) Comparing profitabil- ing range breakouts. Ph.D. Dissertation, Worcester Polytechnic ity of day trading using ORB strategies on index futures markets Institute, Worcester in Taiwan, Hong-Kong and USA. In: 10th annual conference of de Prado ML, Vince R, Zhu QJ (2013) Optimal risk budgeting under a the Asia-Pacific association of derivatives, 21–22 August 2014, finite investment horizon. SSRN Electron. J. Available at SSRN. Busan, Korea http://ssrn.com/abstract=2364092 or doi:10.2139/ssrn.2364092 Vince R (2012) Risk-opportunity analysis. Create space independent Fama EF (1970) Efficient capital markets: a review of theory and empir- publishing platform. ISBN 9781466344402 ical work. J Financ 25(2):383–417 Vince R, Zhu QJ (2013a) Inflection point significance for the investment Holmberg U, Lönnbark C, Lundström C (2012) Assessing the prof- size. SSRN Electron J. doi:10.2139/ssrn.2230874 itability of intraday opening range breakout strategies. Financ Res Vince R, Zhu QJ (2013b) Optimal betting sizes for the game of black- Lett 10(1):27–33 jack. SSRN Electron J. doi:10.2139/ssrn.2324852 Hung TW,Wu ME, Wang CJ, Hsu WWY,Ho JM (2014) On the design of Wikipedia, Jensen–Shannoon divergence. https://en.wikipedia.org/ trading schemes of equity funds based on random traders. In: Proc. wiki/Jensen-Shannon_divergence. Accessed 16 Feb 2016 of 2014 IEEE int. conf. granluar comput. (GrC’14), Noboribetsu Wikipedia, Kullback–Leibler divergence. https://en.wikipedia.org/ Jegadeesh N, Titman S (1993) Returns to buying winners and selling wiki/Jensen-Shannon_divergence. Accessed 18 Feb 2016 losers: implications for efficiency. J Financ 48(1):65– Zhu QJ (2007) Mathematical analysis of investment systems. J Math 91 Anal Appl 326(1):708–720 MacLean LC, Ziemba WT (2006) The Kelly criterion: theory and prac- Zhu QJ, Vince R, Malinsky S (2012) A dynamic implementations of tice. In: Handbook of asset and liability management volume a: the leverage space portfolio. SSRN Electron J. doi:10.2139/ssrn. theory and methodology. North Holland, Amsterdam 2230866 Park CH, Irwin SH (2007) What do we know about the profitability of technical analysis? J Econ Surv 21(4):786–826 Schulmeister S (2009) Profitability of technical stock trading: has it moved from daily to intraday data? Rev Financ Econ 18(4):190– 201 Tharp VK (2008) Van Tharp’s definite guide to position sizing SM: how to evaluate your system and use position sizing. International Institute of Trading Mastery Inc., Cary

123