The following part visualizes the share of the crytocurrency's market among the addresses of the blockchains. The data has been collected by Blockchair's database dumps which provided us with information about the balance of each of the addresses. The data itself reveals some interesting facts about the distribution of the coins among the addresses.Speaking of it, the top 0.007% Bitcoin cash addresses hold 50% of the coins in circulation. Same applies for the top 0.0063% Litecoin addresses which represents slighlty greater concentration of coins on top. Bitcoin seems to be having the most "equal" distribution of the three, having the top 0.013% addresses hold half the capital. The data shows that, as expected, Bitcoin has the most active addresses (over 31 milion), followed by Bitcoin Cash(>16 milion) and Litecoin comming last with two and a half milion addresses.
Plot
This plot represents the number of addresses(on y axis) that hold the first x percent of the total number of coins. The percentages are shown on the x axis. The marker size on the other hand and it's color share the same dimension which is the average number of coins that are held by each address if the distribution among that particular group was to be uniform. For example, if the top richest 100 addresses hold the first 5% of the wealth (which is let's say 4 milion coins), that means that, on average, each address in this group owns 20 000 coins. The marker's size and color will be scaled with respect to this number. You can click on the toggle button to expand the code for the plot.
import pandas as pd
import numpy as np
import plotly.graph_objects as go
import tabulate
import plotly.tools as tls
from plotly.offline import plot, iplot, init_notebook_mode
from IPython.core.display import display, HTML
init_notebook_mode(connected = True)
config={'showLink': False, 'displayModeBar': False}
percentage = [5,10,20,30,40,50,60,70,80,90,100]
def open_csv():
df = []
df.append(pd.read_csv('bitcoin_addresses.tsv', delimiter ="\t"))
df.append(pd.read_csv('cash_addresses.tsv',delimiter = "\t"))
df.append(pd.read_csv('litecoin_addresses.tsv',delimiter = "\t"))
return df
def calculate_cap(total_sum):
a =[]
for value in percentage:
a.append(total_sum*value/100)
return a
def accurate_wealthPerAddress(df, margins):
a = np.zeros(11)
for i in range(0,11):
if(i is 0):
a[i] = df['balance'][0:margins[i]].sum()/(margins[i])
else:
a[i] = df['balance'][margins[i-1]:margins[i]].sum()/(margins[i]-margins[i-1])
return a
def calculate_margin(df,values_percentage):
count = np.zeros(11)
summ = np.zeros(10)
for ad_balance in df['balance']:
if(values_percentage[9]>=summ[9]+ad_balance):
summ[9]+=ad_balance
count[9]+=1
else:
break
if(values_percentage[8]>=summ[8]+ad_balance):
summ[8]+=ad_balance
count[8]+=1
else:
continue
if(values_percentage[7]>=summ[7]+ad_balance):
summ[7]+=ad_balance
count[7]+=1
else:
continue
if(values_percentage[6]>=summ[6]+ad_balance):
summ[6]+=ad_balance
count[6]+=1
else:
continue
if(values_percentage[5]>=summ[5]+ad_balance):
summ[5]+=ad_balance
count[5]+=1
else:
continue
if(values_percentage[4]>=summ[4]+ad_balance):
summ[4]+=ad_balance
count[4]+=1
else:
continue
if(values_percentage[3]>=summ[3]+ad_balance):
summ[3]+=ad_balance
count[3]+=1
else:
continue
if(values_percentage[2]>=summ[2]+ad_balance):
summ[2]+=ad_balance
count[2]+=1
else:
continue
if(values_percentage[1]>=summ[1]+ad_balance):
summ[1]+=ad_balance
count[1]+=1
else:
continue
if(values_percentage[0]>=summ[0]+ad_balance):
summ[0]+=ad_balance
count[0]+=1
else:
continue
count[10] = len(df)
return count
df = open_csv()
total_satoshis = np.zeros(3)
total_coins = np.zeros(3)
values_percentage = []
margins =[]
satoshis_per_ad = []
bitcoins_per_ad =[]
for i in range(0,3):
total_satoshis[i] = df[i]['balance'].sum()
total_coins[i] = total_satoshis[i]/100000000
values_percentage.append(calculate_cap(total_satoshis[i]))
margins.append(calculate_margin(df[i],values_percentage[i]).astype(int))
satoshis_per_ad.append(accurate_wealthPerAddress(df[i], margins[i]))
bitcoins_per_ad.append(satoshis_per_ad[i]/100000000)
df2 = []
df2.append(pd.DataFrame(list(zip(percentage[0:10],margins[0][0:10],satoshis_per_ad[0][0:10],bitcoins_per_ad[0][0:10],np.log10(satoshis_per_ad[0][0:10]))), columns =['Percentage of total amount of Bitcoins','Number of Addresses',
'Satoshis per Address', 'Average number of Bitcoins per Address','Log10Satoshis']))
df2.append(pd.DataFrame(list(zip(percentage[0:10],margins[1][0:10],satoshis_per_ad[1][0:10],bitcoins_per_ad[1][0:10],np.log10(satoshis_per_ad[1][0:10]))), columns =['Percentage of total amount of Bitcoin Cash Coins','Number of Addresses',
'Satoshis per Address', 'Average number of Bitcoin Cash coins per Address','Log10Satoshis']))
df2.append(pd.DataFrame(list(zip(percentage[0:10],margins[2][0:10],satoshis_per_ad[2][0:10],bitcoins_per_ad[2][0:10],np.log10(satoshis_per_ad[2][0:10]))), columns =['Percentage of total amount of Litecoins','Number of Addresses',
'Satoshis per Address', 'Average number of Litecoins per Address','Log10Satoshis']))
##a = np.append(satoshis_per_ad[0][0:10],satoshis_per_ad[1][0:10])
##a = np.append(a,satoshis_per_ad[2][0:10])
##b = np.append(bitcoins_per_ad[0][0:10].astype(int),bitcoins_per_ad[1][0:10].astype(int))
##b = np.append(b,bitcoins_per_ad[2][0:10].astype(int))
##a.sort()
##b.sort()
##a_new = (np.append(a[0],a[28]))
##b_new =np.append(b[0],b[28])
import plotly.express as px
import plotly.graph_objects as go
fig = px.scatter( df2[0], x = 'Percentage of total amount of Bitcoins', y = 'Number of Addresses',size = 'Average number of Bitcoins per Address',
size_max = 100, color = 'Log10Satoshis',hover_data = {
'Percentage of total amount of Bitcoins':True,
'Number of Addresses':True,
'Satoshis per Address':False,
'Average number of Bitcoins per Address':True,
'Log10Satoshis':False})
fig2 = px.scatter(df2[1], x = 'Percentage of total amount of Bitcoin Cash Coins', y = 'Number of Addresses',size = 'Average number of Bitcoin Cash coins per Address',
size_max = 100, color = 'Log10Satoshis',hover_data = {
'Percentage of total amount of Bitcoin Cash Coins':True,
'Number of Addresses':True,
'Satoshis per Address':False,
'Average number of Bitcoin Cash coins per Address':True,
'Log10Satoshis':False})
fig3 = px.scatter(df2[2], x = 'Percentage of total amount of Litecoins', y = 'Number of Addresses',size = 'Average number of Litecoins per Address',
size_max = 100, color = 'Log10Satoshis',hover_data = {
'Percentage of total amount of Litecoins':True,
'Number of Addresses':True,
'Satoshis per Address':False,
'Average number of Litecoins per Address':True,
'Log10Satoshis':False})
fig.add_trace(fig2.data[0])
fig.add_trace(fig3.data[0])
fig.add_trace(go.Scatter(showlegend = False,line=dict(color='Gray',width = 0.5), mode = 'lines', hoverinfo='skip' ,x = df2[0]['Percentage of total amount of Bitcoins'], y = df2[0]['Number of Addresses'], marker = dict(size = 0,symbol = 'circle-open') ))
fig.add_trace(go.Scatter(showlegend = False,line=dict(color='Gray',width = 0.5), mode = 'lines', hoverinfo='skip' ,x = df2[1]['Percentage of total amount of Bitcoin Cash Coins'], y = df2[1]['Number of Addresses'], marker = dict(size = 0,symbol = 'circle-open') ))
fig.add_trace(go.Scatter(showlegend = False,line=dict(color='Gray',width = 0.5), mode = 'lines', hoverinfo='skip' ,x = df2[2]['Percentage of total amount of Litecoins'], y = df2[2]['Number of Addresses'], marker = dict(size = 0,symbol = 'circle-open') ))
fig.update_layout(plot_bgcolor='rgb(255,255,255)',coloraxis_colorbar=dict(
title="Coins per address",
#tickvals=np.log(a_new)/np.log(10),
#ticktext=b_new,
tickvals=[3,4],
ticktext=[4,5],
),
updatemenus=[
dict(
active=0,
buttons=list([
dict(label="Bitcoin",
method="update",
args=[{"visible":
[True,False,False,True,False,False]},
{"title": "",
'xaxis': {'title': 'Percentage of total amount of Bitcoins'}}
]),
dict(label=" Bitcoin Cash",
method="update",
args=[{"visible":
[ False, True, False, False,True,False]},
{"title": "",
'xaxis': {'title': 'Percentage of total amount of Bitcoin Cash Coins' },
'layout':{'coloraxis_colorbarlorbar':{'title':'mora da rabotish'}}}
]),
dict(label="Litecoin",
method="update",
args=[{"visible":
[False,False,True,False,False,True]},
{"title": "",
'xaxis': {'title': 'Percentage of total amount of Litecoins'}}
])
]),
)
]
)
plot(fig, filename = 'fig.html', config = config)
display(HTML('fig.html'))
df[0]['Balance in Bitcoin'] = (df[0]['balance']/100000000).astype(int)
df[0]['Balance in Euros (as of 25.08)'] = (df[0]['Balance in Bitcoin'].astype(float)*9968.88)
df[1]['Balance in Bitcoin Cash'] = (df[1]['balance']/100000000).astype(int)
df[1]['Balance in Euros (as of 25.08)'] = (df[1]['Balance in Bitcoin Cash'].astype(float)*246.57).astype(int)
df[2]['Balance in Litecoin'] = (df[2]['balance']/100000000).astype(int)
df[2]['Balance in Euros (as of 25.08)'] = (df[2]['Balance in Litecoin'].astype(float)*52.64).astype(int)
display(df[0][0:10])
- Bitcoin Cash
display(df[1][0:10])
- Litecoin
display(df[2][0:10])