Giter Site home page Giter Site logo

paper-hgtan's Introduction

HGTAN

Implementation of Paper:Temporal-Relational Hypergraph Tri-Attention Networks for Stock Trend Prediction

Abstract

Predicting the future price trends of stocks is a challenging yet intriguing problem given its critical role to help investors make profitable decisions. In this paper, we present a collaborative temporal-relational modeling framework for end-to-end stock trend prediction. The temporal dynamics of stocks is firstly captured with an attention-based recurrent neural network. Then, different from existing studies relying on the pairwise correlations between stocks, we argue that stocks are naturally connected as a collective group, and introduce the hypergraph structures to jointly characterize the stock group-wise relationships of industry-belonging and fund-holding. A novel hypergraph tri-attention network (HGTAN) is proposed to augment the hypergraph convolutional networks with a hierarchical organization of intra-hyperedge, inter-hyperedge, and inter-hypergraph attention modules. In this manner, HGTAN adaptively determines the importance of nodes, hyperedges, and hypergraphs during the information propagation among stocks, so that the potential synergies between stock movements can be fully exploited. Extensive experiments on real-world data demonstrate the effectiveness of our approach. Also, the results of investment simulation show that our approach can achieve a more desirable risk-adjusted return.

Overall Architecture

Image text

Dataset

Historical Price Data

We used a financial data API-https://tushare.pro to collect the historical price and relational data of stocks from China’s A-share market. We further performed a filtering step to eliminate those stocks that were traded on less than 98% of all trading days. This finally results in 758 stocks between 01/04/2013 and 12/31/2019. You can download result(758)_label.csv file from the Google Drive link: https://drive.google.com/file/d/1T7OHfe8lOrv_fED545yArLDVj8sLVqP2/view?usp=sharing.

Relation Data

We considered the industry-belonging and fund-holding relationships of stocks. For the former, we grouped all stocks into 104 industry categories according to the Shenwan Industry Classification Standard. For the latter, we selected 61 mutual funds established before 2013 in the A-share market, and acquired the constituent stocks of each fund from the quarterly portfolio reports.

Models

  • /HGTAN/models.py: end-to-end prediction framework;
  • /HGTAN/temp_layers.py: temporal attention layer;
  • /HGTAN/hyperedge_attn.py: implementation of intra-hyperedge attention module;
  • /HGTAN/tri_attn.py: inter-hyperedge attention module and inter-hypergraph attention module;
  • /HGTAN/layers.py: implementation of attention layer;

Requirements

Python >= 3.6
torch >= 1.4.0
torchvision >= 0.1.8
numpy
sklearn

Hyperparameter Settings

Epoch: 600
BatchSize: 64
Learning Rate: 1e-3
Dropout: 0.5

Contact

If you have any questions, please contact [email protected].

paper-hgtan's People

Contributors

lixiaojieff avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.