Analysing the Cryptocurrency of May 2021 in Python – Analytics Vidhya

This article was published as a part of the Data Science Blogathon

Introduction

Cryptocurrency serves as a digital asset and is a medium of exchange between individuals where mint ownership records are stored in a guarantee computerize database. They are named as such because complicated cryptography helps in creating and processing these digital currencies and transactions across decentralized systems .
Note: The article is written at the end of May 2021. Current conditions will be different.

Overview of Cryptocurrencies

Cryptocurrencies do not belong to any nation or then. traditional currencies are normally related to the central banks of nations or the government, India has indian Rupee, the USA has US Dollar, Japan has Yen, the EU has Euro and the list goes on.

cryptocurrency overview
( Image Source : hypertext transfer protocol : //www.dnaindia.com/analysis/report-understanding-the-concept-of-cryptocurrency-2820473 )
Cryptocurrencies are designed to be complimentary from the control of any Government or Central bank. The Crypto commercialize has always been highly fluid and erratic and a assortment of factors determine the overall guidance .

Crypto Fall of May 2021

The Crypto market was on the rise in the pandemic season. Since mid-2020, about all cryptocurrencies were on the advance. The social media was all buzzed up on bitcoin and the other cryptocurrencies .
cryptocurrency fall may 2021
Memes spread all over social media regarding the originate of cryptocurrencies. One of the major factors about the cryptocurrency trends was Elon Musk. In February 2021, Tesla bought $ 1.5 billion in bitcoin, and Elon musk evening mentioned that Tesla would accept cryptocurrency as requital .
In early February 2021, the bitcoin price was about 32000 USD, and by February end, it had crossed 50000 INR. Elon Musk besides added the hashtag # bitcoin to his Twitter bio, which did help in the advance of cryptocurrency prices .
The cryptocurrency had become the new “ cool ” thing among youngsters and people wanted to buy as much crypto as possible .

Dogecoin

similarly, Dogecoin was another cryptocurrency that rose to fame was Dogecoin. In February 2021, when Elon Musk and many other celebrities tweeted about Dogecoin, the rate of the coin shot up suddenly. And Dogecoin, unlike Bitcoin or Ethereum has technically no practice. It is a meme cryptocurrency .
Dogecoin
In 2013, a japanese Shiba Inu chase was vastly viral and Dogecoin was started, as a jest. And it was just a playfulness experiment .
On 1st April 2021, Elon Musk tweeted that SpaceX will put a literal Dogecoin on the moon. This immediately became an internet meme, and the monetary value of Dogecoin on the spur of the moment soared .
Dogecoin to the moon
( Image Source : hypertext transfer protocol : //techvivi.com/elon-musk-is-sending-dogecoin-to-the-moon/ )
Images like this scatter all over the internet. The populace might have been physically apart due to the Covid19 pandemic, but through the internet, everyone was together. Bitcoin and Dogecoin gained the limelight and this ultimately pushed the prices of most early cryptocurrencies. People got hyped up that crypto is the raw future and will replace traditional currencies soon .
Musk then tweeted SpaceX ’ snew satellite will be called Doge-1. In an unexpected move, it was besides said that the integral mission will be paid in DogeCoin. This entail Doge would be the inaugural cryptocurrency to contribute to space exploration and besides be the first meme in space .
All this social media hype and jokes lead to an increase in prices in the unharmed crypto market .

The Great Crash:

On 13th May 2021, Elon Musk announced that Tesla will suspend Vehicle purchases using Bitcoin .
elon musk on cryptocurrency
So what are these climate concerns ?
well, Bitcoin mine involves using high-octane computers to solve building complex algorithm. This involves multiple computers and involves high electricity and bandwidth consumption .
On the other hand, China banned fiscal institutions and payment companies from providing services to buy/sell cryptocurrency or provide any other services. Investors were besides warned against crypto trade .
A report from JP Morgan besides mentioned that investors were moving away from Crypto and back to Gold. many other factors besides contributed, and on the spur of the moment the massive descend in cryptocurrency prices wiped out $ 1 trillion of wealth .
Let us try to look at the data of some important cryptocurrencies and have a look at what in truth happened .

Getting started with Python for Finance:

We will extract assorted crypto prices from Yahoo finance. Let us get started by importing the libraries .

import warnings
warnings.filterwarnings('ignore')  # Hide warnings
import datetime as dt
import pandas as pd
pd.core.common.is_list_like = pd.api.types.is_list_like
import pandas_datareader.data as web
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns

import matplotlib.dates as mdates
import plotly.express as px
start = dt.datetime(2021, 1, 1)
end = dt.datetime(2021,5,29)

We set the start and ending dates of the data .

btc = web.DataReader("BTC-USD", 'yahoo', start, end)  # Collects data
btc.reset_index(inplace=True)

Bitcoin

“ BTC-USD ” indicates Bitcoin prices in US dollars. So we extract bitcoin prices .

#bitcoin

crypto= btc[['Date','Adj Close']]
crypto= crypto.rename(columns = {'Adj Close':'BTC'})
# 7 day moving average

crypto[ 'BTC_7DAY_MA' ] = crypto.BTC.rolling( 7).mean()

A roll out average or go average is a way to analyze data points by creating a series of averages of the data already present in the datum. here we calculate average prices based on the former 7 days ’ data of Bitcoin price. Moving averages are much used in technical psychoanalysis .
To read more on move averages, visit this yoke .

Ethereum

adjacent, we try Ethereum. Ethereum is the 2nd largest cryptocurrency by market detonator, after bitcoin. Ethereum went survive on 30 July 2015 with 72 million coins .

#Ethereum

eth = web.DataReader("ETH-USD", 'yahoo', start, end)  # Collects data
eth.reset_index(inplace=True)
crypto["ETH"]= eth["Adj Close"]

# 7 day moving average
crypto[ 'ETH_7DAY_MA' ] = crypto.ETH.rolling( 7).mean()

Dogecoin

following up is Dogecoin. We already discussed Dogecoin. It was introduced on Dec 6, 2013 .

#doge coin

doge = web.DataReader("DOGE-USD", 'yahoo', start, end)  # Collects data
doge.reset_index(inplace=True)
crypto["DOGE"]= doge["Adj Close"]

# 7 day moving average
crypto[ 'DOGE_7DAY_MA' ] = crypto.DOGE.rolling( 7).mean()

BinanceCoin

next, we proceed with Binance Coin. Binance was launched in July 2017 and is based on the Ethereum network. But Binance has its own blockchain, the Binance chain.

#BinanceCoin 

bnb = web.DataReader("BNB-USD", 'yahoo', start, end)  # Collects data
bnb.reset_index(inplace=True)
crypto["BNB"]= bnb["Adj Close"]

# 7 day moving average
crypto[ 'BNB_7DAY_MA' ] = crypto.BNB.rolling( 7).mean()

Cardano

following, we take Cardano. Cardano is a public blockchain platform and peer-to-peer transactions are facilitated by its cryptocurrency ADA. It was launched in September 2017 .

#Cardano

ada = web.DataReader("ADA-USD", 'yahoo', start, end)  # Collects data
ada.reset_index(inplace=True)
crypto["ADA"]= ada["Adj Close"]


# 7 day moving average
crypto[ 'ADA_7DAY_MA' ] = crypto.ADA.rolling( 7).mean()

Ripple is a payment organization and currency substitution platform that can be used to process transactions all over the ball. XRP is deducted as a little fee, whenever users make a transaction using Ripple .

#XRP

xrp = web.DataReader("XRP-USD", 'yahoo', start, end)  # Collects data
xrp.reset_index(inplace=True)
crypto["XRP"]= xrp["Adj Close"]

# 7 day moving average
crypto[ 'XRP_7DAY_MA' ] = crypto.XRP.rolling( 7).mean()

Dash

Dash is an open-source cryptocurrency. It was forked from the Bitcoin protocol. It was launched in January 2014 .

#Dash

dash = web.DataReader("DASH-USD", 'yahoo', start, end)  # Collects data
dash.reset_index(inplace=True)
crypto["DASH"]= dash["Adj Close"]

# 7 day moving average

crypto [ ‘ DASH_7DAY_MA ’ ] = crypto.DASH.rolling ( 7 ) .mean ( )
now, with the data at hand, we format the dates .

#getting the dates 

crypto.set_index("Date", inplace=True)

nowadays, let us have a front at the datum .

crypto[['BTC','ETH','DOGE','BNB','ADA','XRP','DASH']].head()

cryptocurrency data
As we can see all the data has been properly extracted .

Now, let us check the correlation between the data.

crypto[['BTC','ETH','DOGE','BNB','ADA','XRP','DASH']].corr()

cryptocurrency corelation
nowadays, we have some concern revelations. All the datum points have a high correlation coefficient with each early. Let us just compare bitcoin to the others, even the lowest correlation with DOGE is 0.237, which is quite a dependable value. Dash being forked from BTC, has the highest correlation with BTC at 0.77 .
Looking at other datum points, BNB and XRP have a high correlation of 0.93 which is extremely high. It is as if, they are the lapp value .
now let us understand why ? Well, it is simple. The crypto market follows trends. When Bitcoin and Dogecoin were rising, other coins besides increased in value. This was chiefly due to populace sentiment regarding crypto. Who doesn ’ triiodothyronine want to look cool in front man of friends saying that they brought cryptocurrency ?
And similarly, when the values of BTC and DOGE fell, others besides fell. It was like a chain reaction .

Let us look at the correlation heatmap.

#heatmap

plt.figure(figsize = (10,10))
sns.heatmap(crypto[['BTC','ETH','DOGE','BNB','ADA','XRP','DASH']].corr(),annot=True, cmap='Blues')

heatmap
The heatmap clearly shows the high correlation coefficient between the prices of all cryptocurrencies .

Let us plot the data using Plotly express.

fig = px.line(crypto, y=["BTC",'ETH','DOGE','BNB','ADA','XRP','DASH'] )
fig.show()

plot data
well, only the BTC crash in mid-may 2021 is clear. But let us have a look at BTC 7 day moving modal values .

fig = px.line(crypto, y=['BTC_7DAY_MA'] )
fig.show()

btc 7 day moving average
An matter to thing about Plotly is that we can interact with the Plot and get the accurate values, kind of like we can do in Power BI .
here, it is clearly visible that the BTC price abruptly increased in Feb 2021 after all those tweets and social media buzz. And on the spur of the moment in May 2021, everything came crashing .

Let us try Ethereum.

fig = px.line(crypto, y=['ETH'] )
fig.show()

cryptocurrency ethereum
And, it is clear that ETH besides follows a similar blueprint. In April 2021 end, everyone saw the sudden rise in prices of BTC and DOGE and bought ETH. This led to a sudden increase in the price of ETH as well .

Moving Average values:

fig = px.line(crypto, y=['ETH_7DAY_MA'] )
fig.show()

cryptocurrency moving average ethereum
The batch fell depressed a cursorily as it rose. People who bought at the eminent faced enormous losses .

DOGE:

fig = px.line(crypto, y=['DOGE'] )
fig.show()

doge
The get up and fall of DOGE is besides interesting. In Jan 2021, DOGE was nothing, and in early May 2021, it had risen a lot. And its fall was besides sudden .

Moving Average Values:

fig = px.line(crypto, y=['DOGE_7DAY_MA'] )
fig.show()

moving average dogecoin
The code for plotting all the other data is pretty much the lapp. I will leave a connect to the Kaggle notebook where I coded all this in the end .

Conclusion

We now reasonably much understand what caused the doss. The entire crypto market seems to related to each other. People see person buy BTC, they go buy ETH. Someone sells DOGE, they besides sell their BTC. It is all interconnected .
The crypto market is highly volatile, diverse factors lead to the frenzied selloff. One of the largest cryptocurrency exchanges in the world, Coinbase faced overhaul disruptions during this selloff. many Crypto investors had invested because they thought Tesla and Elon musk was into Bitcoin and think of it as the next thing in finance and currency .
many critics have said that this lack of regulation and price handling makes Crypto hazardous for new investors, and many people lost their money this fall .
Code Link : Analyzing the Crypto Crash of May 2021

About me:

Prateek Majumder
Data Science and Analytics | Digital Marketing Specialist | SEO | Content Creation
connect with me on Linkedin.

Thank You .
The media shown in this article are not owned by Analytics Vidhya and are used at the Author’s discretion.

Leave a Comment

Your email address will not be published.