• Stars
    star
    2,013
  • Rank 22,994 (Top 0.5 %)
  • Language
    Python
  • License
    Other
  • 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

🐗 🐻 Deep Learning based Python Library for Stock Market Prediction and Modelling

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.

More Repositories

1

pipupgrade

🗽 Like yarn outdated/upgrade, but for pip. Upgrade all your pip packages and automate your Python Dependency Management.
Python
578
star
2

spockpy

✊ ✋ ✌️ ☝️ 🖖 A Python hand gesture recognition library for Kinetic User Interface (KUI).
Python
55
star
3

brains-from-scratch

Machine Learning for dummies - https://bit.do/brains-from-scratch
Jupyter Notebook
30
star
4

pehchaan

Devanagari Character Recognition
Python
29
star
5

digdet

A realtime digit OCR on the browser using Machine Learning
Jupyter Notebook
22
star
6

PyGram

An Instagram-like photo editor in Python
Python
15
star
7

boilpy

📦 The Best Python Package Template in the Universe
Python
12
star
8

Chat

Minimalistic, modern and extensible chat Client + UI Library for the web.
JavaScript
11
star
9

awesome-foss

A curated list of Free and Open Source Software (FOSS) alternatives for Commercial Software.
9
star
10

Practical-Deep-Learning

The only Deep Learning course you'll ever need.
Jupyter Notebook
8
star
11

nude.cpp

Nudity Detection in OpenCV
C++
7
star
12

git-wow

many add, such commit, very push, git wow.
7
star
13

16SMaRT

16s rRNA Sequencing Meta-analysis Reproducibility Tool (using mothur).
Python
7
star
14

Minitron.js

A dot-matrix display-like javascript plugin.
TypeScript
5
star
15

Flask-React-Boilerplate

A basic Flask + React + Redux Boilerplate for scalable apps.
Python
4
star
16

docker-postgres

A docker image for postgres, but better.
Shell
3
star
17

docker-rpy2

Alpine-based Docker Image for rpy2
Dockerfile
3
star
18

awesome-tools

A curated list of Awesome Developer Tools!
3
star
19

SnackJS

Android Snackbars done right for the web. https://achillesrasquinha.github.io/SnackJS
JavaScript
3
star
20

schema

🔖 Metadata, for humans.
Python
3
star
21

docker-template

A template repository for building and testing docker images
Shell
2
star
22

frappe-noob

If this is your first day at @frappe, this repository is definitely what you need.
Python
2
star
23

fluxml

Flux Balance Analysis using Machine Learning
Python
2
star
24

docker-redis

A docker image for redis, but better.
Shell
2
star
25

balboa_core

ROS Package for Balboa 32U4
CMake
1
star
26

k.ai

A female chatbot assistant
JavaScript
1
star
27

bootstrap-scoped

Scope your Bootstrap assets in a jiffy!
Python
1
star
28

deeply

A library for Deep Learning Implementations and utils
Python
1
star
29

fluxviz

A visualizer for metabolic models.
Python
1
star
30

upyog

A collection of various common Python utilities
Python
1
star
31

dash-class

A simple light-weight javascript utility for the class attribute.
JavaScript
1
star
32

gixpert

GI Endoscopy using Deep Learning
Python
1
star
33

docker-ipython

Alpine-based Dockerfile for IPython
Dockerfile
1
star
34

docker-docker-compose

Docker-Compose in Alpine-Based Docker Image
Dockerfile
1
star
35

docker-cobrapy

Alpine-based Docker Image for CobraPy
Dockerfile
1
star