Computer Engineering and Applications ›› 2023, Vol. 59 ›› Issue (13): 325-334.DOI: 10.3778/j.issn.1002-8331.2212-0127

• Engineering and Applications • Previous Articles    

Causal Attention Transformer Model for Stock Price Prediction

REN Jiayi, WANG Aiyin   

  1. School of Statistics and Data Science, Xinjiang University of Finance and Economics, Urumqi 830012, China
  • Online:2023-07-01 Published:2023-07-01

融合因果注意力Transformer模型的股价预测研究

任佳屹,王爱银   

  1. 新疆财经大学 统计与数据科学学院,乌鲁木齐 830012

Abstract: Stock price prediction is a key topic of common concern for financial research and quantitative investment, and the use of deep learning techniques to reveal the market patterns of stock markets has become a hot research topic in recent years. Most of the existing deep learning models for stock price prediction only study point-in-time data, and this structural shortcoming causes them to fail to reflect the impact of the cumulative effect of feature factors on stock prices. To address this, a Transformer-based stock price forecasting model Stockformer is proposed by redesigning the model to handle time series data. it mines the time-series dependence between stock prices and feature factors through a causal self-attentiveness mechanism, employs a trend enhancement module to provide the model with the trend features of the series, and uses encoder-specific inputs to provide the prediction direct a priori information of the input features. The experimental results show that the prediction accuracy of Stockformer is significantly better than that of existing deep learning models, and the average absolute error and root mean square error are reduced by 23.2% and 25.7%, respectively, compared with the classical Transformer prediction model, and the predicted values are more suitable to the real values; and the ablation experiments are conducted to evaluate the causal attention mechanism of Stockformer, the effects of the time-series feature extraction means and specific model inputs are evaluated by ablation experiments respectively, and the superiority and generalizability of the proposed model are verified.

Key words: stock price prediction, time series, deep learning, Transformer, attention mechanism

摘要: 股票价格预测是金融研究和量化投资共同关注的重点话题,近年来利用深度学习技术揭示股票市场的行情规律成为研究热点。现有股票价格预测深度学习模型多数仅研究时间点数据,这种结构上的缺陷导致其不能反映出特征因子的累积作用对股价的影响。针对此,通过重新设计模型处理时间序列数据,提出一种基于Transformer的股票价格预测模型Stockformer。它通过因果自注意力机制挖掘股票价格与特征因子之间的时序依赖关系,采用趋势增强模块为模型提供序列的趋势特征,同时利用编码器的特定输入为预测提供输入特征的直接先验信息。实验结果表明,Stockformer的预测精度显著优于已有深度学习模型,且相较经典Transformer预测模型的平均绝对误差和均方根误差分别降低了23.2%和25.7%,预测值与真实值更为拟合;通过消融实验分别评估了Stockformer的因果注意力机制、时序特征提取手段以及特定的模型输入的效果及必要性,验证了所提模型的优越性及普适性。

关键词: 股票价格预测, 时间序列, 深度学习, Transformer, 注意力机制