In [1]:
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.image as image
%matplotlib inline
plt.xkcd()
Out[1]:
In [2]:
start='20130428'
end='20190112'
In [46]:
def plotter(currency,i,c='orange',st='2012-12-20',last='2017'):
dfs=pd.read_html('https://coinmarketcap.com/currencies/'+currency+'/historical-data/?start='+start+'&end='+end)
df=dfs[0]
df=df[['Date','Close**']]
df.columns=['Date','.']
df['Date']=pd.to_datetime(df['Date'])
fig,ax=plt.subplots(figsize=(13,6))
df[(last>df['Date'])&(df['Date']>'2013')].set_index('Date').plot(ax=ax,c='grey')
ax2=ax.twiny()
ax2=ax2.twinx()
dz=df[df['Date']>'2017'].set_index('Date')
dz.columns=[u'Before and after the last bubble\n2013-2016 (bottom + left axis)']
dz.plot(ax=ax2,c='grey')
dz.columns=[currency.capitalize()+u' price in $ since 2017 (top + right axis)']
dz.plot(ax=ax2,c=c)
ax.set_xlim(st,pd.to_datetime(st)+pd.to_timedelta(3, unit='Y'))
ax2.set_xlim('2017','2020')
ax.set_xlabel('')
ax2.legend()
im = image.imread('https://s2.coinmarketcap.com/static/img/coins/32x32/'+str(i)+'.png')
ax3 = fig.add_axes([0.14, 0.7, 0.07, 0.07])
ax3.axis('off')
ax3.imshow(im)
ttl1='peak: '+str(int(max(df[df['Date']>'2017']['.'])/max(df[df['Date']<'2017']['.'])))+'x'
ttl2='latest: '+str(round(df.loc[df.index[0]].values[1]/max(df[df['Date']<'2017']['.']),2))+'x'
ax3.set_title(ttl1+'\n'+ttl2,color=c,)
plt.savefig(currency)
In [48]:
plotter('bitcoin',1,'orange')
In [49]:
plotter('litecoin',2,'lightgrey')
In [50]:
plotter('ripple',52,'black','2012-11-30')
In [51]:
plotter('dash',131,'dodgerblue','2013-06-07')
In [52]:
plotter('namecoin',3,'lightsteelblue','2012-11-18')
In [53]:
plotter('dogecoin',74,'darkkhaki','2013-01-22')
In [54]:
plotter('bytecoin-bcn',372,'deeppink','2013-02-15')
In [55]:
plotter('nxt',66,'deepskyblue','2013-06-15')
In [56]:
plotter('nem',873,'mediumturquoise','2015-06-25','2017-02')
In [57]:
plotter('peercoin',5,'limegreen')
In [58]:
plotter('feathercoin',8,'black','2012-11-20')
In [ ]:
In [ ]:
In [ ]: