Model-based stock price acquisition method and related equipment

By using the VMD-Transformers fusion model to perform multi-scale decomposition and global dependency modeling on stock trading data, the problem of insufficient stock price prediction accuracy in existing technologies is solved, and higher prediction accuracy is achieved.

CN121616399APending Publication Date: 2026-03-06SOUTH CHINA NORMAL UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511653115.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-12
Publication Date
2026-03-06

AI Technical Summary

Technical Problem

Existing stock price prediction models struggle to effectively capture the nonlinear dynamics and complex market behaviors inherent in stock prices, resulting in insufficient prediction accuracy.

Method used

The VMD-Transformers fusion model is adopted to decompose stock trading data into multiple intrinsic mode functions through variational mode decomposition (VMD), and the Transformers model is used to perform global dependency modeling of the long-term self-attention mechanism to capture long-term trend and short-term fluctuation characteristics.

Benefits of technology

It significantly improves the accuracy of stock closing price prediction, enabling more accurate prediction of stock price changes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121616399A_ABST
    Figure CN121616399A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a model-based stock price acquisition method and related equipment, and belongs to the technical field of deep learning. According to the embodiment of the invention, the method can achieve the multi-scale decomposition of the stock transaction data through a VMD technology, enables a complex non-stationary signal to be divided into a plurality of intrinsic mode functions which represent different frequency features, employs a Transformers model as a core frame, carries out the channel-level fusion of the multi-mode features after VMD decomposition with the original stock transaction data, and achieves the recognition of the original stock transaction data. And global dependency modeling is carried out on a time sequence dimension through a multi-head self-attention mechanism, so that the model can simultaneously capture long-term trend and short-term fluctuation characteristics, and the prediction precision is remarkably improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of deep learning technology, and in particular to a model-based method for obtaining stock prices and related equipment. Background Technology

[0002] In the modern financial system, the stock market, as a crucial venue for capital circulation and resource allocation, reflects not only macroeconomic conditions, industry development trends, and corporate performance, but also a multitude of complex factors such as investor psychology, policy guidance, and unforeseen events. Stock price sequences typically exhibit high volatility, nonlinearity, non-stationarity, and strong randomness, making stock price prediction one of the core challenges that has long existed in the fintech field.

[0003] Early stock price forecasting relied primarily on traditional statistical methods and economic models. For example, methods such as the Autoregressive Moving Average (ARIMA) model and the Generalized Autoregressive Conditional Heteroskedasticity (GARCH) model performed well in handling stationary linear time series. However, these models typically assume that the data satisfies linear relationships and stationarity conditions, making it difficult to effectively capture the nonlinear dynamics and complex market behavior inherent in stock prices.

[0004] With the rapid development of computer science and artificial intelligence, researchers have begun to introduce machine learning and deep learning methods to improve the performance of stock prediction. Especially with the support of big data, cloud computing, and high-performance computing architectures, stock prediction is gradually shifting from traditional models relying on human experience to data-driven models. Prediction models based on algorithms such as Neural Networks, Support Vector Machines (SVM), Random Forests, and Long Short-Term Memory Networks (LSTM) can, to some extent, learn the non-linear patterns in stock price sequences, improving prediction accuracy. Although deep learning and machine learning models have good predictive performance for time series, for complex and highly volatile time series like stocks, their prediction accuracy still has significant room for improvement, and the calculated closing prices remain inaccurate.

[0005] In summary, the technical problems existing in the relevant technologies need to be improved. Summary of the Invention

[0006] The main objective of this application is to propose a model-based stock price acquisition method and related equipment to improve the accuracy of stock closing price calculation results.

[0007] To achieve the above objectives, one aspect of this application proposes a model-based stock price acquisition method, the method comprising:

[0008] In some embodiments, inputting the transaction feature data into the VMD-Transformers fusion model to obtain the closing price of the latest trading day output by the model includes: The transaction feature data is input into the VMD model, which is used to perform variational mode decomposition to obtain eigenmode functions of different frequencies. The transaction feature data and the intrinsic mode function are input into the Transformers model to obtain the closing price of the latest trading day output by the Transformers model.

[0009] In some embodiments, the method further includes: generating the VMD-Transformers fusion model; The generation of the VMD-Transformers fusion model includes: Acquire stock training data, which includes stock trading training data and stock training closing prices; The stock trading training data is input into the initial VMD model, and the training intrinsic mode function of the stock trading training data is obtained from the output of the initial VMD model. The trained intrinsic mode function is input into the initial Transformers model to obtain the predicted closing price output by the Transformers model; Based on the closing price difference between the training closing price and the predicted closing price, the parameters of the initial VMD model and the Transformers model are optimized through an optimization layer until the closing price difference is less than a preset difference, thus determining the VMD-Transformers fusion model.

[0010] In some embodiments, the initial Transformers model includes an embedding layer, a multi-head self-attention structure, a linear fully connected network, an output layer, and an optimization layer; The input embedding layer of the initial Transformers model has a dimension of 256, the number of attention heads in the multi-head self-attention structure is 4, and the network dimension of the linear fully connected network is 1024.

[0011] In some embodiments, the step of optimizing the parameters of the initial VMD model and the Transformers model through an optimization layer based on the closing price difference between the stock training closing price and the predicted closing price, until the closing price difference is less than a preset difference, and determining the VMD-Transformers fusion model, includes: The method involves optimizing the parameters of the initial VMD model and the Transformers model using a Bayesian optimization algorithm loaded in the optimization layer based on the closing price difference between the training closing price and the predicted closing price, until the closing price difference is less than a preset difference, thereby determining the VMD-Transformers fusion model.

[0012] In some embodiments, the step of inputting the stock trading training data into an initial VMD model and obtaining the training intrinsic mode function of the stock trading training data output by the initial VMD model includes: The stock trading training data is input into the initial VMD model to obtain the four training intrinsic mode functions of the stock trading training data with continuous frequencies output by the initial VMD model.

[0013] To achieve the above objectives, another aspect of this application proposes a stock price acquisition device based on a fusion model, the device comprising: The acquisition module is used to acquire stock trading data, which includes the opening price, highest price, lowest price, closing price and trading volume of at least one trading day. The processing module is used to preprocess the stock trading data to obtain trading feature data; The prediction module is used to input the transaction feature data into the VMD-Transformers fusion model to obtain the closing price of the latest trading day output by the model.

[0014] To achieve the above objectives, another aspect of this application provides an electronic device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the method described above.

[0015] To achieve the above objectives, another aspect of the embodiments of this application proposes a computer-readable storage medium storing a computer program that, when executed by a processor, implements the methods described above.

[0016] To achieve the above objectives, another aspect of this application provides a computer program product, including a computer program that, when executed by a processor, implements the methods described above. The embodiments of this application include at least the following beneficial effects: This application provides a model-based stock price acquisition method, apparatus, electronic device, storage medium, and program product. This solution acquires stock trading data, including at least one trading day's opening price, highest price, lowest price, closing price, and trading volume; preprocesses the stock trading data to obtain trading feature data; and inputs the trading feature data into a VMD-Transformers fusion model to obtain the latest trading day's closing price output by the model. This embodiment can utilize the VMD-Transformers fusion model, combined with stock trading data from previous trading days, to output the latest trading day's closing price. Through VMD technology, stock trading data is decomposed into multiple scales, dividing complex non-stationary signals into multiple intrinsic mode functions, each representing different frequency characteristics. Using the Transformers model as the core framework, the multi-modal features decomposed by VMD are fused with the original stock trading data at the channel level. Furthermore, a multi-head self-attention mechanism is used to perform global dependency modeling in the time-series dimension, enabling the model to simultaneously capture long-term trends and short-term fluctuations, significantly improving prediction accuracy. Attached Figure Description

[0017] Figure 1 This is a flowchart of a model-based stock price acquisition method provided in an embodiment of this application; Figure 2 This is the closing price prediction candlestick chart output by the VMD-Transformers fusion model; Figure 3 This is a schematic diagram of the structure of the stock price acquisition device based on the fusion model provided in the embodiments of this application; Figure 4 This is a schematic diagram of the hardware structure of the electronic device provided in the embodiments of this application. Detailed Implementation

[0018] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of this application and are not intended to limit it. In the following description, when referring to the accompanying drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with those of this application; they are merely examples of apparatuses and methods consistent with some aspects of the embodiments of this application as detailed in the appended claims.

[0019] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of this application only and is not intended to limit this application.

[0020] Before providing a detailed description of the embodiments of this application, some of the nouns and terms involved in the embodiments of this application will be explained first. The nouns and terms involved in the embodiments of this application are subject to the following interpretations.

[0021] 1) Variational mode decomposition (VMD) is an advanced signal processing technique that can decompose signals in the time and frequency domains, thereby revealing the complex structure and dynamic characteristics of signals.

[0022] 2) Bayesian optimization algorithm: a sequence model optimization method used for global optimization.

[0023] In the context of related technologies, the stock market, as a crucial venue for capital circulation and resource allocation within the modern financial system, reflects not only macroeconomic conditions, industry development trends, and corporate performance, but also a multitude of complex factors such as investor psychology, policy guidance, and unforeseen events. Stock price sequences typically exhibit high volatility, nonlinearity, non-stationarity, and strong randomness, making stock price prediction one of the core challenges that has long existed in the fintech field.

[0024] Early stock price forecasting relied primarily on traditional statistical methods and economic models. For example, methods such as the Autoregressive Moving Average (ARIMA) model and the Generalized Autoregressive Conditional Heteroskedasticity (GARCH) model performed well in handling stationary linear time series. However, these models typically assume that the data satisfies linear relationships and stationarity conditions, making it difficult to effectively capture the nonlinear dynamics and complex market behavior inherent in stock prices.

[0025] With the rapid development of computer science and artificial intelligence, researchers have begun to introduce machine learning and deep learning methods to improve the performance of stock prediction. Especially with the support of big data, cloud computing, and high-performance computing architectures, stock prediction is gradually shifting from traditional models relying on human experience to data-driven models. Prediction models based on algorithms such as Neural Networks, Support Vector Machines (SVM), Random Forests, and Long Short-Term Memory Networks (LSTM) can, to some extent, learn the non-linear patterns in stock price sequences, improving prediction accuracy. Although deep learning and machine learning models have good predictive performance for time series, for complex and highly volatile time series like stocks, their prediction accuracy still has significant room for improvement, and the calculated closing prices remain inaccurate.

[0026] In view of this, this application provides a stock price acquisition method based on a fusion model. This method acquires stock trading data, including the opening price, highest price, lowest price, closing price, and trading volume of at least one trading day; preprocesses the stock trading data to obtain trading feature data; and inputs the trading feature data into a VMD-Transformers fusion model to obtain the closing price of the latest trading day output by the model. This embodiment utilizes the VMD-Transformers fusion model, combined with stock trading data from previous trading days, to output the closing price of the latest trading day. Through VMD technology, stock trading data is decomposed into multiple scales, dividing complex non-stationary signals into multiple intrinsic mode functions (IMFs) to represent different frequency characteristics. Using the Transformers model as the core framework, the multimodal features decomposed by VMD are fused with the original stock trading data at the channel level. Furthermore, a multi-head self-attention mechanism is used to perform global dependency modeling in the time-series dimension, enabling the model to simultaneously capture long-term trends and short-term fluctuations, significantly improving prediction accuracy.

[0027] The model-based stock price acquisition method provided in this application relates to the field of deep learning technology. This model-based stock price acquisition method can be applied to a terminal, a server, or software running on either a terminal or a server. In some embodiments, the terminal can be a smartphone, tablet, laptop, desktop computer, smart speaker, smartwatch, or in-vehicle terminal, but is not limited to these. The server can be configured as an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. The server can also be a node server in a blockchain network. The software can be an application implementing the model-based stock price acquisition method, but is not limited to the above forms.

[0028] This application can be used in a wide variety of general-purpose or special-purpose computer system environments or configurations. Examples include: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics devices, network PCs, minicomputers, mainframe computers, and distributed computing environments including any of the above systems or devices. This application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc., that perform specific tasks or implement specific abstract data types. This application can also be practiced in distributed computing environments where tasks are performed by remote processing devices connected via a communication network. In distributed computing environments, program modules can reside in local and remote computer storage media, including storage devices.

[0029] It should be noted that in all specific embodiments of this application, when processing data related to user identity or characteristics, such as user information, user behavior data, user historical data, and user location information, user permission or consent is obtained first. Furthermore, the collection, use, and processing of this data comply with relevant laws, regulations, and standards. In addition, when embodiments of this application require access to sensitive personal information of users, separate permission or consent from the user is obtained through pop-ups or redirection to confirmation pages. Only after obtaining the user's separate permission or consent is the necessary user-related data required for the proper functioning of these embodiments acquired.

[0030] Figure 1This is an optional flowchart of the model-based stock price acquisition method provided in the embodiments of this application. Figure 1 The method may include, but is not limited to, steps S101 to S103.

[0031] Step S101: Obtain stock trading data, which includes the opening price, highest price, lowest price, closing price, and trading volume for at least one trading day.

[0032] The collected stock trading data can be complete stock information for a company from January 1, 2006 to January 1, 2018 for all trading days. Stock trading data is then filtered out from this data. The stock trading data is shown in Table 1.1, where Date is the trading date, Open is the opening price, High is the highest price, Low is the lowest price, Close is the closing price, Volume is the trading volume, and Name is the stock name.

[0033]

[0034] Table 1.1 Partial Stock Trading Data of a Certain Company Step S102: Perform data preprocessing on the stock trading data to obtain trading feature data.

[0035] When performing data preprocessing, specific processing steps may include: (1) Read stock trading data and map the stock trading data, delete missing values, and keep only the key feature columns Open, High, Low, Close and Volume.

[0036] (2) Use MinMaxScaler (data normalization tool) to scale all features to the [0,1] interval to ensure that data of different scales are trained on the same scale.

[0037] (3) Time series samples are generated by sliding with a fixed window length (seq_length). Each input sample contains five-dimensional features for L consecutive time steps, which are used to predict the Close value at the next time step.

[0038] Step S103: Input the transaction feature data into the VMD-Transformers fusion model to obtain the closing price of the latest trading day output by the model.

[0039] Variational Mode Decomposition (VMD) is an adaptive signal processing method suitable for the analysis of nonlinear and non-stationary signals. This algorithm decomposes complex signals into several intrinsic mode functions (IMFs) with finite bandwidth by establishing a variational optimization model. Each IMF corresponds to an oscillation mode in the signal.

[0040] Assuming each mode has a finite frequency bandwidth, the goal of the problem is to solve for the K mode functions. Where k = 1, 2, ..., K. Then, the center frequency of each mode is used for calculation. The specific structural steps are as follows: a. For each mode function Perform a Hilbert transform, denoted as And obtain the corresponding instantaneous frequency: (1) b. Predict the center frequency of each mode by combining and analyzing the mode signals. The frequency bandwidth of each mode is adjusted using the following formula: (2) in, Represents the complex exponential form in the frequency domain. This is the center frequency of the mode.

[0041] c. Calculate the frequency bandwidth of each mode signal, and solve for the signal's frequency bandwidth based on the frequency domain transformation. The goal is to minimize the following expression: (3) The constraints are: (4) Where K is the number of patterns that need to be solved. Let f be the signal function corresponding to each mode in the solution result, and f be the input signal. The center frequency for each mode.

[0042] The Transformer model is a time series forecasting model based on a multi-head self-attention mechanism, capable of simultaneously capturing short-term and long-term dependencies between different time steps in a stock sequence. Compared to traditional recurrent neural networks (RNN, LSTM), this structure does not rely on recursive computation but instead achieves global feature extraction through matrix parallel operations, thereby improving training efficiency and prediction accuracy. The basic architecture of this model is as follows: 1) Input layer The input data is a normalized multidimensional time series: Where T is the time step length, This indicates the input feature dimensions, corresponding to the opening price, highest price, lowest price, closing price, and volume.

[0043] During the input phase, the model first projects the input features onto a unified model dimension through a linear mapping. And position encoding is superimposed to preserve the temporal information of the sequence. H 0: (5) in Let P be the input mapping matrix, and P be the position encoding matrix.

[0044] 2) Self-attention mechanism The core of the Transformer is its self-attention mechanism, which captures global dependencies by calculating the correlation matrix between time steps. For any layer of input representation... Where T is the sequence length. Define the query (Q), key (K), and value (V) matrix as follows: ,in dk is the key and query vector dimension of each attention head. The formula for calculating single-head attention is: (6) Softmax represents the normalization function. d k The dimension of the key vector is represented by , and Attention represents the output of the attention mechanism.

[0045] The multi-head attention mechanism consists of h independent attention heads, each of which learns temporal dependencies in a different subspace. (7) head 1 , ...head h This represents the individual heads in a multi-head attention mechanism. Concat This indicates a splicing operation. W O This represents the output weight matrix.

[0046] in: (8) This design allows the model to extract information in parallel at different time scales or feature subspaces, thereby improving modeling capabilities.

[0047] 3) Feedforward fully connected network Each Transformer encoding layer also contains a position-wise feedforward network for performing non-linear feature transformations on the attention output: (9) in, , d ff Usuallyd model Four times that.

[0048] The output of the coding layer employs residual connections and layer normalization to enhance stability.

[0049] (10) 4) Output layer and prediction After several layers of encoding, the hidden state matrix of the Transformer output sequence The model takes the hidden state vector h at the last time step. t The predicted result is obtained after linear layer mapping: (11) in , The predicted closing price at the next moment. b o This represents the bias term of the output layer.

[0050] (5) Loss function and optimization The model training uses the mean squared error (MSE) loss function to measure the difference between the predicted and actual values: (12) The optimizer uses the Adam algorithm to update model parameters through backpropagation: (13) θ Represents the model parameter vector. η This represents the learning rate.

[0051] Steps S101 to S103, as illustrated in this embodiment, involve acquiring stock trading data, including the opening price, highest price, lowest price, closing price, and trading volume of at least one trading day; preprocessing the stock trading data to obtain trading feature data; and inputting the trading feature data into the VMD-Transformers fusion model to obtain the closing price of the latest trading day output by the model, such as... Figure 2As shown, the prediction is generated. This embodiment utilizes the VMD-Transformers fusion model, combining stock trading data from previous trading days to output the closing price for the latest trading day. Through VMD technology, stock trading data is decomposed into multiple scales, dividing complex non-stationary signals into multiple intrinsic mode functions (IMFs) to represent different frequency characteristics. Using the Transformers model as the core framework, the multimodal features decomposed by VMD are fused with the original stock trading data at the channel level. Furthermore, a multi-head self-attention mechanism is used to perform global dependency modeling in the time series dimension, enabling the model to simultaneously capture long-term trends and short-term fluctuations, significantly improving prediction accuracy.

[0052] Table 1.2 shows the comparison results of the accuracy of the VMD-Transformers fusion model in this embodiment with other benchmark models when predicting closing prices:

[0053] Table 1.1 Partial Stock Trading Data of a Certain Company In some embodiments, this application also includes a training process for the VMD-Transformers fusion model, including: Acquire stock training data, which includes stock trading training data and stock training closing prices; Input the stock trading training data into the initial VMD model and obtain the training intrinsic mode function of the stock trading training data output by the initial VMD model; The trained intrinsic mode functions are input into the initial Transformers model to obtain the predicted closing price output by the Transformers model. Based on the closing price difference between the training closing price and the predicted closing price, the parameters of the initial VMD model and the Transformers model are optimized through an optimization layer until the closing price difference is less than a preset difference, thus determining the VMD-Transformers fusion model.

[0054] The entire training process begins with stock training data. This data includes five basic indicators for each trading day: opening price, high price, low price, closing price, and trading volume. These indicators collectively reflect the market's price fluctuations and trading activity on that day. First, this stock training data is cleaned to remove missing or outlier values, and then all feature values ​​are scaled to a uniform range of 0 to 1 using a min-max normalization method. This eliminates differences in numerical magnitude between different features, ensuring that the model is not biased during training due to excessively large values ​​in any one column.

[0055] The normalized data was further divided into multiple time segments to form training samples. The model uses data from 14 consecutive trading days as an input window to predict the closing price on the 15th day. Each sample contains 14 days of historical information, and the system learns the mapping pattern between these "past 14-day trends" and "15-day prices" to gain predictive ability. The sliding window segmentation method generates a large number of samples throughout the training set, allowing the model to comprehensively learn the volatility characteristics of different market phases.

[0056] In each sample, variational mode decomposition (VMD) is performed on the closing price sequence. This step breaks down the original price signal into four intrinsic mode functions (IMFs) of different frequencies. Each IMF corresponds to a component of price volatility, such as long-term trends, cyclical fluctuations, short-term disturbances, and high-frequency noise. In this way, the complex closing price is decomposed into four layers of more easily analyzed sub-signals, helping the model to understand the patterns of price changes hierarchically.

[0057] Next, the five original features (Open, High, Low, Close, Volume) corresponding to each time step are concatenated with the four IMF components by channel to form a 9-dimensional feature input. In this way, when processing the data for each day, the model can see both the original transaction features and simultaneously observe the different frequency information obtained from VMD decomposition, achieving multi-source information fusion. The concatenated data has a shape of (14 days × 9 features), representing a complete input sequence.

[0058] These fused features first enter the model's input embedding layer. Here, a linear transformation maps the 9-dimensional features at each time step to a 256-dimensional high-dimensional representation space (d_model = 256). This process can be understood as "translating" the original tabular data into an internal language that the model can understand. To enable the model to perceive time sequence, positional encoding is also superimposed on each time step to identify "day 1," "day 2," etc., so that the model does not confuse the time sequence during computation.

[0059] Subsequently, the data enters the core of the model—a multi-head self-attention structure. Each layer consists of four attention heads (nhead = 4) operating in parallel. Each attention head analyzes the dependencies in the time series from a different perspective; for example, some heads focus on long-term trends, while others focus on short-term fluctuations. The first layer of self-attention allows the model to capture the interactions between different days from a global perspective. The output is superimposed on the original input through a residual connection, thus preserving the original features while absorbing new information. The second layer of self-attention further strengthens the temporal dependencies, helping the model to understand the price changes over time more deeply. Since the dropout parameter is set to 0.0, there is no additional random discarding in this stage, ensuring the complete transmission of information.

[0060] After attention processing, the model outputs a feature sequence of shape (14 days × 256 dimensions). The system takes the 256-dimensional vector from the last time step (day 14) as the model's comprehensive understanding of the entire window; this vector contains all the temporal relationships and feature fusion information from the previous 14 days. Subsequently, the vector enters a linear fully connected network and is activated by ReLU for further compression and extraction of key features. Finally, it is mapped to a scalar through the output layer—corresponding to the predicted closing price for the next day. The entire predicted value lies in a normalized space of 0 to 1.

[0061] The model learns by minimizing the mean squared error (MSE) between the predicted value and the actual closing price. The optimizer uses the AdamW algorithm with a learning rate of 0.0003 and a weight decay parameter of 0.0. In each epoch, the model updates its parameters on the training set and evaluates its performance on the validation set. If the validation loss (val_loss) reaches its historical minimum in a given epoch, the system saves the model weights for that epoch as the "best model." In the final hyperparameter tuning phase, the system uses the Optuna Bayesian optimization algorithm to automatically search for key hyperparameters. After multiple trials, the optimal configuration was determined to be: input sequence length 14, model dimension 256, attention heads 4, dropout 0, learning rate 0.0003, weight decay 0, batch size 16, and VMD decomposition layers K=4 (the parameters mentioned above).

[0062] Finally, the best-performing model after training is used to make predictions on the test data. The normalized closing price output by the model is denormalized to restore the true price scale and plotted on the candlestick chart. The MSE and RMSE in the normalized space are also calculated simultaneously to quantify the model's performance.

[0063] This invention uses two metrics to evaluate the effectiveness of the model: MSE and RMSE. MSE and RMSE are used to measure the accuracy of the model's predictions. Simultaneously, a predicted candlestick chart for each model is plotted and compared with the actual candlestick chart. The following two formulas define MSE and RMSE: (1) Mean Square Error (14) in This represents the true closing price of the sample. Here, N represents the model's predicted value, and N is the sample size. MSE reflects the mean squared deviation between the model's predicted value and the true value; a smaller value indicates a smaller prediction error and a better fit.

[0064] (2) Root mean square error (15) RMSE is the square root of MSE, and it more intuitively reflects the average magnitude of prediction bias. The smaller the RMSE value, the closer the model's prediction is to the true value, and the higher its prediction accuracy.

[0065] RMSE is the square root of MSE, and it more intuitively reflects the average magnitude of prediction bias. The smaller the RMSE value, the closer the model's prediction is to the true value, and the higher its prediction accuracy.

[0066] Bayesian optimization is an intelligent algorithm used to automatically find optimal parameters. Unlike traditional trial-and-error methods, Bayesian optimization considers both known information and potential unknowns at each decision step, thus finding the optimal solution with fewer attempts.

[0067] This method is particularly suitable for the automatic adjustment of deep learning model parameters, which can improve model performance while reducing manual parameter tuning work.

[0068] (1) Optimization objective During model training, there are usually several hyperparameters that need to be manually set, such as learning rate, batch size, number of network layers, and hidden unit dimension. The goal of Bayesian optimization is to find a set of optimal hyperparameter vectors. (16) Where x = [x1, x2, ..., xn] represents the hyperparameter vector, f(x) represents the objective function (validation error or model loss), and Z is the hyperparameter search space. Since each model training requires significant computation, Bayesian optimization aims to find the optimal hyperparameter combination as quickly as possible with fewer trials.

[0069] (2) Proxy Model Bayesian optimization approximates the true objective function by constructing a surrogate model. A commonly used surrogate model is the Gaussian Process (GP), which can be understood as a probability curve that is "automatically fitted" based on existing data. Given a set of sampled hyperparameters and their performance results... After that, GP will be at the new hyperparameter point Two prediction results are given below: Forecast Mean The model estimates the performance under this combination of hyperparameters.

[0070] Forecast uncertainty : Indicates the model's confidence level in the prediction result.

[0071] This probabilistic modeling approach allows the algorithm to consider both "areas known to perform well" and "areas yet to be explored".

[0072] (3) Acquisition function To strike a balance between exploring new regions and leveraging existing experience, Bayesian optimization introduces a collection function. Based on the surrogate model's predictions, the collection function measures the "potential benefit" of each candidate hyperparameter combination and selects the point that maximizes the collection function as the hyperparameters for the next experiment. (17) (4) Optimization process Step 1: Define the search space First, determine the types of hyperparameters to be optimized and their value ranges based on the target task. For example, the learning rate can be set to vary between 0.00001 and 0.1, the batch size can be selected as 32, 64, or 128, and the dropout rate can be between 0 and 0.5. These hyperparameters and their ranges together constitute the search space.

[0073] Step 2: Initialize the sample Within the defined search space, randomly select several sets of hyperparameter combinations as initial samples (e.g., 5 sets). For each set of hyperparameters, train the model separately and record the corresponding performance metrics (e.g., accuracy or loss value). Save the hyperparameter combinations and their training results as the initial dataset to provide a foundation for subsequent modeling.

[0074] Step 3: Establish the proxy model Using the data obtained in the previous step, a mathematical model, namely a surrogate model, is constructed that can approximately describe the relationship between hyperparameters and model performance. In this method, a Gaussian process regression model is preferred. This model can not only predict the possible values ​​of model performance under different combinations of hyperparameters, but also quantify the degree of uncertainty in the prediction. In other words, it can "guess" how untried parameter combinations will perform, and at the same time determine whether it is confident in this guess.

[0075] Step 4: Design the data acquisition function After obtaining the surrogate model, a "decision function" is constructed to guide the selection of which hyperparameter combination should be chosen for the next real training iteration. This function is designed to balance two considerations: Exploratory: Tends to select regions where the model is not yet certain in order to discover potential new optimal solutions; Utilization: There is a tendency to continue exploring for better results in areas where current predictions are better.

[0076] Step 5: Determine the next set of candidate parameters Within the entire search space, the value of each possible hyperparameter combination under the acquisition function is calculated, and the combination with the highest value is selected as a candidate point for practical verification in the next round. This combination is considered to be theoretically most likely to improve model performance.

[0077] Step Six: Model Training and Data Update The model is retrained using the selected hyperparameter combination to obtain new performance results. These results, along with the parameter combination, are then added to the dataset to update the data used for surrogate modeling. The surrogate model is then retrained again based on the updated data to improve prediction accuracy.

[0078] Step 7: Iterate until convergence. Repeat steps three through six, continuously updating the surrogate model and acquisition function to guide the search process towards the global optimum. Stop the optimization process when the set maximum number of iterations is reached, performance improvement is insufficient, or computational resources are exhausted. Finally, output the optimal hyperparameter combination as the model's optimal configuration.

[0079] Please see Figure 3 This application also provides a stock price acquisition device based on a fusion model, which can implement the above-described method. The device includes: The acquisition module 31 is used to acquire stock trading data, which includes the opening price, highest price, lowest price, closing price and trading volume of at least one trading day. Processing module 32 is used to preprocess the stock trading data to obtain trading feature data; The prediction module 33 is used to input the transaction feature data into the VMD-Transformers fusion model to obtain the closing price of the latest trading day output by the model.

[0080] In some embodiments, the prediction module 33 is used to input the transaction feature data into the VMD model, the VMD model being used to perform variational mode decomposition to obtain eigenmode functions of different frequencies; The transaction feature data and the intrinsic mode function are input into the Transformers model to obtain the closing price of the latest trading day output by the Transformers model.

[0081] In some embodiments, the apparatus further includes: a model generation module 34, comprising: Acquire stock training data, which includes stock trading training data and stock training closing prices; The stock trading training data is input into the initial VMD model, and the training intrinsic mode function of the stock trading training data is obtained from the output of the initial VMD model. The trained intrinsic mode function is input into the initial Transformers model to obtain the predicted closing price output by the Transformers model; Based on the closing price difference between the training closing price and the predicted closing price, the parameters of the initial VMD model and the Transformers model are optimized through an optimization layer until the closing price difference is less than a preset difference, thus determining the VMD-Transformers fusion model.

[0082] The model generation module 34 is used to generate the initial Transformers model, which includes an embedding layer, a multi-head self-attention structure, a linear fully connected network, an output layer, and an optimization layer. The input embedding layer of the initial Transformers model has a dimension of 256, the number of attention heads in the multi-head self-attention structure is 4, and the network dimension of the linear fully connected network is 1024.

[0083] The model generation module 34 is used to: optimize the parameters of the initial VMD model and the Transformers model by using the Bayesian optimization algorithm loaded in the optimization layer based on the closing price difference between the stock training closing price and the predicted closing price, until the closing price difference is less than a preset difference, and determine the VMD-Transformers fusion model.

[0084] Model generation module 34 is used for: The stock trading training data is input into the initial VMD model to obtain the four training intrinsic mode functions of the stock trading training data with continuous frequencies output by the initial VMD model.

[0085] It is understood that the content of the above method embodiments is applicable to the present device embodiments. The specific functions implemented by the present device embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.

[0086] This application also provides an electronic device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the above-described method. This electronic device can be any smart terminal, including tablet computers, in-vehicle computers, etc.

[0087] It is understood that the content of the above method embodiments is applicable to this device embodiment. The specific functions implemented by this device embodiment are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.

[0088] Please see Figure 4 , Figure 4 The hardware structure of an electronic device according to another embodiment is illustrated. The electronic device includes: The processor 401 can be implemented using a general-purpose CPU (Central Processing Unit), microprocessor, application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this application. The memory 402 can be implemented as a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 402 can store the operating system and other applications. When the technical solutions provided in the embodiments of this specification are implemented through software or firmware, the relevant program code is stored in the memory 402 and is called and executed by the processor 401 using the methods described in the embodiments of this application. Input / output interface 403 is used to implement information input and output; The communication interface 404 is used to enable communication and interaction between this device and other devices. Communication can be achieved through wired means (such as USB, Ethernet cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.). Bus 405 transmits information between various components of the device (e.g., processor 401, memory 402, input / output interface 403, and communication interface 404); The processor 401, memory 402, input / output interface 403 and communication interface 404 are connected to each other within the device via bus 405.

[0089] This application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described method.

[0090] It is understood that the content of the above method embodiments is applicable to this storage medium embodiment. The specific functions implemented in this storage medium embodiment are the same as those in the above method embodiments, and the beneficial effects achieved are also the same as those achieved in the above method embodiments.

[0091] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the above-described method.

[0092] It is understood that the content of the above method embodiments is applicable to the embodiments of this program product. The specific functions implemented by the embodiments of this program product are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.

[0093] Memory, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs and non-transitory computer-executable programs. Furthermore, memory may include high-speed random access memory, and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some embodiments, memory may optionally include memory remotely located relative to the processor, and these remote memories can be connected to the processor via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.

[0094] The embodiments described in this application are for the purpose of more clearly illustrating the technical solutions of the embodiments of this application, and do not constitute a limitation on the technical solutions provided by the embodiments of this application. As those skilled in the art will know, with the evolution of technology and the emergence of new application scenarios, the technical solutions provided by the embodiments of this application are also applicable to similar technical problems.

[0095] Those skilled in the art will understand that the technical solutions shown in the figures do not constitute a limitation on the embodiments of this application, and may include more or fewer steps than shown, or combine certain steps, or different steps.

[0096] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.

[0097] Those skilled in the art will understand that all or some of the steps in the methods disclosed above, as well as the functional modules / units in the systems and devices, can be implemented as software, firmware, hardware, or suitable combinations thereof.

[0098] The terms “first,” “second,” “third,” “fourth,” etc. (if present) in the specification and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms “comprising” and “having,” and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0099] It should be understood that in this application, "at least one (item)" means one or more, and "more than" means two or more. "And / or" is used to describe the relationship between related objects, indicating that three relationships can exist. For example, "A and / or B" can represent three cases: only A exists, only B exists, and both A and B exist simultaneously, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one (item) of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one (item) of a, b, or c can represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, and c can be single or multiple.

[0100] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of the units described above is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.

[0101] The units described above as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0102] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0103] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes multiple instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing programs, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0104] The preferred embodiments of the present application have been described above with reference to the accompanying drawings, but this does not limit the scope of the claims of the present application. Any modifications, equivalent substitutions, and improvements made by those skilled in the art without departing from the scope and substance of the embodiments of the present application shall be within the scope of the claims of the present application.

Claims

1. A model-based stock price acquisition method, characterized by, The method comprises: obtaining stock transaction data, the stock transaction data comprising opening price, highest price, lowest price, closing price and trading volume of at least one trading day; data preprocessing is carried out on the stock transaction data to obtain transaction feature data; inputting the transaction feature data into a VMD-Transformers fusion model to obtain the closing price of the latest trading day output by the model.

2. The method of claim 1, wherein, The transaction feature data is inputted into a VMD model, and the VMD model is used to perform variational mode decomposition to obtain an intrinsic mode function of different frequencies. The transaction feature data and the intrinsic mode function are inputted into the Transformers model to obtain the closing price of the latest trading day output by the Transformers model. The method further comprises generating the VMD-Transformers fusion model.

3. The method of claim 1, wherein, The generation of the VMD-Transformers fusion model comprises: obtaining stock training data, the stock training data comprising stock transaction training data and stock training closing price; inputting the stock transaction training data into an initial VMD model to obtain training intrinsic mode functions of the stock transaction training data output by the initial VMD model; inputting the training intrinsic mode functions into an initial Transformers model to obtain predicted closing prices output by the Transformers model; performing parameter optimization on the initial VMD model and the Transformers model through an optimization layer according to the closing price difference between the stock training closing price and the predicted closing price until the closing price difference is less than a preset difference value, to determine the VMD-Transformers fusion model. The initial Transformers model comprises an embedding layer, a multi-head self-attention structure, a linear fully connected network, an output layer and an optimization layer; 4. The method of claim 3, wherein, the input embedding layer dimension of the initial Transformers model is 256, the number of attention heads in the multi-head self-attention structure is 4, and the network dimension of the linear fully connected network is 1024. The parameter optimization on the initial VMD model and the Transformers model through the optimization layer according to the closing price difference between the stock training closing price and the predicted closing price until the closing price difference is less than a preset difference value to determine the VMD-Transformers fusion model comprises:

5. The method of claim 3, wherein, the parameter optimization on the initial VMD model and the Transformers model through the Bayesian optimization algorithm loaded in the optimization layer according to the closing price difference between the stock training closing price and the predicted closing price until the closing price difference is less than a preset difference value to determine the VMD-Transformers fusion model. ​ 6. The method of claim 3, wherein, The inputting the stock transaction training data into the initial VMD model comprises: The inputting the stock transaction training data into the initial VMD model comprises:

7. A stock price acquisition device based on a fusion model, characterized in that, The device comprises: The acquisition module is configured to acquire stock transaction data, the stock transaction data comprising opening price, highest price, lowest price, closing price and trading volume of at least one trading day; The processing module is configured to perform data preprocessing on the stock transaction data to obtain transaction feature data; The prediction module is configured to input the transaction feature data into a VMD-Transformers fusion model to obtain the closing price of the latest trading day output by the model.

8. An electronic device / computer apparatus, characterized by The electronic device / computer device comprises a memory and a processor, the memory storing a computer program, and the processor implements the method of any one of claims 1-7 when executing the computer program.

9. A computer-readable storage medium storing a computer program, the computer program comprising instructions that, when executed by a computer, cause the computer to perform the method of any one of claims 1 to 8. The computer program is executed by the processor to implement the method of any one of claims 1-6.

10. A computer program product comprising a computer program, characterized in that, The computer program is executed by the processor to implement the method of any one of claims 1-6.