Algo trading digital assets

Quantification of the the efficiency of trading ETH/BTC or LTC/BTC using simple moving averages (SMAs)

bitcoin trading
By John Mathews
In: Data
Oct 28 2017
In [1]:
from IPython.display import HTML
HTML('''

 This analysis was made using Python. If you'd like to see the code used, click here.
''')
Out[1]:
This analysis was made using Python. If you’d like to see the code used, click here.

Introduction

This notebook shows the process of investigating the price history of Bitcoin, Ethereum and Litecoin using Simple Moving Averages (SMAs).

I noticed that the 7 day and 30 day SMAs would cross each other occasionally, and I wondered how profitable it would be to use this as a trading strategy.

I generate a heat map to show how profitability varies across different pairs of SMAs.

For a given SMA pair I show the trading algorithms performance between two dates.

Setup and import data

Setup involves importing the python packages required and changing the default notebook settings. I use Plotly figures rather than a simpler method of visualising data and whilst creating the notebook I use the offline Plotly options. If I use other visualisation packages I’ll set figures to appear below the code cell that called the plot command.

The price data is downloaded from Quandl. In order to keep my Quandl and Plot.ly credentials private, I keep my account credentials in a separate .py file.

The Pickle package and get_data() functions are used to download Quandl data only once and then store it locally in a .pkl file. This is quicker than downloading it every time I (re)run the notebook.

In [2]:
## Setup - libraries
%matplotlib inline
import os
import pickle
import quandl
import matplotlib.pyplot as plt
import pandas as pd
import datetime as dt
import numpy as np
import credentials # keep my quandl and plot.ly api keys private

import plotly
#import plotly.offline as py
import plotly.plotly as py
import plotly.graph_objs as go
import plotly.figure_factory as ff
#py.init_notebook_mode(connected=True)
plotly.offline.init_notebook_mode()

#from mpl_toolkits.mplot3d import Axes3D