In [1]:
import matplotlib.pyplot as plt
import pandas as pd
from pprint import pprint
from coindesk import btc_interval
from tobtc import tobtc
plt.style.use('ggplot')
In [2]:
btc = btc_interval('20170101', '20170119')
In [3]:
btc = btc['bpi']
In [4]:
df = pd.DataFrame(list(btc.items()), columns=['Date', 'USD'])
df
Out[4]:
In [5]:
df.max()
Out[5]:
In [6]:
df.min()
Out[6]:
In [7]:
df.plot(x='Date', y='USD', figsize=(20, 10))
plt.show()
In [8]:
df.plot.box()
plt.show()
In [9]:
percent_change = df['USD'].pct_change()
percent_change.plot(figsize=(20, 10))
plt.show()
In [10]:
h = df.merge(percent_change.to_frame(), left_index=True, right_index=True)
h.columns = ['Date', 'USD', 'percent_change']
h
Out[10]:
In [11]:
date_inc = h[h['percent_change'] > 0.09]
date_inc['Date']
Out[11]:
In [12]:
date_dec = h[h['percent_change'] < -0.09]
date_dec['Date']
Out[12]:
In [13]:
from bitcoin_calc import timestamp_convert
t = timestamp_convert(h)
print(t)
In [14]:
# from reddit_search import reddit_search
# hi = reddit_search('InternationalNews', t['high'])
# lo = reddit_search('InternationalNews', t['low'])
# pprint(lo)
In [15]:
from nyt_get import nyt_bitcoin
from bitcoin_calc import high_percents, low_percents
tlo = nyt_bitcoin(low_percents(h).values.tolist())
pprint(tlo)