The Python Quants

Analyzing Bitcoin Data with PQP and Quandl.com

Dr. Yves J. Hilpisch

The Python Quants GmbH

analytics@pythonquants.com

www.pythonquants.com

Free trials for the Python Quant Platform under http://trial.quant-platform.com.

In [1]:
import pandas as pd
import urllib
import json
%matplotlib inline
In [2]:
def read_quandl(url):
    d = json.loads(urllib.urlopen(url).read())
    df = pd.DataFrame(d['data'], columns=d['column_names']).set_index('Date').sort()
    return df

Number of Bitcoins

In [3]:
url = "https://www.quandl.com/api/v1/datasets/BCHAIN/TOTBC.json"
In [4]:
number = read_quandl(url)

Number of Bitcoins in existence.

In [5]:
number.plot(figsize=(10, 5))
Out[5]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f2fe9e3ad50>

Bitcoin Rate

In [6]:
url = "https://www.quandl.com/api/v1/datasets/BAVERAGE/USD.json"
In [7]:
quotes = read_quandl(url)

Historical Bitcoin rate in USD.

In [8]:
quotes[['24h Average', 'Total Volume']][quotes.index > '2012-12-31'].plot(subplots=True, figsize=(10, 5), color='b')
Out[8]:
array([<matplotlib.axes._subplots.AxesSubplot object at 0x7f2fe9afb650>,
       <matplotlib.axes._subplots.AxesSubplot object at 0x7f2fe9cecdd0>], dtype=object)

Bitcoin rate to the USD in January.

In [9]:
quotes[['24h Average', 'Total Volume']][quotes.index > '2014-12-31'].plot(subplots=True, figsize=(10, 5), color='b')
Out[9]:
array([<matplotlib.axes._subplots.AxesSubplot object at 0x7f2fe99bf290>,
       <matplotlib.axes._subplots.AxesSubplot object at 0x7f2fe9949f50>], dtype=object)