# Predicting Stock Market Volatility from Candlestick Charts: A Multiple Attention Mechanism Graph Neural Network Approach

Authors: Jun Wang; Xiaohan Li; Huading Jia; Tao Peng; Jinghua Tan
Journal: Mathematical Problems in Engineering
 (2022)

---

## Abstract

As an important part of financial market, stock market price volatility analysis has been the focus of academic and industry attention. Candlestick chart, as the most widely used indicator for evaluating stock market price volatility, has been intensively studied and explored. With the continuous development of computer technology, the stock market analysis method based on candlestick chart is gradually changed from manual to intelligent algorithm. However, how to effectively use stock market graphical indicators to analyze stock market price fluctuations has been pending solution, and deep learning algorithms based on structured data such as deep neural networks (DNN) and recurrent neural networks (RNNs) always have the problems of making it difficult to capture the laws and low generalization ability for stock market graphical indicators data processing. Therefore, this paper proposes a quantification method of stock market candlestick chart based on Hough variation, using the graph structure embedding method to represent candlestick chart features and multiple attention graph neural network for stock market price fluctuation prediction. The experimental results show that the proposed method can interpret the candlestick chart features more accurately and has superiority performance over state-of-the-art deep learning methods, including SVM, CNN, LSTM, and CNN-LSTM. Relative to these algorithms, the proposed method achieves an average performance improvement of 20.51% in terms of accuracy and further achieves at least 26.98% improvement in strategy returns in quantitative investment experiments.


---

## Body

## 1. Introduction

Stock price movement is a nonlinear and nonstationary time series. Over the past three decades, market regulators and investors have never stopped researching and forecasting stock price analysis, from the initial evaluation of manual indicators, to computer-generated trading data indicators, to more intuitive stock market evaluation indicators such as graphs. In fact, the development history of research on stock price forecasting is closely related to the iterations of information technology, with the earliest research on stock price forecasting dating back to the late 20th century, when Lo and Mackinlay demonstrated that stock prices do not follow the nonrandom walk theory, thus corroborating the predictability of stock market prices [1]. Then Allen et al. [2] used genetic algorithms to achieve the capture of stock price trends through historical trading data. Kim proposed support vector machines (SVMs) for stock price research [3] and in subsequent studies further studied stock price fluctuations using multilayer perceptrons [4]. Since then, more and more machine learning algorithms have been applied to the study of stock market price fluctuations. In recent years, neural network techniques have started to emerge, and algorithms based on neural networks such as convolutional neural networks (CNN) [5, 6] and recurrent neural networks (RNN) or improved neural networks have been widely used in the field of stock price volatility research [7, 8]. Due to the quality characteristics exhibited by neural network techniques in processing speech and images, neural network techniques can not only parse structured data such as stock quotes and transactions, but also help scholars to predict stock market price movements using stock graphical features, such as historical movement patterns and features based on the candlestick chart and 30-day average [9]. Specifically, among the currently popular stock graphical indicators forecasting methods, scholars mainly use two methods, similar search forecasting [10] and pattern forecasting [11]. However, neural network techniques often face two important problems in the analysis of stock graphical indicators. First, most of the analysis of candlestick chart technical indicators in the financial field is based on the color, the length of the solid and upper and lower shadows, and the pattern presented by the candlestick chart combination, and the traditional stock market candlestick chart feature embedding methods are mostly expressed in a tensor or vector manner, ignoring the financial characteristics of the candlestick chart as a graphical indicator. Secondly, traditional neural network methods for prediction of stock graphical indicators are mostly state recognition, and due to the uncertainty of the number of hidden layers of neural networks, traditional neural networks will have a long training time, low prediction accuracy, and unsatisfactory analysis when performing stock market prediction [12]. These two critical problems hinder the research of stock graphical indicators prediction based on neural network technology and become a difficult problem to be solved in related research fields.Therefore, this paper introduces a pioneering approach to embedding stock market candlestick chart graphs to fully represent graphical indicator features, setting a single-day candlestick chart as a node with node features including candlestick chart color, upper shadow length, lower shadow length, and solid length, which are quantified through trading data. Edges are created between adjacent single-day candlestick chart, and the edge feature is the offset value of the center coordinate of the adjacent candlestick chart entity. To be able to accurately capture the important morphological features of the combined candlestick chart, multiple attention graph neural networks are introduced for stock market price volatility prediction based on the constructed stock market graphical indicator candlestick chart data. Experimental results show that the method in this paper can better interpret the financial features of stock market candlestick chart, and the prediction accuracy of the constructed graph neural network is better than other classical prediction algorithms such as LSTM and SVM.In the next sections of this paper, Section2 reviews the theories covered in this paper and the current status of research, Section 3 describes the stock market prediction model based on graph neural networks, and Section 4 introduces the experimental procedure and presents the model experimental results. Section 5 summarizes the paper and proposes the next research directions.


## 2. Related Work

### 2.1. Stock Market Price Forecasting

It has been demonstrated in stock market research that stock price trend forecasting is closely related to the characteristics of financial time series [1]. Indeed, financial time series have noisy, nonlinear, stochastic financial time characteristics among them and numerous and complex influencing factors [13]. However, Edwards et al. [14] demonstrated that financial time series trends are reproducible and individual special time series trends will appear extremely similar to future time series trends. Therefore, stock price movements, as typical financial time series, are often introduced by scholars as various evaluation indicators for the prediction of stock market price fluctuations.Among them, scholars have gradually derived kinetic and weight indicators by combining direct indicators such as opening price, closing price, high price, low price, and volume. For example, Jegadeesh and Titman [15] proposed that the price of a stock has a tendency to continue the original direction of movement, and volume and turnover are derived as momentum factors for stock price movement prediction. Fama and French constructed a factor pricing model [16] for explaining cross-sectional changes in expected stock payoffs using derived indicator factors such as total market capitalization and book-to-market ratio.With the development of computer visualization, graphical indicators such as time-of-day charts, averages, and candlesticks were introduced for stock price trend evaluation in order to be able to reflect stock price fluctuation trends more intuitively. Moving averages proposed by Granville [17] help traders to confirm existing trends, judge trends that will emerge, and detect overdelayed trends that are about to reverse. Candlestick charts, on the other hand, visually present stock price trends through a wealth of elements such as shapes, colors, and patterns. Therefore, candlestick charts [18] have been most widely used as an important tool to help investors make decisions, and a large number of researchers have devoted themselves to its study, mainly using search for time series similarity of candlestick charts [19] and identification of patterns [20] to predict stock price trends.With the newer changes in the research of evaluation indexes, the stock market forecasting methods are also evolving. Forecasting methods have gradually changed from the initial manual forecasting through trading data to forecasting aided by the statistical properties of financial time series obtained by computers. For example, methods such as autoregressive moving average model (ARMA) are based on the statistical properties of time series for stock price forecasting [21]. With the rapid development of artificial intelligence, stock trend prediction gradually changed from machine-assisted prediction to computer-autonomous iterative learning prediction. Classical machine learning algorithms such as SVM and LSTM are widely used for stock price trend prediction [22]. Cutting-edge technologies such as computer vision techniques are also commonly applied to quantitative trading, using various graphical indicators such as candlestick and moving averages for forecasting. Kamijo and Tanigawa [23] applied recurrent neural networks to candlestick pattern recognition to determine the future trend of stock market prices by identifying triangular patterns in the trend. Naranjo et al. [24] used fuzzy logic to resolve the ambiguity and uncertainty of candlestick patterns and provide rational decision support for investors, when to buy and sell. Scholars have explored a lot of financial time series graphical indicators forecasting, as shown in Table 1, but how to combine the financial characteristics of graphical indicators to achieve an efficient embedding representation of graphical indicators needs to be further explored.Table 1
Analytical methods for processing graphical indicators of securities market.
LiteratureResearch contentExperimentFocusFeaturesTargetSingle-day candlestick featuresTime series correlation[25]An analysis of candlestick chart composition and characteristics was conducted, focusing on visual representations and financial technical analysis tools.High, low, open, and close pricesVisual analysisYesNo[26]Developed an expert system for candlestick chart analysis, or chart interpreter, to predict the best market timing. This expert system has patterns and rules for predicting future stock price movements. Depending on their meaning, the defined patterns can be divided into five groups: Down patterns, up patterns, neutral patterns, trend continuation patterns, and trend reversal patterns.Predefined patternsPredicting stock price movementsNoNo[27]Based on the color, size, and relative position of the candlesticks, these features are combined into a tree trading strategy using the Chi-square automatic interaction detector (CAD) algorithm. The features and methods constructed for candlesticks proved to be effective in identifying the candlestick patterns.Color, size, and relative position of candlesticksPredicting buy, sell, or holdNoYes[28]Two models were constructed. Model 1 is a committee machine with a generalized regression neural network (GRNN). Model 2, on the other hand, is a hybrid fuzzy logic-controlled network for identifying candlestick charts and predicting stock market conditions.Color, size, and relative position of candlesticksPredicting stock price movementsNoYes[29]Extracted the sentiment features of social media, constructed historical time series data candlestick charts, integrated candlestick charts and social media data, and proposed a multichannel collaborative network based on convolutional neural networks for stock price trend analysis.Candlestick chartsPredicting stock price movementsNoNoOursEmbedding stock market candlestick chart graphs to fully represent graphical indicator features, setting a single-day candlestick chart as a node. Edges are created between adjacent single-day candlestick chart. Multiple attention graph neural networks are introduced for stock market price volatility prediction based on the constructed stock market graphical indicator candlestick chart data.Color, upper shadow, lower shadow, and solid lengthPredicting stock price movementsYesYes


### 2.2. Graph Neural Network

To be able to solve the deep learning problem of graph data, graph neural network was born. In just a few years graph neural network technology has progressed by leaps and bounds and has been widely used [30–32]. Bruna et al. [33] in 2013 first proposed graph convolutional neural networks, using a spectral space approach to define the graph convolution. ChebNet [34] and graph convolutional networks (GCN) [35] define the weight matrix of the nodes from a spatial perspective to be able to reduce the spatiotemporal complexity and optimize the parameters of the kernel function. Kim [36] et al. proposed a hierarchical attention network for stock market prediction using relational data. Selectively aggregating information about different relationship types and adding this information to the representation of each company, this method is used to predict the movements of individual stock prices and market indices. Liu [37, 38] et al. proposed a method to predict stock price fluctuations using a knowledge graph of relationships among listed companies using a closed-form regression cell model combined with related stock news sentiment, focal stock news sentiment, and quantitative characteristics of the focal stock. Matsunaga [39] investigated the effectiveness of cross-working between market forecasting and graphical neural networks by introducing company knowledge graphs into the forecasting model to mimic investors’ decision making. The validity of different markets and longer time spans was tested using rolling window backtracking. Scholars have explored the application of graph neural networks to stock market forecasting in a large number of ways. The main role of graph data is to expand feature indicators based on relational data and solve the multiscale problem of time series forecasting for stock market movement forecasting. In order to analyze and predict stock market fluctuations and tap the implicit relational information in the stock market, the research conducted on the construction and analysis of graphical data structure of stock market information is still in the initial stage.Therefore, this paper combines the characteristics of stock market graphical indicators candlestick, introduces the relationship dimension information, and fully represents the single-day candlestick image characteristics and candlestick combination pattern characteristics by graph embedding method. Based on this embedding method, we fully exploit the information of candlestick implicit features and construct a multiple attention graph neural network to analyze and predict the stock market price fluctuations.


## 2.1. Stock Market Price Forecasting

It has been demonstrated in stock market research that stock price trend forecasting is closely related to the characteristics of financial time series [1]. Indeed, financial time series have noisy, nonlinear, stochastic financial time characteristics among them and numerous and complex influencing factors [13]. However, Edwards et al. [14] demonstrated that financial time series trends are reproducible and individual special time series trends will appear extremely similar to future time series trends. Therefore, stock price movements, as typical financial time series, are often introduced by scholars as various evaluation indicators for the prediction of stock market price fluctuations.Among them, scholars have gradually derived kinetic and weight indicators by combining direct indicators such as opening price, closing price, high price, low price, and volume. For example, Jegadeesh and Titman [15] proposed that the price of a stock has a tendency to continue the original direction of movement, and volume and turnover are derived as momentum factors for stock price movement prediction. Fama and French constructed a factor pricing model [16] for explaining cross-sectional changes in expected stock payoffs using derived indicator factors such as total market capitalization and book-to-market ratio.With the development of computer visualization, graphical indicators such as time-of-day charts, averages, and candlesticks were introduced for stock price trend evaluation in order to be able to reflect stock price fluctuation trends more intuitively. Moving averages proposed by Granville [17] help traders to confirm existing trends, judge trends that will emerge, and detect overdelayed trends that are about to reverse. Candlestick charts, on the other hand, visually present stock price trends through a wealth of elements such as shapes, colors, and patterns. Therefore, candlestick charts [18] have been most widely used as an important tool to help investors make decisions, and a large number of researchers have devoted themselves to its study, mainly using search for time series similarity of candlestick charts [19] and identification of patterns [20] to predict stock price trends.With the newer changes in the research of evaluation indexes, the stock market forecasting methods are also evolving. Forecasting methods have gradually changed from the initial manual forecasting through trading data to forecasting aided by the statistical properties of financial time series obtained by computers. For example, methods such as autoregressive moving average model (ARMA) are based on the statistical properties of time series for stock price forecasting [21]. With the rapid development of artificial intelligence, stock trend prediction gradually changed from machine-assisted prediction to computer-autonomous iterative learning prediction. Classical machine learning algorithms such as SVM and LSTM are widely used for stock price trend prediction [22]. Cutting-edge technologies such as computer vision techniques are also commonly applied to quantitative trading, using various graphical indicators such as candlestick and moving averages for forecasting. Kamijo and Tanigawa [23] applied recurrent neural networks to candlestick pattern recognition to determine the future trend of stock market prices by identifying triangular patterns in the trend. Naranjo et al. [24] used fuzzy logic to resolve the ambiguity and uncertainty of candlestick patterns and provide rational decision support for investors, when to buy and sell. Scholars have explored a lot of financial time series graphical indicators forecasting, as shown in Table 1, but how to combine the financial characteristics of graphical indicators to achieve an efficient embedding representation of graphical indicators needs to be further explored.Table 1
Analytical methods for processing graphical indicators of securities market.
LiteratureResearch contentExperimentFocusFeaturesTargetSingle-day candlestick featuresTime series correlation[25]An analysis of candlestick chart composition and characteristics was conducted, focusing on visual representations and financial technical analysis tools.High, low, open, and close pricesVisual analysisYesNo[26]Developed an expert system for candlestick chart analysis, or chart interpreter, to predict the best market timing. This expert system has patterns and rules for predicting future stock price movements. Depending on their meaning, the defined patterns can be divided into five groups: Down patterns, up patterns, neutral patterns, trend continuation patterns, and trend reversal patterns.Predefined patternsPredicting stock price movementsNoNo[27]Based on the color, size, and relative position of the candlesticks, these features are combined into a tree trading strategy using the Chi-square automatic interaction detector (CAD) algorithm. The features and methods constructed for candlesticks proved to be effective in identifying the candlestick patterns.Color, size, and relative position of candlesticksPredicting buy, sell, or holdNoYes[28]Two models were constructed. Model 1 is a committee machine with a generalized regression neural network (GRNN). Model 2, on the other hand, is a hybrid fuzzy logic-controlled network for identifying candlestick charts and predicting stock market conditions.Color, size, and relative position of candlesticksPredicting stock price movementsNoYes[29]Extracted the sentiment features of social media, constructed historical time series data candlestick charts, integrated candlestick charts and social media data, and proposed a multichannel collaborative network based on convolutional neural networks for stock price trend analysis.Candlestick chartsPredicting stock price movementsNoNoOursEmbedding stock market candlestick chart graphs to fully represent graphical indicator features, setting a single-day candlestick chart as a node. Edges are created between adjacent single-day candlestick chart. Multiple attention graph neural networks are introduced for stock market price volatility prediction based on the constructed stock market graphical indicator candlestick chart data.Color, upper shadow, lower shadow, and solid lengthPredicting stock price movementsYesYes


## 2.2. Graph Neural Network

To be able to solve the deep learning problem of graph data, graph neural network was born. In just a few years graph neural network technology has progressed by leaps and bounds and has been widely used [30–32]. Bruna et al. [33] in 2013 first proposed graph convolutional neural networks, using a spectral space approach to define the graph convolution. ChebNet [34] and graph convolutional networks (GCN) [35] define the weight matrix of the nodes from a spatial perspective to be able to reduce the spatiotemporal complexity and optimize the parameters of the kernel function. Kim [36] et al. proposed a hierarchical attention network for stock market prediction using relational data. Selectively aggregating information about different relationship types and adding this information to the representation of each company, this method is used to predict the movements of individual stock prices and market indices. Liu [37, 38] et al. proposed a method to predict stock price fluctuations using a knowledge graph of relationships among listed companies using a closed-form regression cell model combined with related stock news sentiment, focal stock news sentiment, and quantitative characteristics of the focal stock. Matsunaga [39] investigated the effectiveness of cross-working between market forecasting and graphical neural networks by introducing company knowledge graphs into the forecasting model to mimic investors’ decision making. The validity of different markets and longer time spans was tested using rolling window backtracking. Scholars have explored the application of graph neural networks to stock market forecasting in a large number of ways. The main role of graph data is to expand feature indicators based on relational data and solve the multiscale problem of time series forecasting for stock market movement forecasting. In order to analyze and predict stock market fluctuations and tap the implicit relational information in the stock market, the research conducted on the construction and analysis of graphical data structure of stock market information is still in the initial stage.Therefore, this paper combines the characteristics of stock market graphical indicators candlestick, introduces the relationship dimension information, and fully represents the single-day candlestick image characteristics and candlestick combination pattern characteristics by graph embedding method. Based on this embedding method, we fully exploit the information of candlestick implicit features and construct a multiple attention graph neural network to analyze and predict the stock market price fluctuations.


## 3. Forecasting Model Construction

### 3.1. Method Overview

The research object of this paper is the candlestick chart, which is most widely used in the stock market. According to the characteristics of graphical indicators, different colors of the candlestick chart represent the up and down state, and the upper and lower shadows and entities represent the relationship between the opening price, closing price, highest price, and lowest price, respectively, and the pattern formed by the candlestick of consecutive trading days can reflect the price trend of the securities market. In this paper, for graphical indicator features, each trading day candlestick is used as a node, and the vector is used to adequately represent the single-day candlestick color, upper and lower shadows, and entity length, and the single-day candlestick feature is defined as a node feature. The single-day candlesticks between adjacent trading days are set as edges, and the edges are characterized by the displacement offset values of the rectangular center coordinates of the candlesticks of the adjacent trading days. The constructed graphical indicator subgraph uses graphical neural network to complete the classification prediction of the subgraph. The framework of the graphical indicator-based stock market volatility prediction model is shown in Figure1.Figure 1
Framework of the stock market volatility prediction model based on graphical indicators.The first part of the figure is mainly intended to get stock market transaction data, that is, obtain the opening price, highest price, lowest price, and closing price through the stock market transaction data API interface of financial websites provided by Pandas library; the acquired stock market transaction data is processed to generate candlestick for subsequent model training and prediction. In order to improve the efficiency of graphical indicator expression, the corresponding graphical indicator labels are generated by the time sliding window to improve the efficiency of subsequent model training and forecasting. The second part of the figure is the quantitative expression of the candlestick, the candlestick features to be expressed quantitatively are divided into two categories, the first category of features is the color, upper and lower shadows, and the length of the entity presented by the single-day candlestick, and the second category of features is the displacement pattern features in the combination of candlestick lines for multiple trading days. In the third part of our framework, combining the characteristics of the graphical indicators, each trading day candlestick is set as a node, and the adjacent nodes are set as edges. In the last part of the figure, a multiple attention mechanism graphical neural network has been constructed to classify the embedded generated candlestick graph data and complete the prediction of stock market price fluctuations.


### 3.2. Model Introduction

In this section, we detail each component of the proposed approach, including feature extraction and quantification, graph embedding method, and multiple attention graph neural network. Table2 summaries the mathematical notations and symbols frequently used in this study.Table 2
Symbols and description.
SymbolsDefinitions and descriptionsG=V,E,HA data graph with a setV of vertices, a set E of edges, and the feature representation of nodes HgkThekth subgraph, consisting of five single-day candlesticksei,jThe edge between nodei and node jhinNode feature in thenth aggregation layerai,jWeight of node attention between graph nodesi and jEi,jEdge feature between nodei and node jFi,jCorrelation between the graph nodesi and jMSingle-layer feedforward neural networkWWeight parameters in graph learningVWeight parameters in attention mechanism


#### 3.2.1. Feature Extraction Quantification

The single-day candlestick features mainly include candlestick color, upper shadow length, lower shadow length, and entity length. The features are quantified by trading data for the features. The positive color feature is red, the upper shadow length is indicated as the highest price − closing price, the lower shadow length is indicated as the opening price – lowest price, and the entity length is the closing price − opening price. The negative color is green, the upper shadow length is the highest price − the opening price, the lower shadow length is the closing price − the lowest price, and the entity is the opening price − the closing price. The characteristics are expressed as1∗4 vectors. The positive line characteristics vector values are [1, ln (Highest price – Closing price), ln (Opening price − Lowest price), ln (Closing price − Opening price)] and the negative line characteristics vector values are [0, ln (Highest price − Opening price), ln (Closing price − Lowest price), ln (Opening price − Closing price)].The combined candlestick pattern, on the other hand, is a morphological characteristic consisting of multiple daily candlesticks, and for the expression of the candlestick pattern the displacement between the rectangular center coordinates of the main single-day candlesticks is obtained by the process of the OpenCV module. The core method of candlestick coordinate acquisition is matrix detection through Hough transform, which is an important method to check the shape of intermittent point boundaries, and it uses the image coordinate space to convert to plane space parameters to complete rectangle detection. The quantization flow of combined candlestick feature extraction is shown in Figure2.Figure 2
Flowchart of combined candlestick pattern displacement quantification.After image processing, the original 5 trading day images are converted to binary images, and the single-day candlestick contours are detected by Hough changes to obtain a list of single-day candlestick contours. On this basis, cv2.rectangle() is used to label the positioned contours using a matrix. cv2.minAreaRect() is calculated to obtain an array of external minimum rectangle point sets and directly obtains the center point coordinates, rectangle width and height, and rotation angle. cv2.boxPoints() locates the candlestick according to the obtained rectangle point set and draws the external minimum rectangle with annotation. Finally, the candlesticks can be quantified as features for further processing in graph learning.In fact, the quantification method of the graphical indicator K-line is one of the core innovations of this paper. Figure2 describes the technical implementation process and presents a lot of technical details. Such a detailed description can better clarify the exact implementation process and ensure the reproducibility of this work. On this basis, we hope that subsequent researchers will learn more about the technical implementation methods and can further expand the quantitative methods to improve the analysis and processing efficiency of quantitative features.


#### 3.2.2. Graph Embedding Method

Based on the recent research on the graphical index candlestick chart of the stock market, as shown in Table1, this paper considers the embedding method of the graphical indicators from three aspects to construct the graphical indicator data. Firstly, based on the characteristics of the graphical indicators of the stock market, mainly including the color, graphical structure, and relative position of the graphical indicators, the node characteristics in the constructed graph data are the characteristic values of single-day K lines, and the side weights are the location characteristics between multiple single-day K lines, in order to be able to improve the efficiency of the model calculation. Drawing on [40], candlestick combinations are mostly analyzed with 3–5 day candlestick series as candlestick patterns, the number of graphical indicator graph nodes created in this paper is 5, each node has 1∗4 feature vectors, and the edge feature vectors are 1∗2.The graphical indicator subchart nodes consist of multiday candlestick charts. This paper returns to the origin of graphical indicators, using graphical indicators single-day candlestick and candlestick chart combination patterns for embedding, effectively avoiding the overlap of trading data and graphical indicator data dimensions. The single-day candlestick chart is used as a node, and the node characteristics are represented by1∗4 vectors. The positive feature vector values are [1, ln (highest price − closing price), ln (opening price − lowest price), ln (closing price − opening price)], and the negative feature vector values are [0, ln (highest price − opening price), ln (closing price − lowest price), ln (opening price − closing price)]. Edges are set between adjacent trading day candlesticks, the weight of the edge is a 1∗2 vector, and the feature vector is the center coordinate offset value [△x, △y]. The graphical indicator subgraph consists of two main parts, the node set V and the edge set E. The stock market graphical indicator embedding method is shown in Figure 3. This embedding method more comprehensively expresses the single-day candlestick characteristics and the patterns of candlestick combinations, so as to accurately judge the stock market price fluctuation trends.Figure 3
Stock market graphical graph embedding method.The candlestick chart graph dataGk=gki contains the construction of graphical indicator charts according to trading days. gki=V,E,H illustrates subgraph of the candlestick chart graph data Gk, where V denotes the node set V=vki and E denotes the edge set E=eki. The weight of the graph edge eki is initially set to [△x, △y], that is, adjacent single-day candlestick center coordinates offset. Assume that, for the adjacent nodes A and B, the center coordinates of node A are x1,y1, the center coordinates of point B are x2,y2, and the coordinates offsets are △x=x1−x2 and △y=y1−y. H=hki represents the graph node feature, where hki is the graphical indicator feature vector, and i represents the trading day. To further improve the efficiency of graphical indicator representation, the graphical indicator subplots constructed by combining the graphical indicator image features of stock market, image candlestick combinations, and the main information contained include single-day candlestick features and combined candlestick pattern features. Single-day candlesticks are characterized by nodes and node features, while candlestick patterns are represented by edges and their weights.


#### 3.2.3. Multiple Attention Graph Neural Network

In order to be able to effectively mine the effective information in the candlestick indicators, according to the candlestick graph data constructed by the described quantization and embedding methods, multiple attention mechanisms are introduced in this paper. The first type of node attention mechanism is used to interpret the single-day candlestick node features, while the second type of edge attention is used to interpret the combined candlestick displacement features. The update of the node feature statehin+1 is derived from the neighboring node features hkn, as shown in equation (1), where Wn is a weight matrix that ai,k represents the weight of node attention among nodes. In order to be able to obtain the attention weights between the neighboring nodes, first, the nodes hi and hk by formula (1) nodes share weight parameters W to increase the dimensionality of the nodes and M⋅ for the weight parameterized single-layer feedforward neural network, mapping high-dimensional features to the real number range, the network uses LeakyReLU as activation function to obtain the correlation coefficient Fikn between the nodes used to indicate the correlation between the nodes, and ai,k is obtained by normalizing the coefficient.(1)hin+1=∑k∈Niai,kWhkn,ai,k=softmaxiFikn,Fikn=LeakyReLUMWhi∥Whk.The edge featureseijn+1 updated by the edge attention mechanism are obtained from (2), V⟶ is the weight vector, Eijn is the edge features, by equation (3) through the weight matrix We, the activation function LeakyReLU is used, hi and hj are the node features of the input, and Eij is the edge features.(2)eijn+1=V⟶Eijn,(3)Eijn=LeakyReLUWehiEijhj.The graph feature states are updated by the two types of attention mechanisms, i.e., node and edge attention mechanisms. After aggregation, the obtained graph feature stateshin+1,eijn+1 are used to complete the graphical indicator graph classification prediction using the fully connected layer, as indicated in formula (4). Wn indicates the node and edge weight matrix after aggregation.(4)y=∑i,nsoftmaxWnhin+1,eijn+1.


## 3.1. Method Overview

The research object of this paper is the candlestick chart, which is most widely used in the stock market. According to the characteristics of graphical indicators, different colors of the candlestick chart represent the up and down state, and the upper and lower shadows and entities represent the relationship between the opening price, closing price, highest price, and lowest price, respectively, and the pattern formed by the candlestick of consecutive trading days can reflect the price trend of the securities market. In this paper, for graphical indicator features, each trading day candlestick is used as a node, and the vector is used to adequately represent the single-day candlestick color, upper and lower shadows, and entity length, and the single-day candlestick feature is defined as a node feature. The single-day candlesticks between adjacent trading days are set as edges, and the edges are characterized by the displacement offset values of the rectangular center coordinates of the candlesticks of the adjacent trading days. The constructed graphical indicator subgraph uses graphical neural network to complete the classification prediction of the subgraph. The framework of the graphical indicator-based stock market volatility prediction model is shown in Figure1.Figure 1
Framework of the stock market volatility prediction model based on graphical indicators.The first part of the figure is mainly intended to get stock market transaction data, that is, obtain the opening price, highest price, lowest price, and closing price through the stock market transaction data API interface of financial websites provided by Pandas library; the acquired stock market transaction data is processed to generate candlestick for subsequent model training and prediction. In order to improve the efficiency of graphical indicator expression, the corresponding graphical indicator labels are generated by the time sliding window to improve the efficiency of subsequent model training and forecasting. The second part of the figure is the quantitative expression of the candlestick, the candlestick features to be expressed quantitatively are divided into two categories, the first category of features is the color, upper and lower shadows, and the length of the entity presented by the single-day candlestick, and the second category of features is the displacement pattern features in the combination of candlestick lines for multiple trading days. In the third part of our framework, combining the characteristics of the graphical indicators, each trading day candlestick is set as a node, and the adjacent nodes are set as edges. In the last part of the figure, a multiple attention mechanism graphical neural network has been constructed to classify the embedded generated candlestick graph data and complete the prediction of stock market price fluctuations.


## 3.2. Model Introduction

In this section, we detail each component of the proposed approach, including feature extraction and quantification, graph embedding method, and multiple attention graph neural network. Table2 summaries the mathematical notations and symbols frequently used in this study.Table 2
Symbols and description.
SymbolsDefinitions and descriptionsG=V,E,HA data graph with a setV of vertices, a set E of edges, and the feature representation of nodes HgkThekth subgraph, consisting of five single-day candlesticksei,jThe edge between nodei and node jhinNode feature in thenth aggregation layerai,jWeight of node attention between graph nodesi and jEi,jEdge feature between nodei and node jFi,jCorrelation between the graph nodesi and jMSingle-layer feedforward neural networkWWeight parameters in graph learningVWeight parameters in attention mechanism


### 3.2.1. Feature Extraction Quantification

The single-day candlestick features mainly include candlestick color, upper shadow length, lower shadow length, and entity length. The features are quantified by trading data for the features. The positive color feature is red, the upper shadow length is indicated as the highest price − closing price, the lower shadow length is indicated as the opening price – lowest price, and the entity length is the closing price − opening price. The negative color is green, the upper shadow length is the highest price − the opening price, the lower shadow length is the closing price − the lowest price, and the entity is the opening price − the closing price. The characteristics are expressed as1∗4 vectors. The positive line characteristics vector values are [1, ln (Highest price – Closing price), ln (Opening price − Lowest price), ln (Closing price − Opening price)] and the negative line characteristics vector values are [0, ln (Highest price − Opening price), ln (Closing price − Lowest price), ln (Opening price − Closing price)].The combined candlestick pattern, on the other hand, is a morphological characteristic consisting of multiple daily candlesticks, and for the expression of the candlestick pattern the displacement between the rectangular center coordinates of the main single-day candlesticks is obtained by the process of the OpenCV module. The core method of candlestick coordinate acquisition is matrix detection through Hough transform, which is an important method to check the shape of intermittent point boundaries, and it uses the image coordinate space to convert to plane space parameters to complete rectangle detection. The quantization flow of combined candlestick feature extraction is shown in Figure2.Figure 2
Flowchart of combined candlestick pattern displacement quantification.After image processing, the original 5 trading day images are converted to binary images, and the single-day candlestick contours are detected by Hough changes to obtain a list of single-day candlestick contours. On this basis, cv2.rectangle() is used to label the positioned contours using a matrix. cv2.minAreaRect() is calculated to obtain an array of external minimum rectangle point sets and directly obtains the center point coordinates, rectangle width and height, and rotation angle. cv2.boxPoints() locates the candlestick according to the obtained rectangle point set and draws the external minimum rectangle with annotation. Finally, the candlesticks can be quantified as features for further processing in graph learning.In fact, the quantification method of the graphical indicator K-line is one of the core innovations of this paper. Figure2 describes the technical implementation process and presents a lot of technical details. Such a detailed description can better clarify the exact implementation process and ensure the reproducibility of this work. On this basis, we hope that subsequent researchers will learn more about the technical implementation methods and can further expand the quantitative methods to improve the analysis and processing efficiency of quantitative features.


### 3.2.2. Graph Embedding Method

Based on the recent research on the graphical index candlestick chart of the stock market, as shown in Table1, this paper considers the embedding method of the graphical indicators from three aspects to construct the graphical indicator data. Firstly, based on the characteristics of the graphical indicators of the stock market, mainly including the color, graphical structure, and relative position of the graphical indicators, the node characteristics in the constructed graph data are the characteristic values of single-day K lines, and the side weights are the location characteristics between multiple single-day K lines, in order to be able to improve the efficiency of the model calculation. Drawing on [40], candlestick combinations are mostly analyzed with 3–5 day candlestick series as candlestick patterns, the number of graphical indicator graph nodes created in this paper is 5, each node has 1∗4 feature vectors, and the edge feature vectors are 1∗2.The graphical indicator subchart nodes consist of multiday candlestick charts. This paper returns to the origin of graphical indicators, using graphical indicators single-day candlestick and candlestick chart combination patterns for embedding, effectively avoiding the overlap of trading data and graphical indicator data dimensions. The single-day candlestick chart is used as a node, and the node characteristics are represented by1∗4 vectors. The positive feature vector values are [1, ln (highest price − closing price), ln (opening price − lowest price), ln (closing price − opening price)], and the negative feature vector values are [0, ln (highest price − opening price), ln (closing price − lowest price), ln (opening price − closing price)]. Edges are set between adjacent trading day candlesticks, the weight of the edge is a 1∗2 vector, and the feature vector is the center coordinate offset value [△x, △y]. The graphical indicator subgraph consists of two main parts, the node set V and the edge set E. The stock market graphical indicator embedding method is shown in Figure 3. This embedding method more comprehensively expresses the single-day candlestick characteristics and the patterns of candlestick combinations, so as to accurately judge the stock market price fluctuation trends.Figure 3
Stock market graphical graph embedding method.The candlestick chart graph dataGk=gki contains the construction of graphical indicator charts according to trading days. gki=V,E,H illustrates subgraph of the candlestick chart graph data Gk, where V denotes the node set V=vki and E denotes the edge set E=eki. The weight of the graph edge eki is initially set to [△x, △y], that is, adjacent single-day candlestick center coordinates offset. Assume that, for the adjacent nodes A and B, the center coordinates of node A are x1,y1, the center coordinates of point B are x2,y2, and the coordinates offsets are △x=x1−x2 and △y=y1−y. H=hki represents the graph node feature, where hki is the graphical indicator feature vector, and i represents the trading day. To further improve the efficiency of graphical indicator representation, the graphical indicator subplots constructed by combining the graphical indicator image features of stock market, image candlestick combinations, and the main information contained include single-day candlestick features and combined candlestick pattern features. Single-day candlesticks are characterized by nodes and node features, while candlestick patterns are represented by edges and their weights.


### 3.2.3. Multiple Attention Graph Neural Network

In order to be able to effectively mine the effective information in the candlestick indicators, according to the candlestick graph data constructed by the described quantization and embedding methods, multiple attention mechanisms are introduced in this paper. The first type of node attention mechanism is used to interpret the single-day candlestick node features, while the second type of edge attention is used to interpret the combined candlestick displacement features. The update of the node feature statehin+1 is derived from the neighboring node features hkn, as shown in equation (1), where Wn is a weight matrix that ai,k represents the weight of node attention among nodes. In order to be able to obtain the attention weights between the neighboring nodes, first, the nodes hi and hk by formula (1) nodes share weight parameters W to increase the dimensionality of the nodes and M⋅ for the weight parameterized single-layer feedforward neural network, mapping high-dimensional features to the real number range, the network uses LeakyReLU as activation function to obtain the correlation coefficient Fikn between the nodes used to indicate the correlation between the nodes, and ai,k is obtained by normalizing the coefficient.(1)hin+1=∑k∈Niai,kWhkn,ai,k=softmaxiFikn,Fikn=LeakyReLUMWhi∥Whk.The edge featureseijn+1 updated by the edge attention mechanism are obtained from (2), V⟶ is the weight vector, Eijn is the edge features, by equation (3) through the weight matrix We, the activation function LeakyReLU is used, hi and hj are the node features of the input, and Eij is the edge features.(2)eijn+1=V⟶Eijn,(3)Eijn=LeakyReLUWehiEijhj.The graph feature states are updated by the two types of attention mechanisms, i.e., node and edge attention mechanisms. After aggregation, the obtained graph feature stateshin+1,eijn+1 are used to complete the graphical indicator graph classification prediction using the fully connected layer, as indicated in formula (4). Wn indicates the node and edge weight matrix after aggregation.(4)y=∑i,nsoftmaxWnhin+1,eijn+1.


## 3.2.1. Feature Extraction Quantification

The single-day candlestick features mainly include candlestick color, upper shadow length, lower shadow length, and entity length. The features are quantified by trading data for the features. The positive color feature is red, the upper shadow length is indicated as the highest price − closing price, the lower shadow length is indicated as the opening price – lowest price, and the entity length is the closing price − opening price. The negative color is green, the upper shadow length is the highest price − the opening price, the lower shadow length is the closing price − the lowest price, and the entity is the opening price − the closing price. The characteristics are expressed as1∗4 vectors. The positive line characteristics vector values are [1, ln (Highest price – Closing price), ln (Opening price − Lowest price), ln (Closing price − Opening price)] and the negative line characteristics vector values are [0, ln (Highest price − Opening price), ln (Closing price − Lowest price), ln (Opening price − Closing price)].The combined candlestick pattern, on the other hand, is a morphological characteristic consisting of multiple daily candlesticks, and for the expression of the candlestick pattern the displacement between the rectangular center coordinates of the main single-day candlesticks is obtained by the process of the OpenCV module. The core method of candlestick coordinate acquisition is matrix detection through Hough transform, which is an important method to check the shape of intermittent point boundaries, and it uses the image coordinate space to convert to plane space parameters to complete rectangle detection. The quantization flow of combined candlestick feature extraction is shown in Figure2.Figure 2
Flowchart of combined candlestick pattern displacement quantification.After image processing, the original 5 trading day images are converted to binary images, and the single-day candlestick contours are detected by Hough changes to obtain a list of single-day candlestick contours. On this basis, cv2.rectangle() is used to label the positioned contours using a matrix. cv2.minAreaRect() is calculated to obtain an array of external minimum rectangle point sets and directly obtains the center point coordinates, rectangle width and height, and rotation angle. cv2.boxPoints() locates the candlestick according to the obtained rectangle point set and draws the external minimum rectangle with annotation. Finally, the candlesticks can be quantified as features for further processing in graph learning.In fact, the quantification method of the graphical indicator K-line is one of the core innovations of this paper. Figure2 describes the technical implementation process and presents a lot of technical details. Such a detailed description can better clarify the exact implementation process and ensure the reproducibility of this work. On this basis, we hope that subsequent researchers will learn more about the technical implementation methods and can further expand the quantitative methods to improve the analysis and processing efficiency of quantitative features.


## 3.2.2. Graph Embedding Method

Based on the recent research on the graphical index candlestick chart of the stock market, as shown in Table1, this paper considers the embedding method of the graphical indicators from three aspects to construct the graphical indicator data. Firstly, based on the characteristics of the graphical indicators of the stock market, mainly including the color, graphical structure, and relative position of the graphical indicators, the node characteristics in the constructed graph data are the characteristic values of single-day K lines, and the side weights are the location characteristics between multiple single-day K lines, in order to be able to improve the efficiency of the model calculation. Drawing on [40], candlestick combinations are mostly analyzed with 3–5 day candlestick series as candlestick patterns, the number of graphical indicator graph nodes created in this paper is 5, each node has 1∗4 feature vectors, and the edge feature vectors are 1∗2.The graphical indicator subchart nodes consist of multiday candlestick charts. This paper returns to the origin of graphical indicators, using graphical indicators single-day candlestick and candlestick chart combination patterns for embedding, effectively avoiding the overlap of trading data and graphical indicator data dimensions. The single-day candlestick chart is used as a node, and the node characteristics are represented by1∗4 vectors. The positive feature vector values are [1, ln (highest price − closing price), ln (opening price − lowest price), ln (closing price − opening price)], and the negative feature vector values are [0, ln (highest price − opening price), ln (closing price − lowest price), ln (opening price − closing price)]. Edges are set between adjacent trading day candlesticks, the weight of the edge is a 1∗2 vector, and the feature vector is the center coordinate offset value [△x, △y]. The graphical indicator subgraph consists of two main parts, the node set V and the edge set E. The stock market graphical indicator embedding method is shown in Figure 3. This embedding method more comprehensively expresses the single-day candlestick characteristics and the patterns of candlestick combinations, so as to accurately judge the stock market price fluctuation trends.Figure 3
Stock market graphical graph embedding method.The candlestick chart graph dataGk=gki contains the construction of graphical indicator charts according to trading days. gki=V,E,H illustrates subgraph of the candlestick chart graph data Gk, where V denotes the node set V=vki and E denotes the edge set E=eki. The weight of the graph edge eki is initially set to [△x, △y], that is, adjacent single-day candlestick center coordinates offset. Assume that, for the adjacent nodes A and B, the center coordinates of node A are x1,y1, the center coordinates of point B are x2,y2, and the coordinates offsets are △x=x1−x2 and △y=y1−y. H=hki represents the graph node feature, where hki is the graphical indicator feature vector, and i represents the trading day. To further improve the efficiency of graphical indicator representation, the graphical indicator subplots constructed by combining the graphical indicator image features of stock market, image candlestick combinations, and the main information contained include single-day candlestick features and combined candlestick pattern features. Single-day candlesticks are characterized by nodes and node features, while candlestick patterns are represented by edges and their weights.


## 3.2.3. Multiple Attention Graph Neural Network

In order to be able to effectively mine the effective information in the candlestick indicators, according to the candlestick graph data constructed by the described quantization and embedding methods, multiple attention mechanisms are introduced in this paper. The first type of node attention mechanism is used to interpret the single-day candlestick node features, while the second type of edge attention is used to interpret the combined candlestick displacement features. The update of the node feature statehin+1 is derived from the neighboring node features hkn, as shown in equation (1), where Wn is a weight matrix that ai,k represents the weight of node attention among nodes. In order to be able to obtain the attention weights between the neighboring nodes, first, the nodes hi and hk by formula (1) nodes share weight parameters W to increase the dimensionality of the nodes and M⋅ for the weight parameterized single-layer feedforward neural network, mapping high-dimensional features to the real number range, the network uses LeakyReLU as activation function to obtain the correlation coefficient Fikn between the nodes used to indicate the correlation between the nodes, and ai,k is obtained by normalizing the coefficient.(1)hin+1=∑k∈Niai,kWhkn,ai,k=softmaxiFikn,Fikn=LeakyReLUMWhi∥Whk.The edge featureseijn+1 updated by the edge attention mechanism are obtained from (2), V⟶ is the weight vector, Eijn is the edge features, by equation (3) through the weight matrix We, the activation function LeakyReLU is used, hi and hj are the node features of the input, and Eij is the edge features.(2)eijn+1=V⟶Eijn,(3)Eijn=LeakyReLUWehiEijhj.The graph feature states are updated by the two types of attention mechanisms, i.e., node and edge attention mechanisms. After aggregation, the obtained graph feature stateshin+1,eijn+1 are used to complete the graphical indicator graph classification prediction using the fully connected layer, as indicated in formula (4). Wn indicates the node and edge weight matrix after aggregation.(4)y=∑i,nsoftmaxWnhin+1,eijn+1.


## 4. Experimental Simulation and Result Analysis

### 4.1. Experiment Introduction

The experimental data are selected from January 1, 2016, to December 31, 2020, for the CSI 300 index components. 292500 trading days closing prices of 300 stocks between January 1, 2016, and December 31, 2019, are used as the training validation dataset, and 72900 trading days of 300 stocks between January 1, 2020, and December 31, 2020, are used as the test dataset (link:https://pan.baidu.com/s/17_WbIrJtwiiIIZ6zNHaIgw,password:ornr). Because the CSI 300 index constituents have an update mechanism, in order to ensure the continuity of model training, this paper updates the CSI 300 constituents on January 1 every year and divides them into six industries: finance, public utilities, real estate, composite, industrial, and commercial according to the industry classification rules in the CMSAR database. The individual stock samples were selected from Ping An Bank, COSCO, Vanke A, Shepherd Field, China Nuclear Power, and Yonghui Supermarket, which belong to finance, public utilities, real estate, composite, industrial, and commercial and were labeled in four categories using the closing price increase and decrease compared with the previous trading day and the closing price increase and decrease compared with the previous trading day. Y represents the rise and fall values, in accordance with the four categories of labels Y ≤ −5%, −5% < Y < 0, 0 ≤ Y < 5%, 5% ≤ Y for the candlestick charts are constructed and labeled. Strategy backtesting experiments in accordance with the model classification predict the closing price compared to the previous trading day up and down, generating stock market buying and selling trading signals and the corresponding quantitative investment operations; investment return overview mainly includes Sharpe ratio, maximum retracement value, and other investment return evaluation index data. The experimental running environment is done on Intel Xeon 4210R 2.4 GHz 12C (core) 64G RDIMM memory server, and the software environment is Python 3.6.1. GPU : NVIDIA Tesla 16G, computing platform using CUDA 10.2.


### 4.2. Experimental Results

The single-day candlestick node features are obtained from the trading data, while the key to the extraction of the combined candlestick features lies in the single-day candlestick positioning and contour minimum matrix labeling, based on which the center coordinates are calculated; the experiment achieved good experimental results as shown in Figure4. The contours were accurately labeled and the accurate center coordinate values of the labeled single-day candlestick contours were extracted.Figure 4
Single-day candlestick positioning and matrix labeling. The vertical coordinate is the stock prices, and the horizontal coordinate is the different time distribution (trading day).The graphical quantification of the stock market is followed by an embedding operation to build a graphical indicator graph data, which represents the single-day candlestick characteristics in the form of nodes and features. The adjacent single-day candlesticks create edges to represent the time series correlation, and the weights of the edges are quantified by the above single-day candlestick positioning and matrix labeling method to extract the position information of the candlestick combinations and fully interpret the sequence combination pattern of candlesticks. This type of graph data analysis and forecasting processing allows for a more accurate reflection of stock market price fluctuations as it contains sufficient graphical indicator information elements. Following the graph embedding method described in 3.2.2 for candlestick embedding expression, the structural characteristics of the graph data effectively enhance the efficiency of data analysis and processing, and the visualization of the constructed candlestick graph data is shown in Figure5.Figure 5
Stock market graphical indicator chart data. The vertical and the horizontal coordinate are the same as Figure4. The difference is that the value is quantified for relative positions.In this paper, the baseline model is selected mainly from three different ways of candlestick processing and analysis: based on image recognition techniques CNN1 [41] and RNN [42], based on structured data processing and analysis methods LSTM [43] and SVM [44], and based on graphical indicators embedding methods CNN2 [45] and CNN-LSTM [46]. The first class of methods mainly uses image processing intelligent algorithms to extract the feature information contained in graphical indicators through their image features and train models for stock market price fluctuation prediction. The second type of method uses the trading data to determine the pattern of the graphical indicator to which it belongs and then judges the subsequent stock market price fluctuations based on the pattern to which it belongs. The third method is to convert the feature information contained in the graphical indicators of the securities market into transaction data in the form of tensors. Compared with the graphical indicators in this paper, the transaction volume information is increased. CNN and LSTM are used for feature extraction and aggregation. Complete the forecast of price fluctuations in the securities market. This kind of method innovates the quantitative and embedding method combined with the graphical indicators of the securities market. The parameter settings of the baseline model used in this paper are shown in Table 3.Table 3
Model parameter settings.
MethodParametersCNN1Kernel_size = (3, 3); strides = (2, 2); dropout = 0.25; lr = 0.0001CNN2Input_layer-lisset = (5, 5); convolutional_filter = (3, 3)RNNnn.LSTM (num_layers = 2); lr = 0.0001LSTMrnn_unit = 10; lstm_layers = 1; lr = 0.0006SVMC = 0.8; kernel = liner; max_iter = 1000CNN-LSTMConvolutional_filter = (3, 3); max_pooling = (2, 2)Table4 shows the prediction results of the six classification models. Compared with the first type of image-based recognition methods, the method in this paper has 29.17% and 13.33% higher accuracy in predicting price fluctuations less than or equal to 5% and greater than 5%, respectively. Compared with the second type of structured data-based methods, they are 28.17% and 12.5% higher, respectively. Compared with the prediction based on the third innovative embedding method, the accuracy is 35.33% and 16.75% higher, respectively. The method proposed in this paper exhibits the best prediction performance. The proposed method has a lower prediction accuracy for trading days with closing price volatility greater than or equal to 5% compared to trading days with closing price volatility less than 5% in the financial, public utilities, real estate, and general industries. Industrial and commercial show the opposite result, with a higher accuracy rate for predicting closing price volatility greater than or equal to 5% for T + 1 trading days than for trading days with less than 5% volatility. Among the stocks belonging to various industries, Ping An Bank, COSCO, Vanke A, and Shepherd Field, which belong to the finance, public utilities, real estate, and general industries, also show the performance advantage of this paper’s model for predicting the accuracy of small-amplitude volatility. For stocks belonging to industrial and commercial sectors, China Nuclear Power and Yonghui Supermarket, the method proposed in this paper has more advantages for predicting large fluctuations. On the other hand, for the trading data of the test time period, there were only 2 and 8 trading days with closing price fluctuations greater than or equal to 5% for China Nuclear Power and Yonghui Supermarket, respectively, and the accuracy of the prediction for large fluctuations presented in this paper needs further verification.Table 4
Accuracy of the four categories of the algorithm presented.
StocksCNN1CNN2RNNLSTMSVMCNN-LSTMOur method≥5%<5%≥5%<5%≥5%<5%≥5%<5%≥5%<5%≥5%<5%≥5%<5%Finance28.12 ± 0.2343.65 ± 0.6331.51 ± 0.3346.73 ± 0.8233.85 ± 0.3755.13 ± 0.8331.65 ± 0.2855.19 ± 0.9528.83 ± 0.1944.72 ± 0.5335.36 ± 0.7346.65 ± 0.9335.76∗ ± 0.6363.53∗ ± 0.23Public sector17.26 ± 0.1641.56 ± 0.7826.43 ± 0.8753.34 ± 0.1117.12 ± 0.8963.34 ± 0.3722.56 ± 02354.34 ± 0.2320.76 ± 0.7251.32 ± 0.4332.56∗ ± 0.7853.21 ± 0.8030.54 ± 0.3767.14∗ ± 0.21Real estate18.87 ± 0.8741.87 ± 0.9623.45 ± 0.3447.21 ± 0.3420.89 ± 0.8347.65 ± 0.2616.34 ± 0.6152.12 ± 0.2823.78 ± 0.7340.14 ± 0.4627.34∗ ± 0.6347.19 ± 0.7621.16 ± 0.6558.67∗ ± 0.23Composite31.56 ± 1.3843.78 ± 0.3421.23 ± 0.8737.34 ± 0.1535.31 ± 0.7654.18 ± 0.5636.78 ± 0.7148.45 ± 0.3622.12 ± 0.8747.27 ± 0.5221.31 ± 0.5437.54 ± 0.5636.52∗ ± 0.4166.54∗ ± 0.27Industrial25.71 ± 0.8447.56 ± 1.1623.87 ± 1.1451.34 ± 0.2626.15 ± 0.8663.45 ± 0.4760.75 ± 0.6562.45 ± 0.4123.41 ± 0.6551.71 ± 0.3723.69 ± 0.7451.26 ± 0.2381.67∗ ± 0.3065.17∗ ± 0.31Commercial19.15 ± 1.2151.34 ± 0.6316.98 ± 0.7143.45 ± 0.2571.52 ± 0.5659.64 ± 0.5257.91 ± 0.4351.56 ± 0.1717.81 ± 0.5448.23 ± 0.8717.12 ± 0.6443.24 ± 0.4581.56∗ ± 0.3463.41∗ ± 0.27Ping An Bank40.62 ± 0.3436.34 ± 0.9526.78 ± 0.4642.12 ± 0.4520.56 ± 0.9440.12 ± 0.6160.43 ± 0.7336.89 ± 0.5640.34 ± 0.6139.56 ± 0.6727.35 ± 1.5342.13 ± 0.3079.12∗ ± 0.2853.41∗ ± 0.15COSCO Sea Control32.45 ± 0.8144.34 ± 0.7637.34 ± 0.5640.34 ± 0.1650.41 ± 0.9546.45 ± 0.6936.87 ± 0.5652.16 ± 0.8123.19 ± 0.7340.34 ± 0.3436.73 ± 0.7440.18 ± 0.5659.67∗ ± 0.6566.34∗ ± 0.19Vanke A32.56 ± 1.2350.34 ± 0.2828.56 ± 0.6738.34 ± 0.4550.45 ± 1.1348.19 ± 0.7317.73 ± 0.6955.19 ± 0.8532.56 ± 0.6554.32 ± 0.4526.54 ± 0.8138.40 ± 0.5665.89∗ ± 0.4357.34∗ ± 0.13Makara32.18 ± 0.7544.23 ± 0.6946.89 ± 0.9146.34 ± 0.7147.14 ± 0.9642.21 ± 0.7458.65 ± 0.7850.64 ± 0.9142.57 ± 0.7146.17 ± 0.3243.27 ± 0.5446.84 ± 0.2362.87∗ ± 0.4361.56∗ ± 0.31China Nuclear Power48.33 ± 0.3945.78 ± 0.5631.67 ± 0.3152.45 ± 0.1536.67% ± 0.3352.43 ± 1.5651.67 ± 0.3348.54 ± 0.6225.00 ± 0.3535.67 ± 0.5650.00 ± 0.3640.43 ± 0.6466.67∗ ± 0.3465.56∗ ± 0.27Yong Hui38.75 ± 0.7643.62 ± 0.7123.89 ± 0.8441.23 ± 0.5325.23% ± 1.1250.29 ± 0.9613.45 ± 0.6254.51 ± 0.5450.56 ± 0.9146.18 ± 0.5423.35 ± 1.3442.16 ± 0.4575.42∗ ± 0.3158.34∗ ± 0.56Each reported result is the average performance on ten training process, followed by their standard deviation. The best result (in bold) is further marked with∗, if it is significantly different from the runner-up (underlined) under the two-tail paired t-test at the 0.01 level.After comparing the accuracy, the running time of the models is compared on this basis and the results are shown in Table5 and Figure 6. In particular, Table 5 presents the average training and test running times for the algorithms involved in this study. Figure 6 further compares the execution time in terms of individual stock. To show the comparison of the running results more clearly and intuitively, the models with better prediction performance, including RNN, LSTM, and CNN-LSTM, are used for this comparison. The compared running time results are shown in Figure 6.Table 5
Execution time of different algorithms.
StocksCNN1CNN2RNNLSTMSVMCNN-LSTMOur methodTrainTestTrainTestTrainTestTrainTestTrainTestTrainTestTrainTestExecution time41567.593426.3037319.363061.8045681.723645.0043628.813193.0235637.072843.1063617.633112.8335314.572551.50Figure 6
Execution time of different algorithms.In Table5, the predicted execution time of each model is shown, respectively. The above results show that the method proposed in this paper greatly reduces the training cost of the model and shortens the prediction running time of the model because the graphical indicators are quantified into structured data. Figure 6 shows the comparison more intuitively, and the smooth line trend shows that the method proposed in this paper has better operation stability. The model proposed in this paper has better processing ability and efficient information mining ability for large-scale stock market graphical indicator data. In high-frequency trading applications, it is more advantageous for the processing of graphic indicators of the stock market at the hour, minute, and second level.


### 4.3. Strategy Backtesting

The prediction results presented in Table4 show that the method proposed in this study has good prediction performance. These obtained predicted results of stock market rise and fall can further form buy and sell signals. Specifically, consecutive identical prediction results do not generate trading signals, and buy or sell operations are only performed when reversals of the rise or fall occur. Therefore, stochastic trading returns and fundamental returns are introduced in this study to compare with the returns of the investment strategies formed by the proposed model.The green line in Figure7 indicates the investment returns of individual stocks and stock portfolios of this paper’s model strategy, the yellow line indicates the benchmark returns, and the green line indicates the returns of the stochastic strategy; the stochastic strategy is to randomly generate information on the rise and fall of stocks 0 and 1, to complete the investment behavior according to this information, to complete the buying and selling operation when the information on the rise and fall changes, and to not generate the investment behavior when the information does not change, and Figures 7(a)–7(f) in Figure 7 are the corresponding average return results of the stock portfolio within the industry. Figures 7(g)–7(l) are the results for individual stocks in the industry. The results presented in the figure show that the proposed method outperforms the stochastic probability and outperforms the benchmark return by 26.98%.Figure 7
Trading strategy backtest returns. The vertical coordinate is the rate of return, and the horizontal coordinate is the different time distribution (days). (a) Financial category returns. (b) Utilities returns. (c) Real estate returns. (d) General returns. (e) Industrial returns. (f) Commercial returns. (g) Ping An Bank: individual share returns. (h) COSCO returns. (i) Vanke A: individual returns. (j) Shepherd Plains individual returns. (k) China nuclear power individual returns. (l) Yonghui Supermarket returns.
(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)(l)The results presented in Table6 indicate that the proposed method has good predictive performance for abnormally large stock fluctuations. The outbreak of the novel coronavirus in 2020, the unprecedented panic, and the subsequent economic recovery after the epidemic were under control, which brought about large fluctuations in the stock market. This paper uses multiple attention graph neural networks to predict stocks using graph data with candlestick financial characteristics, efficiently capturing the sudden negative investor sentiment and stopping losses in time, which plays a good risk prevention and control effect and achieves a good quantitative investment return during the backtest period. In Figure 7(e) industrial stocks have a large data sample and there are substantial fluctuations in industrial due to the epidemic during 2020. The strategy return of this category of stocks is 68.22% higher than the benchmark return, which is the highest strategy return among all quantitative investment groups. (i) COSCO China Holdings stock has a relatively small training sample of public utility stocks, and the overall price of this stock shows an upward trend, the strategy return is only 7.79% higher than the basic return, and it is the lowest strategy return among the quantitative investment groups compared to the benchmark return. Table 6 provides a strategy overview of quantitative investment. From the perspective of systematic risk, the average Alpha is 0.22 and the average Beta is 0.95, and the systematic risk is greater than the nonsystematic risk. The average Sharpe ratio is 0.95 and the average Sortino ratio is 1.23, indicating that each downside risk can come with a greater excess return. The average information ratio is 1.12, indicating that excess risk brings more excess return than average risk. The average maximum retracement of the strategy is 23.79%, achieving a smooth investment return in the face of the novel coronavirus outbreak. The overall overview of the investment strategy shows that the proposed method in this paper obtains better prediction and quantitative investment results, and it can also provide more accurate systemic risk warning to market regulators.Table 6
Overview of backtested returns of trading strategies.
StocksBenchmark return (%)Strategy return (%)AlphaBetaSharpeSortinoInformationMaximum (%)Financial−12.482.190.371.3080.7611.0221.82128.29Utilities−22.706.110.0491.0340.4060.5150.35433.58Real estate−18.290.180.0861.0460.520.6850.67325.31Combined−7.7227.790.0240.2820.2860.5060.53118.61Industrial8.0676.280.1870.3860.5260.5530.19514.26Commercial−12.699.300.2321.2090.5780.7851.61324.73Ping An18.5539.720.2521.2021.3722.0231.0428.90COSCO93.85101.640.4850.9391.2681.7351.97923.05Vanke A−7.9931.350.0960.9672.7183.0991.13721.64Makara44.8963.390.561.0741.6541.8641.86319.11CNNC−1.2717.720.0360.7580.2410.3570.59127.30Yong Hui−2.0928.690.2951.1391.091.6531.6820.73


## 4.1. Experiment Introduction

The experimental data are selected from January 1, 2016, to December 31, 2020, for the CSI 300 index components. 292500 trading days closing prices of 300 stocks between January 1, 2016, and December 31, 2019, are used as the training validation dataset, and 72900 trading days of 300 stocks between January 1, 2020, and December 31, 2020, are used as the test dataset (link:https://pan.baidu.com/s/17_WbIrJtwiiIIZ6zNHaIgw,password:ornr). Because the CSI 300 index constituents have an update mechanism, in order to ensure the continuity of model training, this paper updates the CSI 300 constituents on January 1 every year and divides them into six industries: finance, public utilities, real estate, composite, industrial, and commercial according to the industry classification rules in the CMSAR database. The individual stock samples were selected from Ping An Bank, COSCO, Vanke A, Shepherd Field, China Nuclear Power, and Yonghui Supermarket, which belong to finance, public utilities, real estate, composite, industrial, and commercial and were labeled in four categories using the closing price increase and decrease compared with the previous trading day and the closing price increase and decrease compared with the previous trading day. Y represents the rise and fall values, in accordance with the four categories of labels Y ≤ −5%, −5% < Y < 0, 0 ≤ Y < 5%, 5% ≤ Y for the candlestick charts are constructed and labeled. Strategy backtesting experiments in accordance with the model classification predict the closing price compared to the previous trading day up and down, generating stock market buying and selling trading signals and the corresponding quantitative investment operations; investment return overview mainly includes Sharpe ratio, maximum retracement value, and other investment return evaluation index data. The experimental running environment is done on Intel Xeon 4210R 2.4 GHz 12C (core) 64G RDIMM memory server, and the software environment is Python 3.6.1. GPU : NVIDIA Tesla 16G, computing platform using CUDA 10.2.


## 4.2. Experimental Results

The single-day candlestick node features are obtained from the trading data, while the key to the extraction of the combined candlestick features lies in the single-day candlestick positioning and contour minimum matrix labeling, based on which the center coordinates are calculated; the experiment achieved good experimental results as shown in Figure4. The contours were accurately labeled and the accurate center coordinate values of the labeled single-day candlestick contours were extracted.Figure 4
Single-day candlestick positioning and matrix labeling. The vertical coordinate is the stock prices, and the horizontal coordinate is the different time distribution (trading day).The graphical quantification of the stock market is followed by an embedding operation to build a graphical indicator graph data, which represents the single-day candlestick characteristics in the form of nodes and features. The adjacent single-day candlesticks create edges to represent the time series correlation, and the weights of the edges are quantified by the above single-day candlestick positioning and matrix labeling method to extract the position information of the candlestick combinations and fully interpret the sequence combination pattern of candlesticks. This type of graph data analysis and forecasting processing allows for a more accurate reflection of stock market price fluctuations as it contains sufficient graphical indicator information elements. Following the graph embedding method described in 3.2.2 for candlestick embedding expression, the structural characteristics of the graph data effectively enhance the efficiency of data analysis and processing, and the visualization of the constructed candlestick graph data is shown in Figure5.Figure 5
Stock market graphical indicator chart data. The vertical and the horizontal coordinate are the same as Figure4. The difference is that the value is quantified for relative positions.In this paper, the baseline model is selected mainly from three different ways of candlestick processing and analysis: based on image recognition techniques CNN1 [41] and RNN [42], based on structured data processing and analysis methods LSTM [43] and SVM [44], and based on graphical indicators embedding methods CNN2 [45] and CNN-LSTM [46]. The first class of methods mainly uses image processing intelligent algorithms to extract the feature information contained in graphical indicators through their image features and train models for stock market price fluctuation prediction. The second type of method uses the trading data to determine the pattern of the graphical indicator to which it belongs and then judges the subsequent stock market price fluctuations based on the pattern to which it belongs. The third method is to convert the feature information contained in the graphical indicators of the securities market into transaction data in the form of tensors. Compared with the graphical indicators in this paper, the transaction volume information is increased. CNN and LSTM are used for feature extraction and aggregation. Complete the forecast of price fluctuations in the securities market. This kind of method innovates the quantitative and embedding method combined with the graphical indicators of the securities market. The parameter settings of the baseline model used in this paper are shown in Table 3.Table 3
Model parameter settings.
MethodParametersCNN1Kernel_size = (3, 3); strides = (2, 2); dropout = 0.25; lr = 0.0001CNN2Input_layer-lisset = (5, 5); convolutional_filter = (3, 3)RNNnn.LSTM (num_layers = 2); lr = 0.0001LSTMrnn_unit = 10; lstm_layers = 1; lr = 0.0006SVMC = 0.8; kernel = liner; max_iter = 1000CNN-LSTMConvolutional_filter = (3, 3); max_pooling = (2, 2)Table4 shows the prediction results of the six classification models. Compared with the first type of image-based recognition methods, the method in this paper has 29.17% and 13.33% higher accuracy in predicting price fluctuations less than or equal to 5% and greater than 5%, respectively. Compared with the second type of structured data-based methods, they are 28.17% and 12.5% higher, respectively. Compared with the prediction based on the third innovative embedding method, the accuracy is 35.33% and 16.75% higher, respectively. The method proposed in this paper exhibits the best prediction performance. The proposed method has a lower prediction accuracy for trading days with closing price volatility greater than or equal to 5% compared to trading days with closing price volatility less than 5% in the financial, public utilities, real estate, and general industries. Industrial and commercial show the opposite result, with a higher accuracy rate for predicting closing price volatility greater than or equal to 5% for T + 1 trading days than for trading days with less than 5% volatility. Among the stocks belonging to various industries, Ping An Bank, COSCO, Vanke A, and Shepherd Field, which belong to the finance, public utilities, real estate, and general industries, also show the performance advantage of this paper’s model for predicting the accuracy of small-amplitude volatility. For stocks belonging to industrial and commercial sectors, China Nuclear Power and Yonghui Supermarket, the method proposed in this paper has more advantages for predicting large fluctuations. On the other hand, for the trading data of the test time period, there were only 2 and 8 trading days with closing price fluctuations greater than or equal to 5% for China Nuclear Power and Yonghui Supermarket, respectively, and the accuracy of the prediction for large fluctuations presented in this paper needs further verification.Table 4
Accuracy of the four categories of the algorithm presented.
StocksCNN1CNN2RNNLSTMSVMCNN-LSTMOur method≥5%<5%≥5%<5%≥5%<5%≥5%<5%≥5%<5%≥5%<5%≥5%<5%Finance28.12 ± 0.2343.65 ± 0.6331.51 ± 0.3346.73 ± 0.8233.85 ± 0.3755.13 ± 0.8331.65 ± 0.2855.19 ± 0.9528.83 ± 0.1944.72 ± 0.5335.36 ± 0.7346.65 ± 0.9335.76∗ ± 0.6363.53∗ ± 0.23Public sector17.26 ± 0.1641.56 ± 0.7826.43 ± 0.8753.34 ± 0.1117.12 ± 0.8963.34 ± 0.3722.56 ± 02354.34 ± 0.2320.76 ± 0.7251.32 ± 0.4332.56∗ ± 0.7853.21 ± 0.8030.54 ± 0.3767.14∗ ± 0.21Real estate18.87 ± 0.8741.87 ± 0.9623.45 ± 0.3447.21 ± 0.3420.89 ± 0.8347.65 ± 0.2616.34 ± 0.6152.12 ± 0.2823.78 ± 0.7340.14 ± 0.4627.34∗ ± 0.6347.19 ± 0.7621.16 ± 0.6558.67∗ ± 0.23Composite31.56 ± 1.3843.78 ± 0.3421.23 ± 0.8737.34 ± 0.1535.31 ± 0.7654.18 ± 0.5636.78 ± 0.7148.45 ± 0.3622.12 ± 0.8747.27 ± 0.5221.31 ± 0.5437.54 ± 0.5636.52∗ ± 0.4166.54∗ ± 0.27Industrial25.71 ± 0.8447.56 ± 1.1623.87 ± 1.1451.34 ± 0.2626.15 ± 0.8663.45 ± 0.4760.75 ± 0.6562.45 ± 0.4123.41 ± 0.6551.71 ± 0.3723.69 ± 0.7451.26 ± 0.2381.67∗ ± 0.3065.17∗ ± 0.31Commercial19.15 ± 1.2151.34 ± 0.6316.98 ± 0.7143.45 ± 0.2571.52 ± 0.5659.64 ± 0.5257.91 ± 0.4351.56 ± 0.1717.81 ± 0.5448.23 ± 0.8717.12 ± 0.6443.24 ± 0.4581.56∗ ± 0.3463.41∗ ± 0.27Ping An Bank40.62 ± 0.3436.34 ± 0.9526.78 ± 0.4642.12 ± 0.4520.56 ± 0.9440.12 ± 0.6160.43 ± 0.7336.89 ± 0.5640.34 ± 0.6139.56 ± 0.6727.35 ± 1.5342.13 ± 0.3079.12∗ ± 0.2853.41∗ ± 0.15COSCO Sea Control32.45 ± 0.8144.34 ± 0.7637.34 ± 0.5640.34 ± 0.1650.41 ± 0.9546.45 ± 0.6936.87 ± 0.5652.16 ± 0.8123.19 ± 0.7340.34 ± 0.3436.73 ± 0.7440.18 ± 0.5659.67∗ ± 0.6566.34∗ ± 0.19Vanke A32.56 ± 1.2350.34 ± 0.2828.56 ± 0.6738.34 ± 0.4550.45 ± 1.1348.19 ± 0.7317.73 ± 0.6955.19 ± 0.8532.56 ± 0.6554.32 ± 0.4526.54 ± 0.8138.40 ± 0.5665.89∗ ± 0.4357.34∗ ± 0.13Makara32.18 ± 0.7544.23 ± 0.6946.89 ± 0.9146.34 ± 0.7147.14 ± 0.9642.21 ± 0.7458.65 ± 0.7850.64 ± 0.9142.57 ± 0.7146.17 ± 0.3243.27 ± 0.5446.84 ± 0.2362.87∗ ± 0.4361.56∗ ± 0.31China Nuclear Power48.33 ± 0.3945.78 ± 0.5631.67 ± 0.3152.45 ± 0.1536.67% ± 0.3352.43 ± 1.5651.67 ± 0.3348.54 ± 0.6225.00 ± 0.3535.67 ± 0.5650.00 ± 0.3640.43 ± 0.6466.67∗ ± 0.3465.56∗ ± 0.27Yong Hui38.75 ± 0.7643.62 ± 0.7123.89 ± 0.8441.23 ± 0.5325.23% ± 1.1250.29 ± 0.9613.45 ± 0.6254.51 ± 0.5450.56 ± 0.9146.18 ± 0.5423.35 ± 1.3442.16 ± 0.4575.42∗ ± 0.3158.34∗ ± 0.56Each reported result is the average performance on ten training process, followed by their standard deviation. The best result (in bold) is further marked with∗, if it is significantly different from the runner-up (underlined) under the two-tail paired t-test at the 0.01 level.After comparing the accuracy, the running time of the models is compared on this basis and the results are shown in Table5 and Figure 6. In particular, Table 5 presents the average training and test running times for the algorithms involved in this study. Figure 6 further compares the execution time in terms of individual stock. To show the comparison of the running results more clearly and intuitively, the models with better prediction performance, including RNN, LSTM, and CNN-LSTM, are used for this comparison. The compared running time results are shown in Figure 6.Table 5
Execution time of different algorithms.
StocksCNN1CNN2RNNLSTMSVMCNN-LSTMOur methodTrainTestTrainTestTrainTestTrainTestTrainTestTrainTestTrainTestExecution time41567.593426.3037319.363061.8045681.723645.0043628.813193.0235637.072843.1063617.633112.8335314.572551.50Figure 6
Execution time of different algorithms.In Table5, the predicted execution time of each model is shown, respectively. The above results show that the method proposed in this paper greatly reduces the training cost of the model and shortens the prediction running time of the model because the graphical indicators are quantified into structured data. Figure 6 shows the comparison more intuitively, and the smooth line trend shows that the method proposed in this paper has better operation stability. The model proposed in this paper has better processing ability and efficient information mining ability for large-scale stock market graphical indicator data. In high-frequency trading applications, it is more advantageous for the processing of graphic indicators of the stock market at the hour, minute, and second level.


## 4.3. Strategy Backtesting

The prediction results presented in Table4 show that the method proposed in this study has good prediction performance. These obtained predicted results of stock market rise and fall can further form buy and sell signals. Specifically, consecutive identical prediction results do not generate trading signals, and buy or sell operations are only performed when reversals of the rise or fall occur. Therefore, stochastic trading returns and fundamental returns are introduced in this study to compare with the returns of the investment strategies formed by the proposed model.The green line in Figure7 indicates the investment returns of individual stocks and stock portfolios of this paper’s model strategy, the yellow line indicates the benchmark returns, and the green line indicates the returns of the stochastic strategy; the stochastic strategy is to randomly generate information on the rise and fall of stocks 0 and 1, to complete the investment behavior according to this information, to complete the buying and selling operation when the information on the rise and fall changes, and to not generate the investment behavior when the information does not change, and Figures 7(a)–7(f) in Figure 7 are the corresponding average return results of the stock portfolio within the industry. Figures 7(g)–7(l) are the results for individual stocks in the industry. The results presented in the figure show that the proposed method outperforms the stochastic probability and outperforms the benchmark return by 26.98%.Figure 7
Trading strategy backtest returns. The vertical coordinate is the rate of return, and the horizontal coordinate is the different time distribution (days). (a) Financial category returns. (b) Utilities returns. (c) Real estate returns. (d) General returns. (e) Industrial returns. (f) Commercial returns. (g) Ping An Bank: individual share returns. (h) COSCO returns. (i) Vanke A: individual returns. (j) Shepherd Plains individual returns. (k) China nuclear power individual returns. (l) Yonghui Supermarket returns.
(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)(l)The results presented in Table6 indicate that the proposed method has good predictive performance for abnormally large stock fluctuations. The outbreak of the novel coronavirus in 2020, the unprecedented panic, and the subsequent economic recovery after the epidemic were under control, which brought about large fluctuations in the stock market. This paper uses multiple attention graph neural networks to predict stocks using graph data with candlestick financial characteristics, efficiently capturing the sudden negative investor sentiment and stopping losses in time, which plays a good risk prevention and control effect and achieves a good quantitative investment return during the backtest period. In Figure 7(e) industrial stocks have a large data sample and there are substantial fluctuations in industrial due to the epidemic during 2020. The strategy return of this category of stocks is 68.22% higher than the benchmark return, which is the highest strategy return among all quantitative investment groups. (i) COSCO China Holdings stock has a relatively small training sample of public utility stocks, and the overall price of this stock shows an upward trend, the strategy return is only 7.79% higher than the basic return, and it is the lowest strategy return among the quantitative investment groups compared to the benchmark return. Table 6 provides a strategy overview of quantitative investment. From the perspective of systematic risk, the average Alpha is 0.22 and the average Beta is 0.95, and the systematic risk is greater than the nonsystematic risk. The average Sharpe ratio is 0.95 and the average Sortino ratio is 1.23, indicating that each downside risk can come with a greater excess return. The average information ratio is 1.12, indicating that excess risk brings more excess return than average risk. The average maximum retracement of the strategy is 23.79%, achieving a smooth investment return in the face of the novel coronavirus outbreak. The overall overview of the investment strategy shows that the proposed method in this paper obtains better prediction and quantitative investment results, and it can also provide more accurate systemic risk warning to market regulators.Table 6
Overview of backtested returns of trading strategies.
StocksBenchmark return (%)Strategy return (%)AlphaBetaSharpeSortinoInformationMaximum (%)Financial−12.482.190.371.3080.7611.0221.82128.29Utilities−22.706.110.0491.0340.4060.5150.35433.58Real estate−18.290.180.0861.0460.520.6850.67325.31Combined−7.7227.790.0240.2820.2860.5060.53118.61Industrial8.0676.280.1870.3860.5260.5530.19514.26Commercial−12.699.300.2321.2090.5780.7851.61324.73Ping An18.5539.720.2521.2021.3722.0231.0428.90COSCO93.85101.640.4850.9391.2681.7351.97923.05Vanke A−7.9931.350.0960.9672.7183.0991.13721.64Makara44.8963.390.561.0741.6541.8641.86319.11CNNC−1.2717.720.0360.7580.2410.3570.59127.30Yong Hui−2.0928.690.2951.1391.091.6531.6820.73


## 5. Summary and Outlook

In this paper, we propose a multiattention-based graph neural network approach for stock market volatility prediction. The stock market candlestick is studied, the candlestick is represented by graph embedding, the single-day and combined candlestick features are fully extracted, and the stock market volatility prediction is accomplished by using multiple attention graph neural networks. The prediction method proposed in this paper effectively improves the prediction accuracy and achieves better quantitative investment returns, but there are numerous factors affecting stock market price volatility. We will consider adding news texts, trading index data and other factors to expand and improve the current study in the next step. The hyperparameters in the model will be continuously tuned so that the model can be applied to the early warning monitoring of abnormal stock market price fluctuations and generalized to the prediction of other financial products.



---

*Source: 4743643-2022-09-13.xml*