Trading Algorithms for Cryptocurrencies without Survivorship Bias

Geek Culture
Published in
3 min readJul 28, 2021


At Quantiacs we are running a contest for quantitative trading algorithms focused on cryptocurrencies and we provide data and tools for avoiding survivorship bias. In this article we describe the main features of the contest.

Survivorship bias is an example of sample selection bias which takes place when a dataset consists only of existing (surviving) observations but does not take into account those which do not exist anymore.

The problem is well known in finance and algorithmic trading and normally it leads to overoptimistic expectations. Imagine to develop a trading system for stocks. Given the large number of assets, it is customary to define a subset of them for research and development. A reasonable choice is to start with the most liquid stocks in the United States and to use an index as a selection criterion: for example, a quant could decide to focus her/his research on all members of the S&P500 index.

Let us imagine that the quant uses the current members of the index and performs a study using their historical data: probably a simple long-only strategy would perform very well as the quant has implicitly selected the current winners for the analysis.

A correct historical study requires to include all stocks which at some point in the past were part of the S&P500 index but they have been later delisted or they have disappeared.

The same issue affects cryptocurrencies: normally we focus on the current top performers, but neglect those which disappeared after having an initial success.

Photo by Bermix Studio on Unsplash

The Quantiacs Q16 Contest

The current Quantiacs Q16 contest focuses on a survivorship-bias free set of cryptocurrencies built as follows:

  • we provide data for cryptocurrencies from January 1st 2014;
  • we define a “liquid” universe of cryptocurrencies at a given point in time by considering the top 10 in terms of market capitalization using data from coinmarketcap;
  • we include data for all cryptocurrencies which at least once since January 1st 2014 were part of the top 10 terms of market capitalization;
  • we provide a filter function which for each point in time selects assets which are part of the “liquid” universe.

For getting started we recommend making an account at Quantiacs and starting from the Q16 Quick Start Python template which is publicly available on our github page.

The Python Code

The full Python code for the simple template is:

import xarray as xr

import qnt.ta as qnta
import qnt.backtester as qnbt
import as qndata

def load_data(period):
return qndata.cryptodaily_load_data(tail=period)

def strategy(data):
close = data.sel(field="close")
is_liquid = data.sel(field="is_liquid")
sma_slow = qnta.sma(close, 200).isel(time=-1)
sma_fast = qnta.sma(close, 20).isel(time=-1)
weights = xr.where(sma_slow < sma_fast, 1, 0)
weights = weights * is_liquid
weights = weights / 10.0
return weights

weights = qnbt.backtest(
competition_type = "crypto_daily_long",
load_data = load_data,
lookback_period = 365,
start_date = "2014-01-01",
strategy = strategy

The code consists of 4 parts:

  • first of all, we load the needed Python libraries, xarray and the Quantiacs library;
  • next, we define a function which loads the cryptocurrency data on a daily basis. The function loads historical data for all cryptocurrencies which were at least one liquid enough;
  • the function defining the strategy is a trivial long-only crossover system. We use the “close” field for defining the averages used for the crossing and a logical field “is_liquid” which tags cryptocurrencies which at a given point in time were among the top 10 according to market capitalization. After computing weights, the filter sets to 0 positions for cryptocurrencies which are not among the top 10.
  • finally we compute allocation weights calling the built-in backtester.

This simple example can be used a starting point for more complex ideas. The liquidity filter can be easily applied to the other examples we provide for the past contests:

Submissions will be accepted until end of October 2021 and, after the live evaluation phase, 2M USD will be allocated to the best sytems.

Do you have questions? Write us on our Forum!



Geek Culture

Quantiacs is building a crowdsourced quant fund and provides quants worldwide with free data, software and computational resources.