How to Predict Stock Prices Easily Demo

Overview

How-to-Predict-Stock-Prices-Easily-Demo

How to Predict Stock Prices Easily - Intro to Deep Learning #7 by Siraj Raval on Youtube

##Overview

This is the code for this video on Youtube by Siraj Raval part of the Udacity Deep Learning nanodegree. We use an LSTM neural network to predict the closing price of the S&P 500 using a dataset of past prices.

##Dependencies

  • keras
  • tensorflow

Install Keras from here and Tensorflow from here.

##Usage

Run this using jupyter notebook. Just type jupyter notebook in the main directory and the code will pop up in a browser window.

#Coding Challenge - Due Date, Thursday, March 2nd 2017 at 12 PM PST

Use the price history AND two other metrics of your choice to predict the price of GOOGL stock with an LSTM network. You can find the CSV here. Metrics could be sentiment analysis from Twitter of what people have said about Google, dividends, etc.

##Credits

Credits go to jaungiers. I've merely created a wrapper to get people started.

Comments
  • Windows 7 Install & Python 3.5 Upgrade - An Exciting Story [Solved]

    Windows 7 Install & Python 3.5 Upgrade - An Exciting Story [Solved]

    Thank you for the example. I get the following error:

    Using Theano backend. WARNING (theano.configdefaults): g++ not detected ! Theano will be unable to execute optimized C-implementations (for both CPU and GPU) and will default to Python implementations. Performance will be severely degraded. To remove this warning, set Theano flags cxx to an empty string. File "C:\BrainPorn\How-to-Predict-Stock-Prices-Easily-Demo-master\lstm.py", line 17 print 'yo' ^ SyntaxError: Missing parentheses in call to 'print'

    I'm more then confused.

    I have Anaconda with a TensorFlow Env and a Keras lib. But I can't start a notebook on the TensorFlow shell, so I start the notebook on the Anaconda shell, where the above output appears in the browser. Who can provide a descent "how to start the example" (cross-platform or Win7)?

    Update Day Two:

    The environment of the example is not install able on Windows, so trying other ways.

    Install native on Windows: Keras install failed, probably because of Scipy Install Anaconda way: Keras install failed, Notebook showing up in Browser (incl. failed dependency Keras) Install Docker way: Jupyter install failed...

    Trying the docker way. Would be nice to have a container, so more people could follow.

    I got a functional container with TensorFlow + Keras from here:

    https://blog.thoughtram.io/machine-learning/2016/09/23/beginning-ml-with-keras-and-tensorflow.html

    Now I have a running TensorFlow with Keras but no jupyter notebook option.

    Unfortunately 'pip install jupyter' in the environment leads to errors too.

    So still no success.

    Does someone has a Docker container with TensorFlow + Keras + Jupitor Notebook?

    Update: Found an all in one docker image here:

    https://github.com/floydhub/dl-docker (Python2 and iTouch Kernel)

    docker run -it -p 192.168.99.100:8888:8888 -p 192.168.99.100:6006:6006 -v /sharedfolder:/root/sharedfolder floydhub/dl-docker:cpu jupyter notebook

    ...does not show the example (empty notebook)...sadly giving up.

    Update:

    Turns out Docker on Win needs a special syntax....

    docker run -it -p 192.168.99.100:8888:8888 -p 192.168.99.100:6006:6006 -v //c/Users//sharedfolder:/root/sharedfolder floydhub/dl-docker:cpu jupyter notebook

    ...finally does the trick....but after a while in the browser I get this:

    The kernel has died, and the automatic restart has failed. It is possible the kernel cannot be restarted. If you are not able to restart the kernel, you will still be able to save the notebook, but running code will no longer work until the notebook is reopened.

    What a disaster after such a long journey!!!

    Which Kernel do we need?

    opened by Steviey 29
  • Cannot get the result as yours ...

    Cannot get the result as yours ...

    Hi,

    I run this demo code in my ubuntu 16.04.2 installed with tensorflow 1.0, keras 2.0.2 and python 2.7.12. Everything runs fine without error and warning, all console printout are similar to yours. However, the output prediction diagram is quite different from yours.

    All those prediction lines are just pointing upwards of nearly the same slope.

    What's wrong with it ? Thanks.

    opened by ckl8964 7
  • NameError: name 'xrange' is not defined

    NameError: name 'xrange' is not defined

    Testing this on python3 and jupyter notebook, I get:


    NameError Traceback (most recent call last) in () 1 #Step 4 - Plot the predictions! ----> 2 predictions = lstm.predict_sequences_multiple(model, X_test, 50, 50) 3 lstm.plot_results_multiple(predictions, y_test, 50)

    ~\git\How-to-Predict-Stock-Prices-Easily-Demo\lstm.py in predict_sequences_multiple(model, data, window_size, prediction_len) 99 #Predict sequence of 50 steps before shifting prediction run forward by 50 steps 100 prediction_seqs = [] --> 101 for i in xrange(len(data)/prediction_len): 102 curr_frame = data[i*prediction_len] 103 predicted = []

    NameError: name 'xrange' is not defined

    opened by zhivko 3
  • Bytes-Like Object Required, not 'str'

    Bytes-Like Object Required, not 'str'

    When calling lstm.load_data('sp500.csv', 50, True) in ipython notebooks I get:


    TypeError Traceback (most recent call last) in () 1 #Step 1 Load Data ----> 2 X_train, y_train, X_test, y_test = lstm.load_data('sp500.csv', 50, True)

    How-to-Predict-Stock-Prices-Easily-Demo/lstm.py in load_data(filename, seq_len, normalise_window) 25 def load_data(filename, seq_len, normalise_window): 26 f = open(filename, 'rb').read() ---> 27 data = f.split('\n') 28 29 sequence_length = seq_len + 1

    TypeError: a bytes-like object is required, not 'str'

    opened by louwjlabuschagne 3
  • must these code run in jupyter ?

    must these code run in jupyter ?

    I just copy the code from stockdemo.ipynb into a .py file. Then, put all other 3 files into a folder and run under my ubuntu. Everything runs fine except the output prediction plot looks quite different from yours.

    Must it be run under jupyter ?

    opened by ckl8964 2
  • Running the code in Python 3.6

    Running the code in Python 3.6

    I changed lstm.py code , so I can test it on Python 3.6: change xraneg to range.
    change range(len(data)/prediction_len): to range(len(data)//prediction_len): I got this error: TypeError: %i format: a number is required, not list

    any help please

    opened by Bellman281 6
  • The prediction result looks not so good.

    The prediction result looks not so good.

    Thanks for your sharing! However, the prediction result looks not so good as shown in the last figure. how do you think about this prediction result? image

    Besides, could you share your thoughts that why you design 2 LSTM layers with the output length of 50 and 100 for this price prediction problem? What's your detailed consideration behind this design ?

    opened by songqiqqq 16
Owner
Siraj Raval
subscribe to my youtube channel! www.youtube.com/c/sirajraval
Siraj Raval
Forecasting directional movements of stock prices for intraday trading using LSTM and random forest

Forecasting directional movements of stock-prices for intraday trading using LSTM and random-forest https://arxiv.org/abs/2004.10178 Pushpendu Ghosh,

Pushpendu Ghosh 270 Dec 24, 2022
Using a Seq2Seq RNN architecture via TensorFlow to predict future Bitcoin prices

Recurrent Bitcoin Network A Data Science Thesis Project About This repository contains the source code for implementing Bitcoin price prediciton using

Frizu 6 Sep 8, 2022
House_prices_kaggle - Predict sales prices and practice feature engineering, RFs, and gradient boosting

House Prices - Advanced Regression Techniques Predicting House Prices with Machine Learning This project is build to enhance my knowledge about machin

Gurpreet Singh 1 Jan 1, 2022
Stock-history-display - something like a easy yearly review for your stock performance

Stock History Display Available on Heroku: https://stock-history-display.herokua

LiaoJJ 1 Jan 7, 2022
Use deep learning, genetic programming and other methods to predict stock and market movements

StockPredictions Use classic tricks, neural networks, deep learning, genetic programming and other methods to predict stock and market movements. Both

Linda MacPhee-Cobb 386 Jan 3, 2023
Predict stock movement with Machine Learning and Deep Learning algorithms

Project Overview Stock market movement prediction using LSTM Deep Neural Networks and machine learning algorithms Software and Library Requirements Th

Naz Delam 46 Sep 13, 2022
ONNX Runtime Web demo is an interactive demo portal showing real use cases running ONNX Runtime Web in VueJS.

ONNX Runtime Web demo is an interactive demo portal showing real use cases running ONNX Runtime Web in VueJS. It currently supports four examples for you to quickly experience the power of ONNX Runtime Web.

Microsoft 58 Dec 18, 2022
Accommodating supervised learning algorithms for the historical prices of the world's favorite cryptocurrency and boosting it through LightGBM.

Accommodating supervised learning algorithms for the historical prices of the world's favorite cryptocurrency and boosting it through LightGBM.

null 1 Nov 27, 2021
NFT-Price-Prediction-CNN - Using visual feature extraction, prices of NFTs are predicted via CNN (Alexnet and Resnet) architectures.

NFT-Price-Prediction-CNN - Using visual feature extraction, prices of NFTs are predicted via CNN (Alexnet and Resnet) architectures.

null 5 Nov 3, 2022
Using python and scikit-learn to make stock predictions

MachineLearningStocks in python: a starter project and guide EDIT as of Feb 2021: MachineLearningStocks is no longer actively maintained MachineLearni

Robert Martin 1.3k Dec 29, 2022
Technical experimentations to beat the stock market using deep learning :chart_with_upwards_trend:

DeepStock Technical experimentations to beat the stock market using deep learning. Experimentations Deep Learning Stock Prediction with Daily News Hea

Keon 449 Dec 29, 2022
This project provides a stock market environment using OpenGym with Deep Q-learning and Policy Gradient.

Stock Trading Market OpenAI Gym Environment with Deep Reinforcement Learning using Keras Overview This project provides a general environment for stoc

Kim, Ki Hyun 769 Dec 25, 2022
This project uses reinforcement learning on stock market and agent tries to learn trading. The goal is to check if the agent can learn to read tape. The project is dedicated to hero in life great Jesse Livermore.

Reinforcement-trading This project uses Reinforcement learning on stock market and agent tries to learn trading. The goal is to check if the agent can

Deepender Singla 1.4k Dec 22, 2022
:boar: :bear: Deep Learning based Python Library for Stock Market Prediction and Modelling

bulbea "Deep Learning based Python Library for Stock Market Prediction and Modelling." Table of Contents Installation Usage Documentation Dependencies

Achilles Rasquinha 1.8k Jan 5, 2023
Use AI to generate a optimized stock portfolio

Use AI, Modern Portfolio Theory, and Monte Carlo simulation's to generate a optimized stock portfolio that minimizes risk while maximizing returns. Ho

Greg James 30 Dec 22, 2022
Streamlit Tutorial (ex: stock price dashboard, cartoon-stylegan, vqgan-clip, stylemixing, styleclip, sefa)

Streamlit Tutorials Install pip install streamlit Run cd [directory] streamlit run app.py --server.address 0.0.0.0 --server.port [your port] # http:/

Jihye Back 30 Jan 6, 2023
A Deep Reinforcement Learning Framework for Stock Market Trading

DQN-Trading This is a framework based on deep reinforcement learning for stock market trading. This project is the implementation code for the two pap

null 61 Jan 1, 2023
Technical Indicators implemented in Python only using Numpy-Pandas as Magic - Very Very Fast! Very tiny! Stock Market Financial Technical Analysis Python library . Quant Trading automation or cryptocoin exchange

MyTT Technical Indicators implemented in Python only using Numpy-Pandas as Magic - Very Very Fast! to Stock Market Financial Technical Analysis Python

dev 34 Dec 27, 2022
Randomizes the warps in a stock pokeemerald repo.

pokeemerald warp randomizer Randomizes the warps in a stock pokeemerald repo. Usage Instructions Install networkx and matplotlib via pip3 or similar.

Max Thomas 6 Mar 17, 2022