Avoiding Survivorship Bias in Python Crypto Backtesting

Avoiding Survivorship Bias in Python Crypto Backtesting EduTechBuddy.com © edutechbuddy.com
Avoiding Survivorship Bias in Python Crypto Backtesting © edutechbuddy.com
Learn how to build more reliable cryptocurrency backtests in Python by reconstructing historical asset universes and handling delisting events to prevent survivorship bias.

Python-based cryptocurrency backtests can look accurate, but if the asset universe isn't rebuilt as it was at each decision point, results may mislead developers. Survivorship bias creeps in when backtests include only assets still active today, leaving out coins or tokens that were delisted or vanished during the test period. This skews strategy results, making them appear stronger than they would have been in real trading. The bias shows up when a historical sample keeps only assets visible at the end, while failed, delisted, or discontinued assets drop out. That overstates performance because the weakest outcomes are gone before the strategy is measured. In crypto markets, this bias matters, since exchange listings and trading pairs can disappear even if the token itself still exists elsewhere.

Why Point-in-Time Asset Universes Matter

Developers can counter this by using point-in-time universe construction. This method includes only assets available for trading at each historical date in the backtest. The result: the backtest matches the real choices a trader could have made, instead of filtering out assets that failed or were later removed from exchanges. Quantitative-investing best practices call for using only information that was public at the time of portfolio construction and not limiting data to surviving companies. This helps avoid inflating backtest results to levels that can't be repeated in the future.

Building a Historical Asset Directory in Python

A practical first step is to build a table that logs each asset's listing and delisting dates. For example, with pandas, you can set up a DataFrame where each row lists the asset symbol, the date it was listed, and the date it was delisted (if any):

import pandas as pd
assets = pd.DataFrame([
 { "asset": "BTC", "listed_at": "2018-01-01", "delisted_at": None },
 { "asset": "ETH", "listed_at": "2018-01-01", "delisted_at": None },
 { "asset": "ALT_A", "listed_at": "2020-03-01", "delisted_at": "2023-06-15" },
 { "asset": "ALT_B", "listed_at": "2021-01-01", "delisted_at": "2022-11-10" }
])
assets["listed_at"] = pd.to_datetime( assets["listed_at"] )
assets["delisted_at"] = pd.to_datetime( assets["delisted_at"] )

These dates are for illustration. In real research, you may need to separate the status of a trading pair on a specific exchange from the broader existence of the asset. Exchange delisting isn't a single event but can involve several operational dates: the end of deposits, the end of trading, and the last withdrawal deadline. For instance, a delisting-monitoring service tracks official notices from exchanges like Binance, OKX, Bybit, and KuCoin, pulling the dates when deposits stop, trading ends, and the last day users can withdraw. This matters for backtesting because a strategy might have been able to sell an asset after deposits stopped but before trading ended, while withdrawal could still be possible after market access closed.

Reconstructing the Universe at Each Date

On any historical date, the eligible universe includes assets listed on or before that date and not delisted before it. You can code this logic in Python to filter the DataFrame at each backtest step, so only tradable assets are included at each point. Historical-universe reconstruction should model exchange, trading pair, deposit status, trading status, and withdrawal status separately, instead of treating the token symbol as always tradable.

Handling Delisting Events with Event Tables

Deleting delisted assets from the directory hides important details. Instead, keep a separate event table that logs delisting, trading suspensions, and other events. For example:

events = pd.DataFrame([
 { "asset": "ALT_A", "event": "TRADING_PAIR_DELISTED", "exchange": "EXCHANGE_A", "effective_at": "2023-06-15", "reason": "Trading pair removal" },
 { "asset": "ALT_B", "event": "TRADING_SUSPENDED", "exchange": "EXCHANGE_A", "effective_at": "2022-11-10", "reason": "Trading suspension" }
])
events["effective_at"] = pd.to_datetime( events["effective_at"] )

This method keeps the context of each event: exchange, asset, event type, effective date, and reason. For strict point-in-time research, also track the announcement date, since a strategy might react to a delisting announcement before the event takes effect. Venue-specific delistings need separate records for listing, trading suspension, and withdrawal, not just a single global "asset death" date. For example, on June 27, 2023, Robinhood removed Cardano, Polygon, and Solana from its supported crypto assets after the U.S. Securities and Exchange Commission identified those tokens as securities in lawsuits against major crypto exchanges. This shows why a backtest must separate an asset’s existence from its availability on a particular venue, since an asset may stay active elsewhere while becoming unavailable to users of one exchange.

Comparing Survivor-Only and Historical Universes

To see how survivorship bias changes results, compare a portfolio built from the historical universe at a given date with one that includes only assets still active at the end of the sample. For example, filtering the DataFrame for assets not delisted before a chosen end date gives the survivor-only universe. This comparison shows how leaving out delisted assets can distort backtest results. A 2025 ACM International Conference on AI in Finance paper found that excluding failed coins changes the cross-section especially during crash regimes, when the assets most likely to disappear are also among the worst performers. The study reported that survivorship-free crypto samples had only seven to nine formation dates, so their statistical significance was suggestive rather than conclusive, but pointed out that hiding the coins that died most reshapes the cross-section.

Consistent Portfolio Performance Calculation

When calculating portfolio returns, use only information available at the time of portfolio formation. For an equal-weighted portfolio, you can define a function that drops missing returns and averages the rest:

def equal_weight_return(returns):
 returns = returns.dropna()
 if returns.empty:
  return None
 weights = 1 / len(returns)
 return (weights * returns).sum()

example_returns = pd.Series({ "BTC": 0.20, "ETH": 0.40, "ALT_A": -0.40, "ALT_B": -1.00 })
portfolio_return = equal_weight_return( example_returns )
print("Portfolio return:", portfolio_return)

This example assumes all assets are held over the same period, with a zero final value for a fully delisted asset. In practice, how you treat delisted assets should match the actual exit opportunity, residual value, or conversion terms, not just set to zero. Binance’s periodic asset reviews, for example, keep producing delistings and trading-pair removals. One review scheduled the delisting of ALCX, ARDR, NFP, and POND effective July 10, 2026, while another removed 14 FDUSD margin pairs on January 6, affecting assets including BCH, ADA, LINK, AVAX, LTC, SUI, and TAO. These actions show that the investable universe can change through both full asset delistings and narrower pair-level removals. A robust backtest should log the exact exchange announcement, trading cutoff, affected pair, and any liquidation or withdrawal instructions.

Preventing Look-Ahead Bias

Point-in-time universe construction is just one part of building a credible backtest. Developers also need to make sure asset rankings, volume filters, and rebalancing schedules use only data available before each decision. Delisting information should be timestamped accurately, and missing outcomes shouldn't be ignored. Backtesting methods must also control for look-ahead bias, which happens when information unavailable at the portfolio-formation date enters the historical decision process. Performance statistics like returns, drawdown, Sharpe ratio, and hit rate should be recalculated after including assets that later disappeared or became untradable. For more on handling forward returns and overlapping labels in Python, see this related guide.

Key Takeaways for Python Crypto Backtesting

Survivorship bias in crypto backtesting goes beyond missing prices. It involves rebuilding the actual market universe at each decision point, keeping listing and delisting events, and documenting terminal outcomes. Python gives you the tools to organize and test these elements, but the reliability of results depends on the completeness and accuracy of historical records. A credible backtest must include assets that disappeared, not just those that survived. Researchers have warned that survivorship-free crypto evidence can be statistically underpowered when only a small number of historical formation dates are available, but this doesn't justify leaving out failed assets. Instead, researchers should report sample size, formation dates, missing observations, and confidence intervals clearly, and publish both survivorship-biased and survivorship-aware results, explaining the universe-construction rules and showing how delistings affect the strategy’s returns and drawdowns. For more on the technical aspects of backtesting and bias prevention, see the ACM International Conference on AI in Finance proceedings.

Camila Ferreira Editor EduTechBuddy.com
Co-Founder

Camila Ferreira

Camila Ferreira is the Co-Founder of EduTechBuddy, where her editorial focus is programming education and practical software development skills. Her primary subjects include Python programming, Git version control, and the fundamental concepts beginners need to understand when working with code.