Math in Solidity

By Mikhail Vladimirov

Ethereum is a programmable blockchain, whose functionality could be extended by publishing pieces of executable code, known as smart contracts, into the blockchain itself. This distinguishes Ethereum from the first generation of blockchains, where new functionality requires client software to be modified, nodes to be upgraded, and the whole blockchain to be forked.

A smart contract is a piece of executable code published on-chain, that has a unique blockchain address assigned to it. Smart contract controls all the assets belonging to its address and may act on behalf of this address when interacting with other smart contracts. Each smart contract has persistent storage that is used to preserve the smart contract state between invocations.

Solidity is the primary programming language for smart contract development on Ethereum, as well as on several other blockchain platforms that use Ethereum Virtual Machine (EVM).

Programming was always about math, blockchain was always about finance, and finance was about math since ancient times (or maybe math was about finance). Being the primary programming language for Ethereum blockchain, Solidity has to do math well.

In this series, we discuss various aspects of how Solidity does the math, and how developers do math in Solidity. The first topic to discuss is numbers.

Numeric Types in Solidity

In comparison to mainstream programming languages, Solidity has quite many numeric types: namely 5,248. Yes, according to the documentation, there are 32 signed integer, 32 unsigned integer, 2592 signed fixed-point, and 2592 unsigned fixed-point types. JavaScript has only two numeric types. Python 2 used to have four, but in Python 3 type “long” was dropped, so now there are only three. Java has seven and C++ has something about fourteen.

With so many numeric types, Solidity should have proper type for everybody, right? Not so fast. Lets look at these numeric types a bit closer.

We will start with the following question:

Why Do We Need Multiple Numeric Types?

Spoiler: we don’t.

There are no numeric types in pure math. A number may be integer or non-integer, rational or irrational, positive or negative, real or imaginary etc, but these are just properties, the number may or may not have, and single number may have several such properties at once.

Many high-level programming languages have single numeric type. JavaScript had only “number” until “BigInt” was introduced in 2019.

Unless doing hardcore low-level stuff, developers don’t really need multiple numeric types, they just need pure numbers with arbitrary range and precision. However, such numbers are not natively supported by hardware, and are somewhat expensive to emulate in software.

That’s why low-level programming languages and languages aimed at high performance usually have multiple numeric types, such as signed/unsigned, 8/16/32/64/128 bits wide, integer/floating-point etc. These types are natively supported by hardware and are widely used in file formats, network protocols etc, thus low-level code benefits from them.

However, for performance reasons, these types usually inherit all the weird semantics of underlying CPU instructions, such as silent over- and underflow, asymmetric range, binary fractions, byte ordering issues etc. This makes them painful in high-level business logic code. Straightforward usage often appears insecure, and secure usage often becomes cumbersome and unreadable.

So, the next question is:

Why Does Solidity Has So Many Numeric Types?

Spoiler: it doesn’t.

EVM natively supports two data types: 256-bit word and 8-bit byte. Stack elements, storage keys and values, instruction and memory pointers, timestamps, balances, transaction and block hashes, addresses etc are 256-bit words. Memory, byte code, call data, and return data consist of bytes. Most of the the EVM opcodes deal with words, including all math operations. Some of the math operations treat words as signed integers, some as unsigned integers, while other operations just work the same way regardless of whether arguments are signed on unsigned.

So EVM natively supports two numeric types: signed 256-bit integer and unsigned 256-bit integer. These types are known in Solidity as int and uint respectively.

Apart from these two types (and their aliases int256 and uint256) Solidity has 62 integer types int<N>, and uint<N>, where <N> could be any multiple of 8 from 8 to 248, i.e. 8, 16, …, 248. On EVM levels, all these types are backed by the same 256-bit words, but result of every operation is truncated to N bits. They could be useful for specific cases, when particular bit width is needed, but for general calculations these types are just less powerful and less efficient (truncating after every operation is not free) versions of int and uint.

Finally, Solidity has 5184 fixed-point types fixedNxM and ufixedNxM where N is multiple of 8 from 8 to 256 and N is an integer number from 0 to 80 inclusive. These types are supposed to implement decimal fixed-point arithmetic of various range and precision, but as of now (Solidity 0.6.2) the documentation says that:

Fixed point numbers are not fully supported by Solidity yet. They can be declared, but cannot be assigned to or from.

So fixed-point numbers as well as fractions numbers in general are not currently supported.

Then, the next question is:

What If We Need Fraction Numbers or Integers Bigger Than 256 Bit?

Spoiler: you have to emulate them.

One would say, that 256 bit ought to be enough for anybody. However, once most of the numbers in Ethereum are 256 bit wide, even simple sum of two numbers may be as wide as 257 bit, and product of two numbers may be up to 512 bit wide.

Common way to emulate fixed or variable width integers numbers, that are wider, than types natively supported by programming language, is to represent them as fixed or variable length sequences of shorter, natively supported integer numbers. So bit image of wide integer is the concatenation of bit images of shorter integers.

In Solidity, wide integers may be represented as fixed or dynamic arrays whose elements are either bytes or uint vales.

For fractions situation is a bit more complicated, as as there are different flavors of them, each having its own advantages and drawback.

The most basic are simple fractions: just one integer, called “numerator”, divided by another integer, called “denominator”. In Solidity simple fraction could be represented as a pair of two integers, or as a single integer, whose bit image is the concatenation of bit images of numerator and denominator. In the latter case, numerator and denominator has to be of the same width.

Another popular format for fractions is fixed-point numbers. Fixed-point number is basically a simple fraction whose denominator is a predefined constant, usually power of 2 or 10. The former case is known as “binary” fixed-point, while the latter is known as “decimal” fixed-point. As long as denominator is predefined, there is no need to specify is explicitly, so only the numerator need to be specified. In Solidity fixed-point numbers are usually represented as a single integer numerator, while commonly used denominators are 10¹⁸, 10²⁷, 2⁶⁴, and 2¹²⁸.

Yet another well-known format for fraction numbers is floating-point. Basically, floating point number could be described as following: m×B^e, where m (mantissa) and e (exponent) are integers, while B (base) is a predefined integer constant, usually 2 or 10. The former case is known as “binary” floating-point, and the latter case is known as “decimal” floating-point.

IEEE-754 standardizes several common floating-point formats, including five binary formats known as “half”, “single”, “double”, “quadruple”, and “octuple” precision. Each of these formats packs both, mantissa and exponent, into single sequence of 16, 32, 64, 128, or 256 bits respectively. In Solidity, these standard formats could be represented by binary types bytes2bytes4bytes8bytes16, and bytes32. Alternatively, mantissa and exponent could be represented separately as a pair of integers.

And the file question for this section:

Do We Have to Implement All This by Ourselves?

Spoiler: not necessary.

The good news is that there are Solidity libraries for various number formats, such as: fixidity (decimal fixed-point with arbitrary number of decimals), DSMath (decimal fixed-point with 18 or 27 decimals), BANKEX Library (IEEE-754 octuple precision floating-point), ABDK Libraries (binary fixed-point and quadruple precision floating-point) etc.

The bad news is that different libraries use different formats, so it is really hard to combine them. The roots of this problem will be discussed in the next section.

Numeric Literals in Solidity

In the previous section we discussed how numbers are represented at run time. Here we will look at how they are represented at the development time, i.e. in the code itself.

Compared to mainstream languages, Solidity has quite a rich syntax for numeric literals. First of all, good old decimal integers are supported, such as 42. As in other C-like languages, there are hexadecimal integer literals, like 0xDeedBeef. So far so good.

In Solidity, literals may have unit suffix, such as 6 ether, or 3 days. A unit, is basically a factor, the literal is multiplied by. Here ether is 10¹⁸ and days is 86,400 (24 hours × 60 minutes × 60 seconds).

Apart from this, Solidity supports scientific notation for integer literals, such as 2.99792458e8. This is quite unusual, as mainstream languages support scientific notation for fractional literals only.

But probably the most unique feature of the whole Solidity language, is its support for rational literal expressions. Virtually every mature compiler is able to evaluate constant expressions at compile time, so x = 2 + 2 does not generate add opcode, but is rather equivalent to x = 4. Solidity is able to do this as well, but actually, it goes far beyond that.

In mainstream languages, compile-time evaluation of constant expression is just an optimization, so constant expression is evaluated at compile time exactly the same way as it would be evaluated at run time. This makes it possible to replace any part of such expression with named constant or variable holding the same value, and get exactly the same result. However, for Solidity this is not the case.

At run time, division in Solidity rounds result towards zero, and other arithmetic operations wraps on overflow, while at compile time, expressions are evaluated using simple fractions with arbitrary large numerator and denominator. So, at run time, expression ((7 / 11 + 3 / 13) * 22 + 1) * 39 would be evaluated to 39, while at compile time the very same expression is evaluated to 705. The difference is because at run time, 7 / 11 and 3 / 13 are rounded to zero, but at compile time, the whole expression is evaluated in simple fractions without any rounding at all.

Even more interesting, the following expression is is valid in Solidity: 7523 /48124631 * 6397, while this is not valid: 7523 / 48125631 * 6397. The difference is that the former evaluates to integer number, while the latter evaluates to non-integer. Remember, that Solidity do not support fractions at run time, so all literals have to be integer.

While fractional numbers and big integers may be represented in Solidity at run time, as described in the previous sections, there is no convenient way to represent them in the code. This makes any code, that performs operations with such numbers, rather cryptic.

As long as Solidity does not have a standard fixed-point nor floating-point format, every library uses its own, which makes libraries incompatible with each other.

Overflow

Every time I see +*, or ** doing audit of another Solidity smart contract, I start writing the following comment: “overflow is possible here”. I need a few seconds to write these four words, and during these seconds I observe nearby lines trying to find a reason, why overflow is not possible, or why overflow should be allowed in this particular case. If the reason is found, I delete the comment, but most often the comment remains in the final audit report.

Things aren’t meant to be this way. Arithmetic operators supposed to allow writing compact and easy to read formulas such as a**2 + 2*a*b + b**2. However, this expression would almost definitely raise a bunch of security concerns, and the real code is more likely to look like this:

add (add (pow (a, 2), mul (mul (2, a), b)), pow (b, 2))

Here addmul, and pow are functions implementing “safe” versions of +*, and ** respectively.

Concise and convenient syntax is discouraged, plain arithmetic operators are marginally used (and not more than one at a time), cumbersome and unreadable functional syntax is everywhere. In this article we analyse the problem, that made things so weird, whose infamous name is: overflow.

We Took a Wrong Turn Somewhere

One would say, that overflow was always there, and all programming languages suffer from it. But is this really true? Did you ever see something like SafeMath library implemented for C++, Python, or JavaScript? Do you really think, that every + or * is a security breach, until the opposite is proven? Most probably, your answer for both questions is “no”. So,

Why Overflow in Solidity Is So Much Painful?

Spoiler: nowhere to run, nowhere to hide.

Numbers do not overflow in pure math. One may add two arbitrary large numbers and get precise result. Numbers do not overflow in high-level programming languages such as JavaScript and Python. In some cases the result could fall into infinity, but at least adding two positive numbers may never produce negative result. In C++ and Java integer numbers do overflow, but floating-point numbers don’t.

In those languages, where integer types do overflow, plain integers are used primarily for indexes, counters, and buffer sizes, i.e. for values limited by the size of data being processed. For values, that potentially may exceed range of plain integers, there are floating-point, big integer, and big decimal data types, either built-in or implemented via libraries.

Basically, when the result of an arithmetic operation does not fit into the type of the arguments, there are a few options what compiler may do: i) use wider result type; ii) return truncated result and use side channel to notify the program about overflow; iii) throw an exception; and iv) just silently return truncated result.

The first option is implemented in Python 2 when handling int type overflows. The second option is what carry/overflow flags in CPUs are for. The third option is implemented for Solidity by SafeMath library. The fourth option is what Solidity implements by itself.

The fourth option is probably the worst one, as it makes arithmetic operations error-prone, and at the same time makes overflow detection quite expensive, especially for multiplication case. One needs to perform additional division after every multiplication to be on the safe side.

So, Solidity neither has safe types, one could run to, nor it has safe operations, one could hide behind. Having nowhere to run and nowhere to hide, developers have to meet overflows face to face and fight them all throughout the code.

Then, the next question is:

Why Doesn’t Solidity Have Safe Types Nor Operations?

Spoiler: because EVM don’t have them.

Smart contracts have to be secure. Bugs and vulnerabilities in them cost millions of dollars, as we’ve already learned the hard way. Being the primary language for smart contracts development, Solidity takes security very seriously. If has many features supposed to prevent developers from shooting themselves in the feet. We mean features like payable keyword, type cast limitations etc. Such features are added with every major release, often breaking backward compatibility, but the community tolerates this for the sake of better security.

However, basic arithmetic operations are so unsafe that almost nobody use them directly nowadays, and the situation doesn’t improve. The only operation that became a bit safer is division: division by zero used to return zero, but now it throws an exception, but even division didn’t become fully safe, as it still may overflow. Yes, in Solidity int type division overflows when -2¹²⁷ is being divided by -1, as correct answer (2¹²⁷) does not fit into int. All other operations, namely +-*, and ** are still prone to over- or underflow and thus are intrinsically unsafe.

Arithmetic operations in Solidity replicate the behavior of corresponding EVM opcodes, and making these operations safe at compiler level would increase gas consumption by several times. Plain ADD opcode costs 3 gas. The cheapest opcode sequence for implementing safe add the author of the article managed to find is:

DUP2(3) DUP2(3) NOT(3) LT(3) <overflow>(3) JUMPI(10) ADD(3)

Here <overflow> is the address to jump on overflow. Numbers in brackets are gas costs of the operations, and these numbers give us 28 gas in total. Almost 10 times more, than plain ADD. Too much, right? It depends on what you compare with. Say, calling add function from SafeMath library would cost about 88 gas.

So, safe arithmetic at library or compiler level costs much, but

Why Doesn’t EVM Have Safe Arithmetic Opcodes?

Spoiler: for no good reason.

One would say that arithmetic semantic in EVM replicates that of CPU for performance reasons. Yes, some modern CPUs have opcodes for 256-bit arithmetic, however mainstream EVM implementations don’t seem to use these opcodes. Geth uses big.Int type from the standard library of Go programming language. This type implements arbitrary wide big integers backed by arrays of native words. Parity uses its own library implementing fixed-width big integers on top of native 64-bit words.

For both implementations, additional cost of arithmetic overflow detection would virtually be zero. Thus, once EVM would have versions of arithmetic opcodes, that revert on overflow, their gas cost could be made the same as for existing unsafe versions, or just marginally higher.

Even more useful would be opcodes that do not overflow at all, but return the whole result instead. Such opcodes would permit efficient implementation of arbitrary wide big integers at compiler or library level.

We don’t know why EVM doesn’t have the opcodes described above. Maybe just because other mainstream virtual machines don’t have them?

So far we were telling about real overflow: a situation when calculation result is too big to fit into the result data type. Now it is time to discover the other side of the problem:

Phantom Overflows

How one would calculate 3% of x in Solidity? In mainstream languages one just writes 0.03*x, but Solidity doesn’t support fractions. What about x*3/100? Well, this will work in most cases, but what if x is so large, that x*3 will overflow? From the previous section we know what to do, right? Just use mul from SafeMath and be in the safe side: mul (x, 3) / 100… Not so fast.

The latter version is somewhat more secure, as it reverts where the former version returns incorrect result. This is good, but… Why on earth calculating 3% of something may ever overflow? 3% of something is guaranteed to be less that original value: in both, nominal and absolute terms. So, as long as x fits into 256-bit word, then 3% of x should also fit, shouldn’t it?

Well, I call this “phantom overflow”: a situation when final calculation result would fit into the result data type, but some intermediate operation overflows.

Phantom overflows are much harder to detect and address than real overflows. One solution is to use wider integer type or even floating-point type for intermediate values. Another is to refactor the expression in order to make phantom overflow impossible. Let’s try to do the latter with our expression.

Arithmetic laws tell us that the following formulas should produce the same result:

(x * 3) / 100
(3 * x) / 100
(x / 100) * 3
(3 / 100) * x

However, integer division in Solidity is not the same as division in pure math, as in Solidity it rounds the result toward zero. The first two variants are basically equivalent, and both suffer from phantom overflow. The third variant does not have phantom overflow problem, but is somewhat less precise, especially for small x. The fourth variant is more interesting, as it surprisingly leads to a compilation error:

browser/Junk.sol:5:18: TypeError: Operator * not compatible with types rational_const 3 / 10 and uint256browser/Junk.sol:5:18: TypeError: Operator * not compatible with types rational_const 3 / 10 and uint256

We already described this behavior in our previous article. To make the fourth expression compile we need to change it like this:

(uint (3) / 100) * x

However this does not help much, as the result of corrected expression is always zero, because 3 / 100 rounded towards zero is zero.

Via the third variant we managed to to solve phantom overflow problem at the cost of precision. Actually, precision loss is significant only for small x, while for large x it is negligible. Remember, that for the original expression, phantom overflow problem arises for large x only, so it seems that we may combine both variants like this:

x > SOME_LARGE_NUMBER ? x / 100 * 3 : x * 3 / 100

Here SOME_LARGE_NUMBER could be calculated as (2²⁵⁶-1)/3 and rounding this value down. Now for small x we use original formula, while for large x we use modified formula that do no permit phantom overflow. Looks like we solved phantom overflow problem without significant loss of precision now. Great work, right?

In this particular case, probably yes. But what if we need to calculate not 3%, but rather 3.1415926535%? The formula would be:

x > SOME_LARGE_NUMBER ?
x / 1000000000000 * 31415926535 :
x * 31415926535 / 1000000000000

Our SOME_LARGE_NUMBER will become (2²⁵⁶-1)/31415926535. Not so large then. And what about 3.141592653589793238462643383279%? Being good for simple cases, this approach does not seem to scale well.

Via Coinmonks

Bitcoin Casinos — 5 Reasons Why You Should Only Gamble Here

Bitcoin casinos have been around for a few years. Ever since online casinos started letting you gamble with cryptocurrency, players from around the world have flocked to their sites. We live in a society, where the government tries to control every aspect of our lives. So, if we keep allowing ourselves to be tied down by rules and regulations, then all the fun and joy in our lives will cease to exist.

Many adults around the world, enjoy a good gamble once in a while. Tourists from all over, flock to Las Vegas all year long, for a few days of great entertainment. Fine dining, live shows, shopping and of course gambling are all on the menu. Some play and win, some play and lose, but in the end, everyone leaves with a smile on their faces.

Online gambling is exactly the same, except that you can enjoy yourself from any location, around the world, on your computer or mobile device. But, when governments start to intervene with your own personal expenses, that’s where we need to draw the line. So, here are the 5 main reasons you should only gamble at Bitcoin casinos:

1. No Invasion of Privacy

One of the biggest issues with regulation in online gambling is privacy. As an online gambler, you need to pass credit checks, supply documents and copies of your personal ID’s. Furthermore, you need to send statements of wealth to prove that you can afford to gamble. Gambling can be addictive, and some people can lose more than they can afford to. However, it’s a severe invasion of privacy, to ask how much money one has in their bank account. Why would anyone want to tell a casino how money they have?

Additionally, it’s your money! No one should be allowed to tell you where and how to spend it. It’s your responsibility and your decision only. Moreover, no one should be allowed to tell you how much you can spend, daily, monthly or yearly on gambling. 

That’s why cryptocurrency was invented. People got fed up with banks and governments controlling their money. When you gamble with crypto, you can do so anonymously, and you’ll never have to identify yourself. On top of this, you don’t have to provide any docs or go through a verification process. You can just sign up with an email and password, transfer money from your crypto wallet and start gambling.

2. No Country Restrictions

Cryptocurrency is not like Fiat currency. Crypto transactions are borderless, and they do not need to be approved by banks. So, if you want to send money to someone abroad, you can do so instantly, without any hassles. You may need to pay a small fee on each transaction but it’s very minor compared to fees banks charge you. 

When it comes to crypto gambling, transactions are not restricted by any regulations. Many countries around the world do not allow their citizens to gamble online. This is due to state owned gambling and lottery companies keeping their monopolies in place. Another reason is that land-based casinos, with political ties to the government do not want to lose potential visitors and revenues to off-shore companies. 

Since cryptocurrency transactions are fully anonymous, government restrictions and regulations do not apply. For example, if you live in the USA or Australia, where online gambling is prohibited or limited, then BTC casinos that accept cryptocurrency are the place for you. You can gamble freely, without anyone knowing.

3. 100% Guaranteed Transactions 

Every crypto transaction is guaranteed. When you want to send or receive cryptocurrency, all you have to do is enter a valid wallet address and the payment is instantly sent or received. Some platforms charge a small fee per transaction, usually around 2.5%. But it’s nothing compared to credit card and e-wallet transaction fees that can reach up to 20%.

What’s even better is that cryptocurrency casinos offer deposits and withdrawals in many different cryptocurrencies. Although BTC is the most popular currency, crypto gamblers also enjoy playing in XRP, LTC and ETH. So, you can deposit and cash out money in your preferred currency, without exchange rate fees.

4. No Limitations

One thing that gamblers do not like is having a babysitter, telling them Which, What, When and How:

  • Which limits you’re allowed to bet on.
  • What games you’re allowed to play.
  • When, can you play those games.
  • How long, can you play those games for.

In regulated casinos, players need to set limitations before they can start gambling. You need to state how many hours you want to be able to gamble per day as well as setting a daily, weekly or monthly deposit limit. Furthermore, you may also be limited to certain betting stakes. So, imagine trying to play blackjack or roulette with a maximum bet of $10. Where’s the fun in that? On top of that, you may also not have access to all the different casino games available at nonregulated casinos.

Bitcoin casinos have no limitations when it comes to game selections, deposits, withdrawals and playing time. You are your own boss. You can play what you want, when you want, for as high a limit as you like and for as long as you want. On top of that your winnings are not capped, and you have no withdrawal limits. So, you can play freely, without someone watching over your shoulder all the time to see what you’re doing.

Casino games at BTC casinos also tend to have higher payouts, averaging around 96.70% RTP’s, as well as bigger jackpot prizes. So, you tend to get more return for your money, which allows you to play longer and have more fun.

5. Cryptocurrency Value

Which brings us to the main reason to gamble at Bitcoin casinos. Cryptocurrency value is very speculative and volatile. One day 1 Bitcoin could be worth $10,000 and a few hours later it could be worth $12,000 or $9,000. So, when you gamble with cryptocurrency, you could choose to withdraw your winnings when the coin value goes up. Therefore, you’re not only cashing out casino winnings, but you also have the option of cashing in your cryptocurrency for even more money than you started off with. 

Additionally, you can exchange one cryptocurrency for another cryptocurrency that potentially has more value. Since, many different currencies are accepted today at crypto casinos, you can cash in on these rises in coin value. All you have to do is just add additional cryptocurrencies to your casino wallet and play casino games in each currency. 

Big Wall Street reps will continue to talk bad of it, but the reality is that cryptocurrency is good. Many big Fintech companies have already integrated cryptocurrency into their payment systems. For us gamblers, cryptocurrency is a blessing. At KingBit Casino, you can gamble freely without worrying about breaking the law and without limits. Moreover, players from all around the world, including US gamblers are welcome, and you can gamble with many different cryptocurrencies. Crypto is the future and is not going anywhere. So, transfer some coins and have a good time gambling online.

Eight centuries of global real interest rates, 1311–2018

BANK OF ENGLAND, Staff Working Paper No. 845 By Paul Schmelzing, January 2020

Download PDF

In a Bank of England staff paper, economic historian Paul Schmelzing has gathered an incredible 800-years of data on interest rates and inflation going back to the early 1300s. The research combines interest rates on hundreds of loans made to sovereigns by court bankers and wealthy merchants. Schmelzing’s paper has many curious details about medieval financial markets. Not included in his interest rate data, for instance, are loans denominated in various odd units. In times past, a lender might stipulate repayment in chickens, jewellery, land, fruit, wheat, rye, leases for offices, or some sort of entitlement. To keep calculation easier, Schmelzing only collects information on loan that are payable in cash.

Schmelzing’s data shows that real interest rates have been gradually falling for centuries (the real interest rate is the return that one gets on a bond or a loan after adjusting for inflation). The monetary standard seams to have no influence on the trend.

Seasonality in Bitcoin: Examining Almost A Decade of Price Data

With almost ten years of price data for bitcoin now available, this article will investigate if there are any seasonal effects for BTC-USD.

In traditional markets, seasonal trends are often found in financial time series data such as GDP (e.g., recessions and expansions), the price of a commodity because of changes in the weather (e.g., summer versus winter) or calendar events for a company’s stock price (e.g., earnings season).

BTC-USD price history (log transformed). Source: CoinMetrics.

Bitcoin’s price history — illustrated above — is limited. But since there is now almost ten years of data, we can begin to uncover any seasonal trends.

There are several hypotheses about seasonal trends in BTC-USD — such as the influence of tax season, increased trading/blockchain activity during winter months (shadowing internet usage), and the effect of public holidays such as the Chinese New Year and Christmas (i.e., the “Santa Claus rally”).

The calendar heatmap below display the rolling 30-day return on investment for bitcoin (BTC) since mid-August 2010. Positive returns were transformed to 1 and we code negative returns as 0 to provide more clarity:

  • green square on the calendar means that on that day, the 30-day return on investment was positive.
  • red square on the calendar means that on that day, the 30-day return on investment was negative.
Source: CoinMetrics, bitcoin 30-day ROI data for 18/08/2010 to 31/01/2020.

For the 113 months we have full price data for, there have been 28 months where the 30-day return for bitcoin was positive every single day. For example, the 30-day return for BTC was positive every single day in April, May and June during 2019. There’s also a strong momentum effect. Ten of these months that were fully green were followed by another straight month of positive returns.

There’s less tendency for the 30-day return to remain in the red for an entire calendar month, with ten examples so far. Again, there’s a similar momentum effect, with three of these months followed by another month of straight red. The last time this happened was September-October 2014.

Another glance at the calendar heatmap also shows that in July and November, if bitcoin’s 30-day return is positive or negative during the first day of these months, it usually stays that way. There are six instances in both July and November where the 30-day return was negative (or positive) for the entire month.

Looking at public holidays such as Chinese New Year and Christmas, we see that the 30-day return around the start of Chinese New Year has been negative in recent years (2016–2019) while the 30-day return was positive in 2020 and between 2011–2015. There’s not much evidence for a “Santa Claus rally” with bitcoin, since just five of the past ten years display a positive ROI in the run up the Christmas.

The 30-day returns are usually negative around tax deadlines in many countries such as the US and the UK (late March-early April). During this period, investors may engage in as tax loss harvesting — selling digital currency to incur losses and reduce their tax burden. Another explanation could be the sale of digital assets by investors to pay their capital gains tax or other tax liabilities. Out of nine years, the 30-day return has been negative during this period seven times.

Volatility

Are there any seasonal trends in the price volatility of bitcoin?

Bitcoin’s price history is cut into two parts to account for the falling volatility over time. The calendar heatmap below shows the raw volatility data for the years 2010-2014 and 2015-2019 separately.

Green/yellow days where the price action was high volatile while orange/red show moderate/low volatility days.

Bitcoin was more volatility during the spring or summer months during 2010–2014, with periods of high volatility during November 2010, June 2011, April-May 2013. We also saw a period of volatility during December 2013-January 2014.

Source: CoinMetrics, volatility of 30-day returns for bitcoin between 18/08/2010 to 31/12/2019.

For the years 2015–2019, the first few months of the year have been volatile as compared to the rest of the year (with 2017 and 2019 being exceptions).

Looking at both calendar heatmaps together, it’s clear that BTC-USD usually experiences heightened volatility in summer (June, July, August) and winter (December, January, February).

Let’s look at the seasonal trends in bitcoin differently by plotting the distribution of monthly returns.

The Distribution of Monthly Returns

How do bitcoin returns vary by month?

The distribution of monthly returns are plotted in the chart below and exclude outliers.

Returns by month — outliers excluded. Source: CoinMetrics, daily bitcoin price data for 18/07/2010 to 31/01/2020.

When excluding outliers, the median returns by month are negative for January, March, August, and September. Historically, the largest returns are seen in April and June, with median gains near 20 percent.

The summer and winter months have been much more profitable for bitcoin investors. The chart also shows the volatility of monthly returns, with the ranges of the boxplots being much larger during the summer and winter months.

The violin chart below shows the true distribution of the data with outliers included. The density of each plot represents the frequency of observations and the mean return is shown as a diamond. Reading a violin chart is the same as reading a density plot: thicker parts of the chart represent more observations in that range.

Monthly returns — outliers included. Source: CoinMetrics, daily bitcoin price data for 18/07/2010 to 31/01/2020.

In January 2020, Bitcoin’s performance was +30%. The distribution for January above shows that the current performance is higher than average, but is not unprecedented — with bitcoin gaining 53% and 75% in January 2013 and January 2011, respectively.

A few observations from the violin chart above:

  • The average monthly returns are all positive — except for September.
  • The lower bound of April’s plot is just below zero, while most of the distribution is in positive territory. Since 2011, you’d have only lost money twice (in 2014 and 2015) if you bought bitcoin at the start of April and sold at the end of April. Even in 2014 and 2015, the losses were -4.39% and -6.29% respectively.
  • Comparing the violin chart with the boxplot for March, one outlier makes March’s average return positive. When excluding outliers, March has the second lowest median return, suggesting we’re more likely to see negative price growth in bitcoin during this month.
  • April, May, October and November have the largest average monthly returns. These months also show the highest variability in returns.
  • The variation in returns is smallest for July and September.

The Distribution of Returns by Weekday

Is there any link between bitcoin’s price changes and the day of the week?

Wednesdays are usually the most volatile and busiest day in Forex markets, as the data release cycle is in full swing. However, cryptocurrencies are traded 24/7, 365 days a year, so it would be interesting to see if there are any patterns in returns on the weekend.

The true distributions of returns by the day of the week are shown by the violin plot below. The diamonds represent the mean returns.

Source: CoinMetrics, daily bitcoin price data for 18/07/2010 to 31/01/2020.

The distributions of daily returns are similar for each weekday, with the peak at (or close to) zero percent. The range of price changes are similar for Mondays, Wednesdays, and Fridays, as shown by the length of each violin plot.

The biggest returns have been on Saturdays, but the biggest drops have occurred on Thursdays. These two days of the week also display the highest variation in returns.

Saturday appears to have two peaks, unlike all other days, suggesting that while most of the time returns are clustered around 0, returns also tend to cluster (although to a lesser extent) around a positive value of about 4 percent.

Intraday Returns, Volatility and Trends for BTC-USD

Are there any hourly patterns? Is there an effect on the price of bitcoin corresponding with the opening of the global financial centres, such as London, New York or Tokyo?

Price Change by Hour/Day of the Week on Bitstamp for BTC-USD

The heatmap below uses hourly price data from Bitstamp, spanning 06:00 on 12/11/2017 to 02:00 on 22/01/2020 (with 19,221 observations). All times are in UTC.

The colour of the squares represent the intensity of hourly price changes:

  • Dark purple squares show the hours where the trend in the price of bitcoin has usually been negative.
  • Orange/yellow squares show the hourly sessions where the bitcoin price action has usually been bullish.
  • Light purple squares show that the price has remained relatively stable.
Source: cryptodatadownload, (Bitstamp 1h), data is for 12/11/2017 (06:00) to 22/01/2020 (02:00).

One of the first time periods that stands out is 06:00–07:00 on Sundays — where the average gain in BTC-USD is close to 10 percent. The 22:00–23:00 trading session on Sundays is also positive for BTC-USD, along with the 16:00–17:00 hourly session on Thursday.

The dark purple square on Friday morning shows that the European market open (07:00–08:00) corresponds with a tendency of the bitcoin price to fall around five percent on average — at least according to the past 25 months of data from Bitstamp. Large negative price movements usually occur between 06:00–07:00 on Sundays and towards the end of the London trading session on Mondays (16:00–17:00).

Volatility by Hour/Day of the Week on Bitstamp for BTC-USD

The heatmap above shows the hourly change in prices on average, but doesn’t take into account the highs or lows. The same infographic is shown below for the hourly volatility of BTC-USD on Bitstamp (which is calculated as [(high-low)/open].

Dark purple squares show the hours where volatility is relatively low while the orange/yellow squares show where volatility is relatively high.

Source: cryptodatadownload, (Bitstamp 1h), data is for 12/11/2017 (06:00) to 22/01/2020 (02:00).

For the available data, we see that volatility is higher on Sundays (especially in the morning), on Mondays and during the 06:00–07:00 hourly session on Fridays, as compared to the rest of the week.

Candle Body Ratio by Hour/Day of the Week on Bitstamp for BTC-USD

To identify when the price of bitcoin has a higher likelihood of trending, we can also look at the Candle Body Ratio by hour and day of the week. To understand the Candle Body Ratio, let’s look at two extremes (where the ratio is equal to 1 and close to 0).

The formula for the Candle Body Ratio.

If the Candle Body Ratio equals 1, then the change between the opening and closing price is equal to the difference between the high and the low. In candlestick analysis, this is known as a Marubozu.

A Candle Body Ratio close to 0 indicates indecision and these readings are associated with Doji patterns. Two examples are shown in the chart below.

Illustrating the Candle Body Ratio.

The Candle Body Ratio is used to identify which trading sessions are more likely to display trending candles and the hours where BTC-USD is more prone to trendless conditions.

The heatmap below shows the Candle Body Ratio by hour and by weekday on the Bitstamp exchange. The yellow/orange squares show that the Candle Body Ratio is close to 1, while the dark purple/indigo squares show where the candle body ratio is close to zero.

Source: cryptodatadownload, (Bitstamp 1h), data is for 12/11/2017 (06:00) to 22/01/2020 (02:00).

Stronger trends (i.e., yellow squares) on Bitstamp are seen:

  • Prior to the European open on Fridays (06:00–07:00),
  • On Tuesday evenings (18:00–19:00),
  • Near the close of the European markets on Mondays, (14:00–16:00) and prior to the open of Asian markets (22:00–23:00).

Choppier price action (i.e., dark purple squares) is seen:

  • Around the open of the markets in New York on Tuesdays (12:00- 13:00).
  • The early hours of Fridays (01:00–03:00).

The heatmaps shown above vary for different exchanges. For instance, when looking at the data for Coinbase and Kraken, the returns are very close to zero for pretty much all trading hours and the Candle Body Ratio heatmaps look slightly different, as these exchanges have more data points on cryptodatadownload.

But the heatmaps above are only useful to spot traders on the Bitstamp exchange. Derivatives platforms like Interdax use an index where the price of bitcoin comprises price quotes from several spot exchanges.

To uncover trends more useful to derivatives traders, we’ve produced the same infographics for the entire history of BitMEX’s BTC-USD pair (spanning 01/01/2017 to 30/01/2020), using both hourly and 4-hour data.

Since volume in the derivatives market have overtaken the spot market and is where the main price discovery is happening now, we should be able to draw stronger conclusions from the following heatmaps.

Price Change by Hour/Day of the Week for BTC-USD on BitMEX

The heatmap for BitMEX shows a different picture with fewer variations in returns by hour, which is expected since the number of observations are larger (above 27,000).

Source: CryptoDatum, (bitmex1h), data is for 01/01/2017 (00:00) to 31/01/2020 (00:00).

The largest, positive price movements are clustered around 10:00–11:00 on Friday, and Tuesday evenings (between 22:00–23:00 and 23:00–00:00).

The two darkest purple squares are found during the 11:00–12:00 hourly session on Wednesday and the 23:00–00:00 trading session on Saturday.

Volatility by Hour/Day of the Week for BTC-USD on BitMEX

The hourly heatmap for the price volatility of BTC-USD on BitMEX is shown below.

Source: CryptoDatum, (bitmex1h), data is for 01/01/2017 (00:00) to 31/01/2020 (00:00).

The price of bitcoin is more volatile during the 15:00–16:00 session on Thursday.

Another session that is usually volatile according to the historical data is 22:00–23:00 on Tuesday.

Candle Body Ratio by Hour/Day of the Week for BTC-USD on BitMEX

Source: CryptoDatum, (bitmex1h), data is for 01/01/2017 (00:00) to 31/01/2020 (00:00).

The heatmap of the Candle Body Ratio shows that the price of bitcoin displays stronger trends during certain hours. For instance, yellow squares represent trading sessions where there is a higher likelihood that BTC-USD displays a strong trend.

The dark purple squares show us when the candle body size is low compared to the difference between the session’s high and low. For example, on Wednesday morning between 00:00 and 02:00, we usually see choppy price action in BTC-USD.

Looking at the 01:00–02:00 hourly session across different days, we see that BTC-USD’s price action tends to be choppy in the first half of the week (Monday to Wednesday), while during the second half of the week strong trends occur more frequently in this hour.

The 11:00–12:00 trading session is usually directionless no matter what day of the week it is (although to a lesser extent on Thursday), as indicated by the purple squares during that time period.

We can also identify consecutive hourly trading sessions that display high Candle Body Ratios. However, looking above, we see that there’s no more than two consecutive hourly sessions with strong trending candles (i.e., the Candle Body Ratio is above 0.60).

There are usually two consecutive hourly sessions with strong-trending candles on:

  1. Sunday mornings (01:00–03:00),
  2. Tuesday nights (22:00–00:00),
  3. Wednesday afternoons (14:00–16:00), and
  4. Friday mornings (00:00–02:00).

According to the hourly price data, these four time periods are the best times to scalp or enter short-term trades in BTC-USD. Strong-trending candles, where the wicks are small in relation to the candle’s body, are usually observed during these times.

The same metrics are shown below for the 4-hour price data from BitMEX.

Price Change by 4-Hour Trading Session/Weekday for BTC-USD on BitMEX

Source: CryptoDatum, (bitmex4h), data is for 01/01/2017 (00:00) to 31/01/2020 (00:00).

Tuesdays (16:00–20:00) usually see the largest positive price changes on average according to the past three years of data from BitMEX.

On average, the biggest percentage drops happen during on Saturday nights (20:00–00:00).

Volatility by 4-Hour Trading Session/Weekday for BTC-USD on BitMEX

Source: CryptoDatum, (bitmex4h), data is for 01/01/2017 (00:00) to 31/01/2020 (00:00).

Volatility is usually highest in the 12:00–16:00 session on Thursday and the 16:00–20:00 session on Tuesdays.

Candle Body Ratio by 4-Hour Trading Session/Weekday for BTC-USD on BitMEX

Source: CryptoDatum, (bitmex4h), data is for 01/01/2017 (00:00) to 31/01/2020 (00:00).

Typically, we see stronger trending candles during the latter half of the day between 12:00 and 00:00, with Thursday being an exception. Most of the yellow and orange squares are found after 12:00, suggesting stronger trends develop in the American trading session.

We generally find the strongest trending movements during the early hours of Thursday morning (00:00–04:00) and Tuesday evening (16:00–20:00).

The dark purple squares show BTC-USD is normally trendless during these hours, e.g., on Wednesdays (08:00–12:00) and Sundays (00:00–04:00).

The heatmap above suggests if you are a trend following trader, you should be active in the hours that display yellow/orange squares and be more cautious entering positions during time periods represented by dark purple squares. The conclusions drawn here assume that historical price action will be similar to that in the future.

Summary

Winter months have been far more profitable for bitcoin traders (especially October and November), with higher median returns and greater volatility. April and May also have high returns on average, while September is usually negative. It’s also interesting to note that the returns for April have been positive seven out of nine years, and in the other years the loss in April wasn’t that large (around -5%/-6%).

Daily returns mostly cluster around zero, although there is a small tendency for returns to cluster around small, positive values on Saturdays. Historically, Saturdays have had the highest upside but Thursdays have had the largest drops. These two days of the week also display the largest variation in returns.

Using the 1-hour and 4-hour data for BitMEX’s perpetual swap, we’ve shown during which hours/4-hour periods are associated with positive/negative growth, high volatility and strong-trending candlesticks for BTC-USD. From the data that is available, some of the findings are:

  • Monday mornings (11:00–12:00) are associated with choppy price action.
  • Candles with low Candle Body Ratios occursmore frequently in the early hours of each weekday (00:00–04:00), except for Thursday.
  • Two consecutive 4-hour trading sessions on Tuesday (16:00–20:00 and 20:00-00:00) are associated with high Candle Body Ratio readings — suggesting stronger trends develop during these hours.
  • The price of bitcoin is more volatile, exhibits greater than usual growth and displays a high Candle Body Ratio reading on Tuesday (22:00–23:00).
  • The early hours of Thursday (00:00–04:00) are associated with strong trending behaviour.
  • Stronger trends on the 4-hour timeframe are more common in the second half of the day (12:00–00:00) for most weekdays (with Thusday and Sunday being exceptions).

Keep in mind that these trends may not always repeat themselves. These insights are just a starting point for looking at seasonality in the price of bitcoin. A deeper dive is coming soon.


All graphics are produced with R Studio. The data and R scripts will be published on GitHub in the coming days.

Disclaimer: This blog post is for informational purposes only and should not be taken as financial advice.

By Interdax

Mycelium Wallet to Support ETH

Starting from Friday, January 31, 2020, Mycelium Wallet for Android supports ETH. The app is one of the oldest on the market and its team has always been known for being skeptical, if not maximalist, about the role the Ethereum protocol and ecosystem have played in the development of decentralized finance and management.

Alexander Kuzmin, Mycelium CEO: 

Although Ethereum remains a tool to proliferate financially risky innovation, the narrative of “flippening” is gone. On one hand, ETH can’t do any more harm to BTC. On the other hand, smart contracts and dApps are here to stay and evolve but most networks are under governments’ control, therefore — “the enemy of my enemy becomes a friend.”

Source: Ad-hoc Economy   

The Invisible ‘Global Currency’ That’s 24 Times Bigger Than Bitcoin

By Stephen McBride via Forbes

How many credit cards do you have? If you’re like the average American, you carry four in your wallet.

Chances are your credit cards are from different banks. But if you dumped out your wallet on the table and laid all your cards side by side, you’d notice something odd.

While all the cards are from different banks—and they all have their own special privileges, prestigious names, and color schemes—most have one thing in common:

Visa” or “MasterCard” stamped on the bottom right.

Visa (V) and Mastercard (MA) Created a “Global Currency”

It hardly matters what bank you use. At the end of the day, your card likely needs Visa or Mastercard’s payment network to function.

Over 80 million stores accept Visa or Mastercard. With one of their cards in your wallet, you can buy stuff anywhere in the world.

Visa and Mastercard have effectively created a universally accepted money—a “global currency.” $13 trillion flowed through their networks last year. That’s 24X more than Bitcoin processed in 2019, according to CCN.

They make money by taking a small cut of each transaction, like a tollbooth on a highway. Both Visa and Mastercard are minting record profits, and their stocks have handed investors tremendous gains:

Here’s why this is important for you.

Banks’ Stranglehold on Money Is Weakening

For many decades, we’ve had to deal with banks to move money. If you wanted to cash your paycheck, wire money, or get a credit card, you often had to talk to a banker.

These days, you can do all these things without ever stepping foot inside a bank. You can even get a mortgage without ever talking to a human banker!

Sending money no longer means writing a check and waiting three days for it to clear. Now you can send and receive money instantly with PayPal’s (PYPL) Venmo.

Roughly 50 million Americans use Venmo every month. You can even pay your taxes with PayPal.

Have you ever used Square’s (SQ) little white box that swipes credit cards? It plugs into your smartphone to turn it into a cash register. Over two million small businesses use it to accept cards instead of cash.

And getting a credit card no longer requires filling out piles of paperwork and answering a banker’s questions. Smartphone giant Apple (AAPL) made a splash when it debuted its shiny new titanium credit card last August.

These disruptors will end banks as we know them. Nobody cares if banks have fancy lobbies with marble floors these days. Most Americans just want a fast and convenient way to manage their money.

I haven’t stepped foot in a bank in years. And foot traffic into branches has fallen close to 50% in the past decade.

Many folks assume “old” money companies like Visa and Mastercard are in trouble too. These folks are wrong.

Visa and Mastercard Are “Untouchable” Stocks

What few people realize is all the “money disruptors” I just mentioned are plugged into Visa and Mastercard’s networks.

Apple designed its titanium card to resemble its sleek products. But did you know it runs on Mastercard’s network? And credit cards from PayPal, Square, and Stripe all have Visa or Mastercard logos.

These disruptors aren’t ripping out the pipes of our financial system and trying to cut out Visa and Mastercard. Instead, they’re partnering with them, sending even more money flowing through their networks.

Remember, each time you pay with a card, Visa and Mastercard collect a small fee. In fact, even when you pay with your phone, these giants make money.

Apple Pay, Google Pay, and Amazon Pay, are simply “apps” built on Visa and Mastercard networks!

Nobody Can Touch These “Untouchable” Stocks

How we move money around and pay for things has changed for good. Yet these changes have only cemented Visa and Mastercard’s dominance.

They’ve built payment networks nobody can match. More than 30,000 banks use their credit cards. There are 3.4 billion Visa cards alone in circulation!

And now partnerships with PayPal, Square, and others are injecting a new wave of growth into Visa and Mastercard. Visa’s sales shot up 11.5% last year to a record $22 billion. And Mastercard’s revenue jumped 20% to $14.5 billion.

They Are Two of the Most Consistently Impressive Businesses I’ve Ever Analyzed

Visa’s profit margins are 5X better than the average US stock. It turns 52 cents on every dollar into pure profit. Mastercard’s profit margins are 3X better than the average S&P 500 company. If you’re investing for the long haul, you could do a lot worse than owning these two undisruptible tollbooth stocks.

So Much Noise about Digital/blockchain Fiat: Decoy, Surrogate or Real Innovation?

European Central Bank, the Bank of International Settlements, central banks of the U.K., Switzerland, Japan, Sweden, and Canada jointly investigate central bank digital currencies.

A few days ago the Reserve Bank of Australia (RBA) had launched a pilot project to research a central bank digital currency (CBDC) for the nation. The Australian Prudential Regulation Authority (APRA) has announced it will now be overseeing stablecoin projects. In plain English, this means they will fight Libra and alike.

Spain’s largest and most systemically important Bank, Santander, joined the chorus earlier in the week, confirming that developments are in full swing.

This week, China’s Central Bank provides an update on the latest news on the Digital Yuan.

All this happens during Davos 2020, it must be noted.

DIAGON (DGN) IEO ON PROBIT EXCHANGE

The eSports industry has grown tremendously over the years. And if in 2015, The Global eSports Market generated $748M, in 2019 it has hit the $1B mark and is expected to go up to $1.7B by 2021.

You may not be into eSports, yet, but that doesn’t have to mean you will lose this opportunity as well. Therefore, Probit Exchange brings you Diagon.

Diagon is a global eSports ecosystem for competitive gaming with three exclusive & innovative features: DiaArena, DiaBet, and DiaExchange. 

  • DiaArena brings users from all around the globe to compete in various eSports tournaments and show who has the best skills.
  • DiaBet is the clean and fresh betting feature that allows you to stake your Diagon Coin at eSports tournaments ongoing around the world. 
  • DiaExchange allows you to collect and trade digital collectible cards and send Diagon Gift Cards.

Our sole virtual currency, Diagon Coin, will be used to perform every form of transaction in our innovative eSports ecosystem including competitive gaming, staking, trading and making virtual and real purchases. 

Even more, Diagon Coin will offer its contributors a unique edge with its value to trade against other cryptos. 

The Bitcoin ship has sailed a long time ago, but DIAGON is taking people on board.

How do you get Diagon Coins?

Go on Diagon Coin’s website and starting from Monday, 20 January 2020 at 12:00 KST you can decide on purchasing the token at $0.20/DGN. The IEO will end on Friday, 24 January 2020 at 11:59 KST.

BONUS

Purchase the Diagon Coin with PROB (ProBit Exchange’s token) and receive 20% more DGN.

Use USDT, BTC, ETH, and XRP to purchase the Diagon Coin and receive 15% more DGN.

Efficient Market Hypothesis and Bitcoin Stock-to-Flow Model

By PlanB

Introduction

Bitcoin Stock-to-Flow (S2F) model was published in March 2019 [1]. The model has been well received by bitcoiners and investors. Many analysts have verified the cointegrated S2F model and confirmed bitcoin price predictions [2][3][4].

The S2F model also received critique. The best steel man argument against the model comes from the Efficient Market Hypothesis (EMH). The argument states that the model is based on publicly available information (S2F, bitcoin’s supply trajectory) and therefore the analysis and conclusion must be already priced in.

In this article I share my point of view on S2F model and EMH. I analyze arbitrage opportunities, risk & return model and derivatives markets.

Stock to Flow Model

S2F model was published as a bitcoin valuation model, inspired by Nick Szabo’s concept of unforgeable scarcity and Saifedean Ammous’ analysis of S2F [1][5][6]. S2F is a measure of scarcity. The power law relation between S2F and bitcoin price over time captures the underlying regularity of bitcoin’s complex dynamic system of network effects as described by Trace Mayer [7].

S2F model is a power law function fitted on Oct 2009 —Feb 2019 monthly data: BTC price =0.4*S2F ^3 (where S2F=1/inflation rate). A later model on 2009–2019 yearly data yields higher predictions: BTC price =0.18*S2F ^3.3

Nick Phraudsta was the first to verify (or better “not falsify”) the S2F model, and he added cointegration analysis, indicating that the correlation is likely not spurious [2]. Marcel Burger verified both S2F model and cointegration, with several addition statistical tests[3]. Manuel Andersch was the first institutional investor (BayernLB) to verify S2F model and cointegration [4].

Efficient Market Hypothesis

EMH is a well known theory in financial economics. EMH is based on ideas of Friedrich Hayek (1974 Nobel prize) and others. According to Hayek markets are information processing systems, delivering the best possible price discovery [8].

EMH is formally described by Eugene Fama (1973 Nobel prize) and comes in three flavors [9]:

  1. Weak EMH: historical price data is already priced in and cannot be used to make profits. Technical Analysis (TA) and Time Series Analysis (TSA) does not work.
  2. Semi-strong EMH: public news from media outlets like MSNBC, Bloomberg, WSJ and research companies is already priced in and cannot be used to make profits. Fundamental Analysis (FA) does not work.
  3. Strong EMH: even inside information can not be used to make a profit, because all information is already priced in.

Most investors and economists agree that modern financial markets are reasonably efficient (i.e. they accept weak and semi-strong EMH), however they reject strong EMH.

Following EMH, S2F model should be priced in, because it is based on publicly available data (S2F).

Risk & Return

To be honest, I have never used EMH directly in my 20+ years experience as an institutional investor managing a multi-billion Euro balance sheet. In practice we assume EMH, and use a risk & return model.

Assuming EMH

Some people argue that bitcoin markets are not efficient, but I do not agree. In the old days you could buy bitcoin at one exchange in USD and sell it shortly afterwards at another exchange in EUR or JPY and convert it back to USD at a profit, arbitrage was possible. Those days are gone, as the table below shows (13 Jan 2020, 20:00 GMT prices):

BTCUSD = 8100
BTCEUR = 7300
BTCUSD/BTCEUR = 8100/7300 = 1.11
EURUSD = 1.11

BTCJPY = 885.000
BTCJPY/BTCUSD = 885.000/8100 = 109
USDJPY = 109

Perhaps there is still some money to be made with big computers, fast communication lines and high-frequency trading (HFT) algorithms, but there are no easy arbitrage opportunities.

We can safely assume that the $150B bitcoin market with $10B daily transactions is reasonably efficient.

Risk & Return Model

Assuming EMH does not mean that you can not make money. You just have to take risk. EMH and non arbitrage lead us to risk & return models.

Harry Markowitz (1990 Nobel prize) introduced an early risk & return model with his famous Portfolio Theory (PT)[10]. William Sharpe (1990 Nobel prize) published his well known Capital Asset Pricing Model (CAPM)[11]. According to Markowitz and Sharpe all returns can be explained by risk.

This is a simplified risk & return model (without correlation or exotic math):

It is crucially important to understand this chart, so let’s dive into it.

The x-axis of this chart is risk (maximum annual loss) and the y-axis is return (average annual return).

The chart shows three classic assets: bonds, gold and stocks. Bonds have the lowest risk 8% and the lowest return 6%. Gold has higher risk 33% and higher return 7.5%. Stocks have the highest risk 40% and the highest return 8%.

Key insight is that returns can be explained by risk alone, consistent with EMH. If you encounter an asset above the line, a first reaction could be that it is a great investment opportunity. A better reaction (from an EMH and non arbitrage point of view) would be that it is too good to be true. We are probably missing risks (or have miscalculated risk) and should try to bring the asset back on the line. Quantifying risk (volatility) is difficult, and indeed the expertise of quants of financial institutions. If an investor calculates that risks are lower than the market prices in, and if he exactly knows why the asset is above the line, then and only then should he decide to invest.

Bitcoin is literally “off the chart”: 200% return, 80% risk. Because I can not plot it on the chart, I resized it to a 1% bitcoin plus 99% cash investment. This bitcoin investment is far above the line: 8% return, 1% risk (note that you can’t loose more than 1%, even if bitcoin drops 99%, because you only invest 1%). So my first reaction is: the market sees risks that are not in the data. Here is a list of some possible risks:

  • Risk that bitcoin dies
  • Risk of governments making bitcoin illegal and prosecuting developers
  • Risk of fatal software bugs
  • Risk of exchange hacks
  • Risk of 51% attacks by centralized miners
  • Risk of miner death spiral after halving
  • Risk of hard forks

From an EMH and risk & return perspective, all these risks should be in the price data. But these risks are not in the data. According to EMH and the risk & return formula in the chart, 1% risk should give 5.5% + 6.2% * 1% = 5.6% return. And the data shows that 1% bitcoin + 99% cash had 8% return last 11 years.

It seems that these risks have been overestimated by the market, and that bitcoin really was a great investment opportunity, in line with S2F model.

Derivatives markets

Let’s look at what derivatives markets are telling us about the future.

Option markets show no spike at or after next halving:

Source: https://twitter.com/skewdotcom

Same story for futures market: slightly higher prices in the future, but no spike at or after the halving, indicating nothing special will happen at the halving:


Source: https://www.theice.com/products/72035464/Bakkt-Bitcoin-USD-Monthly-Futures/data?marketId=6137544

This is interesting because S2F model predicts much higher prices after the halving. How should we interpret this?
I think the simple answer is that the market currently overestimates future risk, like it overestimated risk last 11 years. The efficient bitcoin market not only discounts the fundamental value of scarcity (S2F model), but also all these risks:

  • 42% of investors see bitcoin futures as the biggest risk (whales and governments manipulating the price of bitcoin with ‘paper bitcoin’, spoofing and wash trades).
  • 16% still fears miner capitulation after the halving.
  • 15% fear selling pressure from scams.
  • I know from discussions with institutional investors that their biggest fear is government making bitcoin illegal.
  • Another risk frequently mentioned by institutional investors is “the next bitcoin”, a new (government/central bank backed) coin replacing bitcoin.

Note that without all these risks bitcoin’s value would be much higher, possibly in line with S2F model.

As time progresses, some of these risks will not materialize and disappear from the list. Take miner capitulation for example. I do not think miner capitulation is a big risk, but 15% of investors thinks it is. If hashrate does not decrease after the next halving, the risk of miner capitulation disappears and bitcoin price will rise because the risk is gone.

Conclusion

Bitcoin S2F model was introduced in March 2019 and verified by many others.

EMH implies that S2F and the model predictions should be already priced in by the market, because S2F model uses publicly available S2F data.

Current bitcoin markets are indeed reasonably efficient because easy arbitrage opportunities are not possible.

Historical risk & return data of bonds, gold, stocks and bitcoin, shows that bitcoin markets overestimated risk. Bitcoin return was not in line with risk, but very much in line with S2F model. Bitcoin options and futures markets do not expect rising prices at or after next halving. It is possible that markets still overestimate future risks.

My conclusion is that bitcoin markets are indeed reasonably efficient and price in S2F model, but also overestimate risk. Therefore, I prefer using S2F model over a classic risk & return model to predict future bitcoin price.

So I assume EMH and would definitely pick up that bitcoin!

References

[1] PlanB@100trillionUSDModeling Bitcoin’s Value with Scarcity, Mar 2019

[2] Nick Phraudstra, Falsifying Stock-to-Flow As a Model of Bitcoin Value, Aug 2019

[3] Marcel Burger, Reviewing “Modelling Bitcoin’s Value with Scarcity”, Sep 2019

[4] Mannuel Andersch (BayernLB), Is Bitcoin outshining gold?, Sep 2019

[5] Nick Szabo, Bit Gold, 2008

[6] Saifedean Ammous, The Bitcoin Standard: The Decentralized Alternative to Central Banking, 2018

[7] Trace Mayer, The Seven Network Effects of Bitcoin, 2015

[8] Friedrich Hayek, The Use of Knowledge in Society,1945

[9] Eugene Fama, Efficient Capital Markets: A Review of Theory and Empirical Work, 1970

[10] Harry Markowitz,Portfolio Selection, 1952

[11] William Sharpe, Capital Asset Prices: A Theory of Market Equilibrium under Conditions of Risk, 1964

Ten Jan 14 One-line News

  1. The trading volume on CME on the first day amounted to $2M (it took Bakkt 1 month to pass the $1M mark).
  2. Visa is buying Plaid that serves Coinbase and Abra (for $5.3B).
  3. Binance blocked the account of a Russian client at the request of the Ukrainian police.
  4. The judge has invalidated the decision to collect 500,000 BTC from Craig Wright.
  5. IBM will launch a blockchain application for farmers to track coffee supplies.
  6. Austria’s financial regulator has ordered cryptocurrency companies to register.
  7. The court ordered Telegram to disclose TON financial data.
  8. The SEC demands to collect >$16M from ICOBox.
  9. Dutch ABN Amro bank announced 0% interest.
  10. On this day, dozens of “predictions” were published that BTC will reach the $100k level faster than previously thought.