:boar: :bear: Deep Learning based Python Library for Stock Market Prediction and Modelling

Overview

bulbea

"Deep Learning based Python Library for Stock Market Prediction and Modelling."

Gitter Documentation Status

Table of Contents

Installation

Clone the git repository:

$ git clone https://github.com/achillesrasquinha/bulbea.git && cd bulbea

Install necessary dependencies

$ pip install -r requirements.txt

Go ahead and install as follows:

$ python setup.py install

You may have to install TensorFlow:

$ pip install tensorflow     # CPU
$ pip install tensorflow-gpu # GPU - Requires CUDA, CuDNN

Usage

1. Prediction

a. Loading

Create a share object.

>>> import bulbea as bb
>>> share = bb.Share('YAHOO', 'GOOGL')
>>> share.data
# Open        High         Low       Close      Volume  \
# Date                                                                     
# 2004-08-19   99.999999  104.059999   95.959998  100.339998  44659000.0   
# 2004-08-20  101.010005  109.079998  100.500002  108.310002  22834300.0   
# 2004-08-23  110.750003  113.479998  109.049999  109.399998  18256100.0   
# 2004-08-24  111.239999  111.599998  103.570003  104.870002  15247300.0   
# 2004-08-25  104.960000  108.000002  103.880003  106.000005   9188600.0
...
b. Preprocessing

Split your data set into training and testing sets.

>>> from bulbea.learn.evaluation import split
>>> Xtrain, Xtest, ytrain, ytest = split(share, 'Close', normalize = True)
c. Modelling
>>> import numpy as np
>>> Xtrain = np.reshape(Xtrain, (Xtrain.shape[0], Xtrain.shape[1], 1))
>>> Xtest  = np.reshape( Xtest, ( Xtest.shape[0],  Xtest.shape[1], 1))

>>> from bulbea.learn.models import RNN
>>> rnn = RNN([1, 100, 100, 1]) # number of neurons in each layer
>>> rnn.fit(Xtrain, ytrain)
# Epoch 1/10
# 1877/1877 [==============================] - 6s - loss: 0.0039
# Epoch 2/10
# 1877/1877 [==============================] - 6s - loss: 0.0019
...
d. Testing
>>> from sklearn.metrics import mean_squared_error
>>> p = rnn.predict(Xtest)
>>> mean_squared_error(ytest, p)
0.00042927869370525931
>>> import matplotlib.pyplot as pplt
>>> pplt.plot(ytest)
>>> pplt.plot(p)
>>> pplt.show()

2. Sentiment Analysis

Add your Twitter credentials to your environment variables.

export BULBEA_TWITTER_API_KEY="<YOUR_TWITTER_API_KEY>"
export BULBEA_TWITTER_API_SECRET="<YOUR_TWITTER_API_SECRET>"

export BULBEA_TWITTER_ACCESS_TOKEN="<YOUR_TWITTER_ACCESS_TOKEN>"
export BULBEA_TWITTER_ACCESS_TOKEN_SECRET="<YOUR_TWITTER_ACCESS_TOKEN_SECRET>"

And then,

>>> bb.sentiment(share)
0.07580128205128206

Documentation

Detailed documentation is available here.

Dependencies

  1. quandl
  2. keras
  3. tweepy
  4. textblob

License

This code has been released under the Apache 2.0 License.

Comments
  • import RNN does not work

    import RNN does not work

    When I tried to import RNN as shown in the example, I got the following error message. I use Anaconda with Python 3.7 on Windows 10. I installed all components as described in the manual. Does anyone has a similar issue?

    from bulbea.learn.models import RNN

    Using TensorFlow backend. ERROR:root:Internal Python error in the inspect module. Below is the traceback from this internal error.

    ERROR:root:Internal Python error in the inspect module. Below is the traceback from this internal error.

    opened by xiaodongzhou 1
  • need help

    need help

    import bulbea as bb share = bb.Share('Wiki','GOOGL') share.data

    with this code i get this error

    Warning (from warnings module): File "C:\Users\Caste\AppData\Local\Programs\Python\Python37\lib\site-packages\bulbea-0.1.0-py3.7.egg\bulbea\entity\share.py", line 168 UserWarning: Environment variable BULBEA_QUANDL_API_KEY for Quandl hasn't been set. A maximum of 50000 calls per day can be made. Visit https://www.quandl.com to get your API key.

    what i can do helpppppp meeeeeeee!

    opened by stellarossadibelgrado 1
  • SyntaxWarning and FileNotFoundError

    SyntaxWarning and FileNotFoundError

    I'm getting these errors when trying to run the setup:

    C:\Windows\System32>C:\Users\kanzl\Downloads\bulbea-master\bulbea-master\setup.py install C:\Users\kanzl\Downloads\bulbea-master\bulbea-master\setup.py:65: SyntaxWarning: "is" with a literal. Did you mean "=="? content += '{prepend}{content}'.format(prepend = '' if i is 0 else '\n\n', content = raw) Traceback (most recent call last): File "C:\Users\kanzl\Downloads\bulbea-master\bulbea-master\setup.py", line 107, in main() File "C:\Users\kanzl\Downloads\bulbea-master\bulbea-master\setup.py", line 89, in main long_description = get_long_description(package.long_description), File "C:\Users\kanzl\Downloads\bulbea-master\bulbea-master\setup.py", line 71, in get_long_description raise FileNotFoundError('No such file found: {filepath}'.format(filepath = filepath)) FileNotFoundError: No such file found: README.md

    If you could help I would appreciate, thanks

    opened by umar10001000 0
  • Not able to run the project

    Not able to run the project

    blubea.txt Ubuntu 22.04 LTS Python 3.10.4

    Once again, as many repositories in github, I am not able to run the code/project. Kindly see the attached file.

    opened by GirishKumarSharma 0
  • NotFoundError: (Status 404) (Quandl Error QECx02)

    NotFoundError: (Status 404) (Quandl Error QECx02)

    UserWarning: Environment variable BULBEA_QUANDL_API_KEY for Quandl hasn't been set. A maximum of 50000 calls per day can be made. Visit https://www.quandl.com to get your API key. warnings.warn(message)

    NotFoundError: (Status 404) (Quandl Error QECx02) You have submitted an incorrect Dataset code. Please check your Dataset codes and try again.

    opened by GangababuGB 2
  • bulbea crashes when executing

    bulbea crashes when executing "share = bb.Share('YAHOO', 'GOOGL')" in python2.7

    Hello, today I attempted to install the library and run into an issue. after importing bulbea with >>> import bulbea as bb everything seamed normal but when trying to run >>> share = bb.Share('YAHOO', 'GOOGL') I get this following error: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "bulbea/entity/share.py", line 166, in __init__ message = Color.warn("Environment variable {envvar} for Quandl hasn't been set. A maximum of {max_calls} calls per day can be made. Visit {url} to get your API key.".format(envvar = envvar, max_calls = QUANDL_MAX_DAILY_CALLS, url = ABSURL_QUANDL)) TypeError: unbound method warn() must be called with Color instance as first argument (got str instance instead) Now I have no clue what exactly went wrong or why it isn't working, can someone help me with this?

    opened by realPaulTec 0
  • Fix simple typo: seperated -> separated

    Fix simple typo: seperated -> separated

    Issue Type

    [x] Bug (Typo)

    Steps to Replicate

    1. Examine docs/blog/data-data-everywhere.rst.
    2. Search for seperated.

    Expected Behaviour

    1. Should read separated.

    Semi-automated issue generated by https://github.com/timgates42/meticulous/blob/master/docs/NOTE.md

    To avoid wasting CI processing resources a branch with the fix has been prepared but a pull request has not yet been created. A pull request fixing the issue can be prepared from the link below, feel free to create it or request @timgates42 create the PR.

    https://github.com/timgates42/bulbea/pull/new/bugfix_typo_separated

    Thanks.

    opened by timgates42 0
  • missing 1 required positional argument: 'units' ann.py rnn

    missing 1 required positional argument: 'units' ann.py rnn

    Hi, I have been trying to set this up and I receive this error after running the script in the readme. Please let me know how to fix; I am not very familiar with python. Thanks!

    File "main.py", line 16, in rnn = RNN([1, 100, 100, 1]) # number of neurons in each layer File "/usr/local/lib/python3.7/site-packages/bulbea-0.1.0-py3.7.egg/bulbea/learn/models/ann.py", line 29, in init TypeError: init() missing 1 required positional argument: 'units'

    The whole script:

    import bulbea as bb share = bb.Share('WIKI', 'GOOGL') share.data

    from bulbea.learn.evaluation import split Xtrain, Xtest, ytrain, ytest = split(share, 'Close', normalize = True)

    import numpy as np Xtrain = np.reshape(Xtrain, (Xtrain.shape[0], Xtrain.shape[1], 1)) Xtest = np.reshape(Xtest, (Xtest.shape[0], Xtest.shape[1], 1))

    from bulbea.learn.models import RNN rnn = RNN([1, 100, 100, 1]) # number of neurons in each layer rnn.fit(Xtrain, ytrain)

    from sklearn.metrics import mean_squared_error p = rnn.predict(Xtest) mean_squared_error(ytest, p)

    import matplotlib.pyplot as pplt pplt.plot(ytest) pplt.plot(p) pplt.show()

    opened by EricBollar 2
Owner
Achilles Rasquinha
I write code that automates my job.
Achilles Rasquinha
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
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
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
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
Building Ellee — A GPT-3 and Computer Vision Powered Talking Robotic Teddy Bear With Human Level Conversation Intelligence

Using an object detection and facial recognition system built on MobileNetSSDV2 and Dlib and running on an NVIDIA Jetson Nano, a GPT-3 model, Google Speech Recognition, Amazon Polly and servo motors, I built Ellee - a robotic teddy bear who can move her head and converse naturally.

null 24 Oct 26, 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
Time-series-deep-learning - Developing Deep learning LSTM, BiLSTM models, and NeuralProphet for multi-step time-series forecasting of stock price.

Stock Price Prediction Using Deep Learning Univariate Time Series Predicting stock price using historical data of a company using Neural networks for

Abdultawwab Safarji 7 Nov 27, 2022
Supervised domain-agnostic prediction framework for probabilistic modelling

A supervised domain-agnostic framework that allows for probabilistic modelling, namely the prediction of probability distributions for individual data

The Alan Turing Institute 112 Oct 23, 2022
Attention-based CNN-LSTM and XGBoost hybrid model for stock prediction

Attention-based CNN-LSTM and XGBoost hybrid model for stock prediction Requirements The code has been tested running under Python 3.7.4, with the foll

zshicode 84 Jan 1, 2023
A standard framework for modelling Deep Learning Models for tabular data

PyTorch Tabular aims to make Deep Learning with Tabular data easy and accessible to real-world cases and research alike.

null 801 Jan 8, 2023
A Tensorflow based library for Time Series Modelling with Gaussian Processes

Markovflow Documentation | Tutorials | API reference | Slack What does Markovflow do? Markovflow is a Python library for time-series analysis via prob

Secondmind Labs 24 Dec 12, 2022
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
Neural network for stock price prediction

neural_network_for_stock_price_prediction Neural networks for stock price predic

null 2 Feb 4, 2022
Price-Prediction-For-a-Dream-Home - A machine learning based linear regression trained model for house price prediction.

Price-Prediction-For-a-Dream-Home ROADMAP TO THIS LINEAR REGRESSION BASED HOUSE PRICE PREDICTION PREDICTION MODEL Import all the dependencies of the p

DIKSHA DESWAL 1 Dec 29, 2021
Implementation of the bachelor's thesis "Real-time stock predictions with deep learning and news scraping".

Real-time stock predictions with deep learning and news scraping This repository contains a partial implementation of my bachelor's thesis "Real-time

David Álvarez de la Torre 0 Feb 9, 2022
Pre-trained BERT Models for Ancient and Medieval Greek, and associated code for LaTeCH 2021 paper titled - "A Pilot Study for BERT Language Modelling and Morphological Analysis for Ancient and Medieval Greek"

Ancient Greek BERT The first and only available Ancient Greek sub-word BERT model! State-of-the-art post fine-tuning on Part-of-Speech Tagging and Mor

Pranaydeep Singh 22 Dec 8, 2022
Fast, flexible and easy to use probabilistic modelling in Python.

Please consider citing the JMLR-MLOSS Manuscript if you've used pomegranate in your academic work! pomegranate is a package for building probabilistic

Jacob Schreiber 3k Dec 29, 2022
Civsim is a basic civilisation simulation and modelling system built in Python 3.8.

Civsim Introduction Civsim is a basic civilisation simulation and modelling system built in Python 3.8. It requires the following packages: perlin_noi

null 17 Aug 8, 2022