Coder Social home page Coder Social logo

davidcico / forecasting-direction-of-trade-an-example-with-lstm-neural-network Goto Github PK

View Code? Open in Web Editor NEW
14.0 2.0 5.0 3.18 MB

In this repository, the goal is to predict the tick direction of a stock based on its current order book and trade data. A LSTM Neural Network is used as an example of potential solution for such problem.

Python 100.00%
scikitlearn-machine-learning linear-regression lstm lstm-neural-networks stock-price-prediction tick-data python python3 orderbook stock-forecasting

forecasting-direction-of-trade-an-example-with-lstm-neural-network's Introduction

Forecasting-trade-direction-an-example-with-LSTM-neural-network

In this repository, a study on forecasting trade direction of a stock, from tick data is carried out using two different models:

  • Linear regression which is used as an example to show it's non application in such problem. As a regression model, it's prediction is based on a quantity, and then on thresholds rather than classifying the result with a label.
  • LSTM neural network as an example in this study, which shows good results when applied with a large set of features.

Based on the information provided by the order book, different important features such as Volume Order Imbalance, Bid Ask spread, Mid-price basis, etc are computed to capture the imbalance between buy and sell orders, that will drive the price to move up or down.

As seen in the full study report 'Predicting tick's direction of a stock.pdf' the LSTM neural network has been trained and tested in several conditions, to find which features are the most important to be fed to the model, as well as the lookback period for predicting next days of prices.

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

You need Python 3.x to run the following code. You can have multiple Python versions (2.x and 3.x) installed on the same system without problems. Python needs to be first installed then SciPy and pymysql as there are dependencies on packages.

In Ubuntu, Mint and Debian you can install Python 3 like this:

sudo apt-get install python3 python3-pip

Alongside Python, the SciPy packages are also required. In Ubuntu and Debian, the SciPy ecosystem can be installed by:

sudo apt-get install python-numpy python-scipy python-matplotlib ipython ipython-notebook python-pandas python-sympy python-nose

The latest release of Scikit-Learn machine learning package, which can be installed with pip:

pip install -U scikit-learn

Finally, the Tensorflow package for neural networks modelling, which can be installed with pip:

pip install tensorflow

For other Linux flavors, OS X and Windows, packages are available at:

http://www.python.org/getit/
https://www.scipy.org/install.html
https://scikit-learn.org/stable/install.html

File descriptions

  • 'Predicting tick's direction of a stock.pdf' which is the report written on the full study.
  • 'lin_reg.py' which is one of the main file to run the linear regression on the tick data.
  • 'lstm_rnn.py', which is the other main script for training and testing the lstm neural network. Some of the code needs to be commented/uncommented depending on which data or steps we are in
  • 'functions.py' where helper functions are located to compute diverse new features.
  • 'TRAIN_DATA.csv' which contains the original dataset for this project.
  • The 'PreData' directory contains training statistics for both linear regression and lstm models.

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

See also the list of contributors who participated in this project.

forecasting-direction-of-trade-an-example-with-lstm-neural-network's People

Contributors

davidcico avatar

Stargazers

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

Watchers

 avatar  avatar

forecasting-direction-of-trade-an-example-with-lstm-neural-network's Issues

Stock symbol?

Thanks for sharing your research.
To replicate the results,
could you tell me which stock symbol was used in the training data back in 2017?

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.