CN116385167A - Seasonal stock price prediction method and device - Google Patents

Seasonal stock price prediction method and device Download PDF

Info

Publication number
CN116385167A
CN116385167A CN202310430247.6A CN202310430247A CN116385167A CN 116385167 A CN116385167 A CN 116385167A CN 202310430247 A CN202310430247 A CN 202310430247A CN 116385167 A CN116385167 A CN 116385167A
Authority
CN
China
Prior art keywords
sequence
price
seasonal
stock
historical time
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
CN202310430247.6A
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.)
China Construction Bank Corp
CCB Finetech Co Ltd
Original Assignee
China Construction Bank Corp
CCB Finetech Co Ltd
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 China Construction Bank Corp, CCB Finetech Co Ltd filed Critical China Construction Bank Corp
Priority to CN202310430247.6A priority Critical patent/CN116385167A/en
Publication of CN116385167A publication Critical patent/CN116385167A/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
    • 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"
    • 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
    • G06Q30/00Commerce
    • G06Q30/02Marketing; Price estimation or determination; Fundraising
    • G06Q30/0201Market modelling; Market analysis; Collecting market data
    • G06Q30/0206Price or cost determination based on market factors

Landscapes

  • Business, Economics & Management (AREA)
  • Engineering & Computer Science (AREA)
  • Strategic Management (AREA)
  • Accounting & Taxation (AREA)
  • Finance (AREA)
  • Development Economics (AREA)
  • Economics (AREA)
  • General Business, Economics & Management (AREA)
  • Entrepreneurship & Innovation (AREA)
  • Physics & Mathematics (AREA)
  • Marketing (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Human Resources & Organizations (AREA)
  • Game Theory and Decision Science (AREA)
  • Technology Law (AREA)
  • Operations Research (AREA)
  • Quality & Reliability (AREA)
  • Tourism & Hospitality (AREA)
  • Data Mining & Analysis (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

The invention discloses a seasonal stock price prediction method and a seasonal stock price prediction device, and relates to the technical field of artificial intelligence, wherein the method comprises the following steps: acquiring the prediction time length of seasonal stocks to be predicted; the preset time length comprises a plurality of time points; inputting the prediction time length into a pre-trained stock price prediction model to obtain the stock price and the confidence interval corresponding to each time point of the stock in the season to be predicted in the preset time length; the stock price prediction model is obtained by training a prophet model according to stock prices corresponding to a historical time sequence of seasonal stocks and the historical time sequence. The invention can predict the price of the stock with the seasonal periodical change structure and improve the accuracy of seasonal stock price prediction.

Description

Seasonal stock price prediction method and device
Technical Field
The invention relates to the technical field of artificial intelligence, in particular to a seasonal stock price prediction method and device.
Background
This section is intended to provide a background or context to the embodiments of the invention that are recited in the claims. The description herein is not admitted to be prior art by inclusion in this section.
With the development of economic globalization, the stock market is becoming increasingly large. The benefits and risks of stocks tend to be positively correlated, i.e., the higher the risk, the greater the benefits. Price trend prediction of stock markets is very important. Seasonal stocks refer to stocks exhibiting varying degrees of fluctuation with annual seasonal changes, and mainly include fields of planting and forestry blocks, agricultural product blocks, coal blocks, clothing blocks, port shipping blocks, travel blocks, and the like. For seasonal stocks, factors affecting stock prices are affected to different extents by seasons, in addition to macroscopic factors, market factors, and self factors. In the prior art, most of the methods adopt a deep learning-based mode, such as LSTM, ARIMA and other time sequence prediction methods, so as to perform indifferent analysis and prediction on all stock data, and cannot effectively predict the data with a seasonal periodical change structure.
Disclosure of Invention
The embodiment of the invention provides a seasonal stock price prediction method, which is used for predicting the price of stocks with a seasonal periodical change structure and improving the accuracy of seasonal stock price prediction, and comprises the following steps:
acquiring the prediction time length of seasonal stocks to be predicted; the preset time length comprises a plurality of time points;
inputting the prediction time length into a pre-trained stock price prediction model to obtain the stock price and the confidence interval corresponding to each time point of the stock in the season to be predicted in the preset time length; the stock price prediction model is obtained by training a prophet model according to stock prices corresponding to a historical time sequence of seasonal stocks and the historical time sequence.
The embodiment of the invention also provides a seasonal stock price prediction device, which is used for predicting the price of the stock with a seasonal periodical change structure and improving the accuracy of seasonal stock price prediction, and comprises the following components:
the acquisition module is used for acquiring the prediction time length of seasonal stocks to be predicted; the preset time length comprises a plurality of time points;
the stock price prediction module is used for inputting the prediction time length into a pre-trained stock price prediction model to obtain the stock price and the confidence interval corresponding to each time point of the stock in the season to be predicted in the preset time length; the stock price prediction model is obtained by training a prophet model according to stock prices corresponding to a historical time sequence of seasonal stocks and the historical time sequence.
The embodiment of the invention also provides computer equipment, which comprises a memory, a processor and a computer program stored on the memory and capable of running on the processor, wherein the seasonal stock price prediction method is realized when the processor executes the computer program.
The embodiment of the invention also provides a computer readable storage medium, wherein the computer readable storage medium stores a computer program, and the computer program realizes the seasonal stock price prediction method when being executed by a processor.
Embodiments of the present invention also provide a computer program product comprising a computer program which, when executed by a processor, implements the seasonal stock price prediction method described above.
In the embodiment of the invention, the prediction time length of seasonal stocks to be predicted is obtained; the preset time length comprises a plurality of time points; inputting the prediction time length into a pre-trained stock price prediction model to obtain the stock price and the confidence interval corresponding to each time point of the stock in the season to be predicted in the preset time length; the stock price prediction model is obtained by training a prophet model according to stock prices corresponding to a historical time sequence of seasonal stocks and the historical time sequence. Therefore, the price prediction can be carried out on the stocks with the seasonal period change structure, and the accuracy of seasonal stock price prediction is improved.
Drawings
In order to more clearly illustrate the embodiments of the invention or the technical solutions in the prior art, the drawings that are required in the embodiments or the description of the prior art will be briefly described, it being obvious that the drawings in the following description are only some embodiments of the invention, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art. In the drawings:
FIG. 1 is a flow chart of a seasonal stock price forecast method according to an embodiment of the invention;
FIG. 2 is a flowchart of a method for training to obtain a stock price prediction model according to an embodiment of the present invention;
FIG. 3 is an exemplary diagram of a stock trading chart for seasonal stocks in a historical time series provided in an embodiment of the invention;
FIG. 4 is a flowchart of a method for generating a sample set according to a set price sequence, and a historical time sequence corresponding to a seasonal stock in the historical time sequence according to an embodiment of the present invention;
FIG. 5 is an exemplary diagram of a sample set provided in an embodiment of the present invention;
FIG. 6 is a logic diagram of an overall implementation of a seasonal stock price prediction method provided in an embodiment of the invention;
FIG. 7 is a diagram showing an example of a stock price and a confidence interval corresponding to each time point of a seasonal stock to be predicted within a part of a preset time period according to an embodiment of the present invention;
FIG. 8 is an exemplary graph of a prediction result provided in an embodiment of the present invention;
FIG. 9 is a schematic diagram of a seasonal stock price prediction apparatus according to an embodiment of the present invention;
fig. 10 is a schematic diagram of a computer device according to an embodiment of the present invention.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the embodiments of the present invention will be described in further detail with reference to the accompanying drawings. The exemplary embodiments of the present invention and their descriptions herein are for the purpose of explaining the present invention, but are not to be construed as limiting the invention.
In the technical scheme, the acquisition, storage, use, processing and the like of the data all accord with the relevant regulations of laws and regulations.
The term "and/or" is used herein to describe only one relationship, meaning that there may be three relationships, e.g., a and/or B, which may mean: a exists alone, A and B exist together, and B exists alone. In addition, the term "at least one" herein means any one of a plurality or any combination of at least two of a plurality, for example, including at least one of A, B, C, and may mean including any one or more elements selected from the group consisting of A, B and C.
In the description of the present specification, the terms "comprising," "including," "having," "containing," and the like are open-ended terms, meaning including, but not limited to. Reference to the terms "one embodiment," "a particular embodiment," "some embodiments," "for example," etc., means that a particular feature, structure, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the present application. In this specification, schematic representations of the above terms do not necessarily refer to the same embodiments or examples. Furthermore, the particular features, structures, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples. The sequence of steps involved in the embodiments is used to schematically illustrate the practice of the present application, and is not limited thereto and may be appropriately adjusted as desired.
Research has found that with the development of globalization of economy, stock markets become increasingly large. The benefits and risks of stocks tend to be positively correlated, i.e., the higher the risk, the greater the benefits. Price trend prediction of stock markets is very important. Seasonal stocks refer to stocks exhibiting varying degrees of fluctuation with annual seasonal changes, and mainly include fields of planting and forestry blocks, agricultural product blocks, coal blocks, clothing blocks, port shipping blocks, travel blocks, and the like. For seasonal stocks, factors affecting stock prices are affected to different extents by seasons, in addition to macroscopic factors, market factors, and self factors. In the prior art, most of the methods adopt a deep learning-based mode, such as LSTM, ARIMA and other time sequence prediction methods, so as to perform indifferent analysis and prediction on all stock data, and cannot effectively predict the data with a seasonal periodical change structure.
Financial time series is a kind of time data series, and has strong timeliness and periodicity, and the data series often has deep dependence, and the characteristics make the data series very suitable for an artificial intelligence algorithm model to perform fitting prediction.
For the above study, as shown in fig. 1, an embodiment of the present invention provides a seasonal stock price prediction method, including:
s101: acquiring the prediction time length of seasonal stocks to be predicted; the preset time length comprises a plurality of time points;
s102: inputting the prediction time length into a pre-trained stock price prediction model to obtain the stock price and the confidence interval corresponding to each time point of the stock in the season to be predicted in the preset time length; the stock price prediction model is obtained by training a prophet model according to stock prices corresponding to a historical time sequence of seasonal stocks and the historical time sequence.
In the embodiment of the invention, the prediction time length of seasonal stocks to be predicted is obtained; the preset time length comprises a plurality of time points; inputting the prediction time length into a pre-trained stock price prediction model to obtain the stock price and the confidence interval corresponding to each time point of the stock in the season to be predicted in the preset time length; the stock price prediction model is obtained by training a prophet model according to stock prices corresponding to a historical time sequence of seasonal stocks and the historical time sequence. Therefore, the price prediction can be carried out on the stocks with the seasonal period change structure, and the accuracy of seasonal stock price prediction is improved.
The seasonal stock price prediction method will be described in detail.
For S101 described above, the predicted time length is, for example, in years (365 days or 366 days), wherein the time point may be, for example, days.
In the step S102, the stock price prediction model is obtained by training the propset model in advance based on the stock price corresponding to the historical time series of seasonal stocks and the historical time series. The predicted time is set to a predicted time length, for example, 365 days, by a propset_future_dataframe method of a stock price prediction model, and then the stock price prediction model starts to predict, resulting in a stock price of one whole year in the future, and a confidence interval.
The prophet model provided by the embodiment of the invention is used for a univariate time sequence prediction library, and can be used for processing the situation that a time sequence has some abnormal values and the situation that a part of values are missing. The propset can also perform data fitting by taking a data fluctuation trend item, a season item and a holiday item as characteristics, and is suitable for the financial field.
As shown in fig. 2, a flowchart of a method for training to obtain a stock price prediction model according to an embodiment of the present invention includes:
s201: and collecting a drive price sequence and a closing price sequence corresponding to the seasonal stock in the historical time sequence.
In an embodiment of the present invention, for example, a stock trade chart corresponding to a historical time sequence may be obtained, for example, as shown in fig. 3, which is an exemplary chart of a stock trade chart corresponding to a seasonal stock in a historical time sequence, where the stock trade chart includes: stock code (ts_code), trade date (trade_date), open price (open), closing price (close), maximum current price (high), minimum current price (low), closing price (front copy) yesterday (pre_close), expansion and drop (change), expansion and drop (pct_chg), volume (hand) (vol), volume (thousand-element) (current), etc., the historical time series is extracted from the stock trade map or table, and the open price series and closing price series corresponding to the seasonal stock in the historical time series, for example, the extraction of the historical time series from fig. 3 includes: [20140102, 20140103, 20140104, 20140105, 20140106], extracting a listing sequence for seasonal stocks corresponding to a historical time series includes: [6.87, 6.95, 7.02, 7.08, 7.03]; the method for extracting the closing price sequence corresponding to the seasonal stock in the historical time sequence comprises the following steps: [6.79, 6.90, 6.97, 7.02, 7.07].
S202: and generating a sample set according to the opening price sequence, the closing price sequence and the historical time sequence corresponding to the seasonal stock in the historical time sequence.
Here, for example, the historical time series is used as the input of the sample set, and the input of the sample set is obtained from the opening price series and the closing price series corresponding to the seasonal stock in the historical time series.
In one embodiment of the present invention, format conversion is performed on the historical time series to convert date information in the historical time series into a fixed format, for example, format conversion is performed on the historical time series [20140102, 20140103, 20140104, 20140105, 20140106] to obtain [2014-01-02, 2014-01-03, 2014-01-04, 2014-01-05, 2014-01-06].
As shown in fig. 4, a flowchart of a method for generating a sample set according to a driving price sequence, a closing price sequence and a historical time sequence corresponding to a seasonal stock in the historical time sequence according to an embodiment of the present invention includes:
s401: and carrying out missing value processing on the opening price sequence and the closing price sequence corresponding to the seasonal stock in the historical time sequence to obtain a complete opening price sequence and a complete closing price sequence corresponding to the seasonal stock in the historical time sequence.
In an embodiment of the present invention, missing value processing is performed on a opening price sequence and a closing price sequence corresponding to a seasonal stock in a historical time sequence to obtain a complete opening price sequence and a complete closing price sequence corresponding to the seasonal stock in the historical time sequence, which comprises the following two embodiments (1) or (2):
(1) the method comprises the following steps When the data quantity of the seasonal stock, which is missing in the opening price sequence and the closing price sequence corresponding to the historical time sequence, is smaller than a preset data quantity threshold value, deleting the position corresponding to the missing data in the opening price sequence and the closing price sequence, and deleting the time point corresponding to the missing data from the historical time sequence to obtain the complete opening price sequence and the complete closing price sequence, which are corresponding to the historical time sequence, of the seasonal stock.
Here, for stock data in which missing data is small and the overall data distribution is not affected, a row containing a missing value is directly deleted.
For example, the preset number threshold is 2, the historical time series is [20140102, 20140103, 20140104, 20140105, 20140106], and the open price series is: [6.87, -, 7.02, 7.08, 7.03]; the closing price sequence is [6.79, 6.90, 6.97, 7.02 and 7.07], the opening price sequence lacks 20140104 opening price data corresponding to the historical time point, and the quantity of the missing data is 1 and is smaller than a preset data quantity threshold value 2, so that the opening price sequence, the position corresponding to the missing data in the closing price sequence and the time point corresponding to the missing data in the historical time sequence are deleted to obtain the historical time sequence: [20140102, 20140104, 20140105, 20140106]; opening price sequence: [6.87, 7.02, 7.08, 7.03]; a closing price sequence: [6.79, 6.97, 7.02, 7.07].
The preset quantity threshold value can be determined by combining the historical time sequence, the opening price sequence and the data quantity contained in the closing price sequence in the actual training scene.
(2) The method comprises the following steps And when the data quantity of the seasonal stock missing in the opening price sequence and the closing price sequence corresponding to the historical time sequence is larger than or equal to a preset data quantity threshold value, filling the missing data according to the opening price sequence of the seasonal stock corresponding to the historical time sequence and the data of the adjacent positions of the missing data in the closing price sequence, so as to obtain a complete opening price sequence and a complete closing price sequence of the seasonal stock corresponding to the historical time sequence.
In an embodiment of the present invention, filling missing data according to data of adjacent positions of missing data in a driving price sequence corresponding to a seasonal stock in a historical time sequence and a closing price sequence includes: filling the missing data by using an average value of the first data and the second data when a first difference value between the first data at a position before the missing data and the second data at a position behind the missing data in a price opening sequence corresponding to the historical time sequence of seasonal stocks is larger than a preset difference value, and filling the missing data by using the first data when the first difference value between the first data and the second data is smaller than or equal to the preset difference value; and when a second difference value between third data of a position before missing data and fourth data of a position after missing data in a closing price sequence corresponding to the historical time sequence of seasonal stocks is larger than a preset difference value, filling the missing data by using an average value of the third data and the fourth data, and when the second difference value between the third data and the fourth data is smaller than or equal to the preset difference value, filling the missing data by using the third data.
Here, if a case occurs in which deleting the missing value directly results in a large reduction in the amount of stock data, a padding method is used. For example, if the preset difference is 10%, a. If the values across the missing items differ by more than 10%, filling is performed using the average of the values across the missing items. b. If the value of the two ends of the missing item does not exceed 10%, the previous value of the missing item is directly filled in by using a front filling mode.
S402: and summing the complete listing sequence and the complete closing sequence corresponding to the seasonal stock in the historical time sequence to obtain a sum sequence of the seasonal stock.
For example, the complete opening price sequence corresponding to the seasonal stock in the historical time sequence is [6.87, 6.95, 7.02, 7.08, 7.03], and the complete closing price sequence is [6.79, 6.90, 6.97, 7.02, 7.07], and the complete opening price sequence corresponding to the seasonal stock in the historical time sequence and the complete closing price sequence are summed to obtain the sum value sequence of the seasonal stock: [13.66, 13.85, 13.99, 14.10].
S403: dividing the sum value sequence of the seasonal stocks by two to obtain a seasonal stock price sequence corresponding to the seasonal stocks in the historical time sequence.
For example, the sum value sequence is [13.66, 13.85, 13.99, 14.10], and the sum value sequence of seasonal stocks is divided by two to obtain seasonal stock price sequences [6.83, 6.925, 6.955, 7.05] corresponding to the seasonal stocks in the history time sequence.
S404: and outputting seasonal stock prices corresponding to the seasonal stocks in the historical time sequence as samples, and inputting the historical time sequence as samples to obtain a sample set.
As shown in fig. 5, an exemplary diagram of sample sets obtained from historical time series [2014-01-02, 2014-01-03, 2014-01-04, 2014-01-05, 2014-01-06], and seasonal stock price series [6.83, 6.925, 6.955, 7.05].
S203: and dividing the samples in the sample set into training samples and test samples according to a preset proportion.
S204: the prophet model is trained using training samples.
In an embodiment of the present invention, training a prophet model using training samples includes: configuring initial parameters of a propset model to obtain the initial propset model; wherein the initial parameters include: sparse prior parameter values, prediction interval range values and elastic parameters of seasonal components; and training the initial propset model by using a training sample, and adjusting initial parameters of the initial propset model according to the Bayesian optimization library in the training process.
For example, a propset model is built, and an input parameter changepoint_priority_scale (sparse prior parameter) is set to be 0.01 to adjust the degree of sparse prior so as to prevent the model from being over fitted; an interval_width (prediction interval range) value is set to 0.3 to control the width of the prediction interval to be 30% floating.
In addition, the embodiment of the invention performs the super-parameter search by using bayesian optimization, and sets "change point_priority_scale" and "setup_priority_scale" as a set of candidate super-parameter values, and uses the average absolute error as an evaluation function to evaluate the effects of the two super-parameters so as to find the optimal super-parameters.
S205: and testing the trained propset model by using a test sample, and obtaining a trained stock price prediction model when the test passes.
In addition, in another embodiment of the present invention, when the test is not passed, for example, the sample data may be selected again to continue training the propset model until the trained propset model passes the test, so as to obtain a trained stock price prediction model.
Specifically, as shown in fig. 6, a logic diagram is implemented for an overall seasonal stock price prediction method provided by the embodiment of the present invention, stock data is collected in advance, the collected stock data is subjected to data preprocessing to obtain a sample set, the sample set is divided into a training set and a test set, a propset model is trained by using the training set, a propset model is tested by using the test set to obtain a trained stock price prediction model, a seasonal stock to be predicted is predicted according to the stock price prediction model, and a predicted stock price and a confidence interval are obtained, for example, as shown in fig. 7, an exemplary diagram of a stock price and a confidence interval corresponding to each time point of a seasonal stock to be predicted within a part of a preset time length is provided, where the predicted time length ds includes time points: 2023-11-27, 2023-11-28, 2023-11-29, 2023-11-30, 2023-12-01, the stock price yhat contains stock prices corresponding to respective time points: 7.058610, 7.060872, 7.065474, 7.067209, 7.061413, and confidence interval upper limit yhat_upper and confidence interval lower limit yhat_lower, and the prediction results can be shown in fig. 8, for example.
The embodiment of the invention also provides a seasonal stock price prediction device, which is described in the following embodiment. Because the principle of the device for solving the problem is similar to that of the seasonal stock price prediction method, the implementation of the device can refer to the implementation of the seasonal stock price prediction method, and the repetition is not repeated.
As shown in fig. 9, a schematic diagram of a seasonal stock price prediction apparatus according to an embodiment of the present invention includes:
an obtaining module 901, configured to obtain a predicted time length of a seasonal stock to be predicted; the preset time length comprises a plurality of time points;
the stock price prediction module 902 is configured to input a predicted time length into a pre-trained stock price prediction model, so as to obtain a stock price corresponding to each time point of the season stock to be predicted within a preset time length, and a confidence interval; the stock price prediction model is obtained by training a prophet model according to stock prices corresponding to a historical time sequence of seasonal stocks and the historical time sequence.
In one possible embodiment, the method further comprises: the model training module is used for collecting a driving price sequence and a receiving price sequence of seasonal stocks corresponding to the historical time sequence; generating a sample set according to a drive price sequence, a take-up price sequence and a historical time sequence which correspond to the seasonal stock in the historical time sequence; dividing samples in the sample set into training samples and test samples according to a preset proportion; training the propset model by using a training sample; and testing the trained propset model by using a test sample, and obtaining a trained stock price prediction model when the test passes.
In a possible implementation manner, the model training module is specifically configured to perform missing value processing on a price opening sequence and a price closing sequence corresponding to a seasonal stock in a historical time sequence, so as to obtain a complete price opening sequence and a complete price closing sequence corresponding to the seasonal stock in the historical time sequence; summing the complete price opening sequence and the complete price closing sequence corresponding to the seasonal stock in the historical time sequence to obtain a sum sequence of the seasonal stock; dividing the sum value sequence of the seasonal stocks by two to obtain a seasonal stock price sequence corresponding to the seasonal stocks in the historical time sequence; and outputting seasonal stock prices corresponding to the seasonal stocks in the historical time sequence as samples, and inputting the historical time sequence as samples to obtain a sample set.
In a possible implementation manner, the model training module is specifically configured to delete a position corresponding to missing data in the opening price sequence and the closing price sequence when the missing data amount in the opening price sequence and the closing price sequence corresponding to the historical time sequence of the seasonal stock is smaller than a preset data amount threshold, delete a time point corresponding to the missing data from the historical time sequence, and obtain a complete opening price sequence and a complete closing price sequence corresponding to the historical time sequence of the seasonal stock; and when the data quantity of the seasonal stock missing in the opening price sequence and the closing price sequence corresponding to the historical time sequence is larger than or equal to a preset data quantity threshold value, filling the missing data according to the opening price sequence of the seasonal stock corresponding to the historical time sequence and the data of the adjacent positions of the missing data in the closing price sequence, so as to obtain a complete opening price sequence and a complete closing price sequence of the seasonal stock corresponding to the historical time sequence.
In a possible implementation manner, the model training module is specifically configured to configure initial parameters of the propset model to obtain an initial propset model; wherein the initial parameters include: sparse prior parameter values, prediction interval range values and elastic parameters of seasonal components; and training the initial propset model by using a training sample, and adjusting initial parameters of the initial propset model according to the Bayesian optimization library in the training process.
Based on the foregoing inventive concept, as shown in fig. 10, the present invention further proposes a computer device 1000, including a memory 1010, a processor 1020, and a computer program 1030 stored on the memory 1010 and executable on the processor 1020, wherein the processor 1020 implements the seasonal stock price prediction method when executing the computer program 1030.
The embodiment of the invention also provides a computer readable storage medium, wherein the computer readable storage medium stores a computer program, and the computer program realizes the seasonal stock price prediction method when being executed by a processor.
Embodiments of the present invention also provide a computer program product comprising a computer program which, when executed by a processor, implements the seasonal stock price prediction method described above.
In the embodiment of the invention, the prediction time length of seasonal stocks to be predicted is obtained; the preset time length comprises a plurality of time points; inputting the prediction time length into a pre-trained stock price prediction model to obtain the stock price and the confidence interval corresponding to each time point of the stock in the season to be predicted in the preset time length; the stock price prediction model is obtained by training a prophet model according to stock prices corresponding to a historical time sequence of seasonal stocks and the historical time sequence. Therefore, the price prediction can be carried out on the stocks with the seasonal period change structure, and the accuracy of seasonal stock price prediction is improved.
It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
The foregoing description of the embodiments has been provided for the purpose of illustrating the general principles of the invention, and is not meant to limit the scope of the invention, but to limit the invention to the particular embodiments, and any modifications, equivalents, improvements, etc. that fall within the spirit and principles of the invention are intended to be included within the scope of the invention.

Claims (13)

1. A seasonal stock price prediction method, comprising:
acquiring the prediction time length of seasonal stocks to be predicted; the preset time length comprises a plurality of time points;
inputting the prediction time length into a pre-trained stock price prediction model to obtain the stock price and the confidence interval corresponding to each time point of the stock in the season to be predicted in the preset time length; the stock price prediction model is obtained by training a prophet model according to stock prices corresponding to a historical time sequence of seasonal stocks and the historical time sequence.
2. The seasonal stock price prediction method according to claim 1, further comprising:
collecting a price opening sequence and a price closing sequence corresponding to the seasonal stock in the historical time sequence;
generating a sample set according to a drive price sequence, a take-up price sequence and a historical time sequence which correspond to the seasonal stock in the historical time sequence;
dividing samples in the sample set into training samples and test samples according to a preset proportion;
training the propset model by using a training sample;
and testing the trained propset model by using a test sample, and obtaining a trained stock price prediction model when the test passes.
3. The seasonal stock price prediction method of claim 2, wherein generating the sample set based on the opening price sequence, the closing price sequence, and the historical time sequence of the seasonal stock corresponding to the historical time sequence comprises:
carrying out missing value processing on the opening price sequence and the closing price sequence corresponding to the seasonal stock in the historical time sequence to obtain a complete opening price sequence and a complete closing price sequence corresponding to the seasonal stock in the historical time sequence;
summing the complete price opening sequence and the complete price closing sequence corresponding to the seasonal stock in the historical time sequence to obtain a sum sequence of the seasonal stock;
dividing the sum value sequence of the seasonal stocks by two to obtain a seasonal stock price sequence corresponding to the seasonal stocks in the historical time sequence;
and outputting seasonal stock prices corresponding to the seasonal stocks in the historical time sequence as samples, and inputting the historical time sequence as samples to obtain a sample set.
4. The seasonal stock price prediction method of claim 3, wherein the missing value processing is performed on the opening price sequence and the closing price sequence corresponding to the seasonal stock in the historical time sequence to obtain a complete opening price sequence and a complete closing price sequence corresponding to the seasonal stock in the historical time sequence, comprising:
deleting the positions corresponding to the missing data in the opening price sequence and the closing price sequence when the missing data amount in the opening price sequence and the closing price sequence corresponding to the historical time sequence of the seasonal stock is smaller than a preset data amount threshold, and deleting the time points corresponding to the missing data from the historical time sequence to obtain a complete opening price sequence and a complete closing price sequence corresponding to the historical time sequence of the seasonal stock;
and when the data quantity of the seasonal stock missing in the opening price sequence and the closing price sequence corresponding to the historical time sequence is larger than or equal to a preset data quantity threshold value, filling the missing data according to the opening price sequence of the seasonal stock corresponding to the historical time sequence and the data of the adjacent positions of the missing data in the closing price sequence, so as to obtain a complete opening price sequence and a complete closing price sequence of the seasonal stock corresponding to the historical time sequence.
5. The seasonal stock price prediction method of claim 4, wherein filling the missing data according to the data of the missing data adjacent to the open price sequence corresponding to the historical time sequence and the close price sequence of the seasonal stock comprises:
filling the missing data by using an average value of the first data and the second data when a first difference value between the first data at a position before the missing data and the second data at a position behind the missing data in a price opening sequence corresponding to the historical time sequence of seasonal stocks is larger than a preset difference value, and filling the missing data by using the first data when the first difference value between the first data and the second data is smaller than or equal to the preset difference value;
and when a second difference value between third data of a position before missing data and fourth data of a position after missing data in a closing price sequence corresponding to the historical time sequence of seasonal stocks is larger than a preset difference value, filling the missing data by using an average value of the third data and the fourth data, and when the second difference value between the third data and the fourth data is smaller than or equal to the preset difference value, filling the missing data by using the third data.
6. The seasonal stock price prediction method of claim 2, wherein training the propset model with the training samples comprises:
configuring initial parameters of a propset model to obtain the initial propset model; wherein the initial parameters include: sparse prior parameter values, prediction interval range values and elastic parameters of seasonal components;
and training the initial propset model by using a training sample, and adjusting initial parameters of the initial propset model according to the Bayesian optimization library in the training process.
7. A seasonal stock price forecasting device, comprising:
the acquisition module is used for acquiring the prediction time length of seasonal stocks to be predicted; the preset time length comprises a plurality of time points;
the stock price prediction module is used for inputting the prediction time length into a pre-trained stock price prediction model to obtain the stock price and the confidence interval corresponding to each time point of the stock in the season to be predicted in the preset time length; the stock price prediction model is obtained by training a prophet model according to stock prices corresponding to a historical time sequence of seasonal stocks and the historical time sequence.
8. The seasonal stock price prediction apparatus of claim 7, further comprising:
the model training module is used for collecting a driving price sequence and a receiving price sequence of seasonal stocks corresponding to the historical time sequence;
generating a sample set according to a drive price sequence, a take-up price sequence and a historical time sequence which correspond to the seasonal stock in the historical time sequence;
dividing samples in the sample set into training samples and test samples according to a preset proportion;
training the propset model by using a training sample;
and testing the trained propset model by using a test sample, and obtaining a trained stock price prediction model when the test passes.
9. The seasonal stock price prediction apparatus of claim 8, wherein the model training module is specifically configured to perform missing value processing on a starting price sequence and a closing price sequence corresponding to a seasonal stock in a historical time sequence, so as to obtain a complete starting price sequence and a complete closing price sequence corresponding to the seasonal stock in the historical time sequence;
summing the complete price opening sequence and the complete price closing sequence corresponding to the seasonal stock in the historical time sequence to obtain a sum sequence of the seasonal stock;
dividing the sum value sequence of the seasonal stocks by two to obtain a seasonal stock price sequence corresponding to the seasonal stocks in the historical time sequence;
and outputting seasonal stock prices corresponding to the seasonal stocks in the historical time sequence as samples, and inputting the historical time sequence as samples to obtain a sample set.
10. The seasonal stock price prediction apparatus according to claim 9, wherein the model training module is specifically configured to delete a position corresponding to missing data in the opening price sequence and the closing price sequence when the amount of missing data in the opening price sequence and the closing price sequence corresponding to the historical time sequence of the seasonal stock is smaller than a preset data amount threshold, delete a time point corresponding to missing data from the historical time sequence, and obtain a complete opening price sequence and a complete closing price sequence corresponding to the historical time sequence of the seasonal stock;
and when the data quantity of the seasonal stock missing in the opening price sequence and the closing price sequence corresponding to the historical time sequence is larger than or equal to a preset data quantity threshold value, filling the missing data according to the opening price sequence of the seasonal stock corresponding to the historical time sequence and the data of the adjacent positions of the missing data in the closing price sequence, so as to obtain a complete opening price sequence and a complete closing price sequence of the seasonal stock corresponding to the historical time sequence.
11. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor implements the method of any of claims 1 to 6 when executing the computer program.
12. A computer readable storage medium, characterized in that the computer readable storage medium stores a computer program which, when executed by a processor, implements the method of any of claims 1 to 6.
13. A computer program product, characterized in that the computer program product comprises a computer program which, when executed by a processor, implements the method of any of claims 1 to 6.
CN202310430247.6A 2023-04-20 2023-04-20 Seasonal stock price prediction method and device Pending CN116385167A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310430247.6A CN116385167A (en) 2023-04-20 2023-04-20 Seasonal stock price prediction method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310430247.6A CN116385167A (en) 2023-04-20 2023-04-20 Seasonal stock price prediction method and device

Publications (1)

Publication Number Publication Date
CN116385167A true CN116385167A (en) 2023-07-04

Family

ID=86975017

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310430247.6A Pending CN116385167A (en) 2023-04-20 2023-04-20 Seasonal stock price prediction method and device

Country Status (1)

Country Link
CN (1) CN116385167A (en)

Similar Documents

Publication Publication Date Title
Perla et al. Equilibrium imitation and growth
Stanton et al. Inside the integrated assessment models: Four issues in climate economics
Fdez-Riverola et al. Fsfrt: Forecasting system for red tides
Clarke Land use change modeling with sleuth: Improving calibration with a genetic algorithm
CN103886218B (en) Storehouse, the lake algal bloom Forecasting Methodology compensated with neutral net and support vector machine based on polynary non-stationary time series
CN111027629A (en) Power distribution network fault outage rate prediction method and system based on improved random forest
Gilbert et al. Probabilistic access forecasting for improved offshore operations
CN113434685A (en) Information classification processing method and system
Colmenar et al. Automatic generation of models for energy demand estimation using Grammatical Evolution
Wiedenmann et al. Autocorrelated error in stock assessment estimates: implications for management strategy evaluation
CN109872252A (en) A kind of electricity provider integrated evaluating method based on MATLAB algorithm
CN114580762A (en) Hydrological forecast error correction method based on XGboost
KR100920529B1 (en) Method of estimating salt contamination
CN116340726A (en) Energy economy big data cleaning method, system, equipment and storage medium
CN112036598A (en) Charging pile use information prediction method based on multi-information coupling
Bateman et al. The The Supervised Learning Workshop: A New, Interactive Approach to Understanding Supervised Learning Algorithms
Clarke Improving SLEUTH calibration with a genetic algorithm
CN109190810B (en) TDNN-based prediction method for NDVI (normalized difference vegetation index) of northern grassland area of China
Fielder et al. Large-scale fish movement affects metrics of management importance as indicated by quantitative stock assessment
CN116385167A (en) Seasonal stock price prediction method and device
CN116304699A (en) Critical sample set generation method and system based on new energy multi-station short circuit ratio
CN115185804A (en) Server performance prediction method, system, terminal and storage medium
Dornpunya et al. The reservoir inflow prediction of Sirikit dam using artificial intelligence with machine learning: extreme gradient boosting techique
CN117828312B (en) Method for managing watershed hydrologic environment and related equipment
CN113723717B (en) Method, device, equipment and readable storage medium for predicting short-term load before system day

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