Causality in CryptoMarkets

In this article: We discuss causality in crypto markets. Specifically, when is a good time to buy / sell a cryptocurrency; this analysis will be conducted from (at the time) live data from

Intro to Trends on

For this article, we will be applying Granger Causality to a few cryptocurrencies for the past few months. We’ll use live trend and pricing data from, between April 1, 2017 and December 1, 2017.

The goal of is to provide insights from experts to the masses; bubble up the knowledge, if you will. In the case of crypto-markets, it’s often the reverse, where the masses tell the experts how they feel. Specifically, (crypto)currencies are massively impacted by how confident masses feel. This is part of the reason for the federal reserve in the U.S., as it stabilizes the U.S. Dollar. In contrast, cryptocurrencies have no such system, so a boom-bust cycle is inevitable.

Luckily, with we can use this to our advantage, particularly by reviewing the Trend Data / Chart (as it provides insights about the masses):


If you’re interested in the specifics regarding the chart, feel free to checkout our explanation. In summary, trend’s are the normalized volume of discussions between 0 and 1, as tracked by

Code for Granger Causality

Now, lets get to the fun part – coding!

First, we create a function that takes in trend and pricing data, normalizes the data using zscore, and formats the data for the granger causality function we will be using (from the python package statsmodels):

From there it’s relatively easy to ingest into the Granger Causality function (from the python package statsmodels). The only part we have left to do is defining the “max lag”, or how far back in time should be assessed by the function. In this case, 60 days was chosen as we are only looking at a few months of data. Just make sure it is less than one third of the data’s size (I recommend choosing <10% of the data set size):

With the output from that function it is possible to pull out the F-test and p-value from the “gc” variable (Granger Causality). Both the F-test and p-value are used for determining correlations, however I wont dive into that at the moment. The full documentation on the “grangercausalitytest” function is here, and the full code (in the github, below) will provide further insights.

In addition to the F-test and p-value, the Granger Causality function will provide us with a list of “lags”, which is let us know the offset to look for. For this example, the “lag” is how many days prior a change in trend will impact the price.

With this code it is now possible to run our Granger Causality assessment!

Trend and Price Causality in CryptoCurrencies

Using trend data from, we will review the following cryptocurrencies from April 1, 2017 to December 1, 2017 for “probable causality” (i.e. Granger Causality) based on trend and price data:

  • Bitcoin (BTC)
  • Ethereum (ETH)
  • Litecoin (LTC)
  • Bitcoin Cash (BTC)
  • Ripple (XRP)
  • Monero (XRM)

When we run a modified version of code above; we end up with the following chart representing the number of days lag in price after a trend event, for the six cryptocurrencies above:

Correlations between Trend and Price (based on offset of days)

For reference, a p-value < 0.05 is typically considered the threshold for the correlation, between datasets. In this case, there’s also what we are calling a “Strong Correlation” which is a p-value < 0.01. The strange part is the uniform band of “Strong Correlations” at the bottom.

Upon inspection, it appears that one cryptocurrency in particular is the culprit Bitcoin Cash (BCH):

Zscore BCH Trend & Price

The large amount of no data leading to a high amount of correlation. This is one of the common pitfalls we mentioned Limits of Granger Causality, and is an excellent example of why you always verify your data sets! Once we remove BCH from our dataset we now have the following cryptocurrencies we are searching for Granger Causality:

  • Bitcoin (BTC)
  • Ethereum (ETH)
  • Litecoin (LTC)
  • Bitcoin Cash (BTC)
  • Ripple (XRP)
  • Monero (XRM)

We then appear with the following chart representing the number of days lag in price after a trend event:

Correlations between Trend and Price (based on offset of days)

I’ve personally verified each of the remaining datasets. I believe there is indeed a probable causality (where the trend impacts the price). You’re welcome to do the same with the code / data provided below.

Causality in Crypto Markets

The more specific outputs (i.e. which currencies have causality) from our code are as follows:

Output of Granger Causality

Importantly, it appears there is a pattern – i.e. something we can trade off of. Most of the currencies show a strong movement roughly five days after there is a trend event; averaging major cryptomarket movements eleven days after a trend event and with standard deviation of 7 days.

Further, the one outlier Ripple (XRP) is mostly owned by a single entity. Meaning it might make sense there is no correlation between the price of Ripple (XRP) and the number of people discussing Ripple (XRP); where as the other currencies are mostly owned by various groups / the masses.

Verification of Granger Causality

For safe measure, I typically will do an additional assessments to verify theories and confirm Granger Causality is working. Searching for correlations between trends for each of the cryptocurrencies and a “random walk” (i.e. random data), which outputted the following chart:

Trend of CryptoCurrencies compared to Random Walk

For comparison purposes, it’s clear there is no pattern at all; where as the live data has a clear pattern we can follow. In addition, it’s highly recommended to review the output of the individual timeseries datasets being compared. It’s extremely common to get results such as we did with Bitcoin Cash (BCH).


Our goal in sharing our analysis using Granger Causality was two fold:

  1. Help explain Granger Correlations and how to use them
  2. Intice you to try! (Use coupon code: pigletblog2018 – 25% off for 12 months)

We hope we’ve done both!

The github repo with all the code and example data is here. Feel free to leave comments, tweet, emails, or leave issues on the repo itself.

We’d love feedback and/or to help if you need it.

One thought on “Causality in CryptoMarkets

Leave a Reply

Your email address will not be published. Required fields are marked *