The official code implementation for MCI-GRU: Stock Prediction Model Based on Multi-Head Cross-Attention and Improved GRU.
MCI-GRU: Stock Prediction Model Based on Multi-Head Cross-Attention and Improved GRU (Neurocomputing).
๐ Overview
MCI-GRU is a stock forecasting architecture that replaces the GRU reset gate with an attention mechanism for dynamic temporal feature selection, incorporates a Graph Attention Network (GAT) to model inter-stock dependencies, and employs multi-head cross-attention to infer latent market states. By fusing temporal, cross-sectional, and latent representations, MCI-GRU achieves state-of-the-art performance on CSI 300/500, S&P 500, and NASDAQ 100 benchmarks, delivering higher ARR, Sharpe, and Calmar ratios, and has been deployed in live fund management systems.
๐ Experiment Results
Performance Comparison
๐ Quick Start
Prerequisites
- Python 3.8 or higher
- CUDA-compatible GPU (recommended for training)
- 8GB+ RAM
Installation
- Clone the repository
git clone https://github.com/WinstonLiyt/MCI-GRU.git
cd MCI-GRU
- Create and activate virtual environment
# Using conda
conda create -n mcigru python=3.8
conda activate mcigru
# Or using venv
python -m venv mcigru_env
source mcigru_env/bin/activate # Linux/Mac
# or
mcigru_env\Scripts\activate # Windows
- Install dependencies
pip install -r requirements.txt
Data Preparation
- Prepare your dataset in CSV format with the following columns:
kdcode: Stock code identifier
- dt: Date (YYYY-MM-DD format)
- close, open, high, low: OHLC prices
- turnover: Trading turnover
- volume: Trading volume
- Update the data path in the script:
filename = '/path/to/your/dataset.csv'
Usage
Training and Prediction
Run the main training script for different market indices:
# CSI 300 Index
python code/csi300.py
Ablation Studies
Run ablation studies to analyze component contributions:
# Ablation studies for CSI 300 Index
python ablation/csi300.py
๐ Project Structure
MCI-GRU/
โโโ code/ # Main implementation
โ โโโ csi300.py # CSI 300 index model
โ โโโ csi500.py # CSI 500 index model
โ โโโ sp500.py # S&P 500 index model
โ โโโ nasdaq100.py # NASDAQ 100 index model
โโโ ablation/ # Ablation study implementations
โ โโโ csi300.py # CSI 300 ablation studies
โ โโโ csi500.py # CSI 500 ablation studies
โ โโโ sp500.py # S&P 500 ablation studies
โ โโโ nasdaq100.py # NASDAQ 100 ablation studies
โโโ requirements.txt # Python dependencies
โโโ README.md # This file
โโโ LICENSE # MIT License
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Citation
If you find this repository helpful, please cite our paper:
@article{zhu2025mci,
title={MCI-GRU: Stock prediction model based on multi-head cross-attention and improved GRU},
author={Zhu, Peng and Li, Yuante and Hu, Yifan and Xiang, Sheng and Liu, Qinyuan and Cheng, Dawei and Liang, Yuqi},
journal={Neurocomputing},
volume={638},
pages={130168},
year={2025},
publisher={Elsevier}
}
Disclaimer: This code is for research purposes only. Past performance does not guarantee future results. Please conduct your own research before making investment decisions.