Git Product home page Git Product logo

pricegraph's Introduction

Price graphs: Utilizing the structural information of financial time series for stock prediction

This repository is the official PyTorch implementation of the experiments in the following paper:

Junran Wu, Ke Xu, Xueyuan Chen, Shangzhe Li, Jichang Zhao. Price graphs: Utilizing the structural information of financial time series for stock prediction

Information Sciences

arXiv

Installation

Install PyTorch following the instuctions on the official website. The code has been tested over PyTorch 1.7.0+cu110 version.

Then install the other dependencies.

pip install networkx pyunicorn

Data preparation

  • Unfold data
tar -xvzf data.tar.gz
  • Change directory to code
cd code
  • Transform stock prices to graphs
python price_graph.py
  • Calculate collective influence (CI) for graph nodes
python price_ci.py
  • Price graph embedding
python price_embedding.py
  • Generate dataset for train and test
python dataset.py

Trainer Usage

Train:

usage: trainer.py [-h] [-e EPOCH] [-b BATCH] [-ts TIMESTEP] [-hs HIDDENSIZE] [-y YEARS [YEARS ...]] [-sn SEASON] [-dr DROPRATIO] [-s SPLIT] [-i INTERVAL] [-l LRATE] [-l2 L2RATE] [-t]

Train the price graph model on stock

optional arguments:
  -h, --help            show this help message and exit
  -e EPOCH, --epoch EPOCH
                        the number of epochs
  -b BATCH, --batch BATCH
                        the mini-batch size
  -ts TIMESTEP, --timestep TIMESTEP
                        the length of time_step
  -hs HIDDENSIZE, --hiddensize HIDDENSIZE
                        the length of hidden size
  -y YEARS [YEARS ...], --years YEARS [YEARS ...]
                        an integer for the accumulator
  -sn SEASON, --season SEASON
                        the test season of 2019
  -dr DROPRATIO, --dropratio DROPRATIO
                        the ratio of drop
  -s SPLIT, --split SPLIT
                        the split ratio of validation set
  -i INTERVAL, --interval INTERVAL
                        save models every interval epoch
  -l LRATE, --lrate LRATE
                        learning rate
  -l2 L2RATE, --l2rate L2RATE
                        L2 penalty lambda
  -t, --test            train or test

An example of training process is as follows:

python trainer.py -e 1000 -l 0.001 -hs 32 -ts 20 -b 256 -dr 0 -i 50 -s 30 -l2 0 -y 2017 2018 -sn 1

An example of test with existing models is as follows:

python trainer.py -e 1000 -l 0.001 -hs 32 -ts 20 -b 256 -dr 0 -i 50 -s 30 -l2 0 -y 2017 2018 -sn 1 -t --test_2019

Base Code Repo

VG algorithm is adopted from https://github.com/pik-copan/pyunicorn

CI algorithm is adopted from https://github.com/zhfkt/ComplexCi.

Struc2vec implementation is adopted from https://github.com/shenweichen/GraphEmbedding.

DARNN implementation in PyTorch is adopted from https://github.com/ysn2233/attentioned-dual-stage-stock-prediction

Citation

If you use this code for you research, please cite our paper.

@article{wu2022price,
	title = {Price graphs: Utilizing the structural information of financial time series for stock prediction},
	journal = {Information Sciences},
	volume = {588},
	pages = {405-424},
	year = {2022},
	issn = {0020-0255},
	doi = {https://doi.org/10.1016/j.ins.2021.12.089},
	url = {https://www.sciencedirect.com/science/article/pii/S0020025521013104},
	author = {Junran Wu and Ke Xu and Xueyuan Chen and Shangzhe Li and Jichang Zhao},
	keywords = {Stock prediction, Complex network, Time series graph, Graph embedding, Structure information},
}

pricegraph's People

Contributors

buaa-wjr 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.