datpark

Analyzing Bitcoin Data with PQP and Quandl.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 0x7fbefacc91d0>

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 0x7fbefaa37250>,
       <matplotlib.axes._subplots.AxesSubplot object at 0x7fbefaaa1a10>], 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 0x7fbefa8c66d0>,
       <matplotlib.axes._subplots.AxesSubplot object at 0x7fbefa7510d0>], dtype=object)