Bitcoin-data manipulaton and plotting in python


plot.png -
I wrote a python mini-api to manipulate and visualize the price of bitcoin historically using the coinbase version 1 api.

bitcoin-price (python module)

Get bitcoin price data from the coinbase API and parse it into an easily manipulated form.

>>> from fast_dump_v22 import *
>>> get_page(1)

Will return all the data on page 1 of coinbase’s bitcoin price API (this is the latest data).

You can almost always turn on optional debug statements

>>> get_first_N(3, show=True)
... fetching first 3

You can get all the price data that coinbase has

>>> get_all(show=True)
... getting page 1
... getting page 2
... getting page 3
... getting page 4
... getting page 5
... getting page 6
... getting page 7
... getting page 8
... getting page 9
... etc ...

All the ‘get_*’ functions return a price_data string, which is interlaced timestamps and prices littered with newlines and commas. You can print them to see what is going on more clearly:

>>> print(get_page(1))

Turn on the optional show switch for printing large vectors

>>> prices(get_page(11), show=True)
... returning 11000 prices in specified range ...

You can use prices(data)[k] and timestamps()[j] to return the kth price in data, or the jth timestamp in data.

>>> data = get_page(1)
>>> prices(data)[4]
>>> prices(data, index=4)

are two equivalent ways of returning only the 4th price in the requested range (in this case, page 1). This also works for timestamps.

>>> timestamps(get_page(1)+get_page(2))[1166] == timestamps(get_first_N(2), index=1166)

This shows the expressiveness of this module. In general:

>>> prices(get_page(2)) == parse(get_page(2))[0]

prices() and timestamps() are just functions that return a parsed() object having a specific index, or indices.

>>> parse(get_page(1)+get_page(2)+get_page(3))[0] == prices(get_first_N(3))
>>> parse(get_page(2)+get_page(3))[0] == prices(get_range(2,3))

The parse() function is there to manually control the outputs instead of just getting prices, or timestamps

>>> x = parse(get_page(1))
>>> x[0][0]
>>> x[0][1]
>>> x[1][1]

As you can see, parse(price_data)[0][k] returns the kth price in the list. Indices [1][k] return the kth timestamp.

The parse() function takes care of some weird edge cases:

>>> get_first_N(3) == get_page(1)+get_page(2)+get_page(3)
>>> parse(get_first_N(3)) == parse(get_page(1)+get_page(2)+get_page(3))
>>> x = get_page(1)
>>> y = get_range(2,7)
>>> prices(get_first_N(7)) == prices(x+y)

In general,

OPERATOR( get_page(1) + get_page(2) + ... + get_page(k) ) == OPERATOR(get_first_N(k))

where OPERATOR is parsed(), prices(), or timestamps(). We also know prices() can obviously display and return ranges of values. When returning large vectors, you can verify their length by setting show=True. The “show” parameter is optional for all get_* functions and provides some information about the operation being performed.

>>> print( prices(get_first_N(11), show=True) )
... returning 11000 prices in specified range...

since each page is a thousand pairs of values (timestamp, price).

>>> len(prices(get_page(2))
>>> prices(get_page(2)) # returns a long list

fast_dump_v1* are older versions that are somewhat different. They are designed to store the fetched data in the .data directory. This in v2*, this was abandoned in favor of stdout redirection.
// 2015

Getting started with Bitcoin the “right way” – encrypted wallets, bitcoin core, and linux

A brief introduction to getting started with bitcoin on a linux distribution

For the impatient: Skip to step 1

Bitcoin is one of the most interesting technologies we have seen emerge in the past ten years. And it confuses everyone who sets out to use it.  This post is my definitive guide to beginning your journey with bitcoin the right way.


To me, the right way includes, but is not limited to:

  • Running bitcoin on a linux machine.  My reasons for this are too many to really list here, but suffice it to say that since linux is widely regarded as the most secure operating system available, and the usage of bitcoin involves being your own bank, using bitcoin on linux is the best way to ensure your coins stay safe.
  • Using the bitcoin-core wallet software.  There are other wallets available.  You actually don’t even need a wallet software to own bitcoins or even spend bitcoins.  However, if you want to understand how bitcoin works under the hood – which you should, because you are going to be your own bank, you should use this software.
  • Using the command line to do bitcoin things. Actually, using both the GUI and the command line is the way to go.  This tutorial (this is part 1 of 2) will be a command-line-centric description because afterall, I’m trying to show you the right way to do things.

But that’s just, like, your opinion man.

It is. This is my blog.

You shouldn’t necessarily trust me or anyone – bitcoin isn’t about trust. But if you google “altoidnerd”, you’ll find that I have been around the bitcoin eco-system for quite some time. That’s all I can tell you.

Screen Shot 2015-09-10 at 8.31.28 PM

There are just so many wallets available – why bitcoin-core?  Because I have been using it for years, I have a very good method of keeping my coins safe, and that is what I am sharing with you today.  Use it- it is THE wallet.

But altoidnerd, I don’t want to run linux. I like windows / OSX

I am a linux and an OSX user.  So please understand the scope of my knowledge includes these operating systems. If you want to use OSX, most of this tutorial will make sense with minor changes perhaps.

Screen Shot 2015-09-10 at 8.32.59 PM

If you want to use windows, that’s ok, I’m not going to judge you. Bitcoin-core is available for windows as well. Please understand however, I am not a windows user, so I will not be able to give you “the definitive bitcoin windows guide”. You can still read on, however, since you can apply much of this tutorial to usage of bitcoin-qt’s debug window instead of the command line.

Step 1: Download and install bitcoin-core

Navigate to’s official download page and select the bitcoin-core distribution for your operating system. And do choose linux (tgz).  Do that because you should be running linux.  But if you aren’t, even though you should be, choose the distribution for your operating system. Extract and install the client.

The “right way”

To really take control of things, and understand what is happening, you’re going to want to run bitcoin software from the command line. Though it isn’t really necessary to download the thing from the command line, I’m going to describe that here because this tutorial is the first installment of a start to finish command line approach. For a sneak peak of what I mean, see an earlier post where I described how to use bitcoin-core to generate QR codes without having to trust shady ass websites.

Go to your home directory and create a new directory just for bitcoin.  This is not a necessary step, but once again, this is my “right way” tutorial and I will explain reasons for this later on.  Enter the directory, and download the tarball with the “wget” command.  The extract the tarball like so:

    cd ~

    mkdir bitcoin

    cd bitcoin

    wget ''

    tar -xzvf bitcoin-0.11.0-linux64.tar.gz



Sweet.  Now change directory to where the binaries are,

    cd bitcoin-0.11.0/bin/

and launch “bitcoin-qt” (qt means its the GUI version).


It’s going to show you the dialogue box below and ask you if you’d like to use the default directory. Do it. Click “OK”.




You’ll see a friendly startup screen if you’ve done things right!




Step 2: Encrypt your wallet, and wait a few days

Bitcoin-core is called a “full-node” implementation, which means the first time you start it on your machine, it’s going to download every single bitcoin transaction that has ever taken place.  Wait until the blockchain is synced to start making transactions.

In the mean time, you need to set a passphrase for your wallet.  This is super important.  In the upper left corner of bitcoin-qt, go to settings -> Encrypt Wallet, and set a very strong passphrase.


This will make it impossible for anyone to send bitcoins from your wallet without entering your password:


Just make sure you:

    • Make your password extremely long. I don’t know if there is a length limit in the bitcoin-core code or not. Regardless, seriously push your personal boundaries on what you think a safe password is. Make it super duper long, and impossible to guess. Wise men have discussed password strength to a great extent. Pick a strong password. 20+ characters. Go for 30. No 40. Just make it long, and keep it an absolute secret.
    • Never, ever lose or forget this password. If you lose or forgot your password, your coins will be unspendable forever. Neither you, nor anybody on earth, nor God himself will be able to spend your coins. Your coins will be effectively lost.

Picking a strong passphrase makes security so, so easy

Once you encrypt your wallet, you can copy and store wallet.dat everywhere (I explain wallet.dat in great detail in “Step 3”). I literally have copies of my main wallet.dat on 6 or 7 computers, because come hell or highwater, I will always be able to find a copy of my wallet.dat file. I suggest you do the same. Here is why strong encryption and insane redundancy works:

  • If your password is ridiculously long, you can be very lazy and downright cavelier about where you keep your wallet.dat, because even if someone finds the wallet file, they wont be able to do a damn thing with it. They won’t be able to spend your coins without your passphrase.
  • This means that you can make copies of wallet.dat and store them like literally everywhere, on all your machines, three times over. In the cloud. On your mom’s computer. Hell, theoretically speaking, you can post your encrypted wallet.dat on the internet and just about everyone will have a copy, and be unable to spend your coins, because they don’t know your password. Someone remind me to put some coins into an address, and post the encrypted wallet online to prove my point.

    Bottom Line

    If you encrypt your wallet like a boss, you never forget your password, you never tell anyone your password, and you copy the file to everywhere you possibly can imagine, you will never lose your coins. And nobody will be able to steal them from you. Seriously, nobody. It is computationally impossible.

    Step 3: Understand what you just did on your computer

    Let’s break it down this way. Here are some things that just happened when you launched bitcoin-qt for the first time:

    • A hidden directory ~/.bitcoin was created. It contains among other things the single most important thing ever: a file called wallet.dat. This file is critical. ~/.bitcoin/wallet.dat contains all of your private keys. wallet.dat is life. When you see in headlines in the news like “Frustrated gentleman quite upset having lost a usb jump drive containing 100,000 BTC“, it means he doesn’t have a copy of wallet.dat, so neither he, nor anyone on earth, nor God himself can spend his coins anymore.
    • Your computer started downloading the blockchain. The blockchain is a record of every bitcoin transaction ever to have taken place. This will take a few days. As of today, the blockchain is about 42 gigabytes. Make sure you have space for it.

    Do not delete your wallet.dat file. Just don’t. If you want to start a new wallet, instead of deleting wallet.dat, just rename it to something else, like wallet.dat.old, restart bitcoin-qt, and it will create a new wallet for you. Keep your wallets people. Keep them good.


    Notice how I have a file called wallet.dat.default? That’s because I never delete a wallet. When I installed bitcoin on this computer, I moved the wallet.dat that stores my coins into ~/.bitcoin/, but first I renamed the existing file so I can keep it. Because, why not? I’m telling you – don’t delete a file called wallet.dat, because mistakes happen, and its better to have hundreds of files named wallet.dat.* than it is to lose your coins.

In my next post, I will describe some of the features of the bitcoin-qt debug window, bitcoind and its helper bitcoin-cli.  You can do interesting things, like import new keys, or convert keys to qr-codes.

If you have ay questions, please feel free to comment or contact me.
If you liked this post, you can donate bitcoins to me here: 12gKRdrz7yy7erg5apUvSRGemypTUvBRuJ
Learn about the author here:

How import a bitcoin address private key into breadwallet (iOS) with a QR code using bitcoin-core for Ubuntu / Linux

On encoding private keys from Bitcoin-core as QR codes for use in paper wallets, other wallet software, etc …

Note: Breadwallet will not import the private key upon scanning the qr code. It will offer to transfer the funds in that address to your breadwallet keyring.

Breadwallet, an awesome open source iOS bitcoin SPV client, allows you to import a private key for use within breadwallet.  So, if you’re a user of bitcoin-core, and want to be able to spend some of your funds you have there with breadwallet, you’ll need to create a QR code of your private key to scan it with breadwallet.

Install qrencode

This tutorial uses qrencode, an open source string to QR converter. The source can be found here:

Alternatively, you can install qrencode on ubuntu/debian through repositories

sudo apt-get install qrencode

Then, as of bitcoin-core version 0.11.0 you’ll need to run bitcoind rather than the GUI bitcoin-qt. If you’re using an old version of bitcoin-core that does not have the bitcoin-cli tool, you can get the latest version of bitcoin-core and extract it without having to verify the blockchain again or mess with wallet.dat – your ~/.bitcoin directory will remain unchanged.

Get the newest version of Bitcoin-core

wget ''
tar -xzvf bitcoin-0.11.0-linux64.tar.gz
cd bitcoin-0.11.0/bin

You should see the executables for the bitcoin-core suite here.

Run bitcoind and create your QR

Be sure you quit any versions of bitoin-qt or bitcoind that are already running, then start the bitcoin daemon

./bitcoind &

The & operator makes sure bitcoind detaches from your terminal so you can keep going.

Now you are ready to get a QR code for your desired address. Is your address is “addr”, you can generate a QR code of your private key without ever showing your private key on screen in plain text. Just do:

./bitcoin-cli dumpprivkey "addr" | qrencode -o ~/Desktop/Key.png

Or better yet, if you want to create a new address and QR-encode its private key,

addr=$(./bitcoin-cli getnewaddress)
./bitcoin-cli dumpprivkey $addr| qrencode -o
echo "private key dumped for: "$addr

The QR code should appear on your desktop. Below is a screen shot of me doing an example where I create a new address, and get a QR for its private key.  Enjoy!


Note that if your wallet is password protected (which it really should be), you’ll need to first do

./bitcoin-cli walletpassphrase "your_password" 100

where the argument 100 means the wallet will allow all actions (like spending, or dumping keys) for 100 seconds. That should be plenty of time.

Bitcoin Bubble? Not this time. A qualitative analysis of Bitcoin’s price cycle and unusual economy of scale

Edit: If you find my claims speculative and full of muck, here is the math, and a google drive to some plots the source code in mathematica.  

This isn’t a bubble

Bitcoin is experiencing some rapid growth at the moment that is once again turning heads in the media.  Everyone wants to know when to sell their Bitcoin just before the bubble pops – that is clear.  While the exact timing of the bubble pop is difficult to predict, it is easy to use some key metrics to show that what we are experiencing now is in fact long overdue growth as the past months represented the fallout of the last bubble.

Don’t get me wrong.  There will be another Bitcoin bubble someday. And likely another after that.  It is the natural cycle that bitcoin lives on, which is illuminated plainly by taking the logarithm of the price history.

The Bitcoin Price-Epochs 

You can detect Bitcoin bubbles by realizing a few facts:

1) on average, Bitcoin price increases about 1000% / yr

2) short term deviations from this behavior represent recessions and bubbles

3) Bitcoin’s natural mode (for the moment, because it is young and had not reached equilibrium with other currencies) is to exhibit incredibly fast growth – it’s worth repeating: Bitcoin has gained a staggering 1000% year average growth since its inception.  That rate of increase is so massive, that a recession superimposed over it has the appearance of price stability or even small, slow growth.



Shown above is the entire price history of Bitcoin.  There was a “little” $11 bubble followed by a BIG bubble in April…and now we’re gearing up for an even BIGGER BUBBLE! Right?

Wrong.  Here’s the log plot, which effectively filters out  Bitcoins automatic repeated doubling every few months.


This is a very illuminating chart.  It really makes me happy as a clam, because almost everything about it falls in line with the basic tenets linear impulse response. Bitcoin is quite well behaved in fact.  Notice:

• The truly daunting growth rate of bitcoin is to attain about 10 times its price the previous year (I know, I’ve mentioned this now three times.  I just can’t get over it).

• The bubble in 2011 was actually a much greater deviation from this standard behavior than the bubble in April 2013.  This is entirely expected.  Mark my words – the next bubble will appear quite large on the linear axis, but indeed be smaller than the last in the log linear sense

• Because the 2011 Bitcoin Bubble was so much bigger than the one in April 2013, the associated recession was quite long.  The recession following the 2013 bubble was shorter because it was a smaller bubble.

• The recession periods are in proportion to the size of the bubble.  This is to be anticipated, as just about anything in the universe has a response proportionate in amplitude to that of the impulse which disturbed it.

• The price today is actually the natural expected log linear price – Bitcoin has stayed true to this line since it began.  It cannot rise in this manner forever, but there is no reason to think Bitcoin has left its rapid growth state yet – the currency is still brand new and relatively few people in the world have interacted with it.  The upside will continue until of course it cannot sustain log linear growth.  But it is, to put it lightly, kind for Bitcoin investors that the day has not yet come.

Economy of Scale

Bitcoin will probably continue to follow this pattern for quite some time because of the extremely low friction within the Bitcoin system.  The principle is known as economy of scale.  The simple fact is, there is very little stopping Bitcoin from growing.  Unlike a company, which feels considerable growing pains as its stock price shoots up, and eventually levels off when growth is impossible due to diminishing returns, Bitcoin doesn’t experience any backlash for attracting more users, more excitement, more of everything.  Bitcoin doesn’t feel growing pains. Nothing works like that – not usually anyway, which is why Bitcoin has fooled the silver haired finance veterans, who, despite their vast experience in markets, have gone their entire lives never having met a beast that has nothing to stop it from gaining velocity.

Conclusion:  Bitcoin has a truly unique economy of scale, limited only by the flow of information and technology around the world, and the robustness of the Bitcoin protocol itself.

If I lost you on the last part, watch this TED talk by a particularly captivating scientist who researches economies of scale in both biological and economic systems:

“Geoffrey West: The surprising math of cities and corporations.”

You will be reminded of the Bitcoin price when he characterizes the economies of scale in organisms and likens this to the development and life cycle of an entire city – its people, its culture, its structural map, and its entire social being.

It is not very difficult to swallow, for me, that this really is the way the Bitcoin economy works.  A city is nothing if not a set of connections – the social and economic influences, and the relationships between people in close proximity.  In 2013, where “close proximity” has been redefined to mean “within arms reach of a keyboard” it is no wonder we see the topological structures inherent in the growth of economic centers emerging in the cloud.

You’ll also (hopefully) be entertained by his breakdown of economies of scale, and almost certainly will be enlightened.

Thesis: hold your coins, and watch the log plot.


BTC: 17NA1jYg5u6ejboArdM7HW4MwSa6cWfnEd


XPM: AejVQ34ntJAwUhebe7GMtC8aQ2oPg4bHDf

PPC: PQzT1tFMB5ECbQPhp41R5cTc7jpbgGUDfb

When should I sell my Bitcoin Mining hardware? Bitcoin Mining Hardware Resale Value vs Projected Return

If you have any questions about this process, you can contact me with the form below!  Happy mining. 

In general, the profit margin for miners becomes slimmer through time as the competition to break into bitcoin mining increases and the barriers to entry are higher than ever.  Customers have in general had poor experiences with ASIC manufacturers who have delivered the mining products late, making the hardware purchase a net loss for the investor.  The situation is not so grim for the miner, however, because the bitcoin price and price velocity are as high as they have ever been, and are not showing signs of flinching.

Despite the apparent victory for the miner when the price rises, it is a common misconception that a positive return of investment can be saved for a poor mining hardware purchase if the bitcoin price rises enough.  This is not actually true – well, not exactly.  The truth is, if the only way to make ROI is if the price of bitcoin rises, then you should have simply bought bitcoins, rather than the miner.

The question of when a “good” time to sell your miner is complicated.  What you have is a machine that prints money.  But it prints money at an ever decreasing rate.  When do you sell it?  You need to first make a few back of the envelope calculations.

Calculate your miner’s daily performance today

First you find the number of bitcoins your miner will earn you per day at the present time.  There are many online calculators for this.  You can do it by hand in a number of ways; my favorite way is the following:

• Get an estimate online of the total network hashrate (at the time of writing it is about 4200 TH/s).

• Figure out what fraction of that total hashrate is your contribution; this is

Fraction = (your hasrate)/(network hashrate)

• That’s the fraction of all bitcoins per day which will belong to you (it’s a generous estimate because of mining pool fees which we disregard).

• The total number of bitcoins generated per day is about:

(25 BTC) / (1 block) * (1 block) / (10 minutes) * (60 minutes) / (1 hour) * (24 hours) / (1 day) = 3600 BTC per day

• Your expected Bitcoins/day is then just

My BTC/day = Fraction * 3600 BTC/day

For example: if you own a 576 GH/s KNCMiner Jupiter…

• Your share of the network hashrate is 576/(4200*1000) = .00013714

• This is the fraction of daily bitcoins produced by everyone, which is always 3600.  You generate about 3600*.00013714 = .4937 BTC/day

• This estimate is roughly true when taken for the period of 2 weeks over which the difficulty is adjusted, and is a central tendency.  You actual daily rake will differ day to day due to the nature of Bitcoin.  However this way of estimating is surprisingly accurate, if you get a good Hashrate estimate.

Calculate the expected return of your miner from now on

This can be in principle extremely difficult.  I will present an extremely over simplified model that can be used to roughly calculate the expected return of your miner given market trends by invoking the approximation of a geometric series for the difficulty.

• Divide the last difficulty by the current difficulty.

• This is the value r or the common ratio.  r must be between 0 and 1, or you have have a mistake.

• If you can, find r for the previous diff change or previous 2 or 3 and average them.

Once you have the r you want to use, the number of bitcoins your miner will EVER produce is approximately

Bitcoins from now to eternity = (number of bitcoins I’ll produce this 2 weeks period)/(1 – r)

For today the difficulty is 510 million.  Prior it was 390 million.  That gives an r = .76 which we will proceed with, though you can go back a few steps and average the result if you like by checking a chart like this. 

Anyway, once we have r, we find

Bitcoins ever = (number of bitcoins I’ll produce this 2 weeks period)/(1 – r)

= (14  days)* (.4397 BTC / day)/ (1 – .76)

= 25.6 BTC

Decide when to sell 

Snce I love to disregard complications, let’s assume you can liquidate your Miner instantly, without any problems/costs/risks for a “market price.”  You should sell your miner precisely when the market price of the miner will allow you to buy more bitcoins than the total number left your miner will ever create.

Let’s do this analysis again with KNCMiner (for no real reason other than consistency at this point) as an example.  Here is some data from on sales of “knc miner” equipment over the past 7 days:

Item Title Sold Format Start Price

End Price

Bids End Date
KnCMiner Jupiter **In Hand** 500+ GH/s, Asic Bitcoin Miner Yes $9,999.99 $9,999.99 1 2013-10-28
In Hand KNCminer Jupiter ASIC Bitcoin Miner – 500 GH/s – FREE 2 Day Shipping Yes Bid $5,000.00 $8,100.00 24 2013-10-28
535 GH/s+ KnCMiner Jupiter bitcoin miner – In Hand – Ships Immediately Yes Bid $300.00 $8,100.00 39 2013-11-03
KNCminer Jupiter 550GHash Bitcoin with 1200W Power Supply Yes Bid $5,000.00 $8,050.00 9 2013-10-28
KNC 550+ GH/S Bitcoin miner. KnCminer. Jupiter in Hand Hashing with power supply Yes Bid $5,000.00 $8,000.00 15 2013-10-31
KNCminer Jupiter 550GHash Bitcoin with 1200W Power Supply IN HAND Yes Bid $7,850.00 $7,950.00 2 2013-10-29
KnCMiner Jupiter 550GH/s Asic Bitcoin Miner with SeaSonic 1000W PSU **in-hand** Yes Bid $5,000.00 $7,890.00 1 2013-10-28
KnCMiner Jupiter ASIC Bitcoin Miner 500+GH/s *In-Hand* (Will Sell Now for $7200) Yes Bid $4,995.00 $7,200.00 4 2013-11-03
KnCMiner SATURN ASIC Bitcoin Miner 285+ GH/s IN HAND! FREE Overnight w/ BuyNow Yes Bid $3,800.00 $4,970.00 1 2013-10-29
KnCMiner Jupiter **In Hand** 550+ GH/s, Asic Bitcoin Miner Yes $4,900.00 $4,900.00 1 2013-11-01
KnCMiner Saturn **In Hand** 275+ Gh/s, ASIC Bitcoin Miner Yes Bid $1.00 $3,995.00 14 2013-11-03

Because there is some variance here and not too many data points, let’s calculate some quantities for only one of these examples – the one on 11/3 which went for $8100.

On 11/3 let’s assume the expected return for the Miner was 25.6 BTC just as it is today. The price of bitcoin – that is, the bitcoin to USD conversion – is a far (perhaps infinitely) more volatile quantity than the expected return of Mining hardware when returns are stated in BTC.  So a quick search of data on for example shows the price that day was, on average, 218.24 USD.  So if this seller collected precisely 8100 USD for this sale (he didn’t because of ebay and paypal fees) he could have turned around about bought

BTC earned by selling = (8100 USD)/(218.24 USD/BTC) = 37 BTC

That’s a pretty good sell, IF the seller turned around with his money and bought BTC immediately.  This is true regardless of the future price of bitcoin because this is a bitcoin to bitcoin comparison (in general, by staying within bitcoin when calculating, it is easier to extract information from the market data).

Limitations of this model

This model is completely invalid if the difficulty is not increasing in a pretty particular manner which it seems to be for now.  Specifically, this model will completely fail if the difficulty is increasing but in smaller increments each time.  This model will fail even more massivly if the difficulty is stable or decreasing, which is not the case presently, but has happened before.  A stable difficulty will also almost certainly occur one day again – but I will not digress as to why this is the case in this post.

Furthermore this model assumes bluntly that the network difficulty takes geometric steps upward, which would be the result of a purely exponential hashrate plot. Simply put, the network difficulty is not geometric in general, but only approximates geometric behavior in a sufficiently short period of time. In fact, it is a mathematical certainty that in an appropriate time scale, any relationship at all will trace an exponential curve quite closely and it is this universal principle that I have exploited in this model.

But the difficulty really cannot really be geometric – not only because the ratio of two consecutive difficulties is pseudorandom, but rather because the network hashrate displays kinks, corresponding to generations of ASIC technology..  However, it can be seem empirically that the difficulty function is  approximately geometric within 3 to 5 difficulty increases, over which the ratio r does not deviate strongly from a central value.  Luckily, 4  increases of difficulty amounts to 8 weeks.  Since the advent of ASIC architecture, 8 weeks has been, perhaps consequently, the approximate lifetime of a mining device (some devices has an even shorter lifetime).

This is congruent with the intuition which says if your mining income rate falls off faster than a geometric series, you don’t have much time left before your mining income will be quite literally zero; though an old pentium 4 CPU can “mine” a bit, there comes a point when you will simply die before you mine an amount of bitcoin that exceeds standard transactions fees.  Whether this is the case today is left as an exercise for the reader.

Because of the probabilistic nature of the the bitcoin network’s protocol, there is a fundamental limit on the accuracy one can hope to have predicting short term trends.  bitcoin is also a financial instrument, and being such lends itself poorly to any model with long term accuracy.  Thus we must be sure of the time scale over which a particular model has any validity.  This empirical rule of geometric increases in difficulty is merely a model, so use it with caution.  If you plan on doing such a calculation, it would be wise to trace the difficulty back a few steps and see if something else is going on in the bitcoin economy.  If that is the case, it is time to make a new model.

This week I will make a detailed mathematical analysis of the geometric approximation to network changes.  This will come with a post to generalize the fit to longer times through the use of more complicated models resembling statistical mechanics of physics.  If I forget to do this remind me, seriously.

– Altoidnerd

Donate Bitcoins