<aside> 📌 Since the drop of Bitcoin in 2008, there are tons of various cryptocurrencies coming out that utilized blockchain technology. However, if you look at them closely, you will see their market values varies drastically with Bitcoin being the one that seems to have the most potential in the long run. In this project, I will try to use publicly available datasets to better understand the highly volatile cryptocurrencies market and see if I can discover any valuable insights for people like myself who are interested in investing in this rather new investing opportunity.
</aside>
# Importing all the useful lib
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
%config InlineBackend.figure_format = 'svg'
plt.style.use('fivethirtyeight')
# Reading datasets
dec6 = pd.read_csv('datasets/coinmarketcap_06122017.csv')
# Cleaning the data since we don't want
#cryptocurrencies that don't even have a market value
market_cap_raw = dec6[["id" , "market_cap_usd"]]
print(market_cap_raw.count()) #1326
cap = market_cap_raw.query("market_cap_usd > 0")
print(cap.count()) #1031
TOP_CAP_TITLE = 'Top 10 market capitalization'
TOP_CAP_YLABEL = '% of total cap'
# Selecting the first 10 rows and setting the index
cap10 = cap[:10].set_index("id")
# Calculating market share
cap10 = cap10.assign(market_cap_perc = lambda x: (x.market_cap_usd
/ cap.market_cap_usd.sum()) * 100)
# Plotting barplot1 using colors
COLORS = ['orange', 'green', 'orange', 'cyan', 'cyan', 'blue', 'silver', 'orange', 'red', 'green']
ax = cap10.market_cap_perc.plot.bar(title=TOP_CAP_TITLE, colors = COLORS)
ax.set_yscale("log")
ax.set_ylabel("USD")
ax.set_xlabel("")
# Plotting barplot2
def capcount(query_string):
return cap.query(query_string).count().id
LABELS = ["biggish", "micro", "nano"]
biggish = capcount("market_cap_usd > 3E+8")
micro = capcount("market_cap_usd >= 5E+7 & market_cap_usd < 3E+8")
nano = capcount("market_cap_usd < 50000000")
values = [biggish, micro, nano]
plt.bar(range(len(values)), values, tick_label=LABELS);
Barplot1:
Barplot2:
# Selecting the id, percent_change_24h and percent_change_7d columns
volatility = dec6[["id", "percent_change_24h", "percent_change_7d"]]
# cleaning and sorting
volatility = volatility.set_index("id").dropna()
volatility = volatility.sort_values(by=["percent_change_24h"], ascending = True)
#Defining a function with 2 parameters, the series to plot and the title
def top10_subplot(volatility_series, title):
# Making the subplot and the figure for two side by side plots
fig, axes = plt.subplots(nrows=1, ncols=2, figsize=(10, 6))
# Plotting barplot3
ax = volatility_series[:10].plot.bar(color = "darkred", ax=axes[0])
fig.suptitle(title)
ax.set_ylabel("% change")
ax = volatility_series[-10:].plot.bar(color = "darkred", ax=axes[1])
return fig, ax
DTITLE = "24 hours top losers and winners"
# Plotting barplot4
fig, ax = top10_subplot(volatility.percent_change_24h, DTITLE)
volatility7d = volatility.sort_values("percent_change_7d", ascending = True)
WTITLE = "Weekly top losers and winners"
fig, ax = top10_subplot(volatility7d.percent_change_7d, WTITLE)
Subplot3: