<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Backtesting example
This notebook assumes you have the bitfinex library installed
Step1:  fetching data from Quandl
For better access to Quandl data it is nice to have an API key. Let's see what kind of data Quandl keeps for bitfinex.
Step2:  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
Step3:  Let's check how many points we have.
<ASSISTANT_TASK:>
Python Code:
import sys
sys.path.append('..')
from bitfinex.backtest import data
%pylab inline
Explanation: Backtesting example
This notebook assumes you have the bitfinex library installed
End of explanation
with open('quandl.key', 'r') as f:
    key = f.read().strip()
data.Quandl.search('bitfinex')
Explanation: fetching data from Quandl
For better access to Quandl data it is nice to have an API key. Let's see what kind of data Quandl keeps for bitfinex.
End of explanation
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')
Explanation: 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
End of explanation
history.data.info()
history.data[-10:]
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);
Explanation: Let's check how many points we have.
End of explanation
<END_TASK>