Stock price prediction is an important issue in the financial world, as it contributes to the development of effective strategies for stock exchange transactions. In this paper, we propose a generic framework employing Long Short-Term Memory (LSTM) and convolutional neural network (CNN) for adversarial training to forecast high-frequency stock market. This model takes the publicly available index provided by trading software as input to avoid complex financial theory research and difficult technical analysis, which provides the convenience for the ordinary trader of nonfinancial specialty. Our study simulates the trading mode of the actual trader and uses the method of rolling partition training set and testing set to analyze the effect of the model update cycle on the prediction performance. Extensive experiments show that our proposed approach can effectively improve stock price direction prediction accuracy and reduce forecast error.
Predicting stock prices is an important objective in the financial world [
In most cases, the forecast results are assessed from two aspects: the first is forecast error (chiefly the RMSE (Root Mean Square Error) or RMSRE (Root Mean Square Relative Error)) between real price and forecast value; the second is direction prediction accuracy, which means the percentage of correct predictions of price series direction, as upward and downward movements are what really matters for decision-making. Even small improvements in predictive performance can be very profitable [
However, predicting stock prices is not an easy work, due to the complexity and chaotic dynamics of the markets and the many nondecidable, nonstationary stochastic variables involved [
Generative adversarial network (GAN) was introduced by Goodfellow et al. [
This work uses basic technical index data as an input variable, which can be acquired directly from trading software, so that people outside the financial field can predict stock price through our method easily. This study introduces forecast error loss and direction prediction loss and shows that generative adversarial training [
Overall, our main contributions are twofold: (1) we adapted generative adversarial network for the purpose of price prediction, which constitutes to our knowledge the first application of adversarial training to stock market, and extensive experiments show that our prediction model can achieve remarkable results and (2) we carry out rolling segmentation on training set and testing set of the raw data to investigate the effect the of model parameter update cycle on the stock forecast performance, and the experimental results show that smaller model update cycle can advance prediction performance.
In the remainder of this paper, we begin with a review of the literature on which algorithms have been used for the financial market prediction. Then we formulate the problem and propose our general adversarial network framework. Furthermore, in the experiments section, we presented the experimental analysis with the proposed model, as well as a comparison between the obtained results with those given by classical prediction models. Finally, conclusions and possible extensions are discussed.
This section introduce the related work from the stock market prediction method and the generative adversarial network.
According to the research developed in this field, we can classify the techniques used to solve the stock market prediction problems to twofold.
The first category of related work is
The second category involves
However, to our knowledge, most of these methods require expertise to impose specific restrictions on the input variables, such as combining related stocks together as entry data [
Generative adversarial network (GAN) is a framework for estimating generative models via an adversarial process, in which we simultaneously train two models: a generative model
LSTM is a basic deep learning model and capable of learning long-term dependencies. A LSTM internal unit is composed of a cell, an input gate, an output gate, and a forget gate. LSTM internal units have hidden state augmented with nonlinear mechanisms to allow state to propagate without modification, be updated, or be reset, using simple learned gating functions. LSTM work tremendously well on various problems, such as natural language text compression, handwriting recognition, and electric load forecasting.
CNN is a class of deep, feed-forward artificial neural networks that has successfully been applied to analyzing visual imagery. A CNN consists of an input layer and an output layer, as well as multiple hidden layers. The hidden layers of a CNN typically consist of convolutional layers, pooling layers, fully connected layers, and normalization layers. CNN also has many applications such as image and video recognition, recommender systems, and natural language processing.
Although there are a lot of literatures forecast stock price by using LSTM model, to the best of our knowledge, this paper is the first to adopt GAN to predict stock prices. The experimental part (Section
In this section, we illuminate the details of the generative adversarial network framework for stock market forecasting with high-frequency data.
Under the high-frequency trading environment, high-quality one-step forecasting is usually of great concern to algorithmic traders, providing significant information to market makers for risk assessment and management. In this article, we aim to forecast the price movement of individual stocks or the market index one step ahead, based solely on their historical price information. Our problem can be mathematically formalized as follows.
Let
The deep architecture of the proposed GAN-FD model is illustrated as in Figure
GAN-FD architecture. The generator
The discriminative model
Our main intuition on why to use an adversarial loss is that it can simulate the operating habits of financial traders. An experienced trader usually predicts stock price through the available indicator data, which is the work of the generative model
It is noteworthy that the structure of
The training of the pair (
However, in practice, minimizing adversarial loss alone cannot guarantee satisfying predictions. Imagine that
Furthermore, as mentioned above, stock price direction prediction is crucial to trading, so we define direction prediction loss function
Combining all these losses previously defined with different parameters
Then we perform one SGD iteration on
We train the generator and discriminator iteratively. The entire process is summarized in Algorithm
(
( ( ( (
( ( (
( (
Next, we evaluate the performance of the proposed method based on the China stock market, ranging from January 1, 2016, to December 31, 2016. There are totally 244 trading days and each day contains 242-minute intervals, corresponding to 59048 time points. These stocks selected for the experiment should conform to three criteria: first, they should be the constituent stock of
The sample stocks and their number of increasing directions and decreasing directions.
ID | Stock code | Increase | Decrease |
---|---|---|---|
1 | 000156.SZ | 28927 | 30120 |
2 | 000432.SZ | 28879 | 30168 |
3 | 000783.SZ | 28310 | 30737 |
4 | 000938.SZ | 28537 | 30510 |
5 | 000963.SZ | 29192 | 29855 |
6 | 002007.SZ | 28933 | 30114 |
7 | 002027.SZ | 28623 | 30424 |
8 | 002153.SZ | 28566 | 30481 |
9 | 002183.SZ | 28795 | 30252 |
10 | 002195.SZ | 28861 | 30186 |
11 | 002241.SZ | 29084 | 29963 |
12 | 002241.SZ | 28737 | 30310 |
13 | 002252.SZ | 28696 | 30351 |
14 | 002292.SZ | 28385 | 30662 |
15 | 002304.SZ | 28914 | 30133 |
16 | 002415.SZ | 29036 | 30011 |
17 | 002456.SZ | 28671 | 30376 |
18 | 002475.SZ | 28837 | 30210 |
19 | 002594.SZ | 28525 | 30522 |
20 | 300017.SZ | 28528 | 30519 |
21 | 300024.SZ | 28411 | 30636 |
22 | 300072.SZ | 28884 | 30163 |
23 | 300124.SZ | 28632 | 30415 |
24 | 300146.SZ | 29137 | 29910 |
25 | 600038.SH | 28428 | 30619 |
26 | 600085.SH | 28856 | 30191 |
27 | 600118.SH | 28456 | 30591 |
28 | 600150.SH | 28537 | 30510 |
29 | 600332.SH | 29174 | 29873 |
30 | 600340.SH | 28773 | 30274 |
31 | 600519.SH | 29118 | 29929 |
32 | 600535.SH | 29013 | 30034 |
33 | 600570.SH | 28053 | 30994 |
34 | 600588.SH | 28483 | 30564 |
35 | 600685.SH | 28627 | 30420 |
36 | 600718.SH | 28881 | 30166 |
37 | 600754.SH | 28307 | 30740 |
38 | 600783.SH | 28680 | 30367 |
39 | 601318.SH | 28979 | 30068 |
40 | 601336.SH | 28643 | 30404 |
41 | 601888.SH | 28919 | 30128 |
42 | 603885.SH | 28817 | 30230 |
Many fund managers and investors in the stock market generally accept and use certain criteria for technical indicators as the signal of future market trends [
Basic indicators for prediction.
Indicators |
---|
Opening price |
Maximum price |
Minimum price |
Trading volume |
Turnover |
Bias |
Bollinger bands |
Directional movement index |
Exponential moving averages |
Stochastic index |
Moving averages |
MACD |
Relative strength index |
Most of the related articles use the traditional data partitioning method; that is, the entire dataset is directly split into training set and testing set [
Rolling segmentation on training set and testing set. The green bar represents the entire dataset, the blue bar represents the training set for a round experiment, and the yellow bar represents the corresponding testing set.
Given that the LSTM generator takes on the role of prediction and requires more accurate calculations of values than the CNN discriminator, we set the learning rate
Network architecture of discriminative model
Layer | Configuration |
---|---|
Convolution 1 | Filter |
Convolution 2 | Filter |
Convolution 3 | Filter |
FC 1 | 128, leaky ReLU |
FC 2 | 2, sigmoid |
Optimizer: SGD; batch size: 121; iterations: 10000; LReLU slope: 0.01.
To evaluate the performance of our proposed method, we include three baseline methods for comparison. The first model is ARIMA
We also inspect our GAN-FD model from several ways. The GAN-F model is using a GAN architectural for minimizing forecast error loss, with
For each stock at each time
In order to investigate the effect of the model update cycle on the predictive performance, let
Tables
Summary of RMSRE with different (
|
|
|
|||||||
---|---|---|---|---|---|---|---|---|---|
|
|
|
|
|
|
|
|
|
|
ARIMA-GARCH | 0.0419 | 0.0406 | 0.0425 | 0.0529 | 0.0529 | 0.0516 | 0.0733 | 0.0657 | 0.0739 |
ANN | 0.0419 | 0.0485 | 0.0531 | 0.0522 | 0.0522 | 0.0510 | 0.0739 | 0.0631 | 0.0631 |
SVM | 0.0512 | 0.0450 | 0.0487 | 0.0539 | 0.0507 | 0.0527 | 0.0616 | 0.0666 | 0.0639 |
|
|||||||||
GAN-F | 0.0151 | 0.0155 | 0.0157 | 0.0300 | 0.0243 | 0.0277 | 0.0326 |
|
0.0299 |
GAN-D | 0.0422 | 0.0304 | 0.0503 | 0.0625 | 0.0419 | 0.0405 | 0.0514 | 0.0598 | 0.0420 |
LSTM-FD | 0.0200 | 0.0194 | 0.0180 | 0.0324 | 0.0230 | 0.0245 |
|
0.0335 | 0.0357 |
GAN-FD |
|
|
|
|
|
|
0.0333 | 0.0323 |
|
Summary of DPA with different (
|
|
|
|||||||
---|---|---|---|---|---|---|---|---|---|
|
|
|
|
|
|
|
|
|
|
ARIMA-GARCH | 0.5464 | 0.5479 | 0.5264 | 0.5280 | 0.5315 | 0.5245 | 0.5007 | 0.5214 | 0.5296 |
ANN | 0.5456 | 0.5978 | 0.5738 | 0.5473 | 0.5629 | 0.5575 | 0.5205 | 0.5280 | 0.5394 |
SVM | 0.5715 | 0.5490 | 0.5839 | 0.5377 | 0.5514 | 0.5576 | 0.5147 | 0.5144 | 0.5318 |
|
|||||||||
GAN-F | 0.5347 | 0.5507 | 0.5281 | 0.4930 | 0.5115 | 0.5265 | 0.4880 | 0.5008 | 0.5116 |
GAN-D | 0.6220 | 0.6399 | 0.6409 | 0.6117 | 0.6245 | 0.6437 | 0.5217 | 0.5517 | 0.5498 |
LSTM-FD | 0.6340 | 0.6506 | 0.6509 | 0.6124 | 0.6236 | 0.6256 |
|
|
0.5719 |
GAN-FD |
|
|
|
|
|
|
0.5535 | 0.5583 |
|
Let us take a look at the effects of different (
Table
The number of times about the minimum RMSRE.
|
|
|
|||||||
---|---|---|---|---|---|---|---|---|---|
|
|
|
|
|
|
|
|
|
|
ARIMA-GARCH | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
ANN | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
SVM | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
|
|||||||||
GAN-F | 11 | 2 | 4 | 6 | 6 | 4 | 13 |
|
11 |
GAN-D | 0 | 0 | 0 | 0 | 0 | 0 | 2 | 0 | 7 |
LSTM-FD | 0 | 0 | 5 | 6 | 3 | 3 |
|
10 | 5 |
GAN-FD |
|
|
|
|
|
|
11 | 14 |
|
Table
The number of times about the maximum DPA.
|
|
|
|||||||
---|---|---|---|---|---|---|---|---|---|
|
|
|
|
|
|
|
|
|
|
ARIMA-GARCH | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 6 | 5 |
ANN | 0 | 0 | 0 | 0 | 0 | 0 | 2 | 0 | 3 |
SVM | 0 | 0 | 0 | 0 | 0 | 0 | 3 | 1 | 1 |
|
|||||||||
GAN-F | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
GAN-D | 0 | 1 | 6 | 5 | 1 | 7 | 2 | 6 | 2 |
LSTM-FD | 1 | 3 | 4 | 11 | 4 | 0 |
|
|
12 |
GAN-FD |
|
|
|
|
|
|
17 | 14 |
|
The results of each representation are reported in Figures
DPA and RMSRE of each stock when (
DPA and RMSRE of each stock when (
DPA and RMSRE of each stock when (
DPA and RMSRE of each stock when (
DPA and RMSRE of each stock when (
DPA and RMSRE of each stock when (
DPA and RMSRE of each stock when (
DPA and RMSRE of each stock when (
DPA and RMSRE of each stock when (
In this paper, we propose an easy-to-use stock forecasting model called GAN-FD, to assist more and more nonfinancial professional ordinary investors making decisions. GAN-FD adopts 13 simple technical indexes as input data to avoid complicated input data preprocessing. Based on the deep learning network, this model achieves prediction ability superior to other benchmark methods by means of adversarial training, minimizing direction prediction loss, and forecast error loss. Moreover, the effects of the model update cycles on the predictive capability are analyzed, and the experimental results show that the smaller model update cycle can obtain better prediction performance. In the future, we will attempt to integrate predictive models under multiscale conditions.
The authors declare that there are no conflicts of interest regarding the publication of this paper.
This work is supported by the National Key Research Development Program of China (2017YFB0802800) and the National Natural Science Foundation of China (no. 61473149).