Skip to content

daniel-cortez-stevenson/crypto-predict

Repository files navigation

crypto-predict

Build Status Coverage Status Docker Build Docker Build Status

This project is a easily reproducible Python/Docker project to create an API that predicts the price of BTC and ETH using OHLCV data. The API is defined using Zalando's connexion package, which leverages the Flask framework.

Current implementation smooths the raw close % change data (previous 72 hours). This data is fed into a 1D Convolutional Layer, which feeds into a dual-layer LSTM with linear activation function (network graph coming soon!).

Note: Anaconda is recommended to manage the project environment. Environment creation without Anaconda is untested

Install the Development Environment

mv .env_template .env   # Must have a .env file for some functions to find correct path
make create_environment
conda activate crypto_predict
make install_dev
make test

Get/Process Data and Train Models with crypr-* Commands

crypr-data --hours 10000
crypr-features
crypr-models --epochs 20

Run the API with Docker

make run_docker

Now find your prediction at http://localhost:5000/predict?coin=BTC

Jupyter Notebooks

The Jupyter Notebooks in this project serve as rich visual examples of how data preprocessing and model training is done for the prediction API.

Run with

make run_jupyter

Notebook server will be at http://localhost:8888

Future Directions

  • More coins!
  • More models (xgboost)
  • Visualize price predictions in a web app based on the developed prediction api
  • Use unstructured text data to calculate sentiment or other metrics to use in prediction
  • Use transfer learning from financial markets and other crypto coins to enhance the RNN model

Project Organization

├── api/                            # connexion pyfiles and config
│   ├── app.py
│   └── swagger.yaml
├── crypr/                          # Python Package
│   ├── scripts/
│   │   ├── make_dataset.py
│   │   ├── make_features.py
│   │   └── make_train_models.py
│   ├── tests/
│   │   ├── data/
│   │   ├── test_app.py
│   │   ├── test_build.py
│   │   ├── test_cryptocompare.py
│   │   ├── test_model.py
│   │   └── test_transformers.py
│   ├── build.py
│   ├── cryptocompare.py
│   ├── models.py
│   ├── transformers.py
│   ├── types.py
│   ├── util.py
│   └── zoo.py
├── data/
│   ├── external/
│   ├── interim/
│   ├── processed/                        # Data generated by crypr-features
│   └── raw/                              # Data retrieved with crypr-data
├── docker/                               # Deploy the API
│   ├── Dockerfile
│   └── wait_for_healthy.sh
├── models/                               # DL models trained with crypr-models
├── notebooks/
│   ├── cwt_rnn_model_dev.ipynb
│   ├── data_exploration.ipynb
│   ├── jupyter_notebook_config.py
│   ├── model_dev.ipynb
│   ├── preprocessing.ipynb
│   ├── rnn_model_dev.ipynb
│   ├── self-attention-model-dev.ipynb
│   ├── statistical_model_dev.ipynb
│   ├── tree_model_dev.ipynb
│   ├── wt_multiple_preprocessing.ipynb
│   ├── wt_single_preprocessing.ipynb
│   ├── wt_smooth_preprocessing.ipynb
│   └── wt_smooth_rnn_model_dev.ipynb
├── references/
│   ├── bao2017.pdf
│   └── hsieh2011.pdf
├── Dockerfile.dockerhub        # For hub.docker.com automated build hook
├── LICENSE
├── MANIFEST.in
├── Makefile
├── README.md
├── requirements.txt            # Development Python packages
├── setup.cfg
├── setup.py
├── .coveragerc
├── .coveralls.yml
├── .dockerignore
├── .env                        # Copied from .env_template
├── .env_template
├── .gitignore
└── .travis.yml