Development of an Information and Analytical System for Predicting Price Fluctuations and Long-Term Trends Using Generative-Adversarial Neural Networks

Deep learning methods (DML) have been widely used in financial fields recently, such as stock market forecasting, balance the portfolio, financial information processing, and transaction execution strategies. Stock market forecasting and effective trading strategy construction, when using deep learning, are the most popular ways of applying DML in the field of finance. Against the background of the general development of the Russian stock market, the study and investigation of its price dynamics is a highly promising direction for analyzing and forecasting the value of financial assets in which it is planned to invest money. In this study, a new architecture of a conditional generative-adversarial neural network (GAN) with a multi-level perceptron (MLP) as a discriminator and a long short-term memory (LSTM) as a generator for determining trends is proposed. The Box-Jenkins method (ARIMA) is used to determine the confidence interval.


Introduction
Information processes are becoming one of the most important components of human life. The modern development of information technologies has resulted in increasing number of investors, who prefer interactive approaches for securities auction, which allows sending real-time orders for securities sale or purchase to their brokers using a computer. Each financial market is posed a challenge to study and put into practice various methods of analyzing and predicting a price performance of the stock market, as well as to find out which of price forecasting tools are the most accurate and reliable. In this study, we used a technical method of stock market analysis and various mathematical models for predicting price performance based on the theory of time series.
The practical significance of the obtained results is the ability to analyze and predict the value of financial assets which are expected to be invested [7].

Analysis of the results of previous work
An analysis of other studies devoted to this problem has shown that the largest number of scientific publications relates to the economic and statistical analysis of either stock or debt markets. However, in domestic practice, methods of analyzing the securities market using neural networks are not given due attention, as evidenced by the fact that there is a relatively small number of scientific publications. Nevertheless, neural networks are already widely used by financial corporations. For example, Citicorp, using a neurocomputer for analyzing and short-term forecasting of currency fluctuations, outweighed the accuracy of the predictions of the country's leading brokers. The London Stock Exchange (LSE) has implemented an automated system with elements of artificial intelligence based on neural computing to control domestic dealing.
In Russia, despite the financial market turbulence due to the instability of investment flows of both domestic and foreign capitals, as well as the difficult political situation, there is a powerful neurocomputer, which is used by the Central Bank, the Local Compliance Service, and more than 30 Russian banks. Computing systems based on neural networks have also found application on the stock exchanges of the United States and Japan [9,11].
Currently, banks have come to the conclusion that systems based on neural networks can bring significant benefits. For a long time the market has been putting forward similar products, determining the probabilities of risk in cases of loan granting, as well as software and hardware packages that can simulate and predict bankruptcy. The use of such systems does have a positive effect, but the results do not always meet expectations.

Designing the structure of an information and analytical system (IAS)
IAS was developed on the basis of a three-level client/ server architecture. Thanks to this, the database server is free from the tasks of multisequencing work between different users, which significantly reduces its hardware requirements. Figure 1 shows the general structure of the information and analytical system. Django library, a free framework for Python web applications, using the MVC design pattern, was applied as a binding software in case of system's database query [1,8 ].
When using Django library, the most optimal solution was to use Nginx as an IAS server, which is a web server and a mail proxy server running on Unix-like operating systems. It is the Django+Nginx couple that is the most popular and often used in the construction of client/ server systems [2,10]. The IAS also includes a quote analysis module, implementable when using a generative-adversarial neural network, and a data collection module.

Module of the subsystem for acquisition, monitoring and updating data on financial quotes
The software monitoring module keeps track of the financial information provider Yahoo!Finance, which allows interacting with trading systems and getting data on securities quotes available for updates through user-defined time periods . The monitoring process is automated and is initiated automatically when the Linux service is started. In the process of operation of the subsystem's software module for data acquisition, its monitoring and updating in regard to quotes, relevant web standards and the database schema are used. The functioning of this module is provided by the library of Django platform, the Linux service, the PostgreSQL Server and Redis DBMS (Fig. 2). The The data capture system has a distributed architecture, after receiving the necessary data, they are transmitted to the server, where they are processed, converted into the necessary form and recorded in the database [4,12].

Yahoo!Finance monitoring
Database schema The update function block is responsible for processing data received at the monitoring stage, it stores the results of processing in the program database. The update block adds new data to the database and updates the information if necessary. Using the data collection and monitoring module has resulted in the acquisition of information on securities quotations from 2015 to 2020. The total umber of rows is 1,945,346 ( Figure 3).
There are 6 factors for each financial asset: x Date (Date); x Opening price (Open); x Maximum price within a day (High); x Minimum price within a day (Low); x Closing price (Close); x Traded value (Total Trade Quantity).

Elaboration of a predictive algorithm based on neural networks
The idea of generative-adversarial networks was proposed by J. Goodfellow from the University of Montreal [5]. Within just a couple of years, this method has found its application in the tasks of semantic image segmentation, medical information analysis, material recognition, and time series analysis. In a high-frequency trading environment, knowledge of the direction of market move is very important for the management of portfolio risk [6,12]. The purpose of this study is to have a try at determining whether you are in a trend at specific time during. The problem can be formulated mathematically as follows. Assume x is a set of basic indicators (opening price, closing price, minimum price, maximum price, traded value) and y is a trend indicator (1 -trend exists, 0 -there is no) at daily intervals within a day. In this case, the minimax gaming of networks can be described as: Training G lies in tricking the discriminator and getting closer to the real data [6]. Therefore, the generator must minimize the loss function so that D cannot distinguish the generated data from the real data. There is an algorithm, used for training generativeadversarial networks: 1. Make k iterations, optimizing the discriminator D.

Next, we generate m examples {z1, z2, … , zm} using active version G.
3. The next step is updating the generator parameters when using the gradient G* : It should be noted that, just like in many computer-assisted instruction models, generative-adversarial networks tend to overtraining. It is a paradox that this can be more frequent, when using less variable models. It can be explained by the fact that with a miniscule proportion of the generator variation, the entire network resides at a smaller space of possible samples, which effectively reduces the dataset dimension, but results in deadly work of the dynamics of the model predictive ability as a whole. The architecture of the developed contention-based neural network consists of two components: an autoencoder and a discriminator that work during training in a competitive mode. This mode makes it possible to change settings of the autoencoder in the training mode and provide high-quality output data at the subsequent stage of their generation. The task of the discriminator is to distinguish the real data of the trend behavior from the data generated by the autoencoder. The autoencoder is a seven-layer neural network with input and output layers, a latent layer, and four fully connected layers (Fig. 1). The input layer is fed with previously obtained data on quotes after passing through two fully connected layers (the encoder) and getting to the latent layer, where the generator parameters are updated when using the gradient. Then the transformed data passes through two fully connected layers (the decoder) and gets to the output, which, like the input, is a descriptor vector. When training a neural network, it is difficult to determine whether the encoder is really poorly trained or if it is not able 'to trick" the discriminator. In this regard, the following measures have been taken to improve the training process: x the discriminator had been pre-trained prior to training the entire autoencoder; it was assumed that in this case the discriminator would distinguish the random numbers obtained from the untrained encoder from the values corresponding to the normal distribution used; x in the process of training the entire group of models, the discriminator was trained not every epoch, but once every two epochs, i.e. it was trained only in one of the two epochs for the autoencoder model; x the discriminator had been pre-trained prior to training the entire autoencoder; it was assumed that in this case the discriminator would distinguish the random numbers obtained from the untrained encoder from the values corresponding to the normal distribution used; x in the process of training the entire group of models, the discriminator was trained not every epoch, but once every two epochs, i.e. it was trained only in one of the two epochs for the autoencoder model; The Box-Jenkins algorithm was used (Fig. 4), which restricts the direction of the trend movement by constructing a confidence interval, since it is quite possible that the shape of the curve describing the trend is chosen incorrectly or in cases when the trend may change significantly in the future and not follow the type of the curve that was chosen in the forecast. The confidence interval is an interval of values calculated for the trend line based on a sample of the same data that was used to train the neural network, and with a certain probability includes the true value of this parameter in the general totality. The correct construction of the confidence interval provides a side constraint for the neural network in the predicted chunk, which allows making predictions more accurately, excluding random components or "noises" from the set.

Research results
The research has resulted in the development of an information and analytical system for predicting long-term trends using generative-adversarial neural networks. Figure 5 shows the results of trend course predicting for the AMEX stock index and also trend based on data from Yahoo!Financе. The proposed information and analytical system makes it possible to identify the features peculiar to the provided real data on the trend course, and on their basis to generate artificial samples similar to the real ones, which affords an opportunity to predict the trend line with a high degree of probability.
Further steps to improve the IAS for trend forecasting can be the following: 1. Determining of the trend is not based on the majority of votes, but using a probabilistic approach. Thus, it is possible to move away from the binary concept of a trend to the probability of its presence, which in theory should simplify the training of both a discriminator and a generator.
2. Using a different combination of neural network layers as a new neural network, which would allow achieving greater accuracy in the trend predicting.