Under economic globalization,stocks,as an important financial tool,reflect the operating conditions of enterprises and the economic development states of our nation.As stock prices have gradually become the focus of investment institutions,major companies,governments and individual investors,it’s imperative to predict the trend of stock prices accurately.This paper adopts the LSTM-Transformer fusion model for stock price prediction,which is especially appropriate for time series modeling problems because of its recursive structure and quick extraction of time series data.Although LSTM can alleviate the long-term dependency problem to a certain extent,it is still incapable of solving the long-term dependency problem due to the recursive structure.The Transformer model based on the self-attention mechanism adopts a parallel attention mechanism,which does not have long-term dependency problems,and can extract distant time series features.However,it is the parallel mechanism that the input of the Transformer has the lack of time information.According to the above situation,this paper constructs a fusion model based on LSTM and Transformer.First of all,LSTM is used to extract the short-term features of the data.Second,the Transformer is further used to extract long-term features of the output of LSTM.Finally,the final prediction results are generated through the fully connected layer.The present study utilizes the stocks of Ping An Bank,China Unicom,China and Vanke,Eastern Airlines as research objects.The MSE is selected as the loss function.The MAE,MSE,RMSE,and RMPE are chosen as the evaluation indicators.We compare the LSTM-Transformer model with the prediction effects of SVR,LSTM,GRU,and Transformer models.It is verified that the LSTM-Transformer model is better than the above models.At the meantime,the optimum results obtained in four different industry stock price data sets prove that the model has good universality. |