Monday, April 2, 2018

How Much Has Bitcoin Made Society?

Realized Gains Bitcoin

Intro:

How much has bitcoin made Society? This post will calculate the realized gains of bitcoin (up to year 2013) as a measure of how much society has made off of bitcoin.

How are realized gains different from market capitalization?

Realized gains measure the amount of money people can claim to have made off of bitcoin. This can be markedly different from the market capitalization.
For instance suppose we have two stocks A and B both with 100 shares and both with a price of $1 at time t_0. Assume the price of both went up to $2 at time t_1. However, suppose all of shares in stock A traded to new people while only one share of stock B traded to new people. The change in realized gains for stock A is $100 while the realized gains in stock B is $1 (assuming everyone for both stocks paid a price of $1 initially).
The example illustrates how market cap and realized gains are different depending on distribution of shares respective previously traded prices.

Does Realized Gains Mean Anything Else?

The above example illustrates why researching realized gains might be interesting in its own right. For instance: it’s much easier to find only one person to believe high prices are valid as opposed to 100 people who do. It may be that increasing prices without corresponding increase in realized gains may lead to evidence of a bubble.

Why Calculate on Bitcoin?

The block chain allows anyone to see the previous time a user purchased a bitcoin and the amount. We can therefore calculate the average price purchased for each user. Since we do not have this information in stocks or currency we cannot calculate it directly for those assets.
There is one heavy assumption on this: that all ID’s (bitcoin address) stay the same. However, it’s common practice that a user his ID when making a trade. This means that the realized gains calculated below are an upper bound since many transactions are self-traded.

Calculations / Results:

I obtained bitcoin transaction data with a package called BlockSci. I calculated the average purchase price of a particular user’s bitcoin holding calculate the realized / unrealized gains accordingly.
Below is a time series chart of market capitalization, realized gains, and unrealized gains up to December 31 2012.
library(ggplot2)
load('/Users/sweiss/Google Drive/blocksci/blog_data.rdata')
gains_plot
It’s interesting to note how realized gains does not increase or decrease significantly during the ‘bubble’ of mid 2012.
By the end of 2012 people have made ~ $79 million dollars of realized gains on bitcoin. This compares with market capitalization of ~ $142 million.

Example Data

Below is an example transaction history for user_id = 1
timeblock_createridheightnum_tradedpricecumulative_sharesavg_purchase_price
2012-12-3101214411-0.000500013.5100-58.001180.8648193
2012-12-19012127480.000000013.5990-58.000680.8647103
2012-11-2801210000-0.250000012.3477-58.000680.8647103
2012-11-0201206133-0.010000010.4688-57.750680.8150009
2012-10-1401203236-0.033123211.7389-57.740680.8133290
2012-10-0301201702-0.000100012.8900-57.707560.8070579
2012-09-1101198260-0.044111211.3308-57.707460.8070370
2012-09-1101198259-0.058211211.3308-57.663340.7989865
2012-09-1101198258-0.011000111.3308-57.605130.7883439
2012-09-0101196682-1.01010109.9654-57.594130.7863304
2012-08-0701192712-0.000500011.1000-56.584030.6224716
2012-08-06011925340.000000010.8552-56.583530.6223790
2012-08-0301192056-0.000399510.9700-56.583530.6223790
2012-07-2801191184-0.00050008.8881-56.583130.6223060
2012-07-2801191157-0.00050008.8881-56.582630.6222329
2012-07-2401190453-0.00265348.6000-56.582130.6221599
2012-07-2001189913-0.10000008.5200-56.579480.6217858
2012-07-1801189695-0.02200009.1098-56.479480.6078015
2012-07-1501189170-0.00100007.6210-56.457480.6044885
2012-07-1501189169-0.06240007.6210-56.456480.6043643
2012-07-0201187212-0.11530006.7600-56.394080.5966004
2012-06-2801186641-0.12345006.6059-56.278780.5839732
2012-06-1201184132-1.23432105.7000-56.155330.5707348
2012-06-1201184127-1.23456005.7000-54.921010.4554573
2012-06-0701183423-0.00100005.5910-53.686450.3348551
2012-06-0101182508-0.00400005.2748-53.685450.3347572
2012-05-2501181523-0.00200005.1455-53.681450.3343891
2012-05-2301181286-0.00100005.1397-53.679450.3342098
2012-05-1801180618-0.00100005.1180-53.678450.3341203
2012-05-1001179528-0.00001004.8500-53.677450.3340312
2012-05-10011795250.00000004.8500-53.677440.3340303
2012-04-2601177317-0.00000195.0976-53.677440.3340303
2012-04-1401175621-0.00100004.9597-53.677440.3340302
2012-04-0301174138-0.00000044.9520-53.676440.3339440
2012-04-0301174128-0.12345684.9520-53.676440.3339439
2012-03-2701173046-0.50000004.8113-53.552980.3232978
2012-03-2301172435-0.04242424.6860-53.052980.2810005
2012-03-2101172202-1.00000674.8149-53.010550.2774752
2012-03-2101172165-0.01000004.8149-52.010550.1902341
2012-03-2101172153-0.02688774.8149-52.000550.1893448
2012-03-07011700600.00400004.9375-51.973660.1869518
2012-03-0701170052-0.00400004.9375-51.977660.1869518
2012-02-11011663650.00000005.6005-51.973660.1865862
2012-02-0301165214-1.00000005.9593-51.973660.1865862
2012-02-03011650840.01000005.9593-50.973660.0733372
2012-01-3001164467-0.01000005.4905-50.983660.0733372
2012-01-1301161943-0.00100006.4100-50.973660.0722745
2011-11-2401154568-0.84265972.4321-50.972660.0721502
2011-10-0201147782-0.00010045.0270-50.130000.0324806
2011-09-26011469640.00000004.8697-50.129900.0324706
2011-08-1101140494-0.00230009.4625-50.129900.0324706
2011-07-0801135235-0.001000014.3140-50.127600.0320379
2011-07-0601134995-0.066600014.7835-50.126600.0317530
2011-06-1701131408-0.010000015.6810-50.060000.0121272
2011-06-0401128554-0.010000018.8900-50.050000.0089966
2011-06-0101127943-0.01000009.5700-50.040000.0052234
2011-06-01011279090.00000009.5700-50.030000.0033116
2011-05-2801127280-0.01000008.3001-50.030000.0033116
2011-05-1301123723-0.01000008.1980-50.020000.0016529
2010-07-290171036-0.01000000.0699-50.010000.0000140
2009-01-03110-50.00000000.0000-50.000000.0000000


Wednesday, June 14, 2017

Dynamic Networks: Visualizing Arms Trades Over Time

I previously made some network graphs of Middle East country relationships here using Slate's Middle East Friendship Chart. I was thinking of a way to visualize these relationships (and possibly other ones) with more rule based and objective measure over time. What kind of public dataset could show countries relationships accurately?

I used weapons / arms trades between nations to explore these relationships. I think arms trades are a good indicator of how friendly countries are together because 1) countries won't sell to enemies and 2) if a country wants to befriends country, buying weapons are a good way to do buy influence.

SIPRI has a very detailed dataset of international arms transfers between >257 nations / organizations in the post war era. The include a type / description and quantity for all trades. For this analysis I will use only the fact that two countries bought or sold some weapons for a particular year. 

One can create adjacency matrices from this dataset and make some network plots. However, doing this one year at a time will not create have a smooth plots over time. I decided to use siamese network graphs to embed a country indicator and year variable in two dimensions with the response variable being whether or not countries traded arms in that particular year. This will transform the country and year of a country into a 2 dimensional space, and means if two points are near each other they probably traded in that particular year.

You can check out the graph here. It's cool that we can see Iran moving away from US to Russia / Soviet Union around 1979 while Egypt and Iraq move towards US. 

One can also explore other relationships. Below is a graph of relationships of the world in 1960. There is a Russia/ Soviet Union cluster and a US / Western Europe Cluster. Neat!


Analysis was done in python (using the Keras example for siamese network) and R (for plotting).

Tuesday, January 10, 2017

Will it Sell?

The Lexus LC 500 has been introduced to much acclaim by car reviewers. Of notes are the cars decent steering, optional V-8 powertrain, and handling that borders on sports car rather than grand coupe. However, is there enough of a market for the Lexus to sell it's desired 4800 cars a year?

To find out I produced a time series plot of yearly sales by probable competitors (thinking luxury coupes costing ~$100k. Of course these cars might appeal to different customers, but all can be bought by the same luxury seeking demographic (I'm think LA or Hamptons). Also included is the previous version of Lexus' luxury coupe, the SC.



(The general trends of competitors are similar in that they appear to be correlated with the economic environment of the time.)

A dated and underwhelming car Lexus SC sold just under 4000 cars in 2007 and dropped off after that. It seems reasonable that if Lexus followed the script on a plush and luxurious coupe / convertible (think SL500 competitor) it could conceivably come up with 5000 cars a year which is approximate number of cars sold for the 3 competitors displayed, at least in its first years when its still new.

However, Lexus did not follow the script of luxurious convertible that might appeal to its standard base but created a car exciting and involving, more 911 than SL500. Would the traditional Lexus SC buy want a Lexus CS? I doubt it. The CS seems like a drivers car and the SC was not. So previous sales of SC might not be a great indicator of future sales.

More worrying for sales is that the Lexus does not have a convertible at the moment (although there is a concept). It seems hard to sell that many cars in this market without a convertible as all competitors do.

It probably won't come close it its 4800 cars a year but sales probably aren't the point of this car. It probably will bring some much needed cred into the auto enthusiast community. What this car is then, is a halo car.