# Last edited on 2016-10-31 10:13:50 by stolfilocal THE BITCOIN NATIONAL DEBT Definition When someone buys some bitcoin to speculate with, he expects to get his money back eventually, with some profit. Thus we can see bitcoins as a kind of bonds or debt notes, "entitling" the bearer to get back from the Bitcoin System a certain amount, some time in the future. Specifically, if the current owner of some amount B of bitcoin bought them at some day index bd in the past for a price P per bitcoin, he is expectin to receive back from the System the amount D = B × P × R^(cd - bd), where cd is the current day index, and R is the minimum acceptable daily interest rate. (For a return on investment of ~10%, then R would be ~1.000261.) But we do not know when bitcoins were last bought, nor what was the actual price that the owner paid for them. The blockchain does not help If we parsed the blockchain and we could trace the path of each satoshi through every transaction, we would know the time td(0), ltd(1), ..., td(k) of the transactions where it was involved; where td(0) was the date when that satoshi was mined. If we assumed that he may or may not have been bought on those days only, each date td(i) would be a candidate for the day of last buy. However, there are some problems with that idea. First, if a transaction has multiple outputs, it is impossible to say which path each satoshi followed. (It is not clear whether this ambiguity would make a difference, though; must think). Second, it is quite possible that the coin was bought or sold without a transaction being recorded. This could happen, for example, if the satoshi was deposited into an exchange or other entity that maintains BTC accounts for clients, and executed transactions off the blockchain. Or if the coin was sold over-the-counter with a contract that specified actual delivery at a later date. E.g., in the USMS auctions the payment and delivery of the coins were separated by a few days. A trade not recorded in the blockchain could happen even just after the satoshi was created, before the 100 confirmation period elapsed. A trade may even occur before the satoshi was created. But we will ignore this possibility. We also assume that the unit price (USD/BTC) for any trade that happened on some day d was the average market price P(d) of that day. Since over-the-counter trades are not recorded anywhere, we have no upper bound for the total amount traded on any given day. It could be more than the total BTC transaction volume in the blockchain plus the total trading volume at all exchanges. Simplification Because of those problems, we will use a more conservative assumption that actually simplifies the code: if some amount B(md) of bitcoin was created by a miner on a date md, it may have been traded on any day d between md and the current day cd, inclusive both, for a price in USD equal to the average USD/BTC market price on that day, P(d), times the BTC amount B(md). This assumption may not be true for over-the-counter trades, and the price may be different at different exchanges, but we will ignore these possibilities. So, each amount B(md) of BTC that was mined on some day md may have been last bought on some day bd in {md..cd}, for the price B(md) x P(bd); in which case it would contribute B(md) × P × R^(cd - bd) to the current debt D(cd). We will assume that P is between the low and high prices PLO(md) and PHI(md) on some reference exchange. This contribution will be in the interval B(mb) × PLO(md,cd) and B(mb) × PHI(md,cd), where PLO(md,cd) = MIN { PLO(bd) × R^(cd - bd) : md <= bd <= cd } PHI(md,cd) = MAX { PHI(bd) × R^(cd - bd) : md <= bd <= cd } We can then compute DLO(cd) = SUM { B(md) × PLO(md,bd) : md <= cd } DHI(cd) = SUM { B(md) × PHI(md,bd) : md <= cd } Running it: export TZ=UTC; compute_bitcoin_debt.gawk \ -f useful_functions.gawk \ -f price_series_functions.gawk \ -v priceFile="../00-DATA/series/fix/2010-07-17--2016-10-30-PREF-USD-01d.txt" \ -v minedFile="../00-DATA/blockchain/txt-der/2009-01-03--2016-10-30-bitcoins-mined.txt" \ > out/2009-01-03--2016-10-30-debt.txt