A bubbly look at the Bitcoin bubble

2017 was an insane year in the cryptocurrency world as bitcoin and other cryptocurrencies (so-called altcoins) caught the attention of mainstream media. This is associated to the fact that Bitcoin and other cryptos’ prices surged exponentially in a historically short period. Bitcoin went from less than 1000 usd per coin in January 2017 to 13500 usd by the end of the year, with its peak even reached 20000 at sometime during December.

I made the following packing-bubble plot to visualize the capitalization value of over 1300 cryptos that are currently being traded on the market, as depicted by the size of their corresponding bubbles. The data is scraped from coinmarketcap.com and is automatically plotted using the programming language R. The source code is available at the end of this post.

You can hover over each circle to read the names of cryptos and their capitalization value:

You may notice that bitcoin is holding its spot as the biggest cryptocurrency in terms of market capitalization. This is understandable as bitcoin is known as the representative face of the cryptocurrency scene, as well as having the first mover advantage, being the first invented cryptocurrency.

But bitcoin is not the only cryptocurrency that is gaining tractions, so as more than 1300 similar cryptographic currencies, known as the altcoins. Although most of the altcoins are merely copycats of the original Bitcoin system, some are truly innovative, and may potentially overtake bitcoin as the main cryptocurrency sometime in the future. Among the blockchain developers, Ethereum is known as one of the go-to platforms for creating smart contracts – cryptographically secured contracts that automatically executed without third-party interventions. Ripple, a decentralized system whose value sky-rocketed by the end of the year, is a cryptocurrency system that aims to provide cheap, real-time, borderless international transactions, without the needs for correspondent banks. Some other notable examples may include iota (an implementation of cryptocurrency to be used in Internet-of-Things systems), Litecoin (A crypto that is designed to be more well-rounded and practical than Bitcoin), Cardano (the first crypto whose whitepapers are peer-reviewed), etc…

In the light of these emerging substitutions, bitcoin appears to have too many weaknesses: It takes too long to confirm any transaction, albeit insanely high transaction fees; The mining process of Bitcoin is extremely power-consuming, that it infuriates policymakers, prevents them from granting this coin a legal status. As Bitcoin seems to be receiving too much attention than it deserves, people are adjusting their expectations on this coin, as evidenced by the downfall of bitcoin price near the end of 2017.

The bitcoin bubble may pop anytime soon, but the value of bitcoin needs not to be faded into oblivion. The overall increase in cryptos’ market capitalization, including the altcoins, is the sign that people are investing in this young technology. Whenas the technology reaches the Plateau of Productivity may be the story of another few years, we can come to an agreement that it started with this bubble, thanks to Bitcoin.


Click here to view the code to the visualization
## Packages
pkgs <- c("rvest", "dplyr", "ggplot2", "stringr",
          "viridis", "packcircles", "ggrepel", "ggiraph")
sapply(pkgs, require, character.only = TRUE)

## Import & cleaning
coinmarketcap_page <- "https://coinmarketcap.com/all/views/all/"
timestamp <- substr(Sys.time(), 1, 16)

market_tbl <- read_html(coinmarketcap_page) %>%
  html_table()
market_tbl <- market_tbl[[1]]
names(market_tbl) <- names(market_tbl) %>%
  str_replace_all(" ", "_")

market_tbl$Market_Cap <-
  market_tbl$Market_Cap %>%
  str_replace_all("[^0-9.]", "") %>%
  as.numeric()

market_tbl$Price <-
  market_tbl$Price %>%
  str_replace_all("[^0-9.]", "") %>%
  as.numeric()


market_tbl$Name <-
  market_tbl$Name %>%
  str_replace_all(".+\\n[ ]+", "")

market_tbl <- market_tbl %>% arrange(-Market_Cap)

## Layout algorithm
limits <- c(min(market_tbl$Market_Cap, na.rm = TRUE),
            max(market_tbl$Market_Cap, na.rm = TRUE))

res <- circleProgressiveLayout(
  x = market_tbl$Market_Cap,
  sizetype = "area")

layout <- cbind(res, market_tbl) %>%
  mutate(note = paste0(Name,
                       c(paste0("\n $",
                                prettyNum(market_tbl$Market_Cap[1:3],
                                          scientific = FALSE,
                                          big.mark=",")),
                         rep("", nrow(market_tbl) - 3))))

## Plotting
plot <- circleLayoutVertices(res, npoints = 100) %>%
  ggplot() +
  geom_polygon(aes(x, y, group = id, fill = id, color = id)) +
  scale_color_viridis(option = "D", begin = 1, end = 0) +
  scale_fill_viridis(option = "A", begin = 1, end = 0) +
  geom_text(data = head(layout, 10),
            aes(x, y, label = note), color = "#2c3e50",
            family = "Ubuntu") +
  coord_equal() +
  ## labs(title = paste0(
  ##        "Cryptocurrencies Market Capitalization \nAs of ",
  ##        timestamp),
  ##      subtitle = "Data source: coinmarketcap.com\nData viz: Hiếu Phẩy") +
  theme_void() +
  theme(legend.position="none",
        plot.title = element_text(family = "Ubuntu",
                                  face = "bold", color = "#2c3e50"),
        plot.subtitle = element_text(face = "italic", color = "darkred"))

ggsave("crypto_size.svg")
ggsave("crypto_size.png", width = 7, height = 5)

plot

## Interactive
layout$tooltip <- paste0(layout$Name, "\n$",
                         prettyNum(layout$Market_Cap,
                                   scientific = FALSE,
                                   big.mark=",")) %>%
  str_replace_all("'", "")

gg <- circleLayoutVertices(res, npoints = 100) %>%
  ggplot() +
  geom_polygon_interactive(aes(x, y, group = id, fill = id, color = id,
                               tooltip = rep(layout$tooltip, each = 101),
                               data_id = id)) +
  scale_color_viridis(option = "D", begin = 1, end = 0) +
  scale_fill_viridis(option = "A", begin = 1, end = 0) +
  geom_text(data = head(layout, 10),
            aes(x, y, label = note), color = "#2c3e50",
            family = "Ubuntu") +
  coord_equal() +
  labs(title = paste0(
         "Cryptocurrencies Market Capitalization \nAs of ",
         timestamp),
       subtitle = "Data source: coinmarketcap.com") +
  theme_void() +
  theme(legend.position="none",
        plot.title = element_text(family = "Ubuntu",
                                  face = "bold", color = "#2c3e50"),
        plot.margin=unit(c(0,0,0,0),"mm"),
        plot.subtitle = element_text(face = "italic", color = "darkred"))


ggiraph(ggobj = gg, width = 0.95) %>%
  htmlwidgets::saveWidget("crypto_size.html")