Wednesday, September 5, 2018

Who wrote nytimes resistance article?

# nytimes_resistance_letter
Which senior cabinet wrote nytimes 'resistance' article?

Below ranking of each cabinent member. Azar, Acosta, or Haley are most likely to have written article based on data analysis.


['rick perry', 1]
['Kelly_John', 2]
['kirstjen nielsen ', 2]
['mulvaney', 3]
['coats', 3]
['gina haspel', 4]
['mnuchin', 5]
['elaine chao', 5]
['mcmahon', 6]
['mike pomeo', 7]
['sonny perdue', 8]
['mattis', 8]
['zinke', 8]
['ben carson', 8]
['wilbur ross', 8]
['devos', 9]
['Robert Lighthizer', 9]
['sessions', 10]
['Robert L. Wilki', 10]
['haley', 10]
['acosta', 11]
['azar', 16]


I scraped each person's opening testimony as a dataset. I then split each person testimony into sentences. I built a model to predict who wrote a sentence given it's features (bigrams of words and characters).
Applying model to each sentence of resistance article gave a probability that a cabinent member wrote that sentence.
I set a threshold of .1 for each sentence probability; if a person recieved a probability greater than .1 then they were giving a 1 else 0 for that particular sentence. The above ranking is the sum of those scores.


code

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