diff --git a/.github/bulbea.png b/.github/bulbea.png
deleted file mode 100644
index 4fc533b42..000000000
Binary files a/.github/bulbea.png and /dev/null differ
diff --git a/.github/logo.png b/.github/logo.png
new file mode 100644
index 000000000..474690214
Binary files /dev/null and b/.github/logo.png differ
diff --git a/.gitignore b/.gitignore
index 507498f48..449280dd6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,14 +1,9 @@
-# virtualenvs
+# venv
.venv
# docs
docs/_build
-# Jupyter Checkpoints
-examples/.ipynb_checkpoints
-
-# twitter
-twitter.sh
-
-# misc
-snippet.py
+# cache
+notebooks/.ipynb_checkpoints
+.DS_Store
\ No newline at end of file
diff --git a/Makefile b/Makefile
index 79256e022..5b3265123 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,20 @@
.PHONY: docs
-PYTHON = python
+PYTHON ?= python
+PYTHON3 ?= python3
+
+BASEDIR = $(realpath .)
+DOCSDIR = $(BASEDIR)/docs
+GITHUBDIR = $(BASEDIR)/.github
+LOGO = $(GITHUBDIR)/logo.png
+
+PIP ?= pip3
+VIRTUALENV ?= virtualenv
+
+venv:
+ $(PIP) install virtualenv
+
+ $(VIRTUALENV) .venv/py3 --python $(PYTHON3)
install:
cat requirements/*.txt > requirements.txt
@@ -10,9 +24,8 @@ install:
$(PYTHON) setup.py install
- bash twitter.sh
-
docs:
+ cp $(LOGO) $(DOCSDIR)/_static/img
cd docs && make html
tests:
diff --git a/README.md b/README.md
index bfb33fb1a..b24c67eeb 100644
--- a/README.md
+++ b/README.md
@@ -1,9 +1,23 @@
-# bulbea
-> *"Deep Learning based Python Library for Stock Market Prediction and Modelling."*
-
-[](https://gitter.im/bulbea/bulbea) [](http://bulbea.readthedocs.io/en/latest/?badge=latest)
-
-
+
+

+
bulbea
+
Deep Learning based Python Library for Stock Market Prediction and Modelling
+
+
+
### Table of Contents
* [Installation](#installation)
@@ -13,7 +27,7 @@
* [License](#license)
### Installation
-Clone the git repository:
+Download or clone the repository using `git`:
```console
$ git clone https://github.com/achillesrasquinha/bulbea.git && cd bulbea
```
diff --git a/bulbea/config/app.py b/bulbea/config/app.py
index 94b93ce16..1d93b518d 100644
--- a/bulbea/config/app.py
+++ b/bulbea/config/app.py
@@ -26,6 +26,7 @@ class AppConfig(BaseConfig):
ENVIRONMENT_VARIABLE = {
'quandl_api_key': 'BULBEA_QUANDL_API_KEY',
+ 'tiingo_api_key': 'BULBEA_TIINGO_API_KEY',
'twitter_api_key': 'BULBEA_TWITTER_API_KEY',
'twitter_api_secret': 'BULBEA_TWITTER_API_SECRET',
'twitter_access_token': 'BULBEA_TWITTER_ACCESS_TOKEN',
diff --git a/bulbea/entity/share.py b/bulbea/entity/share.py
index a6d2b4f71..4edde1217 100644
--- a/bulbea/entity/share.py
+++ b/bulbea/entity/share.py
@@ -4,12 +4,13 @@
# imports - standard packages
import os
import warnings
+import requests
# imports - third-party packages
import numpy as np
import matplotlib.pyplot as pplt
import pandas as pd
-import quandl
+# import quandl
# module imports
from bulbea.config.app import AppConfig
@@ -156,10 +157,12 @@ class Share(Entity):
Date
2003-05-15 18.6 18.849999 18.470001 18.73 71248800.0 1.213325
'''
- def __init__(self, source, ticker, start = None, end = None, latest = None, cache = False):
- _check_str(source, raise_err = True)
+ # def __init__(self, source, ticker, start = None, end = None, latest = None, cache = False):
+ def __init__(self, ticker, start=None, end=None, latest=None, cache=False):
+ # _check_str(source, raise_err = True)
_check_str(ticker, raise_err = True)
+ '''
envvar = AppConfig.ENVIRONMENT_VARIABLE['quandl_api_key']
if not _check_environment_variable_set(envvar):
@@ -168,8 +171,20 @@ def __init__(self, source, ticker, start = None, end = None, latest = None, cach
warnings.warn(message)
else:
quandl.ApiConfig.api_key = os.getenv(envvar)
-
+
self.source = source
+ '''
+
+ envvar = AppConfig.ENVIRONMENT_VARIABLE['tiingo_api_key']
+ config = {}
+ if not _check_environment_variable_set(envvar):
+ message = Color.warn("Environment variable {envvar} for Tiingo not configure correctly ")
+
+ warnings.warn(message)
+ else:
+ self.tiingo_token = os.getenv(envvar)
+
+
self.ticker = ticker
self.update(start = start, end = end, latest = latest, cache = cache)
@@ -184,10 +199,18 @@ def update(self, start = None, end = None, latest = None, cache = False):
>>> share = bb.Share(source = 'YAHOO', ticker = 'AAPL')
>>> share.update()
'''
- self.data = quandl.get('{database}/{code}'.format(
- database = self.source,
- code = self.ticker
- ))
+ # self.data = quandl.get('{database}/{code}'.format(
+ # database = self.source,
+ # code = self.ticker
+ # ))
+ # url = "https://api.tiingo.com/tiingo/daily/{ticker}/prices?startDate={start_date}&endDate={end_date}&token={token}"
+ # self.data = pd.read_json(url.format(
+ # ticker=ticker,
+ # start_date=start,
+ # end_date=end,
+ # token=self.tiingo_token
+ # ))
+ self.data = self.getDataTiingo(self.ticker, start, end)
self.length = len(self.data)
self.attrs = list(self.data.columns)
@@ -316,4 +339,34 @@ def save(self, format_ = 'csv', filename = None):
filename = _get_share_filename(self, extension = format_)
if format_ is 'csv':
- self.data.to_csv(filename)
\ No newline at end of file
+ self.data.to_csv(filename)
+
+ def getDataTiingo(self, ticker, d_start, d_end):
+ headers = {
+ 'Content-Type': 'application/json',
+ 'Authorization': 'Token ' + self.tiingo_token
+ }
+ url = "https://api.tiingo.com/tiingo/daily/" + ticker + "/prices?startDate=" + d_start + "&endDate=" + d_end
+
+ # print url
+ requestResponse = requests.get(url, headers=headers)
+ json_result = requestResponse.json()
+
+ df = pd.DataFrame.from_records(json_result)
+
+ if not 'adjClose' in df.columns:
+ if 'close' in df.columns:
+ df['adjClose'] = df['close']
+ else:
+ print("Error: No Close information")
+ return
+
+ # Convert ISO date format to Pandas DateTime
+ df['date'] = pd.to_datetime(df['date'])
+ # Align Column Names to previous DataReader names
+ df = df.rename(
+ columns={'date': 'Date', 'open': 'Open', 'adjClose': 'Adj Close', 'volume': 'Volume', 'high': 'High',
+ 'low': 'Low', 'close': 'Close'})
+ a = df.set_index(['Date'])
+ # print a
+ return a
\ No newline at end of file
diff --git a/docs/_static/bulbea.png b/docs/_static/bulbea.png
deleted file mode 100644
index 4fc533b42..000000000
Binary files a/docs/_static/bulbea.png and /dev/null differ
diff --git a/docs/_static/img/logo.png b/docs/_static/img/logo.png
new file mode 100644
index 000000000..186eaf01e
Binary files /dev/null and b/docs/_static/img/logo.png differ
diff --git a/docs/_templates/sidebar-logo.html b/docs/_templates/sidebar-logo.html
index 6396dd99b..958b60eeb 100644
--- a/docs/_templates/sidebar-logo.html
+++ b/docs/_templates/sidebar-logo.html
@@ -1,6 +1,6 @@
-
+