Financial time series forecasting with multi-modality graph neural network
-
Prepare your data
- We have retained the data used as a sample in the
event
,news
, andprice
subfolders in thedata
folder and stored it in the form of.pkl
. These files can be opened using thenp.load()
function to view their specific styles. - At the same time, the sample relationship diagram between companies is placed in the
example_company_relation.pkl
under thedataset
folder.
- We have retained the data used as a sample in the
-
Setup your env
-
We recommend you to create a new python environment for MAGNN. You might run this command in your anaconda prompt in order to create a new environment:
conda create -n magnn python==3.6.13
We recommend to use Python 3.6 in our model.
-
After enter the magnn folder, you might install required packages using command below:
pip install -r requirements.txt
-
-
Run MAGNN
- All functions are integrated in magnn.py, you only need to execute
python magnn.py
in your virtual environment to run. The results of the operation will be placed inmagnn_result.csv
. You might usepandas
to reveal it. - If you want to load your own data to MAGNN, do not forget to change train/test period tuples which are defined in
./dataset/constant.py
-
dataset
This module contains helper functions to initiate train/valid/test datasets including price data, stock event and stock news data for our models. -
model
This module contains all our models(magnn, price-lstm, event-embedding, news-embedding). -
tools This module contains some simple implementation versions of some non-open source functions. Readers can modify the functions as needed.
-
If you find MAGNN is useful for your research, please consider citing the following papers:
@article{cheng2022financial, title={Financial time series forecasting with multi-modality graph neural network}, author={Cheng, Dawei and Yang, Fangzhou and Xiang, Sheng and Liu, Jin}, journal={Pattern Recognition}, volume={121}, pages={108218}, year={2022}, publisher={Elsevier} }