GithubHelp home page GithubHelp logo

fast-eacl's Introduction

FAST: Financial news and tweet based time Aware network for Stock Trading

This codebase contains the python scripts for FAST: Financial News and Tweet Based Time Aware Network for Stock Trading.

EACL - The 16th Conference of the European Chapter of the Association for Computational Linguistics 2021 paper coming soon

Environment & Installation Steps

Create an environment having Python 3.6 and install the following dependencies

pip install -r requirements.txt

Contents

  1. train.py consists of the training, validation, and testing scripts.
  2. model.py comprises the definition of FAST and its components.
  3. evaluator.py contains the script to evaluate model performance.
  4. processed_data comprises the processed data in .npy files.

Data

Find the US S&P 500 data here, and the China & Hong Kong data here.

Training

Execute the following command in the same environment to train and test FAST:

python3 train.py

Processed data

Each .npy file corresponds to data about one lookback period. FAST takes the following data as inputs for training and evaluation:

  1. Text: Text embeddings for each day in the lookback for all stocks in the dataset. Dimensions: (number of stocks, length of lookback period, number of texts, embedding size)
  2. Timestamps: Inverse of time intervals between release of consecutive texts in a day, for all days, for all stocks. Dimensions: (number of stocks, length of lookback period, number of texts, 1)
  3. Mask: A single value for each stock, set to 0 if the daily return ratio is small, or 1 otherwise. Dimensions: (number of stocks, 1)
  4. Price: A single value for each stock, indicating the normalized adjusted closing price across all stocks. Dimensions: (number of stocks, 1)
  5. Ground Truth: A single value for each stock, indicating the trading day's actual normalized return ratio. Dimensions: (number of stocks, 1) In the folder titled processed_data, we provide some sample data for clarity.

Preprocessing

To encode the texts, we use the 768-dimensional embedding obtained per news item or tweet by averaging the token-level outputs from the final layer of BERT. However, FAST is compatible with any and all 1-D text embeddings. To extract the timestamp input, we obtain the time interval (in minutes) between the release of two consecutive texts and compute its inverse. For masking to 0, we keep the return ratio threshold of 0.05. We normalize the adjusted closing prices and the return ratios across all stocks in the dataset.

Cite

If our work was helpful for your research, please kindly cite our work.

fast-eacl's People

Contributors

arnavw96 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fast-eacl's Issues

`no_stocks` is undefined

I ran the your training script, but got the following error.

python train.py 
Traceback (most recent call last):
  File "train.py", line 210, in <module>
    model = FAST().to('cuda')
  File "/home/ubuntu/fast-eacl/model.py", line 74, in __init__
    self.text_lstm = [nn.LSTM(768,64) for _ in range(no_stocks)]
NameError: name 'no_stocks' is not defined

It seems that no_stocks is not defined in train.py. What does no_stocks represent?

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.