In [1]:
import pandas as pd
pd.options.mode.chained_assignment = None # default='warn'
# Need to disable the annoying Pandas warnings that were added in 0.20...
import matplotlib
%matplotlib inline
You can find historical bitcoin data in here: https://www.kaggle.com/mczielinski/bitcoin-historical-data/data please note that currently the code was tested only on Bitstamp data. for the this demo we will use a small sample of data.
In [2]:
from data_handling import get_OHLC_data_from_file
directory_path = 'data'
file_name = 'OHLC_sample.csv'
df = get_OHLC_data_from_file(directory_path, file_name)
In [3]:
df.head(5)
Out[3]:
In [4]:
from plotting import plot_OHLC, SMA_overlay, BBands_overlay, buy_sell_overlay
plot_OHLC(df, '30Min', overlays=[(SMA_overlay,14),(BBands_overlay,20,3)])
In [5]:
from trade_strategies import hindsight_trade_strategy
# This is dummy strategy, it gives ideal buy/sell decision based on future behavior,can only work on old data that was collected
# (or if you know how to see into the future)
df = hindsight_trade_strategy(df, start=1, sensitivity=0.7)
In [6]:
from plotting import plot_trade_strategy
plot_trade_strategy(df)
We also have the abilty to take the latest tick data using the Bitstamp public api https://www.bitstamp.net/market/tradeview/
In [13]:
from data_handling import get_latest_Bitstamp_ticks, convert_tick_to_OHLC
df = get_latest_Bitstamp_ticks()
df = convert_tick_to_OHLC(df, resample_size='1Min')
df = hindsight_trade_strategy(df, start=1, commision=0)
plot_trade_strategy(df)