International Business Environments and Operations 16th Global Edition test b...
Lisbon bitcoin, ethereum and block chain lissabon, portugal
1. Analysing 2018's Bitcoin Blood Moon in 5
Minutes with Python
A quick guide to start investigating Bitcoin’s blood bath
with Python
Rafael
Pierre
Jan 3 · 4 min read
uly 495was the last time many people around the world were able to see a lunar
eclipse — an event popularly known in the media as a “blood moon”.
Many ancient civilisations looked at the “blood moon” with a fearful perspective. Inca
people used to interpret the deep red phenomenon as a jaguar attacking and eating the
moon. They believed the jaguar might attack the Earth next, so their people would
shout, shake their spears and make their dogs bark and howl, in hopes to make enough
noise to drive the evil jaguar away.
The year of 495also marked Bitcoin’s 10 years anniversary. Last year, the
cryptocurrency has also had its worse yearly performance in its short history, amassing
a 70% loss. While the Incans are no longer around us, many bitcoin investors have
been certainly barking and howling.
J
Towards Data Science
Get startedDATA SCIENCE MACHINE LEARNING PROGRAMMING VISUALIZATION AI JOURNALISM PICKS
2. In 2017, bitcoin investors had their honey moon. Has 2018’s bitcoin blood moon
finally marked the end of the line for an investment that was once touted as the
new money?
Investigating Bitcoin Losses with Python
I decided to use Python and Data Science to analyse the losses amassed by bitcoin
(BTC). Python gives freedom and flexibility to visualize bitcoin’s behaviour, calculate
technical indicators, perform fundamentals analysis, run some simulations and most
importantly, act upon obtained insights.
As in any investigation task, we will ask some questions. To answer these questions,
we need to achieve some milestones.
Our main milestones and associated questions are listed below:
Obtaining and Visualizing Bitcoin Price Data: How to use Python to Retrieve
BTC Prices?
Looking at Other Cryptocurrencies: Are other cryptocurrencies correlated with
BTC?
Fundamentals Analysis: How factors such as miners revenue, market cap,
blockchain difficulty and others have influenced BTC price?
Technical Indicators Analysis: Are charts useful for understanding the BTC
losses?
Creating a Performance Dashboard: Can we create a dashboard to monitor all
these insights?
Creating an Alert System: Can we create a platform to generate alerts for BTC
prices and act upon them?
In this post, we will focus on Obtaining Bitcoin Price Data.
Obtaining Bitcoin Price Data
•
•
•
•
•
•
3. Obtaining Bitcoin Price Data
Quandl is the easiest way of retrieving bitcoin data from the mainstream exchanges.
They provide a Python package that allows easy access to their API with a single line of
code.
The Quandl package can be installed using Python’s package manager:
pip install quandl
It can also be installed using the Anaconda Command Line tool (recommended):
conda install quandl
Once it is installed, using it is as simple as this:
import quandl as qdl
import pandas as pd
btc_usd_bitfinex = qdl.get(‘BITFINEX/BTCUSD’, start_date=’01/01/2018', end_date=’31/12/2018')
Running the above line of code returns a Pandas Dataframe and assigns it to our
btc_usd_bitfinex variable.
As the variable name indicates, in this variable we are storing bitcoin prices from the
Bitfinex exchange obtained from January 1st 2018 until December 31st 2018.
If everything went down correctly, one should get a Pandas DataFrame that looks like
the following:
If you are not familiar with Pandas, do not worry, it is a very friendly Python library for
data analysis. The documentation can be found here.
Visualizing Bitcoin Price Data
Now that we have a Pandas Dataframe with our bitcoin price data, we can easily
visualize it using matplotlib.
In the code below, we will:
4. Set matplotlib’s theme to dark, resembling charts generated through Bloomberg
terminals
Set our chart size to (20,7)
Set out chart title
Generate our plot using BTC Closing Prices (“Last”)
import matplotlib.pyplot as plt
plt.style.use(‘dark_background’)
plt.figure(figsize=(20,7))
plt.grid(linewidth=0.2)
plt.title(‘BTC x USD (Bitfinex)’)
plt.plot(btc_usd_bitfinex.index, btc_usd_bitfinex.Last)
From the chart, we can notice that:
Data obtained from Bitfinex is good — we don’t have any date with missing data,
which is usual for some other crypto exchanges
We can see that the worst period for BTC in terms of losses was from the beginning
of January to mid February
In mid February, BTC bounced up to approximately USD 12K, reverting part of the
losses
Apparently pronounced resistance levels can be seen in early March, early May and
late July, depicting a downward trend. In mid November, another significant drop
can be spotted
Main Takeaways and Next Steps
In this post, we discussed how to use Python, Quandl and Matplotlib to obtain and
analyse Bitcoin Price data for 2018.
We did some pretty basic, high level analysis of the price of Bitcoin throughout last
year.
•
•
•
•
•
•
•
•
5. ►►► Lisbon bitcoin ethereum and
block chain lissabon portugal
In the next posts, we will deepen our analysis in order to try to understand why this has
happened and how this has happened.
Last, we will try to create a platform to visualize and act upon these insights in an easy,
efficient way.
Rafael V. Pierre is a Data Scientist based in Amsterdam, NL. He is currently an MSc.
candidate in Information Studies, Data Science at the University of Amsterdam. He is
also a Data Science, AI & Analytics Consultant at Weet Analytics, a company helping
companies unlock unique business opportunities out of data.
Bitcoin Python
Data
Science
Towards Data
Science Cryptocurrency
FollowRafael Pierre
Medium member since Dec 2018
Data Science & Analytics Consultant at Weet Analytics.
https://www.linkedin.com/in/rafaelpierre
FollowTowards Data Science
Sharing concepts, ideas, and
codes.
495claps