Data Science Project: Catching Past Bitcoin Corrections

Hakan Elbas
8 min readJan 4, 2021

--

This article has been written by Alparslan Mesri and Hakan Elbas.

Corrections are important and can be bloody in the Bitcoin market. It is possible to find and mark these corrections manually by ourselves on a graph on the internet. But it needs time to mark every correction above 40%. Maybe you want to increase your research level and see corrections by 20%, which needs more time and effort. Or let us escalate detail and calculate every corrections recovery time and frequency. It needs to be admitted that every 15% drop is not easy to be detected manually for tired eyes neither possible to just neglect them.

But the problem is not limited to detection. In this article, we will see how to detect and digitalize them, but in another aspect, by using data science, detecting and digitilizing these drops will give us new opportunities to develop and try new trade algorithms in these big corrections and maybe dodge from them with minimum damage with help of mathematics and machine learning algorithms. Peter Drucker says “If you can’t measure it, you can’t improve it.”. In this solution, we will learn to define and measure bitcoin corrections.

First Step of Our Journey: Data Gathering, Transformation, and Cleaning…

Firstly we need to access reliable data. Kaggle.com is a beneficial platform for data scientists that contains many problems as well as data sets. We retrieved BTC minutely data csv file from this platform. When this article has been written, the data have included the dates between 01.01.2012 and 15.09.2020. Although continuously data providers are updating the file. Here is the link.

In a data science project, the first step is about imports. After completing that part we defined a function that converts Unix date data to gregorian date data and called it while using read_csv function.

When we take a closer look at the data, we will see there is a lot of nan values. According to kaggle.com related page, the nan values mean that price didn’t change since the previous time unit. It means, in fact, nan values have meaning. Thus we used fillna function and ffill method to replay missing data correctly. Since our studies, we also detected a wrong value and changed it with the correct one.

In this part, we find out max and min values inside of days. Assign them to new variables and concat in a new variable whose name is df_daily. Thus our data frame is daily data now. During these operations, one tricky part is that we crop only bull seasons from the entire data because we aim to catch only bull season corrections. Our study doesn’t interested dumps in bear seasons.

The Algorithm and Results…

We did great work. Now the material is ready to be processed. But there are too many ways to reach the same goal. You can examine our algorithm and customize it according to your style if you wish.

1- Peak Date : 2012-01-12 00:00 --> Bottom Date : 2012-01-27 00:00 
Peak Price : 7.380000 --> Bottom Price : 3.800000
Correction Percentage : 48.509485
Correction Duration : 15 Days Recovery Duration : 182 Days
====================================================================
2- Peak Date : 2012-08-17 00:00 --> Bottom Date : 2012-08-20 00:00
Peak Price : 16.410000 --> Bottom Price : 7.100000
Correction Percentage : 56.733699
Correction Duration : 3 Days Recovery Duration : 156 Days
====================================================================
3- Peak Date : 2013-01-24 00:00 --> Bottom Date : 2013-01-25 00:00
Peak Price : 19.200000 --> Bottom Price : 16.120000
Correction Percentage : 16.041667
Correction Duration : 1 Days Recovery Duration : 4 Days
====================================================================
4- Peak Date : 2013-03-06 00:00 --> Bottom Date : 2013-03-07 00:00
Peak Price : 49.170000 --> Bottom Price : 33.000000
Correction Percentage : 32.885906
Correction Duration : 1 Days Recovery Duration : 12 Days
====================================================================
5- Peak Date : 2013-03-21 00:00 --> Bottom Date : 2013-03-23 00:00
Peak Price : 76.910000 --> Bottom Price : 50.090000
Correction Percentage : 34.871928
Correction Duration : 2 Days Recovery Duration : 3 Days
====================================================================
6- Peak Date : 2013-03-26 00:00 --> Bottom Date : 2013-03-27 00:00
Peak Price : 100.000000 --> Bottom Price : 78.540000
Correction Percentage : 21.460000
Correction Duration : 1 Days Recovery Duration : 5 Days
====================================================================
7- Peak Date : 2013-04-03 00:00 --> Bottom Date : 2013-04-04 00:00
Peak Price : 158.410000 --> Bottom Price : 110.000000
Correction Percentage : 30.559939
Correction Duration : 1 Days Recovery Duration : 1 Days
====================================================================
8- Peak Date : 2013-04-05 00:00 --> Bottom Date : 2013-04-07 00:00
Peak Price : 200.000000 --> Bottom Price : 138.500000
Correction Percentage : 30.750000
Correction Duration : 2 Days Recovery Duration : 3 Days
====================================================================
9- Peak Date : 2015-01-15 00:00 --> Bottom Date : 2015-01-16 00:00
Peak Price : 233.900000 --> Bottom Price : 192.000000
Correction Percentage : 17.913638
Correction Duration : 1 Days Recovery Duration : 6 Days
====================================================================
10- Peak Date : 2015-01-26 00:00 --> Bottom Date : 2015-02-01 00:00
Peak Price : 309.900000 --> Bottom Price : 208.480000
Correction Percentage : 32.726686
Correction Duration : 6 Days Recovery Duration : 166 Days
====================================================================
11- Peak Date : 2015-07-12 00:00 --> Bottom Date : 2015-08-25 00:00
Peak Price : 317.990000 --> Bottom Price : 198.120000
Correction Percentage : 37.696154
Correction Duration : 44 Days Recovery Duration : 108 Days
====================================================================
12- Peak Date : 2015-11-04 00:00 --> Bottom Date : 2015-11-12 00:00
Peak Price : 502.000000 --> Bottom Price : 294.000000
Correction Percentage : 41.434263
Correction Duration : 8 Days Recovery Duration : 205 Days
====================================================================
13- Peak Date : 2016-06-18 00:00 --> Bottom Date : 2016-08-03 00:00
Peak Price : 778.850000 --> Bottom Price : 465.280000
Correction Percentage : 40.260641
Correction Duration : 46 Days Recovery Duration : 176 Days
====================================================================
14- Peak Date : 2017-01-04 00:00 --> Bottom Date : 2017-01-12 00:00
Peak Price : 1139.890000 --> Bottom Price : 751.340000
Correction Percentage : 34.086622
Correction Duration : 8 Days Recovery Duration : 48 Days
====================================================================
15- Peak Date : 2017-03-10 00:00 --> Bottom Date : 2017-03-25 00:00
Peak Price : 1350.000000 --> Bottom Price : 891.330000
Correction Percentage : 33.975556
Correction Duration : 15 Days Recovery Duration : 51 Days
====================================================================
16- Peak Date : 2017-05-11 00:00 --> Bottom Date : 2017-05-13 00:00
Peak Price : 1892.000000 --> Bottom Price : 1601.460000
Correction Percentage : 15.356237
Correction Duration : 2 Days Recovery Duration : 7 Days
====================================================================
17- Peak Date : 2017-05-25 00:00 --> Bottom Date : 2017-05-27 00:00
Peak Price : 2760.100000 --> Bottom Price : 1850.000000
Correction Percentage : 32.973443
Correction Duration : 2 Days Recovery Duration : 11 Days
====================================================================
18- Peak Date : 2017-06-12 00:00 --> Bottom Date : 2017-07-16 00:00
Peak Price : 2980.000000 --> Bottom Price : 1830.000000
Correction Percentage : 38.590604
Correction Duration : 34 Days Recovery Duration : 53 Days
====================================================================
19- Peak Date : 2017-08-17 00:00 --> Bottom Date : 2017-08-22 00:00
Peak Price : 4480.000000 --> Bottom Price : 3600.000000
Correction Percentage : 19.642857
Correction Duration : 5 Days Recovery Duration : 11 Days
====================================================================
20- Peak Date : 2017-09-02 00:00 --> Bottom Date : 2017-09-15 00:00
Peak Price : 4979.900000 --> Bottom Price : 2972.010000
Correction Percentage : 40.319886
Correction Duration : 13 Days Recovery Duration : 39 Days
====================================================================
21- Peak Date : 2017-11-08 00:00 --> Bottom Date : 2017-11-12 00:00
Peak Price : 7888.000000 --> Bottom Price : 5555.550000
Correction Percentage : 29.569599
Correction Duration : 4 Days Recovery Duration : 8 Days
====================================================================
22- Peak Date : 2017-11-29 00:00 --> Bottom Date : 2017-11-30 00:00
Peak Price : 11395.000000 --> Bottom Price : 9000.000000
Correction Percentage : 21.017990
Correction Duration : 1 Days Recovery Duration : 3 Days
====================================================================
23- Peak Date : 2017-12-08 00:00 --> Bottom Date : 2017-12-09 00:00
Peak Price : 16666.660000 --> Bottom Price : 12701.050000
Correction Percentage : 23.793670
Correction Duration : 1 Days Recovery Duration : 2 Days
====================================================================
24- Peak Date : 2018-12-24 00:00 --> Bottom Date : 2019-01-29 00:00
Peak Price : 4236.840000 --> Bottom Price : 3322.190000
Correction Percentage : 21.588023
Correction Duration : 36 Days Recovery Duration : 98 Days
====================================================================
25- Peak Date : 2019-05-16 00:00 --> Bottom Date : 2019-05-17 00:00
Peak Price : 8390.950000 --> Bottom Price : 6178.000000
Correction Percentage : 26.373057
Correction Duration : 1 Days Recovery Duration : 9 Days
====================================================================
26- Peak Date : 2019-05-30 00:00 --> Bottom Date : 2019-06-05 00:00
Peak Price : 9096.790000 --> Bottom Price : 7432.840000
Correction Percentage : 18.291617
Correction Duration : 6 Days Recovery Duration : 16 Days
====================================================================
27- Peak Date : 2020-03-13 00:00 --> Bottom Date : 2020-03-16 00:00
Peak Price : 5990.350000 --> Bottom Price : 4435.890000
Correction Percentage : 25.949402
Correction Duration : 3 Days Recovery Duration : 5 Days
====================================================================
28- Peak Date : 2020-03-20 00:00 --> Bottom Date : 2020-03-23 00:00
Peak Price : 7139.000000 --> Bottom Price : 5686.340000
Correction Percentage : 20.348228
Correction Duration : 3 Days Recovery Duration : 12 Days
====================================================================
29- Peak Date : 2020-05-08 00:00 --> Bottom Date : 2020-05-10 00:00
Peak Price : 10074.000000 --> Bottom Price : 8109.000000
Correction Percentage : 19.505658
Correction Duration : 2 Days Recovery Duration : 24 Days
====================================================================
30- Peak Date : 2020-06-02 00:00 --> Bottom Date : 2020-06-27 00:00
Peak Price : 10429.260000 --> Bottom Price : 8830.630000
Correction Percentage : 15.328317
Correction Duration : 25 Days Recovery Duration : 54 Days
====================================================================

We called our function and got results. It seems that, although their drop percentages are quite high, these corrections are not so much terrifying for long term investors. Because according to results, the recovery duration is relatively less if you are still in bull season and didn’t get caught at the end of the bull market.

Another point is about the trend of corrections. There is still not so much time passed since BTC is invented and enough data is accumulated but we will again examine the result and try to catch a vision about the future.
In the last part, we created a line graph that includes years and the correction percentages. When we compare BTC’s price fluctuations between the first and the second halving periods, we will see that BTC price inclines to be flattened by years. We asked the same questions about correction magnitudes and draw the graph. Until now, there is no such evidence. Maybe only the years of 2019 and 2020 seem to have less movement but we know that these are bear seasons and real increases and thus corrections will appear in 2021.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

No responses yet

Write a response