In [1]:
import sys
sys.path.append('..')
from bitfinex.backtest import data
%pylab inline
In [ ]:
with open('quandl.key', 'r') as f:
key = f.read().strip()
data.Quandl.search('bitfinex')
Apparently Quandl is offering us only daily prices. For backtesting it is nice to have higher frequency data. For that, another possible source is bitcoincharts, which provides some nice CSVs: Trade data is delayed by approx. 15 minutes. It will return the 2000 most recent trades.. The CSV to be loaded below is about 50MB in size: http://api.bitcoincharts.com/v1/csv/bitfinexUSD.csv.gz
In [2]:
history = data.CSVDataSource('bitfinexUSD.csv.gz',fields=['unix_time', 'price', 'ammount'])
history.parse_timestamp_column('unix_time',unit='s')
#history = data.pd.read_csv('bitfinexUSD.csv.gz',names=['unix_time', 'price', 'amount'])
#history['time'] = data.pd.to_datetime(history['unix_time'],unit='s')
#history = history.set_index('time')
Let's check how many points we have.
In [3]:
history.data.info()
In [4]:
history.data[-10:]
Out[4]:
In [5]:
history.data[-500:].plot(y='price',figsize=(10,6), style='-o', grid=True);
history.data[-50:].plot(y='ammount', kind='bar',figsize=(10,6), grid=True);
In [ ]:
In [ ]:
In [ ]: