CN113807964A - Method, equipment and storage medium for predicting stock price and determining parameters - Google Patents

Method, equipment and storage medium for predicting stock price and determining parameters Download PDF

Info

Publication number
CN113807964A
CN113807964A CN202111088196.0A CN202111088196A CN113807964A CN 113807964 A CN113807964 A CN 113807964A CN 202111088196 A CN202111088196 A CN 202111088196A CN 113807964 A CN113807964 A CN 113807964A
Authority
CN
China
Prior art keywords
stock price
date
historical
input sequence
sequence
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202111088196.0A
Other languages
Chinese (zh)
Inventor
陈炜
邱月
姜鳗芮
陈振松
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Individual
Original Assignee
Individual
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Individual filed Critical Individual
Priority to CN202111088196.0A priority Critical patent/CN113807964A/en
Publication of CN113807964A publication Critical patent/CN113807964A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q40/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/04Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/044Recurrent networks, e.g. Hopfield networks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/045Combinations of networks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • G06N3/084Backpropagation, e.g. using gradient descent
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q10/00Administration; Management
    • G06Q10/04Forecasting or optimisation specially adapted for administrative or management purposes, e.g. linear programming or "cutting stock problem"

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Business, Economics & Management (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Economics (AREA)
  • Computational Linguistics (AREA)
  • Data Mining & Analysis (AREA)
  • Evolutionary Computation (AREA)
  • General Health & Medical Sciences (AREA)
  • Molecular Biology (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Biomedical Technology (AREA)
  • Mathematical Physics (AREA)
  • Artificial Intelligence (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Health & Medical Sciences (AREA)
  • Strategic Management (AREA)
  • Biophysics (AREA)
  • General Business, Economics & Management (AREA)
  • Human Resources & Organizations (AREA)
  • Development Economics (AREA)
  • Finance (AREA)
  • Marketing (AREA)
  • Accounting & Taxation (AREA)
  • Entrepreneurship & Innovation (AREA)
  • Tourism & Hospitality (AREA)
  • Quality & Reliability (AREA)
  • Operations Research (AREA)
  • Game Theory and Decision Science (AREA)
  • Technology Law (AREA)
  • Financial Or Insurance-Related Operations Such As Payment And Settlement (AREA)

Abstract

The present disclosure relates to a method, apparatus, and storage medium for predicting a stock price and determining a parameter, wherein the method of predicting a stock price includes: acquiring a historical stock price time sequence before a target date; processing the historical stock price time sequence by a preset sliding time window to obtain N historical stock price sequences corresponding to N intermediate dates; carrying out variation modal decomposition on the historical stock price sequence corresponding to each intermediate date; determining a first input sequence from the decomposed sequence; determining a second input sequence using the historical stock price time sequence; taking the first input sequence and the second input sequence as input, and outputting a predicted stock price corresponding to the intermediate date by using an ELM model; and weighting the N-period predicted stock prices corresponding to the N intermediate dates according to a weight coefficient predetermined by a harmony search method to obtain the predicted stock prices of the target date. The parameter determination method determines a weight coefficient. By the method, the accuracy of stock price prediction is improved.

Description

Method, equipment and storage medium for predicting stock price and determining parameters
Technical Field
The present disclosure relates to the field of computers, and more particularly, to a method, apparatus, and storage medium for predicting a stock price and determining a parameter.
Background
Stock market forecasting has been one of the research hotspots in the financial field, and has been receiving much attention in recent years. Since stock prices exhibit dynamic, nonlinear, non-parametric, and chaotic properties, accurately predicting stock prices is a very difficult and challenging task.
Disclosure of Invention
To solve the above technical problems or to at least partially solve the above technical problems, the present disclosure provides a method, apparatus, and storage medium for predicting a stock price and determining a parameter.
In a first aspect, the present disclosure provides a method of predicting a stock price, comprising: acquiring a historical stock price time sequence before a target date; processing the historical stock price time sequence by a preset sliding time window to obtain N historical stock price sequences corresponding to N intermediate dates; for each of the N intermediate dates: performing variation modal decomposition on the historical stock price sequence corresponding to the intermediate date to obtain K decomposition sequences; determining a first input sequence according to the K decomposition sequences, wherein the first input sequence represents the stock price characteristic of the intermediate date; determining a second input sequence using the historical stock price time sequence, the second input sequence representing a stock price trend prior to the intermediate date; and taking the first input sequence and the second input sequence as input, and outputting the predicted stock price corresponding to the intermediate date by using an ELM model; and weighting the N-period predicted stock prices corresponding to the N intermediate dates according to a weight coefficient predetermined by a harmony search method to obtain the predicted stock prices of the target date.
In some embodiments, determining the first input sequence from the K decomposed sequences comprises: and extracting values of positions corresponding to the intermediate dates in each of the K decomposition sequences to form a first input sequence.
In some embodiments, the second input sequence comprises at least one of: historical stock prices for a number of consecutive days before the intermediate date; historical stock prices on dates separated from the intermediate date by one or more preset days; one or more moving averages of historical stock prices for consecutive days prior to the intermediate date.
In a second aspect, the present disclosure provides a method of determining a parameter, comprising: acquiring a historical stock price time sequence of the stock; selecting a plurality of target dates from the historical dates, determining model input corresponding to each target date by taking the actual stock price of the target date as a label for each target date, and outputting N-period predicted stock price corresponding to the target date by using an ELM model; and performing harmony search by taking the error between the predicted stock price on the minimized target date and the actual stock price as a target, and determining a weight coefficient corresponding to the N-period predicted stock price, wherein the predicted stock price on the target date is obtained by weighting the N-period predicted stock price according to the current weight coefficient.
Wherein, determining the model input corresponding to each target date comprises: processing the historical stock price time sequence before the target date by using a preset sliding time window to obtain N historical stock price sequences corresponding to N intermediate dates; for each of the N intermediate dates: performing variation modal decomposition on the historical stock price sequence corresponding to the intermediate date to obtain K decomposition sequences; determining a first input sequence according to the K decomposition sequences, wherein the first input sequence represents the stock price characteristic of the intermediate date; determining a second input sequence using the historical stock price time sequence, the second input sequence representing a stock price trend prior to the intermediate date; and inputting the model corresponding to the intermediate date by taking the first input sequence and the second input sequence as the model corresponding to the intermediate date.
In some embodiments, determining the first input sequence from the K decomposed sequences comprises: and extracting values of positions corresponding to the intermediate dates in each of the K decomposition sequences to form a first input sequence.
In some embodiments, the second input sequence comprises at least one of: historical stock prices for a number of consecutive days before the intermediate date; historical stock prices on dates separated from the intermediate date by one or more preset days; one or more moving averages of historical stock prices for consecutive days prior to the intermediate date.
In some embodiments, the error is an average absolute percentage error.
In a third aspect, the present disclosure provides a computer device comprising: a memory, a processor, and a computer program stored on the memory and executable on the processor; the computer program, when executed by a processor, implements the steps of the method of predicting a stock price provided by the present disclosure.
In a fourth aspect, the present disclosure provides a computer device comprising: a memory, a processor, and a computer program stored on the memory and executable on the processor; the computer program, when being executed by a processor, realizes the steps of the method of determining a parameter provided by the present disclosure.
In a fifth aspect, the present disclosure provides a computer-readable storage medium having stored thereon a program for predicting a stock price, the program for predicting a stock price implementing the steps of the method for predicting a stock price provided by the present disclosure when executed by a processor.
Compared with the related art, the technical scheme provided by the embodiment of the disclosure has the following advantages: according to the method provided by the embodiment of the disclosure, the first-stage prediction is carried out through the ELM model, and then the second-stage prediction is carried out through harmony searching for the predetermined weight coefficient, so that the accuracy rate of stock price prediction is improved. Moreover, compared with a single model, the prediction result is more stable.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and together with the description, serve to explain the principles of the disclosure.
In order to more clearly illustrate the embodiments or technical solutions in the prior art of the present disclosure, the drawings used in the description of the embodiments or prior art will be briefly described below, and it is obvious for those skilled in the art that other drawings can be obtained according to the drawings without inventive exercise.
FIG. 1 is a flow chart of one embodiment of a method for predicting a stock price provided in accordance with an embodiment of the present disclosure;
FIG. 2 is a flowchart of one implementation of a method for determining parameters according to an embodiment of the present disclosure;
FIG. 3 is a flowchart of one embodiment of a method for determining model inputs corresponding to each target date according to an embodiment of the present disclosure;
FIG. 4 is a schematic diagram of a two-stage prediction method provided by an embodiment of the present disclosure;
fig. 5 is a schematic diagram of a first stage VMD provided by an embodiment of the disclosure;
FIG. 6 is a schematic diagram of first stage prediction provided by embodiments of the present disclosure;
FIG. 7 is a schematic diagram of an improved harmonic search method provided by embodiments of the present disclosure;
FIG. 8 is pseudo code for generating a new harmony in an improved harmony search method provided by embodiments of the present disclosure;
FIG. 9 is pseudo code of mutation and crossover operations in the improved sum-search method provided by embodiments of the present disclosure;
FIG. 10 is a schematic diagram of a two-stage model provided by an embodiment of the present disclosure;
FIG. 11 is a schematic block diagram illustrating one embodiment of a system according to the present disclosure;
fig. 12 is a hardware schematic diagram of an implementation manner of a computer device according to an embodiment of the present disclosure.
Detailed Description
It should be understood that the specific embodiments described herein are merely illustrative of the disclosure and are not intended to limit the disclosure.
In the following description, suffixes such as "module", "component", or "unit" used to denote elements are used only for the convenience of explanation of the present disclosure, and have no specific meaning in themselves. Thus, "module", "component" or "unit" may be used mixedly.
Heretofore, many conventional time series models have been applied to stock market prediction, including autoregressive moving average (ARMA), autoregressive integrated moving average (ARIMA), smooth transition autoregressive model (STAR), generalized autoregressive conditional variance (GARCH), and the like. In order to better ground-to-noise environments, more and more researchers have applied artificial intelligence techniques to stock market forecasting in recent years. For example, Yeh et al developed a multi-kernel Support Vector Regression (SVR) method to predict stock prices. Liu et al designed a type-2 fuzzy neural network model for stock price forecasting. TiCknor proposes a stock index stock price prediction model based on Bayesian network. Laboisiere et al propose an Artificial Neural Network (ANN) to predict the daily maximum minimum stock prices of three distribution companies in brazil. Fischer and Krauss designed a Long Short Term Memory (LSTM) model for financial market forecasting. Zhang et al combines Support Vector Regression (SVR) with firefly algorithm to provide a new method for predicting stock prices.
It is worth noting that using a single artificial intelligence model does not always guarantee a high level of accuracy in all situations. Therefore, in order to reduce the randomness of the primary prediction result, the present disclosure provides a method for predicting a stock price, which performs a first-stage prediction through an ELM (Extreme Learning Machine) model and then performs a second-stage prediction through a weight coefficient determined by a harmonic search method, thereby improving the accuracy of stock price prediction.
Fig. 1 is a flowchart illustrating an embodiment of a method for predicting a stock price according to an embodiment of the present disclosure, and as shown in fig. 1, the method includes steps S102 to S114.
Step S102, obtaining the historical stock price time sequence before the target date.
In the disclosed embodiment, the target date may be the next date to the current date. The historical stock price time series includes a daily closing price for a period of time prior to the target date. Illustratively, the closing prices of the day are collected and recorded every day, forming a historical stock price time series.
In the disclosed embodiment, the historical stock prices in the historical stock price time series are ordered, i.e., the stock prices have changed over time over a period of time in the past.
In some examples, the historical stock price time series is stored in a database, from which the historical stock price time series before the target date is read. The database can be a local database or a remote database, and the remote database can be accessed through a network to obtain data from the remote database.
For example, where the target date is "tomorrow," the historical stock price time series may include daily closing prices from "today" to some time in the past, e.g., a month in the past from the present day.
And step S104, processing the historical stock price time sequence by a preset sliding time window to obtain N historical stock price sequences corresponding to N intermediate dates.
In the embodiment of the present disclosure, the parameters of the preset sliding time window include the size of the sliding window and the step size of the sliding window. In the disclosed embodiment, the size of the sliding window can be set according to the need, for example, the size of the sliding window is set to 7, and a stock price of 7 days is contained in one sliding window. The step size of the sliding window can be set as needed, and in the embodiment of the present disclosure, the step size can be set to 1.
In the disclosed embodiment, the intermediate date is the date closest to the target date after each swipe.
Preferably, the N intermediate dates are consecutive N dates, for example, the target date is 9 months and 10 days, at which time, the 9 intermediate dates may be determined to be 9 months and 1 days to 9 months and 9 days, but not limited thereto. In the disclosed embodiment, the N dates may be transaction days only.
The example is given by taking the size of the sliding window as 7, the step size of the sliding window as 1, N as 4, and the target date as 9 months and 30 days. In this example, with PiThe stock price indicating date i, and the historical stock price sequence corresponding to the intermediate date and the intermediate date are shown in table 1.
TABLE 1 intermediate date and historical stock sequence example
Intermediate date Historical stock price sequence
9 month and 29 days P9-29、P9-28、P9-27、P9-26、P9-25、P9-24P 9-23
9 month and 28 days P9-28、P9-27、P9-26、P9-25、P9-24、P9-23P 9-22
9 month and 27 days P9-27、P9-26、P9-25、P9-24、P9-23、P9-22P 9-21
9 month and 26 days P9-26、P9-25、P9-24、P9-23、P9-22、P9-21、P9-20
As shown in table 1, in this example, the target date is 9 months and 30 days, and the intermediate dates include 9 months and 29 days, 9 months and 28 days, 9 months and 27 days, and 9 months and 26 days. The historical stock price sequence corresponding to the 9-month 29-day is the historical stock price from the 9-month 29-day to the 9-month 23-day, and so on, and each intermediate date comprises the historical stock price of the 7-day internal date.
It should be understood that this example is merely illustrative and not limiting of the size of the sliding window, the step size of the sliding window, and the values of N, etc.
The processing of step S106 to step S112 is performed for each of the N intermediate dates.
Step S106, performs Variational Mode Decomposition (VMD) on the historical stock price sequence corresponding to the intermediate date to obtain K decomposition sequences.
The VMD performs feature selection to improve accuracy. The VMD decomposes an original sample sequence into a plurality of subsequences having different center frequencies, which are referred to as decomposed sequences in the embodiments of the present disclosure. The VMD process may refer to a known technology, which is not described in detail in this disclosure.
And step S108, determining a first input sequence according to the K decomposition sequences, wherein the first input sequence represents the stock price characteristic of the intermediate date.
In some examples, extracting values for positions within each of the K decomposition sequences corresponding to intermediate dates constitutes a first input sequence. Illustratively, referring to table 1, the intermediate date is the last element of the historical stock price sequence, the order of the elements in the decomposition sequence corresponds to the elements of the historical stock price sequence one by one, and the last element in each decomposition sequence is selected to form the first input sequence. The historical stock price sequence for each intermediate date includes K decomposition sequences, at which time the first input sequence includes K elements.
Step S110, a second input sequence is determined using the historical stock price time sequence, the second input sequence representing a stock price trend before the intermediate date.
In some examples, the second input sequence includes historical stock prices for a number of consecutive days before the intermediate date. In this example, the historical stock prices for consecutive days before the intermediate date reflect a recent continuous trend in stock prices. For example, the second input sequence may include historical stock prices for 10 days from the day before the intermediate date, and for example, for the intermediate date of 9 months and 29 days, the second input sequence may include historical stock prices for 9 months and 28 days to 9 months and 19 days.
In some examples, the second input sequence includes historical stock prices for dates separated from the intermediate date by one or more preset days. In this example, the days at different intervals may represent the medium-and long-term trends in stock prices. Illustratively, the second input sequence may include historical stock prices 15 days, 20 days, 30 days from the intermediate date, and for example, the intermediate date is 9 months and 29 days, the second input sequence may include historical stock prices of 9 months and 14 days, 9 months and 9 days, and 8 months and 30 days.
In some examples, the second input sequence includes one or more moving averages of historical stock prices for consecutive days prior to the intermediate date. In this example, a running average of consecutive days may represent a short-term trend in stock prices. Exemplary, include a moving average of 15 days, 20 days, 30 days.
In some examples, the second input sequence may be a combination of the above examples, e.g., the second input sequence includes: historical stock prices for a number of consecutive days before the intermediate date, historical stock prices for a date spaced from the intermediate date by one or more preset days, and one or more moving averages of the historical stock prices for a number of consecutive days before the intermediate date.
And step S112, taking the first input sequence and the second input sequence as input, and outputting the predicted stock price corresponding to the intermediate date by using an ELM model.
ELM is a non-iterative training method for single hidden layer feedforward neural networks. The ELM model differs from other artificial intelligence models in that it does not require any iterative learning to adjust the unknown weights of the single hidden layer feedforward neural network. But the weight value of the connection output layer and the weight value of the hidden layer are analyzed and solved by randomly selecting the unknown weight value. Therefore, from the viewpoint of learning efficiency, the ELM model has three features: minimum manual setting, higher learning precision and faster learning speed.
In the embodiment of the present disclosure, for example, the number of input layer elements of the ELM model is the same as the sum of the numbers of elements of the first and second input sequences, for example, the first and second input sequences include M elements in total, and in this case, the input layer of the ELM model may include M elements.
In the embodiment of the present disclosure, each intermediate date may determine to obtain one predicted stock price, N intermediate dates may obtain N predicted stock prices, which are also referred to as N-period predicted stock prices in the present disclosure, and each period represents a predicted stock price corresponding to the historical stock price sequence at a corresponding interval from the target date.
In connection with the foregoing example (table 1), N (in this example, N is 4) predicted stock prices for the intermediate dates are shown in table 2.
TABLE 2 predicted stock price examples for intermediate dates
Intermediate date Predicting stock prices
9 month and 29 days P 9-29,t
9 month and 28 days P 9-28,t
9 month and 27 days P 9-27,t
9 month and 26 days P9-26,t
As shown in Table 2, P9-29,tThe predicted stock price of the target date t corresponding to the intermediate date of 9 months and 29 days is shown, and so on, P9-28,t、P9-27,t、P9-26,tThe predicted stock prices on the target dates t corresponding to the intermediate dates 9 month 28, 9 month 27 and 9 month 26 are shown, respectively.
Step S114, according to the weight coefficient predetermined by the harmony search method, weighting the N-period predicted stock price corresponding to the N intermediate dates to obtain the predicted stock price of the target date.
In the embodiment of the disclosure, the metaheuristic optimization artificial intelligence model is utilized to improve the prediction performance. Harmony Search (HS) is a meta-heuristic algorithm, proposed by Geem. In the embodiment of the present disclosure, known harmony search methods, including an improved harmony search method, may be adopted, for example, Alatas introduces 6 chaos maps for HS to generate new harmony, Zou, etc. improves the generation step of harmony in the harmony search algorithm based on the genetic mutation operator optimized by particle swarm, and Keshtegar, etc. proposes a new distance adjustment scheme based on dynamic bw. The embodiment of the disclosure provides an improved harmony search method, which is referred to in the following description of the disclosure.
In the embodiment of the present disclosure, the weight coefficient is determined in advance by the harmony search method. The weighting factor has a correspondence with an intermediate date, illustratively, t is a target date, Pt-nIndicates the predicted stock price, theta, corresponding to the intermediate date t-nnRepresenting the weighting factor corresponding to the intermediate date t-N, N being taken from 1 to N. Taking the step size of the sliding window as 1 as an example, Pt-1Representing the predicted stock price, P, of the day preceding the target date t as an intermediate datet-2Represents predicted stock price 2 days before target date t as intermediate date, and so on, theta1And representing the corresponding weight coefficient of the day before the target date t, and so on. The correspondence is shown in table 3.
TABLE 3 weight coefficient corresponding relation table
Predicted stock price on intermediate date Weight coefficient
Pt-1 θ1
··· ···
Pt-N θN
According to the method provided by the embodiment of the disclosure, the first-stage prediction is carried out through the ELM model, and then the second-stage prediction is carried out through harmony searching for the predetermined weight coefficient, so that the accuracy of stock price prediction is improved, and a strong support is provided for investors to make decisions.
The two-stage integrated learning stock price prediction model constructed by the embodiment of the disclosure is superior to the traditional time series model and the stock price prediction model based on machine learning in prediction accuracy. Moreover, compared with a single model, the model built by the embodiment of the disclosure has more stable prediction results.
The embodiment of the present disclosure further provides a method for determining a parameter, which is used to determine the aforementioned weight coefficient of the present disclosure.
Fig. 2 is a flowchart of an implementation manner of a method for determining a parameter according to an embodiment of the present disclosure, and as shown in fig. 2, the method includes steps S202 to S210.
Step S202, obtaining the historical stock price time sequence of the stock.
In the disclosed embodiment, a historical stock price time series is obtained over a period of time. The historical stock price time series can be referred to the previous description of the disclosure, and is not described in detail herein.
In step S204, a plurality of target dates are selected from the history dates.
In the disclosed embodiment, the historical date is the corresponding date in the historical stock price time series, for example, the historical stock price time series is the stock price between 9 months 20 days and 7 months 20 days, and at this time, the historical date is 9 months 20 days to 7 months 20. A plurality of target dates are selected from the historical dates, and the number of the target dates can be set according to needs.
For each target date, the processing of steps S206 to S208 is performed to determine the N-period predicted stock price corresponding to each target date. The predicted stock price of the target date can be determined by the predicted stock price of the N period and the weighting coefficient, and the weighting coefficient is iterated according to the error between the predicted stock price and the actual stock price.
In step S206, the actual stock price on the target date is used as the label.
In the disclosed embodiment, each target date has an actual stock price (recorded in the historical stock price time series).
And S208, determining model input corresponding to each target date, and outputting the N-period predicted stock price corresponding to the target date by using an ELM model.
In an embodiment of the present disclosure, each target date includes N intermediate dates, each intermediate date has a corresponding model input, the model input corresponding to each target date is the model input of the N intermediate dates, and the determination of the model input is shown in subsequent fig. 3 of the present disclosure.
Step S210, the sound mixing search is carried out by taking the error between the predicted stock price and the actual stock price on the minimum target date as a target, and the weight coefficient corresponding to the predicted stock price in the N period is determined.
In the embodiment of the present disclosure, the predicted stock price of the target date is obtained by weighting the predicted stock price of the N period according to the current weighting coefficient.
In some examples, the error is an average absolute percentage error, but is not so limited.
Fig. 3 is a flowchart of an implementation manner of a method for determining a model input corresponding to each target date according to an embodiment of the present disclosure, and as shown in fig. 3, the method includes steps S302 to S310.
Step S302, the historical stock price time sequence before the target date is processed by a preset sliding time window, and N historical stock price sequences corresponding to N intermediate dates are obtained.
For each of the N intermediate dates, the processes of step S304 to step S310 are performed to determine the model input corresponding to each intermediate date.
And S304, performing variation modal decomposition on the historical stock price sequence corresponding to the intermediate date to obtain K decomposition sequences.
Step S306, a first input sequence is determined according to the K decomposition sequences, and the first input sequence represents the stock price characteristic of the intermediate date.
In some examples, determining the first input sequence from the K decomposed sequences includes: and extracting values of positions corresponding to the intermediate dates in each of the K decomposition sequences to form a first input sequence.
In step S308, a second input sequence is determined by using the historical stock price time sequence, and the second input sequence represents the stock price trend before the intermediate date.
In some embodiments, the second input sequence comprises at least one of: historical stock prices for a number of consecutive days before the intermediate date; historical stock prices on dates separated from the intermediate date by one or more preset days; one or more moving averages of historical stock prices for consecutive days prior to the intermediate date.
Step S310, the first input sequence and the second input sequence are used as model input corresponding to the intermediate date.
There is one model input per intermediate date, N intermediate dates per target date, and N model inputs per target date, where each model input may determine a predicted share price from the ELM model, and N predicted share prices per target date, also referred to in this disclosure as N-term predicted share prices.
The embodiment of the present disclosure is described below with reference to an improved harmony search method of the embodiment of the present disclosure, which combines the harmony search method with a differential evolution algorithm, thereby solving the problem that the harmony search algorithm is likely to fall into local optimum, and improving the optimization effect of the harmony search algorithm.
Suppose PtThe stock closing price at the time t is shown,
Figure BDA0003266561020000121
represents PtThe final stock price prediction result. The two-phase ensemble learning stock price prediction model is shown in fig. 4. In the first stage, N ∈ N at different N+Next, the VMD-ELM model is used to pair PtPerforming preliminary prediction to obtain Pn,tAnd t is more than n. In the second stage, a plurality of selected P are processedn,tBy optimizing these P's using designed harmonic search methodsn,tThe weights of (A) are obtained as final and predicted results
Figure BDA0003266561020000122
Details regarding the first and second stages are given later.
The first stage is as follows: stock price preliminary prediction by VMD-ELM
In the first stage, a VMD-ELM model is adopted to obtain a stock price PtAt different N, N ∈ N+Preliminary prediction result P in case ofn,tAnd t is more than n. That is to say Xt-n={xt-n,1,xt-n,2,...,xt-n,iIs an input with i factors at a time t-n of the VMD-ELM model, and then P is obtainedn,t. Further, by changing the size of n (i.e., the distance from time t), sliding a window of size z and training a training set of size γ, more preliminary prediction results can be obtained, as shown in fig. 5. Of note is Pt-nIs considered to be Xt-nBy preprocessing P by VMDt-nThe effect of feature selection is achieved. The decomposed mode and other standardized indexes are used as input of an ELM model together to obtain a preliminary prediction P of stock closing stock pricen,tAs shown in fig. 6.
And a second stage: applying Improved HS (IHS) integrated preliminary prediction results
The harmony search is a heuristic optimization algorithm based on population, and simulates the adjustment process of musicians on the tone.
Let f (-) be an objective function, X ═ X1,x2,...,xN) Wherein x isiN is a decision or design variable, and in the disclosed embodiment, the term predicts the weight coefficient corresponding to the stock price. For the basic harmony search method, table 4 lists several key parameters. The five key steps of HS are as follows:
(1) initializing an algorithm by specifying parameters;
(2) initialize a set of harmony sounds (HM) and sort to find the worst harmony sound Xworst
(3) Create a new harmony Xnew
(4) If X isnewIs superior to XworstThe HM is updated;
and (5) repeating the step (3) and the step (4) until a termination condition is met.
Key parameters in Table 4 HS
Figure BDA0003266561020000131
However, the basic HS convergence speed is slow and may fall into local optima. Thus, the present disclosure combines the HS algorithm with the DE algorithm (differential evolution algorithm) to propose an Improved Harmonic Search (IHS) algorithm, incorporating two parameters CR and F in DE, representing the crossing rate and scale factor, respectively. The structure is shown in fig. 7, and the main operation steps are as follows.
Initialization operation (Initialization operation).
The objective function f (x) is set and all parameters are predefined, for example: CR, F, HMS, HMCR, PAR, MaxImp, and bw. Then random initialization and sound are as follows:
Figure BDA0003266561020000132
wherein
Figure BDA0003266561020000133
Is a solution vector, f (X)j) Is XjThe objective function value of time. By computing the fitness function (objective function value) we can find the best harmony XbestAnd worst harmony Xworst
Impulse authoring (improvisation).
According to Keshtegar et al, bw can be defined as follows:
Figure BDA0003266561020000134
where Imp represents the number of impromptu creations,
Figure BDA0003266561020000135
and
Figure BDA0003266561020000136
representative sum sound xiUpper and lower bounds. A method of generating a new harmony is provided, as shown in fig. 8, fig. 8 showing pseudo code for the method. Wherein, the rand (L, U) obeys normal distribution and is used to obtain random number from L to U, and the randu(L, U) obeys uniform distribution for obtaining random numbers between L and U.
Update operation (update).
Comparison f (X)new) And f (X)best) And updates X according to the following formulabest
Figure BDA0003266561020000141
Selection operation (Selection operation).
Before mutation operation and cross operation begin, we followMachine selection
Figure BDA0003266561020000142
The harmony. It is worth noting that the best harmony sound cannot be selected at this time.
Mutation operations and crossover operations.
The HS algorithm is introduced from the DE algorithm in two operations. For mutation operations, a new harmony is created from the current harmony, defined as:
Xmutation=Xc+F*(Xa-Xb),
wherein Xa,XbAnd XcIs a randomly generated harmony. For the interleaving operation, XmutationCrossing the selected corresponding harmony to obtain a new harmony xnew. More details are given in figure 9. Wherein, randI(L, U) is used to obtain a random integer between L and U.
Replacement operation (Replacement operation).
For selected harmony, contrast
Figure BDA0003266561020000143
And f (X)j) After replacing X according to the following formulaj
Figure BDA0003266561020000144
We will P·,t={Pn,t|n∈N+andn∈NselectedConsider a piece of data input to the IHS at time t. Of note is NselectedObtained according to the following steps:
step 1: computing all P in the training setn,tτ ofn,τnIs defined as follows:
Figure BDA0003266561020000145
step 2: defining a minimum τnIs taumin
And step 3: defining a parameter mu > 1 if taun<μ*τminThen n is selected.
The objective function is then to obtain a minimum Mean Absolute Percent Error (MAPE), defined as follows:
Figure BDA0003266561020000151
subject to Pt>0,
n∈Nselected,
wherein theta isnRepresents Pn,tThe weight of (c).
After a training set with the size q is trained, the trained weight is obtained
Figure BDA0003266561020000152
In summary, the structure of the stock price prediction model according to the embodiment of the present disclosure is shown in fig. 10.
The embodiment of the present disclosure further provides a system, as shown in fig. 11, where the system 1 includes: user equipment 10, server 20, stock server 30. The user device 10 includes a program 11 for predicting stock prices, an ELM model 12, and a database 13. The server 20 comprises a program 21 for determining parameters, an ELM model 22 and a database 23. The stock server 30 includes a database 33.
As shown in fig. 11, a case where the user device 10 performs stock price prediction, the server 20 performs model training, and the stock server 30 stores historical stock prices is shown, but the embodiment of the present disclosure is not limited thereto, and in the embodiment of the present disclosure, prediction and training may both be implemented at the user device or may both be implemented at the server.
In the disclosed embodiment, the user device 10 may comprise a smartphone, a personal computer (PC, MAC, etc.), a tablet, a laptop, etc. The database 23 of the user device 10 stores the aforementioned weighting factors of the present disclosure, as well as historical stock price data obtained from the stock server 20. The program for predicting a stock price 11 is configured to implement the steps of the method for predicting a stock price provided by the embodiment of the present disclosure.
In the disclosed embodiment, the server 20 obtains the historical stock price data from the stock server 30, and the program 21 for determining parameters is configured to implement the steps of the method for determining parameters provided by the disclosed embodiment. After determining the parameters, the server 20 provides the parameters to the user equipment 10.
The method for predicting the stock price and the method for determining the parameters in the system 1 can be referred to the present disclosure to implement the foregoing description, and are not repeated herein.
Embodiments of the present disclosure also provide a computer device, which includes a smartphone, a personal computer (PC, MAC, etc.), a tablet, a laptop, a server, etc. Fig. 12 is a schematic diagram of a hardware structure of an implementation manner of a computer device according to an embodiment of the present disclosure, and as shown in fig. 12, a computer device 120 according to an embodiment of the present disclosure includes: including at least but not limited to: a memory 121 and a processor 122 communicatively coupled to each other via a system bus. It is noted that FIG. 12 only shows computer device 120 having components 121 and 122, but it is understood that not all of the shown components are required and that more or fewer components may be implemented instead.
In this embodiment, the memory 121 (i.e., a readable storage medium) includes a flash memory, a hard disk, a multimedia card, a card-type memory (e.g., SD or DX memory, etc.), a Random Access Memory (RAM), a Static Random Access Memory (SRAM), a read-only memory (ROM), an electrically erasable programmable read-only memory (EEPROM), a programmable read-only memory (PROM), a magnetic memory, a magnetic disk, an optical disk, and the like. In some embodiments, the storage 121 may be an internal storage unit of the computer device 120, such as a hard disk or a memory of the computer device 120. In other embodiments, the memory 121 may also be an external storage device of the computer device 120, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), or the like, provided on the computer device 120. Of course, the memory 121 may also include both internal and external storage devices for the computer device 120. In this embodiment, the memory 121 is generally used for storing an operating system and various types of software installed on the computer device 120. Further, the memory 121 may also be used to temporarily store various types of data that have been output or are to be output.
Processor 122 may be a Central Processing Unit (CPU), controller, microcontroller, microprocessor, or other data Processing chip in some embodiments. The processor 122 generally operates to control the overall operation of the computer device 120. In this embodiment, the processor 122 is configured to execute program codes stored in the memory 121 or process data, such as any one or more of the methods of the embodiments of the present disclosure.
The present embodiment also provides a computer-readable storage medium, such as a flash memory, a hard disk, a multimedia card, a card-type memory (e.g., SD or DX memory, etc.), a Random Access Memory (RAM), a Static Random Access Memory (SRAM), a read-only memory (ROM), an electrically erasable programmable read-only memory (EEPROM), a programmable read-only memory (PROM), a magnetic memory, a magnetic disk, an optical disk, a server, an App application mall, etc., on which a computer program is stored, which when executed by a processor implements corresponding functions. The computer readable storage medium of the present embodiments stores program code of any one or more of the disclosed embodiments, which when executed by a processor implements the method of any one or more of the disclosed embodiments.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
The above-mentioned serial numbers of the embodiments of the present disclosure are merely for description and do not represent the merits of the embodiments.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solutions of the present disclosure may be embodied in the form of a software product, which is stored in a storage medium (e.g., ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal (e.g., a mobile phone, a computer, a server, an air conditioner, or a network device) to execute the method according to the embodiments of the present disclosure.
While the embodiments of the present disclosure have been described in connection with the drawings, the present disclosure is not limited to the specific embodiments described above, which are intended to be illustrative rather than limiting, and it will be apparent to those of ordinary skill in the art in light of the present disclosure that many more modifications can be made without departing from the spirit of the disclosure and the scope of the appended claims.

Claims (10)

1. A method of predicting a stock price, comprising:
acquiring a historical stock price time sequence before a target date;
processing the historical stock price time sequence by a preset sliding time window to obtain N historical stock price sequences corresponding to N intermediate dates;
for each of the N intermediate dates:
performing variation modal decomposition on the historical stock price sequence corresponding to the intermediate date to obtain K decomposition sequences;
determining a first input sequence from the K decomposition sequences, the first input sequence representing a stock price characteristic of the intermediate date;
determining a second input sequence using the historical stock price time sequence, the second input sequence representing a stock price trend prior to the intermediate date; and
taking the first input sequence and the second input sequence as input, and outputting a predicted stock price corresponding to the intermediate date by using an ELM model;
and weighting the N-period predicted stock prices corresponding to the N intermediate dates according to a weight coefficient predetermined by a harmony search method to obtain the predicted stock prices of the target date.
2. The method of claim 1, wherein determining a first input sequence from the K decomposed sequences comprises: and extracting values of positions corresponding to the intermediate dates in each of the K decomposition sequences to form a first input sequence.
3. The method of claim 1, wherein the second input sequence comprises at least one of:
historical stock prices for a plurality of consecutive days before the intermediate date;
historical stock prices for dates separated from the intermediate date by one or more preset days;
one or more moving averages of historical stock prices for consecutive days prior to the intermediate date.
4. A method of determining a parameter, comprising:
acquiring a historical stock price time sequence of the stock;
selecting a plurality of target dates from historical dates, determining model input corresponding to each target date by taking the actual stock price of the target date as a label for each target date, and outputting the N-period predicted stock price corresponding to the target date by using an ELM model; and
performing harmony search by taking an error between the predicted stock price on the minimized target date and the actual stock price as a target, and determining a weight coefficient corresponding to the N-period predicted stock price, wherein the predicted stock price on the target date is obtained by weighting the N-period predicted stock price according to the current weight coefficient;
wherein, determining the model input corresponding to each target date comprises:
processing the historical stock price time sequence before the target date by a preset sliding time window to obtain N historical stock price sequences corresponding to N intermediate dates;
for each of the N intermediate dates:
performing variation modal decomposition on the historical stock price sequence corresponding to the intermediate date to obtain K decomposition sequences;
determining a first input sequence from the K decomposition sequences, the first input sequence representing a stock price characteristic of the intermediate date;
determining a second input sequence using the historical stock price time sequence, the second input sequence representing a stock price trend prior to the intermediate date; and
and taking the first input sequence and the second input sequence as model inputs corresponding to the intermediate dates.
5. The method of claim 4, wherein determining the first input sequence from the K decomposed sequences comprises: and extracting values of positions corresponding to the intermediate dates in each of the K decomposition sequences to form a first input sequence.
6. The method of claim 4, wherein the second input sequence comprises at least one of:
historical stock prices for a plurality of consecutive days before the intermediate date;
historical stock prices for dates separated from the intermediate date by one or more preset days;
one or more moving averages of historical stock prices for consecutive days prior to the intermediate date.
7. The method of claim 4, wherein the error is an average absolute percentage error.
8. A computer device, characterized in that the computer device comprises:
a memory, a processor, and a computer program stored on the memory and executable on the processor;
the computer program, when executed by the processor, implementing the steps of the method of any one of claims 1 to 3.
9. A computer device, characterized in that the computer device comprises:
a memory, a processor, and a computer program stored on the memory and executable on the processor;
the computer program, when executed by the processor, implementing the steps of the method of any one of claims 4 to 7.
10. A computer-readable storage medium, on which a program for predicting a stock price is stored, the program for predicting a stock price implementing the steps of the method for predicting a stock price according to any one of claims 1 to 3 when being executed by a processor.
CN202111088196.0A 2021-09-16 2021-09-16 Method, equipment and storage medium for predicting stock price and determining parameters Pending CN113807964A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111088196.0A CN113807964A (en) 2021-09-16 2021-09-16 Method, equipment and storage medium for predicting stock price and determining parameters

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111088196.0A CN113807964A (en) 2021-09-16 2021-09-16 Method, equipment and storage medium for predicting stock price and determining parameters

Publications (1)

Publication Number Publication Date
CN113807964A true CN113807964A (en) 2021-12-17

Family

ID=78941331

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111088196.0A Pending CN113807964A (en) 2021-09-16 2021-09-16 Method, equipment and storage medium for predicting stock price and determining parameters

Country Status (1)

Country Link
CN (1) CN113807964A (en)

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106202491A (en) * 2016-07-19 2016-12-07 中国银联股份有限公司 A kind of based on seasonal effect in time series data digging method and system
CN108647824A (en) * 2018-05-10 2018-10-12 广东工业大学 A kind of electricity price ultra-short term prediction method
CN108694477A (en) * 2018-07-05 2018-10-23 广东工业大学 A kind of Electricity price forecasting solution and relevant apparatus
CN109598387A (en) * 2018-12-14 2019-04-09 华东师范大学 Forecasting of Stock Prices method and system based on two-way cross-module state attention network model
CN110866829A (en) * 2019-11-20 2020-03-06 深圳市豪斯莱科技有限公司 Stock price prediction method based on integrated learning model
CN111967685A (en) * 2020-08-28 2020-11-20 山西墨丘利科技有限公司 Group decision stock price trend insights method based on graphic feature library
CN112085327A (en) * 2020-08-03 2020-12-15 国网福建省电力有限公司福州供电公司 Multi-layer partition regulation and control method and system for active power distribution network with participation of power distributor

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106202491A (en) * 2016-07-19 2016-12-07 中国银联股份有限公司 A kind of based on seasonal effect in time series data digging method and system
CN108647824A (en) * 2018-05-10 2018-10-12 广东工业大学 A kind of electricity price ultra-short term prediction method
CN108694477A (en) * 2018-07-05 2018-10-23 广东工业大学 A kind of Electricity price forecasting solution and relevant apparatus
CN109598387A (en) * 2018-12-14 2019-04-09 华东师范大学 Forecasting of Stock Prices method and system based on two-way cross-module state attention network model
CN110866829A (en) * 2019-11-20 2020-03-06 深圳市豪斯莱科技有限公司 Stock price prediction method based on integrated learning model
CN112085327A (en) * 2020-08-03 2020-12-15 国网福建省电力有限公司福州供电公司 Multi-layer partition regulation and control method and system for active power distribution network with participation of power distributor
CN111967685A (en) * 2020-08-28 2020-11-20 山西墨丘利科技有限公司 Group decision stock price trend insights method based on graphic feature library

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
王珏 等: "基于SSA-ELM的大宗商品价格预测研究", 《系统工程理论与实践》 *

Similar Documents

Publication Publication Date Title
Gasparin et al. Deep learning for time series forecasting: The electric load case
Alsharef et al. Review of ML and AutoML solutions to forecast time-series data
Tokdar et al. Importance sampling: a review
CN108401459B (en) Predictive subdivision of energy consumers
Hassan et al. A hybrid of multiobjective Evolutionary Algorithm and HMM-Fuzzy model for time series prediction
CN111783873B (en) User portrait method and device based on increment naive Bayes model
KR101656405B1 (en) Evaluation apparatus for probability of winning a case and method thereof
CN110046981B (en) Credit evaluation method, device and storage medium
Li et al. Credibilistic programming
Zhang et al. A novel power-driven fractional accumulated grey model and its application in forecasting wind energy consumption of China
CN112925911B (en) Complaint classification method based on multi-modal data and related equipment thereof
CN112182118A (en) Target object prediction method based on multiple data sources and related equipment thereof
Ozcelik et al. A stochastic approach for the single-machine scheduling problem to minimize total expected cost with client-dependent tardiness costs
CN114118570A (en) Service data prediction method and device, electronic equipment and storage medium
CN112231299B (en) Method and device for dynamically adjusting feature library
Nasios et al. Blending gradient boosted trees and neural networks for point and probabilistic forecasting of hierarchical time series
CN114691838A (en) Training and recommending method of chat robot search recommending model and electronic equipment
CN116911574A (en) Three-level supply chain optimization method and device based on whale algorithm and random forest
CN113807964A (en) Method, equipment and storage medium for predicting stock price and determining parameters
CN114897607A (en) Data processing method and device for product resources, electronic equipment and storage medium
CN115186179A (en) Insurance product pushing method and device
CN115099875A (en) Data classification method based on decision tree model and related equipment
CN114925275A (en) Product recommendation method and device, computer equipment and storage medium
Roy et al. Forecasting of indian stock market using rough set and fuzzy-rough set based models
Slabber et al. Advantages of using factorisation machines as a statistical modelling technique

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination