| Literature DB >> 34764588 |
Dušan Fister1, Matjaž Perc2,3,4, Timotej Jagrič1.
Abstract
This paper aims to find a superior strategy for the daily trading on a portfolio of stocks for which traditional trading strategies perform poorly due to the low frequency of new information. The experimental work is divided into a set of traditional trading strategies and a set of long short-term memory networks. The networks incorporate general and specific trading patterns, where the former takes into account the universal decision factors for trading across many stocks, while the latter takes into account stock-specific decision factors. Our research shows that both long short-term memory networks, regardless of whether they are based on universal or stock-specific decision factors, significantly outperform traditional trading strategies. Interestingly, however, on average neither has the edge compared to the other, thus remaining ambivalent as to whether universality or specificality is to be preferred when it comes to designing long short-term memory networks for optimal trading.Entities:
Keywords: Algorithmic trading; Long short-term memory; Mechanical trading system; Portfolio of stocks
Year: 2021 PMID: 34764588 PMCID: PMC7914042 DOI: 10.1007/s10489-021-02249-x
Source DB: PubMed Journal: Appl Intell (Dordr) ISSN: 0924-669X Impact factor: 5.086
List of stocks obtained from Finanzen.net in May 2020. Additionally, minimum, maximum and mean close prices, the JB test of normality result and the ADF test of stationarity result are attached
| Company | Ticker | Beta | MC | min | max | mean | JB | ADF |
|---|---|---|---|---|---|---|---|---|
| Adidas AG | ADS.DE | 0.88 | 51.834 | 35.01 | 316.05 | 116.79 | 1015.43 | 0 |
| Allianz SE | ALV.DE | 1.10 | 80.483 | 57.47 | 232.00 | 138.11 | 413.81 | 0 |
| BASF SE | BAS.DE | 1.26 | 52.748 | 39.03 | 97.67 | 69.35 | 644.01 | 0 |
| Bayer AG | BAYN.DE | 1.29 | 64.987 | 36.23 | 143.88 | 81.38 | 424.32 | 0 |
| Beiersdorf AG | BEI.DE | 0.17 | 22.473 | 39.35 | 116.35 | 73.39 | 395.75 | 0 |
| Bayerische Motoren | BMW.DE | 1.37 | 38.426 | 28.65 | 122.60 | 73.29 | 1142.10 | 0 |
| Werke AG | ||||||||
| Continental AG | CON.DE | 1.66 | 19.858 | 32.13 | 251.30 | 135.18 | 286.37 | 0 |
| Covestro AG* | 1COV.DE | 1.41 | 6.876 | n/a | n/a | n/a | n/a | n/a |
| Daimler AG | DAI.DE | 1.68 | 42.605 | 21.84 | 95.79 | 55.47 | 658.73 | 0 |
| Deutsche Börse AG | DB1.DE | 0.36 | 28.569 | 36.13 | 157.20 | 75.13 | 1039.76 | 0 |
| Deutsche Bank AG | DBK.DE | 1.63 | 17.981 | 4.87 | 46.90 | 21.59 | 418.91 | 0 |
| Deutsche Post AG | DPW.DE | 1.29 | 39.154 | 9.13 | 40.99 | 23.70 | 417.79 | 0 |
| Deutsche Telekom AG | DTE.DE | 0.59 | 72.140 | 7.71 | 18.05 | 12.69 | 259.05 | 0 |
| E.ON SE | EOAN.DE | 0.87 | 26.204 | 6.03 | 26.61 | 12.34 | 1794.42 | 1 |
| Fresenius Medical | FME.DE | 1.12 | 22.940 | 36.10 | 93 | 63.17 | 321.07 | 0 |
| Care AG & CO. KGaA | ||||||||
| Fresenius | FRE.DE | 0.93 | 29.821 | 13.93 | 79.65 | 44.31 | 310.49 | 0 |
| SE & CO. KGaA | ||||||||
| HeidelbergCement AG | HEI.DE | 1.39 | 10.357 | 24.57 | 95.50 | 60.22 | 456.54 | 0 |
| Henkel | HEN3.DE | 0.58 | 35.031 | 35.21 | 128.90 | 81.85 | 396.51 | 0 |
| AG & Co. KGaA | ||||||||
| Infineon | IFX.DE | 1.42 | 26.953 | 3.77 | 25.49 | 11.92 | 513.43 | 0 |
| Technologies AG | ||||||||
| Deutsche | LHA.DE | 1.22 | 4.498 | 7.18 | 31.12 | 15.19 | 2443.49 | 0 |
| Lufthansa AG | ||||||||
| Linde plc | LIN.DE | 0.73 | 116.213 | 75.96 | 208.60 | 96.35 | 3009.16 | 0 |
| MERCK KGaA | MRK.DE | 0.69 | 45.782 | 28.41 | 125.60 | 70.90 | 318.83 | 0 |
| MTU AERO | MTX.F | n/a | 9.292 | 35.25 | 286.40 | 100.51 | 2218.86 | 0 |
| engines AG | ||||||||
| Münchener | MUV2.DE | 0.76 | 33.946 | 79.55 | 282.60 | 158.76 | 966.62 | 0 |
| Rückversicherungs- | ||||||||
| Gesellschaft AG | ||||||||
| RWE AG | RWE.DE | 1.11 | 18.687 | 9.20 | 68.73 | 27.48 | 2667.97 | 1 |
| SAP SE | SAP.DE | 1.07 | 31.11 | 129.44 | 69.30 | 615.22 | 0 | |
| Siemens AG | SIE.DE | 1.23 | 88.218 | 59.76 | 133.20 | 92.72 | 577.96 | 0 |
| Volkswagen AG | VOW3.DE | 77.899 | 55.50 | 255.20 | 145.20 | 1129.20 | 0 | |
| Vonovia SE* | VNA.DE | 0.41 | 29.727 | n/a | n/a | n/a | n/a | n/a |
| Wirecard AG* | WDI.DE | 0.47 | 11.848 | n/a | n/a | n/a | n/a | n/a |
The examined data are from 1 Jan 2010 to 12 May 2020
“MC” stands for market capitalization and is given in billion euros. Market capitalization data and beta (5-year monthly) were taken on 6th June from Yahoo Finance. Three stock companies, designated by “*”, e.g., 1COV.DE, VNA.DE and WDI.DE, were not suitable for this case study since no financial data were available for full coverage from 2010 on. Bold values denote the highest values. The “min”, “max” and “mean” prices are stated in euros. High JB values show that none of the close prices were practically normally distributed. The ADF test of stationarity shows that only the close prices of two companies, e.g., EOAN.DE and RWE.DE, are time stationary. We concluded that the observed non-normality, non-stationarity and high level of multicollinearity of financial data make the classical regression approach infeasible
Source: Finanzen.net2 and Yahoo Finance3
List of explanatory variables
| Explanatory variables | No. of feat. |
|---|---|
| 1. Market (DAX30) data: | |
| open, close, high, low, adjusted close, volume | 6 |
| 2. Stock data: | |
| open, close, high, low, adjusted close, volume | 6 |
| 3. Date data: | |
| month, day, day of week, days to next trading day, | 5 |
| days from previous trading day | |
| 4. Technical indicators: | |
| RET: | 10 |
| DIFF: | 2 |
| RSI: 14-day period RSI, standardized | 1 |
| MACD: 12-day short, 26-day long and 9-day | 1 |
| signal period | |
| INCL: | 4 |
| CHG_RET: | 2 |
| DIFF_INCL | 4 |
| COEFs | 2 |
| Sum | 43 |
Market and stock data each comprised 6-element financial data. Date data were composed of 5-element periodic data. Technical indicators consisted of n-day returns, n-day differences, RSI and MACD indicators, inclinations over n = {5, 10, 15, 20}-day periods, changes (differences) in returns for n = {1, 2}, differences in inclination values between (1) 5-day inclination to a 5-day inclination shifted for 5-days, (2) 5-day inclination to a 10-day inclination, (3) 5-day inclination to a 15-day inclination and (4) 5-day inclination to a 20-day inclination. Finally, two coefficients were calculated, e.g., the relative quotient between the close to open prices and the relative quotient between high and low prices, both decreased by 1
Source: Fister et al. [20].
Fig. 1Outline of the LSTM cell. LSTMs consist of forget, input and output gates and a central memory cell. The latter makes the LSTM a representative of recurrent neural networks. Source: Buduma and Locascio [5]
Fig. 2The model shown is a kind of many-to-one sequence model. The past market and financial data are supplied and propagated via LSTM cell. After the predefined time steps T, the LSTM establishes stable memory cell state and can output the predicted trading signal , e.g., during the learning procedure after comparing to actual output y
Fig. 3A solid black line indicates the data-sample in use, i.e., in case of an offline LSTM-training, the in-sample (the upper) and in case of an online LSTM-training with LSTM-simulation, the out-of-sample (the lower). Unbiasedness was preserved entirely using this approach. N represents the number of offline epochs and N the number of online epochs a Common-model. b Unique-model.
Algorithm setup
| Variable | Variable name | Value |
|---|---|---|
| No. of LSTM units | 100 | |
| Learning algorithm | Adam | |
| Threshold | 0.035 | |
| No. of epochs for offline training | 200 | |
| No. of epochs for online training | 10 | |
| Offline initial (variable) learning rate | 0.002 | |
| Online (fixed) learning rate | 0.001 | |
| Time horizon | 1 | |
| Time steps | 32 | |
| Dataset split | 66.66%-33.33% | |
| In-sample size | 1717 | |
| Out-of-sample size | 843 | |
| Transaction costs | 1% | |
| Initial cash per stock | 10,000.00 euros | |
| No. of stocks in portfolio | 27 | |
| No. of independent runs | 10 |
The decay in the offline (variable) learning rate was defined as , where i represented the current epoch. The equation guaranteed an exponentially decreasing learning rate. The initial offline learning rate was set as double the keras recommendation, while the online learning rate was held at the default. The time horizon was set at n = 1, which means that one-day returns were used to calculate the response variable. The Adam learning algorithm [30] was used as a robust training algorithm due to its efficacious characteristic of combining AdaGrad and RMSProp. The number of offline training sessions was determined experimentally. The number of offline epochs were set very low (compared to [19]) to ensure that only general relations between data were captured (to avoid overfitting problems, since the batch size was fixed at 1). The time steps T = 32 were held as a compromise between the actualization of the LSTM network on the one hand and the stability of the internal memory cell on the other. The initial cash per stock was set for a moderate investor (due to the relative evaluation of all ITSs, the initial cash is not among the most relevant setup variables)
Fig. 4“LSTM1” represents the unique-model, and “LSTM2” represents the common-model. The former was most profitable among all ITSs. The passive ITS was the most prominent during the bullish trend, while RSI missed the potential profit in the last stage of trading. MACD did not show any indication of profitability. The dotted line shows the initial free cash assets
Robustness test results, where the common- and unique-model columns outline the minimum, maximum and average portfolio values for each of the stocks
| Common-model | Unique-model | Δ | |||||||
|---|---|---|---|---|---|---|---|---|---|
| max | min | mean | max. profit | max | min | mean | max. profit | ||
| ADS.DE | 15,845.5 | 8,372.44 | 12,450.76 | 5,845.5 | 11,385.29 | 8,135.82 | 9,326.09 | 1,385.29 | -3,124.67 |
| ALV.DE | 12,271.80 | 9,903.88 | 11,282.14 | 2,271.80 | 11,765.34 | 10,087.04 | 10,681.49 | 1,765.34 | -600.65 |
| BAS.DE | 7,104.99 | 3,053.42 | 5,081.94 | -2,895.01 | 6,963.76 | 4,202.84 | 5,075.23 | -3,036.24 | -6.71 |
| BAYN.DE | 7,808.00 | 4,850.7 | 5,921.02 | -2,192.00 | 8,962.23 | 5,479.92 | 7,122.02 | -1,037.77 | |
| BEI.DE | 10,821.01 | 7,824.75 | 9,482.37 | 821.01 | 9,516.12 | 8,167.38 | 8,969.41 | -483.88 | -512.96 |
| BMW.DE | 5,826.42 | 4,438.61 | 5,363.15 | -4,173.58 | 11,862.33 | 5,112.01 | 8,482.25 | 1,862.33 | |
| CON.DE | 6,785.01 | 3,981.95 | 4,826.42 | 3,214.99 | 9,471.72 | 4,586.51 | 7,170.49 | -528.28 | |
| DAI.DE | 8,932.15 | 4,467.33 | 6,216.41 | -1,067.850 | 9,106.97 | 4,160.38 | 6,697.23 | -893.03 | |
| DB1.DE | 20,847.38 | 14,574.18 | 16703.23 | 10,847.38 | 16,962.52 | 10,174.6 | 13,591.40 | 6,962.52 | -3.111,83 |
| DBK.DE | 9,542.53 | 3,096.58 | 4,663.74 | -457.47 | 5,622.59 | 2,645.7 | 3,892.91 | -4,377.41 | -770.83 |
| DPW.DE | 10,595.00 | 7,781.89 | 8,607.79 | 595.00 | 11,284.49 | 5,145.3 | 8,574.62 | 1,284.49 | -33.17 |
| DTE.DE | 11,694.17 | 5,796.68 | 9,093.95 | 1,694.17 | 11,026.45 | 7,844.71 | 9,298.95 | 1,026.45 | |
| EOAN.DE | 14,490.76 | 9,733.88 | 12,650.07 | 4,490.76 | 12,470.04 | 9,910.51 | 11,143.65 | 2,470.04 | -1,506.42 |
| FME.DE | 11,869.51 | 6,910.99 | 9,079.01 | 1,869.51 | 14,035.77 | 8,654.79 | 10,986.33 | 4,035.77 | |
| FRE.DE | 10,330.59 | 5,929.14 | 7,364.41 | 330.59 | 12,579.45 | 8,647.24 | 11,322.85 | 2,579.45 | |
| HEI.DE | 10,672.38 | 4,748.70 | 6,403.63 | 672.38 | 9,446.03 | 4,542.3 | 6,193.55 | -553.97 | -210.08 |
| HEN3.DE | 8,899.58 | 6,360.35 | 7,018.19 | -1,100.42 | 10,166.29 | 6,398.33 | 9,023.49 | 166.29 | |
| IFX.DE | 10,263.59 | 7,278.52 | 9,089.54 | 263.59 | 11,884.12 | 6,693.77 | 8,969.47 | 1,884.12 | -120.07 |
| LHA.DE | 14,300.22 | 6,242.53 | 8,003.62 | 4,300.22 | 12,858.99 | 5,223.11 | 7,807.86 | 2,858.99 | -195.76 |
| LIN.DE | 11,794.11 | 7,444.30 | 10,614.41 | 1,794.11 | 11,539.76 | 8,537.72 | 9,900.82 | 1,539.76 | -713.59 |
| MRK.DE | 13,024.75 | 7,009.77 | 10,173.94 | 3,024.75 | 10,859.94 | 8,409.54 | 9,761.69 | 859.94 | -412.25 |
| MTX.F | 13,254.14 | 8,330.39 | 10,659.51 | 3,254.14 | 13,753.86 | 8,422.72 | 11,191.40 | 3,753.86 | |
| MUV2.DE | 10,743.51 | 9,835.41 | 10,314.48 | 743.51 | 10,560.48 | 8,508.62 | 9,623.23 | 560.48 | -691.25 |
| RWE.DE | 21,311.35 | 13,306.65 | 17,427.40 | 11,311.35 | 26,878.27 | 10,000.0 | 17,151.77 | 16,878.27 | -275.63 |
| SAP.DE | 13,041.15 | 9,215.15 | 10,341.75 | 3,041.15 | 11,533.6 | 8,946.38 | 10,366.35 | 1,533.6 | |
| SIE.DE | 9,112.07 | 5,838.69 | 7,343.57 | -887.93 | 10,244.38 | 4,954.37 | 7,610.84 | 244.38 | |
| VOW3.DE | 12,338.66 | 6,636.57 | 9,124.14 | 2,338.66 | 11,540.49 | 4,160.31 | 7,712.78 | 1,540.49 | -1,411.36 |
The number of samples amounts to N = 10
Differences Δ were calculated between the mean values of the unique-model compared to common-model, i.e., Δ = mean(unique-model) − mean(common-model). Bold values denote positive differences (differences where the unique-models scored higher mean values than the common-models). Maximal profit shows the amount of profit per stock, e.g., if initial free cash assets amounted to 10,000.00 euros per stock, and the maximal final value of the individual stock amounted to 15,845.5 euros (for ADS.DE), then the maximal profit was 5,845.5 euros. For stocks that were traded with a negative maximal profit for both proposed LSTM frameworks, we can assume that they suffered a downtrend during the out-of-sample
The results in this table were obtained by analyzing the best results (among the 10 model runs)
| passive | RSI | MACD | common- | unique- | ||
|---|---|---|---|---|---|---|
| Value | euros | 261,136.06 | 244,964.33 | 118,463.91 | 266,268.29 | |
| Profit | -3.29 | -9.27 | -56.12 | -1.38 | ||
| Beta | 0.1812 | 0.5153 | -0.0290 | -0.0091 | ||
| max | 1 | 11 | 30 | 36 | ||
| No. of | min | 1 | 2 | 2 | 4 | |
| transactions | mean | 1 | 7.37 | 12.85 | 9.15 | |
| stdev | 0 | 1.95 | 6.57 | 7.96 | ||
| Sharpe ratio | 0.0765 | -0.1336 | -1.7529 | 0.0032 | ||
| Jensen’s alpha | 1.38 | -9.30 | -53.69 | -3.63 | ||
| Treynor ratio | -0.07 | -0.60 | -1.13 | -15.77 |
For the calculation of Jensen’s α and Treynor’s T, we assumed a risk-free rate R = 2%
The highest values are in bold, “common-” stands for the common-model and “unique-” stands for unique-model. The most profitable ITS was the unique-model LSTM. The riskiest among the ITSs was the passive ITS. The latter also demanded the highest expected return. Beta (β) was calculated compared to the benchmark “DAX30”