• Stars
    star
    755
  • Rank 60,125 (Top 2 %)
  • Language
    Jupyter Notebook
  • Created over 7 years ago
  • Updated almost 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

This solution presents an accessible, non-trivial example of machine learning (Deep learning) with financial time series using TensorFlow


Neural-Net-with-Financial-Time-Series-Data is an open source software project using endogenous factors to predict daily log return of financial asset. The project includes serveral technical indicators (ie. Stochastics, Moving Average Convergence/Divergence oscillator) to train a LSTM neural network by stochastic gradient descent with warm restart(SGDR) and cosine annealing. This flexible architecture enables you to deploy with Nvidia CuDNN computation without rewriting code by yourself. Hyperparameters are fine-tuned by Bayesian search.

Latest Result:

The current LSTM model result for predicting daily log return. Alt text

Old model Result

This old model uses LSTM to predict stock price.

Alt text

LSTM cell

This is the LSTM cell we used in the model.

Alt text

It is faster than normal LSTM cell because of the implementation of CuDNN LSTM and batch normalization in the model.

Update:

26/03/2017 First update

  1. Recurrent neural network with LSTM is added to the code.
  2. Keras with tensorflow is also implemented.
  3. Tensorboard for neural network visualization is also added to the code.

14/04/2017 Second update

  1. Normalized adjusted close price.
  2. A new data downloader has been implemented for simplicity
  3. Added more variable to predict the adjusted close price
  4. More accurate result, significantly less mean square error
  5. Extra visualization for close price
  6. Denormalization will be fixed soon
  7. Twitter sentiment analysis is currently on testing stage

16/04/2017 Third update

  1. Updated denormalization
  2. More test results available

18/04/2017 Fourth update

  1. Updated fundamental data from Kaggle for NYSE

19/04/2017 Fifth update

  1. Supporting Python 3.5 on Windows 10
  2. Significant improvement in accuracy

29/04/2017 Sixth update

  1. ^GSPC Data since 1970 has been added, more training data, higher accuracy
  2. 7 years of test data
  3. Object oriented programming
  4. Hyperparameters for dropout has been tested

08/05/2017 Seventh update

  1. All Hyperparameters have been tested and results have been uploaded.
  2. Fixed comment for the data loader
  3. More technical analysis like volume, moving average and other indexes will be added

28/05/2017 Eighth update

  1. Using Quandl instead of Pandas datareader
  2. Correlation heatmap has been addded
  3. Using Adjusted OHLCV for the network
  4. All functions can be loaded from lstmstock.py
  5. A Quandl api key is provided temporarily for those who do not own a quandl account
  6. Moving averages have been added

02/10/2017 Nineth update

Alt text

  1. Event driven analysis
  2. Switched to Tensorflow LSTM model

25/06/2018 Tenth update

  1. Complete rewrite of News downloader, removed Newsapi in order to get full access to NYTImes data for free
  2. Moving Average Convergence/Divergence oscillator (MACD), Stochastic Oscillator, Average True Range are added to train the model.
  3. log return is now used as target variable.
  4. Keras on top of Tensorflow is used.
  5. Randomized Search from SKLearn is used for optimization.

11/10/2018 Eleventh update Serveral state of the art techniques are applied

  1. CuDNN LSTM is used to accelerate training
  2. Stochastic gradient descent with warm restart
  3. Cosine annealing
  4. Use Bayesian search to optmize hyperparameters.
  5. New splitting method
  6. Dataset is provided
  7. HDF files are used to accelerate reading time

How to use Quandl

If you want to train your neural network on more data, feel free to load the data directly from Quandl. You should be able to get the historic price data of a particular stock after login. Use Export > Python > api key and insert the api key to your model. https://www.quandl.com/databases/WIKIP Alt text

References:

Bernal, A., Fok, S., & Pidaparthi, R. (2012). Financial Market Time Series Prediction with Recurrent Neural Networks.

Box, G. E., Jenkins, G. M., Reinsel, G. C., & Ljung, G. M. (2015). Time series analysis: forecasting and control. John Wiley & Sons.

Gu, J., Wang, Z., Kuen, J., Ma, L., Shahroudy, A., Shuai, B., ... & Cai, J. (2015). Recent advances in convolutional neural networks. arXiv preprint arXiv:1512.07108.

Hutto, C.J. & Gilbert, E.E. (2014). VADER: A Parsimonious Rule-based Model for Sentiment Analysis of Social Media Text. Eighth International Conference on Weblogs and Social Media (ICWSM-14). Ann Arbor, MI, June 2014.

Jaeger, H. (2001). The “echo state” approach to analysing and training recurrent neural networks-with an erratum note. Bonn, Germany: German National Research Center for Information Technology GMD Technical Report, 148(34), 13.

Jaeger, H. (2002). Tutorial on training recurrent neural networks, covering BPPT, RTRL, EKF and the" echo state network" approach (Vol. 5). GMD-Forschungszentrum Informationstechnik.

Maass, W., Natschläger, T., & Markram, H. (2002). Real-time computing without stable states: A new framework for neural computation based on perturbations. Neural computation, 14(11), 2531-2560.

More Repositories

1

Superesolution-and-watermark-removal

Using unet and wgan to enhance resolution and remove watermark
Jupyter Notebook
30
star
2

Tabular-data-Winning-Solution

Rank gaussian normalization, Swap noise, Denoised AutoEncoder as feature engineering
Jupyter Notebook
10
star
3

awesome-language-dataset

Collection of all language dataset for finetuning LLM
10
star
4

Signal-frontier-analysis-and-model-parameterizations

A simplified cross-sectional momentum portfolio and a grid of model parameterizations
Python
7
star
5

Word2Vec-for-The-Big-Short

A two-layer neural networks that are trained to reconstruct linguistic contexts of words from Michael Lewis's book, The Big Short
Jupyter Notebook
5
star
6

Machine-Learning-Python

Code Notebooks for exercise in the book Machine Learning Python
Jupyter Notebook
3
star
7

Twitter-Sentiment-Analysis

Natural language processing (NLP) for the sentiment of a particular topic on twitter with Python
Jupyter Notebook
3
star
8

Standford-Machine-Learning-Assignment

Classic Machine Learning material from Andrew Ng. Matlab and Octave codes for assignments and optional exercises.
MATLAB
3
star
9

Python-for-Finance

This is the Python for finance according to the tutorial series on python programming.net. I modified it for python 2.7.
Python
3
star
10

AWD-LSTM-sentiment-classifier

Using a pretrained wikitext language model and its embedding to create a sentiment classifier for IMDB movie review.
Jupyter Notebook
3
star
11

EfficientNet

Implementation of efficientnet in fastai
Jupyter Notebook
3
star
12

Hong-Kong-Big-Data-Downloader-

A data downloader of Hong Kong Economic indicator. This includes HK Housing price (Centa-City Leading Index), HK GDP, HK Inflation, HSI, HK Unemployment, Chinese housing price, Chinese GDP, Chinese Inflation, CSI300, SP500, US interest, USD:RMB
HTML
3
star
13

Machine-Learning-from-scratch

Custom made regression, clustering and classifier from scratch enable students and learner to have better understanding of the mechanism and algorithm of the actual classifier. The following classifiers are included in the folder 1. Linear Regression, 2. K-nearest neighbour, 3. Support Vector Machine (SVM), 4. K-mean, 5. Mean-shift
Python
3
star
14

Quantum-Entanglement-on-emotion-during-financial-crisis

By using the peculiar stock price during internet bubble between 2000-2002 and US housing bubble between 2007-2008, we entangle intangible information such as human thought in order to get a better understanding of the financial market as well as analyzing the performance of the trader.
Jupyter Notebook
3
star
15

Deep-Neural-Network-from-Udacity

About this Course Machine learning is one of the fastest-growing and most exciting fields out there, and deep learning represents its true bleeding edge. In this course, you'll develop a clear understanding of the motivation for deep learning, and design intelligent systems that learn from complex and/or large-scale datasets. We'll show you how to train and optimize basic neural networks, convolutional neural networks, and long short term memory networks. Complete learning systems in TensorFlow will be introduced via projects and assignments. You will learn to solve new classes of problems that were once thought prohibitively challenging, and come to better appreciate the complex nature of human intelligence as you solve these same problems effortlessly using deep learning methods. We have developed this course with Vincent Vanhoucke, Principal Scientist at Google, and technical lead in the Google Brain team. **Note: This is an intermediate to advanced level course offered as part of the Machine Learning Engineer Nanodegree program. It assumes you have taken a first course in machine learning, and that you are at least familiar with supervised learning methods.
Jupyter Notebook
3
star
16

pretrained-albert-fastai

Integrating huggingface library pretrained gpt2 into fastai
Jupyter Notebook
2
star
17

Optimizing-machine-learning-pipelines-using-genetic-programming

Automatically chooses the best machine learning algorithm and kernel with genetic algorithm to predict financial data
Python
2
star
18

Udacity-deep-learning

This is the material from Udacity nano degree for deep learning
Jupyter Notebook
2
star
19

Linear-Support-Vector-Classifier-for-Hong-Kong-Stock-Price

Using Linear Support Vector Classification to analyze individual stock from Hong Kong
Python
2
star
20

pretrained-efficientnet-fastai

integrating timm efficientnet into fastai
Jupyter Notebook
2
star
21

Zipline-testing

Using zipline system from quantopian to backtest stocks, ETF and Bitcoin locally
Jupyter Notebook
2
star
22

algorithm

introduction to algorithm example
Python
1
star
23

Codewars

Challenge myself on kata, created by the community to strengthen different skills. Master current language of choice, or expand understanding of a new one.
Python
1
star
24

Random-Integers-in-gambling

Random number generator
Python
1
star
25

IBM-AI-Engineering

Jupyter Notebook
1
star
26

Python-for-Data-Analysis-

Python for Data Analysis: Data Wrangling with Pandas, NumPy, and IPython
Jupyter Notebook
1
star
27

Quantopian-0.916

quantopian algo trade backtest result
Python
1
star
28

Genetic-Algorithm-For-Radiation

Gamma Radiation Classifier and use Genetic Programming to pick the best Machine Learning model + hyper-parameters FOR US in 40 lines of Python.
Python
1
star
29

Python-for-Data-Analysis

This is the Python for Data Analysis according to the tutorial series on python programming.net. I modified it for python 2.7.
Python
1
star
30

Monte-Carlo-Simulation-for-BogleHead

Monte Carlo Simulation for BogleHead. This is a tool for all boglehead in Hong Kong to simulate the future return and risk. I will also include the withholding tax for Nonresident alien.
Python
1
star
31

SNN-with-embeddings-for-Malware-Prediction

Self-Normalizing Network with entity embedding to predict malware infection
Jupyter Notebook
1
star