Finding Crypto Asset price correlations in blockchain metrics

James Li
CCData
Published in
6 min readJan 23, 2020

--

This tutorial extends the tutorial by Quynh on Calculating NVT Ratios with the CryptoCompare API.

In this tutorial, we explore the blockchain data and highlight interesting metrics that may correlate with crypto prices.

Specifically, we looked at prices against:

  • NVT signal (NVTS)
  • Active addresses
  • Large blockchain transactions

This tutorial uses the CryptoCompare Blockchain data API. The dataset is powered by our partner, Into The Block — an intelligence company that leverages machine learning and advanced statistics to extract intelligent signals for crypto-assets.

The Jupyter notebook for this tutorial is available here.

NVT signal (NVTS)

NVT (Network Value to Transaction Ratio) is created and popularised by Willy Woo to measure whether a network is over-valued or under-valued. It is similar to the price-earnings ratio (PE ratio) used for companies. It compares the value perceived of the network against how much the network is used.

NVT = Network Value / Daily Transaction Value

In a blog post, Dmitry Kalichkin further refined the metric in an attempt to detect crypto bubbles. He argues that a longer moving average (MA) helps smoothing reflexive effects by short term price movements and reflects the fundamental utility of the network better, the NVT Signal (NVTS).

NVTS = Network Value / 90-Days MA of Transaction Value

Let’s plot a graph of NTVS against Price for BTC:

To generate the above graph, you may use the following tutorial:

Import libraries

import requests
import datetime
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

Get API key

You can only access the blockchain data with a valid API key. Read this guide on getting an API key.

# Replace your API key
api_key = "YOUR_API_KEY_HERE"

Available coins

For a list of coins available for blockchain data, you may use the following endpoint:
https://min-api.cryptocompare.com/data/blockchain/list

symbol = "BTC"
limit = 1000 # Number of data points to return

The following function combines blockchain data with price data to one pandas dataframe, which you may use for your own calculations.

def get_blk_px_data(api_key, symbol, limit):
blockchain_data_url = f"https://min-api.cryptocompare.com/data/blockchain/histo/day?fsym={symbol}&limit={limit}&api_key={api_key}"
price_data_url = f"https://min-api.cryptocompare.com/data/v2/histoday?fsym={symbol}&tsym=USD&limit={limit}&api_key={api_key}"
blk_data = requests.get(blockchain_data_url).json()["Data"]["Data"]
price_data = requests.get(price_data_url).json()["Data"]["Data"]
# Data preparations
df_blk = pd.DataFrame(blk_data)
df_price = pd.DataFrame(price_data)
df_blk["datetime"] = pd.to_datetime(df_blk["time"], unit="s")
df_blk = df_blk.set_index("datetime")
df_price["datetime"] = pd.to_datetime(df_price["time"], unit="s")
df_price = df_price.drop(columns="time")
df_price = df_price.set_index("datetime")
df = df_blk.join(df_price)

return df

Create a dataframe with the necessary data:

df = get_blk_px_data(api_key, symbol, limit)

Blockchain metrics

The following blockchain metrics are provided via the CryptoCompare API:

  • zero_balance_addresses_all_time
  • unique_addresses_all_time
  • new_addresses
  • active_addresses
  • average_transaction_value
  • block_height
  • hashrate
  • difficulty
  • block_time
  • block_size
  • current_supply
  • transaction_count
  • transaction_count_all_time
  • large_transaction_count

Full descriptions of the return fields are available here

Define a function to calculate NVTS, recall that:

NVTS = Network Value / 90-Days MA of Transaction Value

dma = 90
def calc_nvts(df, dma):
df[f"{dma}dma_usd_txn_value"] = (df["transaction_count"] * df["average_transaction_value"] * df["close"]).rolling(window=dma).mean()
df["nvts"] = (df["current_supply"] * df["close"]) / df[f"{dma}dma_usd_txn_value"]
return df

Steps to plot the graph:

df = calc_nvts(df, dma)
fig, ax = plt.subplots(nrows=1, ncols=1, figsize=(13,7))
df["close"].iloc[dma:].plot(color='darkblue', linewidth=2)
ax1 = ax.twinx()
df["nvts"].iloc[dma:].plot(ax=ax1, linewidth=2)
ax.legend(loc=2)
ax1.legend(loc=0)
ax.set_xlabel("Date")
ax.set_ylabel("Price (USD)")
ax1.set_ylabel("NVTS")
plt.title(f"{symbol} NVTS vs Price (Daily)")

In Dmitry’s blog post, he also examined cases where NVTS may not work well and explained that strong trend or external news are usually the reasons.

Further, he mentioned that one of the fundamental weaknesses of NVT is, not taking into account the number of addresses participating in the transactions — the Daily Active Addresses, which we will have a look in the next section.

Active addresses

Metcalfe’s law states that the effect of a network is proportional to the square of number of users in the system. There are different variants of Metcalfe’s Law but the idea is the value of the network is a function of the number of active users.

Let’s look at how the price correlates with the number of active addresses over time.

fig, ax = plt.subplots(nrows=1, ncols=1, figsize=(13,7))
df["close"].plot(linewidth=2, color='darkblue')
ax1 = ax.twinx()
# Plot active addresses as a MA to reduce noise
df["active_addresses"].rolling(window=10).mean().plot(ax=ax1, linewidth=2)
ax.legend(loc=2)
ax1.legend(loc=0)
ax.set_xlabel("Date")
ax.set_ylabel("Price (USD)")
ax1.set_ylabel("Active addresses")
plt.title(f"{symbol} Active addresses vs Price (Daily)")

From the graph above, active addresses seems to correlate with the peaks and troughs of the prices quite well and it seems to precede the price on some occasions.

Large blockchain transactions

Another metric which seems to correlate well with the price is the percentage of large transactions.

We can use the “large_transaction_count” and “transaction_count” data from the Blockchain data API to plot the graph.

df["large_txn_pct"] = df["large_transaction_count"] / df["transaction_count"] * 100fig, ax = plt.subplots(nrows=1, ncols=1, figsize=(13, 7))
df["close"].plot(linewidth=2, color='darkblue')
ax1 = ax.twinx()
# Plot percentage of large transactions as a MA to reduce noise
df["large_txn_pct"].rolling(window=10).mean().plot(ax=ax1, linewidth=2)
ax.legend(loc=2)
ax1.legend(loc=0)
ax.set_xlabel("Date")
ax.set_ylabel("Price (USD)")
ax1.set_ylabel("Large transactions %")
plt.title(f"{symbol} Percentage of large transactions vs Price (Daily)")

From the graph, despite the correlation, it is unclear whether price is leading, preceding or move in tandem with the price.

As per the documentation, note that “Large transactions” is defined by transactions > 100,000 USD.

Since it is a static number, it follows that when the price increases, given the same amount of BTC transacted, the percentage of “Large transactions” also increases.

An alternative measurement may be measuring large transactions by amount in the native coin unit.

Let’s see how the graph looks like:

# Assume all large transactions are worth 100,000 USD
large_txn_dollar = 100000
df[f"large_txn_{symbol}"] = df["large_transaction_count"] * large_txn_dollar / df["close"]
fig, ax = plt.subplots(nrows=1, ncols=1, figsize=(13, 7), sharex='row')
df["close"].plot(linewidth=2, color="darkblue")
ax1 = ax.twinx()
df[f"large_txn_{symbol}"].rolling(window=10).mean().plot(ax=ax1, linewidth=2)
ax.legend(loc=2)
ax1.legend(loc=0)
ax.set_xlabel("Date")
ax.set_ylabel("Price (USD)")
ax1.set_ylabel(f"Large transactions in ({symbol})")
plt.title(f"Large transactions in {symbol} vs Price")

From the graph above, we may be able to draw some interesting observations:

  • Before the rally in 2017, “large transactions” was the norm.
  • As the BTC price crashed in 2017, “large transactions” follows, perhaps a sign that large players were seeking safety.
  • After a period of quietness, followed by the renewed pressure in Nov, 2018, large transactions activities seemed to have picked up again.
  • As the new round of rally tails off, large transactions also started to come down.

Other coins

Let’s have a look at how the mentioned metrics correlate with the price for other coins.

ETH

NVTS vs Price
Active addresses vs Price
Percentage of large transactions vs Price
Large transactions in ETH vs Price

LTC

NVTS vs Price
Active addresses vs Price
Percentage of large transactions vs Price
Large transactions in LTC vs Price

Find out more

Feel free to play around with the API yourself and read the full documentation on the CryptoCompare Blockchain Fundamental API here, or contact us on data@cryptocompare.com.

--

--