Discovering of Cryptocurrencies - Troy Kayne - December 15, 2017

In this Article, I will show you the power of pandas and the data analytics of historical prices of multiple cryptocurrencies. Unfortunately, the data does not represent the recent exponential rise of these stock prices. The purpose of this exersice is to see if more recent cryptocurrencies will rise similar to Bitcoin

Cryptocurrencies used in this study

Bitccoin, Ethereum, Litecoin, and Monero

This Notebook will Read, Concatenate, and Map Reduce multiple DataFrames

In [2]:
import numpy as np
import pandas as pd
import plotly
import plotly.plotly as py
import plotly.graph_objs as go
import plotly.graph_objs as go

This is an example of loading a data frame from a csv file and indexing it by the Date

In [3]:
btc_df = pd.read_csv('/Users/troy/Github/courses/crypto-pirates/cryptocurrencypricehistory/bitcoin_price.csv')
btc_df.set_index('Date',inplace=True)
btc_df.head()
Out[3]:
Open High Low Close Volume Market Cap
Date
28-Apr-13 135.30 135.98 132.10 134.21 - 1,500,520,000
29-Apr-13 134.44 147.49 134.00 144.54 - 1,491,160,000
30-Apr-13 144.00 146.93 134.05 139.00 - 1,597,780,000
1-May-13 139.00 139.89 107.72 116.99 - 1,542,820,000
2-May-13 116.38 125.60 92.28 105.21 - 1,292,190,000

Adding Columns

Here I am adding a new column to the data frame where the value takes in an operation of two columns.

In [4]:
btc_df['Daily Range'] = btc_df['High'] - btc_df['Low']
btc_df.head()
Out[4]:
Open High Low Close Volume Market Cap Daily Range
Date
28-Apr-13 135.30 135.98 132.10 134.21 - 1,500,520,000 3.88
29-Apr-13 134.44 147.49 134.00 144.54 - 1,491,160,000 13.49
30-Apr-13 144.00 146.93 134.05 139.00 - 1,597,780,000 12.88
1-May-13 139.00 139.89 107.72 116.99 - 1,542,820,000 32.17
2-May-13 116.38 125.60 92.28 105.21 - 1,292,190,000 33.32

This is the mean of Daily Range for Bitcoin

In [5]:
btc_df['Daily Range'].mean()
Out[5]:
39.37898765432098
In [8]:
'''
1. Add new column. 2. Define Conditions. 3. Change necessary value to the column that meets the condition.
'''

btc_df['Significant'] = ''

cond1 = btc_df['Daily Range'] > btc_df['Daily Range'].mean()
cond2 = btc_df['Daily Range'] < btc_df['Daily Range'].mean()

yes = btc_df[cond1]
no = btc_df[cond2]

column = 'Significant'
btc_df.loc[cond1, column] = 'Yes'
btc_df.loc[cond2, column] = 'No'
btc_df.set_index('Significant')
Out[8]:
Open High Low Close Volume Market Cap Daily Range
Significant
No 135.30 135.98 132.10 134.21 - 1,500,520,000 3.88
No 134.44 147.49 134.00 144.54 - 1,491,160,000 13.49
No 144.00 146.93 134.05 139.00 - 1,597,780,000 12.88
No 139.00 139.89 107.72 116.99 - 1,542,820,000 32.17
No 116.38 125.60 92.28 105.21 - 1,292,190,000 33.32
No 106.25 108.13 79.10 97.75 - 1,180,070,000 29.03
No 98.10 115.00 92.50 112.50 - 1,089,890,000 22.50
No 112.90 118.80 107.14 115.91 - 1,254,760,000 11.66
No 115.98 124.66 106.64 112.30 - 1,289,470,000 18.02
No 112.25 113.44 97.70 111.50 - 1,248,470,000 15.74
No 109.60 115.78 109.60 113.57 - 1,219,450,000 6.18
No 113.20 113.46 109.26 112.67 - 1,259,980,000 4.20
No 112.80 122.00 111.55 117.20 - 1,255,970,000 10.45
No 117.70 118.68 113.01 115.24 - 1,311,050,000 5.67
No 115.64 117.45 113.44 115.00 - 1,288,630,000 4.01
No 114.82 118.70 114.50 117.98 - 1,279,980,000 4.20
No 117.98 119.80 110.25 111.50 - 1,315,720,000 9.55
No 111.40 115.81 103.50 114.22 - 1,242,760,000 12.31
No 114.22 118.76 112.20 118.76 - 1,274,620,000 6.56
No 118.21 125.30 116.57 123.02 - 1,319,590,000 8.73
No 123.50 125.25 122.30 123.50 - 1,379,140,000 2.95
No 123.21 124.50 119.57 121.99 - 1,376,370,000 4.93
No 122.50 123.62 120.12 122.00 - 1,368,910,000 3.50
No 122.02 123.00 121.21 122.88 - 1,363,940,000 1.79
No 122.89 124.00 122.00 123.89 - 1,374,130,000 2.00
No 123.80 126.93 123.10 126.70 - 1,384,780,000 3.83
No 126.30 133.85 125.72 133.20 - 1,413,300,000 8.13
No 133.10 133.22 128.90 131.98 - 1,489,950,000 4.32
No 131.99 136.00 130.62 133.48 - 1,478,030,000 5.38
No 133.50 135.47 124.70 129.75 - 1,495,520,000 10.77
... ... ... ... ... ... ... ...
Yes 4591.63 4591.63 4108.40 4236.31 2,987,330,000 75,955,500,000 483.23
Yes 4228.29 4427.84 3998.11 4376.53 2,697,970,000 69,954,400,000 429.73
Yes 4376.59 4617.25 4376.59 4597.12 2,172,100,000 72,418,700,000 240.66
Yes 4589.14 4655.04 4491.33 4599.88 1,844,620,000 75,945,000,000 163.71
Yes 4605.16 4661.00 4075.18 4228.75 2,700,890,000 76,220,200,000 585.82
Yes 4229.81 4308.82 4114.11 4226.06 1,386,230,000 70,017,200,000 194.71
Yes 4229.34 4245.44 3951.04 4122.94 1,679,090,000 70,018,100,000 294.40
Yes 4122.47 4261.67 4099.40 4161.27 1,557,330,000 68,256,000,000 162.27
Yes 4168.88 4344.65 4085.22 4130.81 1,864,530,000 69,033,400,000 259.43
Yes 4131.98 4131.98 3789.92 3882.59 2,219,410,000 68,432,200,000 342.06
Yes 3875.37 3920.60 3153.86 3154.95 2,716,310,000 64,191,600,000 766.74
Yes 3166.30 3733.45 2946.62 3637.52 4,148,070,000 52,453,500,000 786.83
Yes 3637.75 3808.84 3487.79 3625.04 1,818,400,000 60,271,600,000 321.05
Yes 3606.28 3664.81 3445.64 3582.88 1,239,150,000 59,757,800,000 219.17
Yes 3591.09 4079.23 3591.09 4065.20 1,943,210,000 59,514,100,000 488.14
Yes 4073.79 4094.07 3868.87 3924.97 1,563,980,000 67,520,300,000 225.20
Yes 3916.36 4031.39 3857.73 3905.95 1,213,830,000 64,918,500,000 173.66
Yes 3901.47 3916.42 3613.63 3631.04 1,411,480,000 64,677,600,000 302.79
Yes 3628.02 3758.27 3553.53 3630.70 1,194,830,000 60,152,300,000 204.74
Yes 3629.92 3819.21 3594.58 3792.40 928,114,000 60,190,000,000 224.63
Yes 3796.15 3796.15 3666.90 3682.84 768,015,000 62,954,300,000 129.25
Yes 3681.58 3950.25 3681.58 3926.07 1,374,210,000 61,061,100,000 268.67
Yes 3928.41 3969.89 3869.90 3892.35 1,043,740,000 65,161,000,000 99.99
Yes 3892.94 4210.05 3884.82 4200.67 1,686,880,000 64,579,200,000 325.23
Yes 4197.13 4279.31 4109.70 4174.73 1,712,320,000 69,633,200,000 169.61
Yes 4171.62 4214.63 4039.29 4163.07 1,367,050,000 69,219,200,000 175.34
Yes 4166.11 4358.43 4160.86 4338.71 1,207,450,000 69,136,600,000 197.57
Yes 4341.05 4403.74 4269.81 4403.74 1,208,210,000 72,047,300,000 133.93
Yes 4395.81 4470.23 4377.46 4409.32 1,431,730,000 72,963,200,000 92.77
Yes 4408.46 4432.47 4258.89 4317.48 1,288,020,000 73,181,300,000 173.58

1620 rows × 7 columns

Read Mulitple Data Frames

In [9]:
btc = pd.read_csv('/Users/troy/Github/courses/crypto-pirates/cryptocurrencypricehistory/bitcoin_price.csv')
mon = pd.read_csv('/Users/troy/Github/courses/crypto-pirates/cryptocurrencypricehistory/monero_price.csv')
lit = pd.read_csv('/Users/troy/Github/courses/crypto-pirates/cryptocurrencypricehistory/litecoin_price.csv')
eth = pd.read_csv('/Users/troy/Github/courses/crypto-pirates/cryptocurrencypricehistory/ethereum_price.csv')

Concatenating Multiple Data Frames

Before I concatenate multiple data frames, I first added a new column to each data frame which is going to be used for map reducing later.

In [10]:
btc['CC'] = 'Bitcoin'
mon['CC'] = 'Monero'
lit['CC'] = 'Litecoin'
eth['CC'] = 'Ethereum'

Now, I will add another column with the Moving averages of each CC

In [11]:
btc['MA'] = btc['Close'].rolling(10).mean()
mon['MA'] = mon['Close'].rolling(10).mean()
lit['MA'] = lit['Close'].rolling(10).mean()
eth['MA'] = lit['Close'].rolling(10).mean()

btc['SMA'] = btc['Close'].rolling(50).mean()
mon['SMA'] = mon['Close'].rolling(50).mean()
lit['SMA'] = lit['Close'].rolling(50).mean()
eth['SMA'] = lit['Close'].rolling(50).mean()

eth['Close'].max()
Out[11]:
401.49000000000001

Discover Iterations of Trends

In [13]:
# btc[['Date', 'Close', 'MA']]
# onUp = (btc['MA'] > btc['Close']) & (btc[])
# btc[onUp][['Date','Close']]

iteration = (btc['Close']>0) & (btc['Close']<1000)
iteration2 = (btc['Close']>1000) & (btc['Close']<2000)
iteration3 = (btc['Close']>2000) & (btc['Close']<3000)
iteration4 = (btc['Close']>3000) & (btc['Close']<4000)
iteration5 = (btc['Close']>4000) & (btc['Close']<5000)

column = 'Iteration'
btc.loc[iteration, column] = '0-1000'
btc.loc[iteration2, column] = '1000-2000'
btc.loc[iteration3, column] = '2000-000'
btc.loc[iteration4, column] = '3000-4000'
btc.loc[iteration5, column] = '4000-5000'
btc.set_index(['CC','Iteration','Date'])
Out[13]:
Open High Low Close Volume Market Cap MA SMA
CC Iteration Date
Bitcoin 0-1000 28-Apr-13 135.30 135.98 132.10 134.21 - 1,500,520,000 NaN NaN
29-Apr-13 134.44 147.49 134.00 144.54 - 1,491,160,000 NaN NaN
30-Apr-13 144.00 146.93 134.05 139.00 - 1,597,780,000 NaN NaN
1-May-13 139.00 139.89 107.72 116.99 - 1,542,820,000 NaN NaN
2-May-13 116.38 125.60 92.28 105.21 - 1,292,190,000 NaN NaN
3-May-13 106.25 108.13 79.10 97.75 - 1,180,070,000 NaN NaN
4-May-13 98.10 115.00 92.50 112.50 - 1,089,890,000 NaN NaN
5-May-13 112.90 118.80 107.14 115.91 - 1,254,760,000 NaN NaN
6-May-13 115.98 124.66 106.64 112.30 - 1,289,470,000 NaN NaN
7-May-13 112.25 113.44 97.70 111.50 - 1,248,470,000 118.991 NaN
8-May-13 109.60 115.78 109.60 113.57 - 1,219,450,000 116.927 NaN
9-May-13 113.20 113.46 109.26 112.67 - 1,259,980,000 113.740 NaN
10-May-13 112.80 122.00 111.55 117.20 - 1,255,970,000 111.560 NaN
11-May-13 117.70 118.68 113.01 115.24 - 1,311,050,000 111.385 NaN
12-May-13 115.64 117.45 113.44 115.00 - 1,288,630,000 112.364 NaN
13-May-13 114.82 118.70 114.50 117.98 - 1,279,980,000 114.387 NaN
14-May-13 117.98 119.80 110.25 111.50 - 1,315,720,000 114.287 NaN
15-May-13 111.40 115.81 103.50 114.22 - 1,242,760,000 114.118 NaN
16-May-13 114.22 118.76 112.20 118.76 - 1,274,620,000 114.764 NaN
17-May-13 118.21 125.30 116.57 123.02 - 1,319,590,000 115.916 NaN
18-May-13 123.50 125.25 122.30 123.50 - 1,379,140,000 116.909 NaN
19-May-13 123.21 124.50 119.57 121.99 - 1,376,370,000 117.841 NaN
20-May-13 122.50 123.62 120.12 122.00 - 1,368,910,000 118.321 NaN
21-May-13 122.02 123.00 121.21 122.88 - 1,363,940,000 119.085 NaN
22-May-13 122.89 124.00 122.00 123.89 - 1,374,130,000 119.974 NaN
23-May-13 123.80 126.93 123.10 126.70 - 1,384,780,000 120.846 NaN
24-May-13 126.30 133.85 125.72 133.20 - 1,413,300,000 123.016 NaN
25-May-13 133.10 133.22 128.90 131.98 - 1,489,950,000 124.792 NaN
26-May-13 131.99 136.00 130.62 133.48 - 1,478,030,000 126.264 NaN
27-May-13 133.50 135.47 124.70 129.75 - 1,495,520,000 126.937 NaN
... ... ... ... ... ... ... ... ... ...
4000-5000 4-Sep-17 4591.63 4591.63 4108.40 4236.31 2,987,330,000 75,955,500,000 4525.570 3562.9578
5-Sep-17 4228.29 4427.84 3998.11 4376.53 2,697,970,000 69,954,400,000 4527.983 3605.9202
6-Sep-17 4376.59 4617.25 4376.59 4597.12 2,172,100,000 72,418,700,000 4549.407 3651.4850
7-Sep-17 4589.14 4655.04 4491.33 4599.88 1,844,620,000 75,945,000,000 4571.129 3698.0140
8-Sep-17 4605.16 4661.00 4075.18 4228.75 2,700,890,000 76,220,200,000 4536.102 3726.2370
9-Sep-17 4229.81 4308.82 4114.11 4226.06 1,386,230,000 70,017,200,000 4502.178 3757.4030
10-Sep-17 4229.34 4245.44 3951.04 4122.94 1,679,090,000 70,018,100,000 4444.133 3783.6594
11-Sep-17 4122.47 4261.67 4099.40 4161.27 1,557,330,000 68,256,000,000 4371.059 3812.2768
12-Sep-17 4168.88 4344.65 4085.22 4130.81 1,864,530,000 69,033,400,000 4326.263 3839.7958
3000-4000 13-Sep-17 4131.98 4131.98 3789.92 3882.59 2,219,410,000 68,432,200,000 4256.226 3865.9180
14-Sep-17 3875.37 3920.60 3153.86 3154.95 2,716,310,000 64,191,600,000 4148.090 3878.4280
15-Sep-17 3166.30 3733.45 2946.62 3637.52 4,148,070,000 52,453,500,000 4074.189 3897.7428
16-Sep-17 3637.75 3808.84 3487.79 3625.04 1,818,400,000 60,271,600,000 3976.981 3914.0634
17-Sep-17 3606.28 3664.81 3445.64 3582.88 1,239,150,000 59,757,800,000 3875.281 3931.1920
4000-5000 18-Sep-17 3591.09 4079.23 3591.09 4065.20 1,943,210,000 59,514,100,000 3858.926 3957.3524
3000-4000 19-Sep-17 4073.79 4094.07 3868.87 3924.97 1,563,980,000 67,520,300,000 3828.817 3978.3450
20-Sep-17 3916.36 4031.39 3857.73 3905.95 1,213,830,000 64,918,500,000 3807.118 4002.0988
21-Sep-17 3901.47 3916.42 3613.63 3631.04 1,411,480,000 64,677,600,000 3754.095 4020.5062
22-Sep-17 3628.02 3758.27 3553.53 3630.70 1,194,830,000 60,152,300,000 3704.084 4037.0256
23-Sep-17 3629.92 3819.21 3594.58 3792.40 928,114,000 60,190,000,000 3695.065 4054.9558
24-Sep-17 3796.15 3796.15 3666.90 3682.84 768,015,000 62,954,300,000 3747.854 4063.5544
25-Sep-17 3681.58 3950.25 3681.58 3926.07 1,374,210,000 61,061,100,000 3776.709 4077.7970
26-Sep-17 3928.41 3969.89 3869.90 3892.35 1,043,740,000 65,161,000,000 3803.440 4088.0652
4000-5000 27-Sep-17 3892.94 4210.05 3884.82 4200.67 1,686,880,000 64,579,200,000 3865.219 4103.6798
28-Sep-17 4197.13 4279.31 4109.70 4174.73 1,712,320,000 69,633,200,000 3876.172 4120.3250
29-Sep-17 4171.62 4214.63 4039.29 4163.07 1,367,050,000 69,219,200,000 3899.982 4135.9608
30-Sep-17 4166.11 4358.43 4160.86 4338.71 1,207,450,000 69,136,600,000 3943.258 4149.7226
1-Oct-17 4341.05 4403.74 4269.81 4403.74 1,208,210,000 72,047,300,000 4020.528 4160.1032
2-Oct-17 4395.81 4470.23 4377.46 4409.32 1,431,730,000 72,963,200,000 4098.390 4166.8244
3-Oct-17 4408.46 4432.47 4258.89 4317.48 1,288,020,000 73,181,300,000 4150.898 4166.6714

1620 rows × 8 columns

Concatenate and add proper indexes

In [14]:
master = pd.concat([btc,mon,lit,eth])
master.set_index(['CC','Iteration','Date'])
Out[14]:
Close High Low MA Market Cap Open SMA Volume
CC Iteration Date
Bitcoin 0-1000 28-Apr-13 134.21 135.98 132.10 NaN 1,500,520,000 135.30 NaN -
29-Apr-13 144.54 147.49 134.00 NaN 1,491,160,000 134.44 NaN -
30-Apr-13 139.00 146.93 134.05 NaN 1,597,780,000 144.00 NaN -
1-May-13 116.99 139.89 107.72 NaN 1,542,820,000 139.00 NaN -
2-May-13 105.21 125.60 92.28 NaN 1,292,190,000 116.38 NaN -
3-May-13 97.75 108.13 79.10 NaN 1,180,070,000 106.25 NaN -
4-May-13 112.50 115.00 92.50 NaN 1,089,890,000 98.10 NaN -
5-May-13 115.91 118.80 107.14 NaN 1,254,760,000 112.90 NaN -
6-May-13 112.30 124.66 106.64 NaN 1,289,470,000 115.98 NaN -
7-May-13 111.50 113.44 97.70 118.991 1,248,470,000 112.25 NaN -
8-May-13 113.57 115.78 109.60 116.927 1,219,450,000 109.60 NaN -
9-May-13 112.67 113.46 109.26 113.740 1,259,980,000 113.20 NaN -
10-May-13 117.20 122.00 111.55 111.560 1,255,970,000 112.80 NaN -
11-May-13 115.24 118.68 113.01 111.385 1,311,050,000 117.70 NaN -
12-May-13 115.00 117.45 113.44 112.364 1,288,630,000 115.64 NaN -
13-May-13 117.98 118.70 114.50 114.387 1,279,980,000 114.82 NaN -
14-May-13 111.50 119.80 110.25 114.287 1,315,720,000 117.98 NaN -
15-May-13 114.22 115.81 103.50 114.118 1,242,760,000 111.40 NaN -
16-May-13 118.76 118.76 112.20 114.764 1,274,620,000 114.22 NaN -
17-May-13 123.02 125.30 116.57 115.916 1,319,590,000 118.21 NaN -
18-May-13 123.50 125.25 122.30 116.909 1,379,140,000 123.50 NaN -
19-May-13 121.99 124.50 119.57 117.841 1,376,370,000 123.21 NaN -
20-May-13 122.00 123.62 120.12 118.321 1,368,910,000 122.50 NaN -
21-May-13 122.88 123.00 121.21 119.085 1,363,940,000 122.02 NaN -
22-May-13 123.89 124.00 122.00 119.974 1,374,130,000 122.89 NaN -
23-May-13 126.70 126.93 123.10 120.846 1,384,780,000 123.80 NaN -
24-May-13 133.20 133.85 125.72 123.016 1,413,300,000 126.30 NaN -
25-May-13 131.98 133.22 128.90 124.792 1,489,950,000 133.10 NaN -
26-May-13 133.48 136.00 130.62 126.264 1,478,030,000 131.99 NaN -
27-May-13 129.75 135.47 124.70 126.937 1,495,520,000 133.50 NaN -
... ... ... ... ... ... ... ... ... ... ...
Ethereum NaN 4-Sep-17 295.17 347.13 279.94 1.676 32,774,000,000 347.13 1.4812 1,801,690,000
5-Sep-17 312.99 318.57 268.29 1.715 28,100,000,000 297.57 1.4854 1,551,050,000
6-Sep-17 334.34 334.66 313.49 1.753 29,639,100,000 313.80 1.4902 1,058,830,000
7-Sep-17 329.43 333.52 319.94 1.788 31,507,500,000 333.52 1.4958 718,624,000
8-Sep-17 296.50 329.64 285.16 1.804 31,147,200,000 329.64 1.4994 1,098,780,000
9-Sep-17 294.40 299.89 287.22 1.783 27,990,500,000 296.17 1.5026 528,621,000
10-Sep-17 288.75 294.76 268.97 1.771 27,797,200,000 294.06 1.5084 698,326,000
11-Sep-17 294.53 300.69 286.69 1.757 27,394,400,000 289.75 1.5146 571,307,000
12-Sep-17 291.46 311.19 287.23 1.744 27,861,800,000 294.63 1.5204 753,144,000
13-Sep-17 277.11 291.12 260.61 1.738 27,535,700,000 291.12 1.5272 921,692,000
14-Sep-17 213.91 280.84 213.91 1.729 26,166,100,000 276.59 1.5342 1,184,590,000
15-Sep-17 250.46 258.65 195.03 1.718 20,364,900,000 215.22 1.5406 1,935,700,000
16-Sep-17 246.52 262.59 238.22 1.714 23,742,600,000 250.87 1.5486 711,737,000
17-Sep-17 251.75 257.00 235.24 1.713 23,272,500,000 245.85 1.5564 427,452,000
18-Sep-17 293.50 293.50 252.23 1.725 23,881,200,000 252.23 1.5632 1,127,750,000
19-Sep-17 282.80 295.77 274.48 1.742 27,809,300,000 293.66 1.5700 646,909,000
20-Sep-17 283.74 290.89 278.05 1.755 26,712,400,000 282.01 1.5768 421,404,000
21-Sep-17 258.58 286.61 255.02 1.772 26,836,000,000 283.26 1.5856 601,266,000
22-Sep-17 264.31 270.54 256.22 1.805 24,458,400,000 258.11 1.5976 430,081,000
23-Sep-17 286.17 286.17 261.12 1.831 25,077,100,000 264.60 1.6116 450,934,000
24-Sep-17 282.48 292.95 278.13 1.943 27,129,900,000 286.21 1.6416 571,411,000
25-Sep-17 292.33 293.51 281.88 2.059 26,755,500,000 282.22 1.6722 483,161,000
26-Sep-17 287.44 293.75 287.02 2.190 27,720,000,000 292.35 1.7070 345,801,000
27-Sep-17 306.47 308.01 286.82 2.291 27,219,400,000 287.02 1.7344 550,244,000
28-Sep-17 299.15 307.20 295.47 2.419 29,068,700,000 306.47 1.7670 501,894,000
29-Sep-17 291.47 299.92 279.77 2.542 28,375,900,000 299.12 1.7990 541,375,000
30-Sep-17 301.46 303.96 291.11 2.665 27,655,200,000 291.48 1.8310 332,439,000
1-Oct-17 302.34 303.19 295.06 2.776 28,615,200,000 301.55 1.8622 306,185,000
2-Oct-17 297.48 302.92 294.58 2.854 28,708,500,000 302.48 1.8896 339,443,000
3-Oct-17 292.46 300.11 288.13 2.937 28,238,500,000 297.48 1.9188 321,680,000

5260 rows × 8 columns

Visual of All our CC prices

Since Bitcoin's price is significantly higher, we gave the other 3 newer CCs a scalar of 10 in order to make cleaner plot.

In [15]:
import plotly
import plotly.plotly as py
import plotly.graph_objs as go
In [16]:
trace1 = go.Scatter(
    x = btc['Date'],
    y = btc['Close'],
    mode = 'Lines',
    name = 'Bitcoin Close Price'
)
trace2 = go.Scatter(
    x = mon['Date'],
    y = 10*mon['Close'],
    mode = 'Lines',
    name = 'Monero Close Price'
)
trace3 = go.Scatter(
    x = lit['Date'],
    y = 10*lit['Close'],
    mode = 'Lines',
    name = 'Litecoin Close Price'
)
trace4 = go.Scatter(
    x = eth['Date'],
    y = 10*eth['Close'],
    mode = 'Lines',
    name = 'Ethereum Close Price'
)

data = [trace1,trace2,trace3,trace4]

py.iplot(data, filename='basic-scatter')
Out[16]:

The goal here is to aggregate data by cryptocurrency. We can approach this by creating a multi-level index that will map a new numerical index for each cc. In order to start the index hierarchy, we need to find the total number of tuples associated with eact cc and then use that number to index the tuples.

In [17]:
master.groupby('CC').mean()
Out[17]:
Close High Low MA Open SMA
CC
Bitcoin 718.804210 736.272765 696.893778 710.501118 716.325031 675.452342
Ethereum 58.631558 61.013183 55.490062 7.087932 58.278590 7.330305
Litecoin 9.330123 9.737444 8.843586 9.221423 9.302488 8.687041
Monero 10.740487 11.325722 10.091139 10.463187 10.668743 9.025200
In [18]:
master.groupby('CC').min()
Out[18]:
Close Date High Iteration Low MA Market Cap Open SMA Volume
CC
Bitcoin 68.430000 1-Apr-14 74.560000 0-1000 65.530000 78.948000 1,000,070,000 68.500000 95.241200 -
Ethereum 0.434829 1-Apr-16 0.482988 NaN 0.420897 1.334000 - 0.431589 1.465400 1,005,910
Litecoin 1.160000 1-Apr-14 1.340000 NaN 1.110000 1.334000 1,039,720,000 1.150000 1.465400 -
Monero 0.223522 1-Apr-15 0.251757 NaN 0.212967 0.251481 1,166,240,000 0.220121 0.293345 1,037,600
In [19]:
master.groupby('CC').max()
Out[19]:
Close Date High Iteration Low MA Market Cap Open SMA Volume
CC
Bitcoin 4892.01 9-Sep-17 4975.04 4000-5000 4678.53 4571.129 909,526,000 4901.42 4166.8244 994,625,000
Ethereum 401.49 9-Sep-17 414.76 NaN 383.47 38.067 999,757,000 397.59 27.2898 986,266,000
Litecoin 86.04 9-Sep-17 92.07 NaN 75.59 74.185 99,946,000 85.83 56.7496 993,855
Monero 145.40 9-Sep-17 154.58 NaN 136.49 132.022 99,903,600 144.24 99.8556 99,815
In [20]:
# Count number of interations
master.groupby('CC').count()
Out[20]:
Close Date High Iteration Low MA Market Cap Open SMA Volume
CC
Bitcoin 1620 1620 1620 1620 1620 1611 1620 1620 1571 1620
Ethereum 789 789 789 0 789 780 789 789 740 789
Litecoin 1620 1620 1620 0 1620 1611 1620 1620 1571 1620
Monero 1231 1231 1231 0 1231 1222 1231 1231 1182 1231
In [21]:
master.groupby('CC').describe()
Out[21]:
Close High ... Open SMA
count mean std min 25% 50% 75% max count mean ... 75% max count mean std min 25% 50% 75% max
CC
Bitcoin 1620.0 718.804210 846.165337 68.430000 261.412500 448.19 705.2800 4892.01 1620.0 736.272765 ... 705.3475 4901.42 1571.0 675.452342 725.604766 95.241200 262.541000 457.11340 687.3790 4166.8244
Ethereum 789.0 58.631558 103.192076 0.434829 5.550000 11.23 43.2400 401.49 789.0 61.013183 ... 42.8700 397.59 740.0 7.330305 6.831907 1.465400 2.471950 3.75790 10.8906 27.2898
Litecoin 1620.0 9.330123 13.145707 1.160000 3.060000 3.84 8.7125 86.04 1620.0 9.737444 ... 8.6750 85.83 1571.0 8.687041 11.349873 1.465400 3.195900 3.87360 8.8001 56.7496
Monero 1231.0 10.740487 22.491004 0.223522 0.513035 1.39 9.4300 145.40 1231.0 11.325722 ... 9.3800 144.24 1182.0 9.025200 17.415058 0.293345 0.522607 1.22189 8.6267 99.8556

4 rows × 48 columns

In [22]:
master.groupby('CC').describe().transpose()
Out[22]:
CC Bitcoin Ethereum Litecoin Monero
Close count 1620.000000 789.000000 1620.000000 1231.000000
mean 718.804210 58.631558 9.330123 10.740487
std 846.165337 103.192076 13.145707 22.491004
min 68.430000 0.434829 1.160000 0.223522
25% 261.412500 5.550000 3.060000 0.513035
50% 448.190000 11.230000 3.840000 1.390000
75% 705.280000 43.240000 8.712500 9.430000
max 4892.010000 401.490000 86.040000 145.400000
High count 1620.000000 789.000000 1620.000000 1231.000000
mean 736.272765 61.013183 9.737444 11.325722
std 870.749477 107.243068 13.847245 23.724047
min 74.560000 0.482988 1.340000 0.251757
25% 266.462500 5.890000 3.120000 0.542731
50% 454.645000 11.520000 3.910000 1.500000
75% 724.555000 44.260000 9.262500 9.810000
max 4975.040000 414.760000 92.070000 154.580000
Low count 1620.000000 789.000000 1620.000000 1231.000000
mean 696.893778 55.490062 8.843586 10.091139
std 812.844163 97.917796 12.272203 21.023287
min 65.530000 0.420897 1.110000 0.212967
25% 255.740000 4.640000 2.990000 0.494739
50% 442.785000 10.880000 3.790000 1.240000
75% 688.002500 39.690000 8.435000 8.980000
max 4678.530000 383.470000 75.590000 136.490000
MA count 1611.000000 780.000000 1611.000000 1222.000000
mean 710.501118 7.087932 9.221423 10.463187
std 824.006709 7.333241 12.835936 21.794368
min 78.948000 1.334000 1.334000 0.251481
25% 259.389000 2.303000 3.094000 0.513099
50% 449.541000 3.593500 3.850000 1.363000
75% 709.338000 10.444500 8.544500 9.608250
max 4571.129000 38.067000 74.185000 132.022000
Open count 1620.000000 789.000000 1620.000000 1231.000000
mean 716.325031 58.278590 9.302488 10.668743
std 841.566485 102.877114 13.103364 22.366494
min 68.500000 0.431589 1.150000 0.220121
25% 261.080000 5.400000 3.070000 0.514239
50% 448.150000 11.220000 3.845000 1.380000
75% 705.347500 42.870000 8.675000 9.380000
max 4901.420000 397.590000 85.830000 144.240000
SMA count 1571.000000 740.000000 1571.000000 1182.000000
mean 675.452342 7.330305 8.687041 9.025200
std 725.604766 6.831907 11.349873 17.415058
min 95.241200 1.465400 1.465400 0.293345
25% 262.541000 2.471950 3.195900 0.522607
50% 457.113400 3.757900 3.873600 1.221890
75% 687.379000 10.890600 8.800100 8.626700
max 4166.824400 27.289800 56.749600 99.855600
In [25]:
master.groupby('CC').describe().transpose()['Bitcoin']
Out[25]:
Close  count    1620.000000
       mean      718.804210
       std       846.165337
       min        68.430000
       25%       261.412500
       50%       448.190000
       75%       705.280000
       max      4892.010000
High   count    1620.000000
       mean      736.272765
       std       870.749477
       min        74.560000
       25%       266.462500
       50%       454.645000
       75%       724.555000
       max      4975.040000
Low    count    1620.000000
       mean      696.893778
       std       812.844163
       min        65.530000
       25%       255.740000
       50%       442.785000
       75%       688.002500
       max      4678.530000
MA     count    1611.000000
       mean      710.501118
       std       824.006709
       min        78.948000
       25%       259.389000
       50%       449.541000
       75%       709.338000
       max      4571.129000
Open   count    1620.000000
       mean      716.325031
       std       841.566485
       min        68.500000
       25%       261.080000
       50%       448.150000
       75%       705.347500
       max      4901.420000
SMA    count    1571.000000
       mean      675.452342
       std       725.604766
       min        95.241200
       25%       262.541000
       50%       457.113400
       75%       687.379000
       max      4166.824400
Name: Bitcoin, dtype: float64

Merging

Merging works like SQL Join logic. We combine multiple dataframes with an index key to form a relational table.

In [26]:
# define left and right data fr
# master_df.merge(left, right, on=['Key1','Key2])
In [27]:
# left = btc_df['Daily Range'] < btc_df['']

Output to csv

In [28]:
master.to_csv('data.csv', index=False)

Conclusion

I have found that these four cryptocurrencies are very correlated with each other. They rise and fall around the same time. Uptrends and Downtrends are common among one another. Howerver, the stocks are very volatile. It is difficult to predict trends. In addtion, I have found that many current events are correlated with specific inclines and declines. Initial Coin Offerings (ICO) have a strong correlation with the data. ICOs publicly announce their launches. If you are interested to invest, make sure you also watch out for ICO launches.