bitcoin trading
Trading digital assets
October 2017

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

In [1]:
from IPython.display import HTML
function code_toggle() {
 if (code_show){
 } else {
 code_show =! code_show
$( document ).ready(code_toggle);

<font> This analysis was made using Python. If you'd like to see the code used, click <a href="javascript:code_toggle()">here</a>.</font>
This analysis was made using Python. If you’d like to see the code used, click here.


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 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 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

#from mpl_toolkits.mplot3d import Axes3D