Stock price forecasting based on mathematical morphology and differential inverted Transformer

Stock price prediction has long been a challenging task in financial data analyses. The rapid development of deep learning and its derivative technologies has provided significant opportunities to address this formidable problem. To improve the prediction accuracy and achieve better forecasting results, we propose a novel hybrid deep learning-based prediction model, namely, the mathematical morphology decomposition based on the Dung Beetle Optimizer (DBOMMD)–Long Short-Term Memory (LSTM)–differential inverted Transformer (DIFF iTransformer). This model introduces, for the first time, a differential attention mechanism into the cutting-edge inverted Transformer framework and combines it with LSTM, enabling the model to not only learn complex long-term temporal dependencies in the data but also capture inter-feature relationships at different spatial scales while mitigating attention noise. Furthermore, to alleviate the impact of stock price nonstationarity on prediction performance, we propose a mathematical morphology decomposition (MMD) based on the Dung Beetle Optimizer (DBO). This algorithm employs a carefully designed multiscale morphological decomposition strategy, along with optimized morphological structuring element sizes, to optimally decompose stock closing prices into relatively stable subsequences. Additionally, to enrich the input features of the model, we incorporate market sentiment factors by utilizing a fine-tuned FinBERT model to quantitatively compute a stock market sentiment index, which is then fused with the relevant stock trading data. We applied the proposed model to predict the next-day closing prices of four stocks: Ping An Insurance (Group) Company of China, Ltd. (PAIC), China Petroleum and Chemical Corporation (SINOPEC), Gree Electric Appliances, Inc. of Zhuhai (Gree), and iFLYTEK CO., Ltd. (iFLYTEK). The experimental results demonstrate that our hybrid model delivers robust and stable predictions, achieving superior performance metrics across all four stock datasets: coefficient of determination (0.9959, 0.9859, 0.9953, and 0.9929), mean squared error (0.1647, 0.0015, 0.0558, and 0.2123), mean absolute error (0.2375, 0.0288, 0.1587, and 0.3186), and mean absolute percentage error (0.0050, 0.0045, 0.0039, and 0.0072). These results outperform those of other cutting-edge deep learning models and ablation study comparison models, confirming the superiority of the proposed hybrid approach. Moreover, the findings highlight the significant contributions of the differential attention mechanism, morphological modal decomposition techniques, and the incorporation of market sentiment factors in enhancing the performance of deep learning models.

Authors

Institutions

Publication Details

Journal
International Journal of Financial Engineering
Published
2025-09-22
DOI
https://doi.org/10.1142/s2424786325500185
Primary Topic
Stock Market Forecasting Methods
Type
article
Field-Weighted Citation Impact
0.00
Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
article

Stock price forecasting based on mathematical morphology and differential inverted Transformer

Wenjie Ou, Shilei Wang, Jianning Zhang, Chunling Li
International Journal of Financial Engineering
Stock Market Forecasting Methods
article

Stock price forecasting based on mathematical morphology and differential inverted Transformer

Wenjie Ou, Shilei Wang, Jianning Zhang, Chunling Li
article en

Abstract

Stock price prediction has long been a challenging task in financial data analyses. The rapid development of deep learning and its derivative technologies has provided significant opportunities to address this formidable problem. To improve the prediction accuracy and achieve better forecasting results, we propose a novel hybrid deep learning-based prediction model, namely, the mathematical morphology decomposition based on the Dung Beetle Optimizer (DBOMMD)–Long Short-Term Memory (LSTM)–differential inverted Transformer (DIFF iTransformer). This model introduces, for the first time, a differential attention mechanism into the cutting-edge inverted Transformer framework and combines it with LSTM, enabling the model to not only learn complex long-term temporal dependencies in the data but also capture inter-feature relationships at different spatial scales while mitigating attention noise. Furthermore, to alleviate the impact of stock price nonstationarity on prediction performance, we propose a mathematical morphology decomposition (MMD) based on the Dung Beetle Optimizer (DBO). This algorithm employs a carefully designed multiscale morphological decomposition strategy, along with optimized morphological structuring element sizes, to optimally decompose stock closing prices into relatively stable subsequences. Additionally, to enrich the input features of the model, we incorporate market sentiment factors by utilizing a fine-tuned FinBERT model to quantitatively compute a stock market sentiment index, which is then fused with the relevant stock trading data. We applied the proposed model to predict the next-day closing prices of four stocks: Ping An Insurance (Group) Company of China, Ltd. (PAIC), China Petroleum and Chemical Corporation (SINOPEC), Gree Electric Appliances, Inc. of Zhuhai (Gree), and iFLYTEK CO., Ltd. (iFLYTEK). The experimental results demonstrate that our hybrid model delivers robust and stable predictions, achieving superior performance metrics across all four stock datasets: coefficient of determination (0.9959, 0.9859, 0.9953, and 0.9929), mean squared error (0.1647, 0.0015, 0.0558, and 0.2123), mean absolute error (0.2375, 0.0288, 0.1587, and 0.3186), and mean absolute percentage error (0.0050, 0.0045, 0.0039, and 0.0072). These results outperform those of other cutting-edge deep learning models and ablation study comparison models, confirming the superiority of the proposed hybrid approach. Moreover, the findings highlight the significant contributions of the differential attention mechanism, morphological modal decomposition techniques, and the incorporation of market sentiment factors in enhancing the performance of deep learning models.

International Journal of Financial EngineeringVol. 12(04)
Yanshan University (CN), Hebei Science and Technology Department (CN)
Openalex Percentile: Top 70%
Stock Market Forecasting Methods
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.