---
title: "Crypto Market Cap"
description: "Crypto Market Cap dataset from CoinGecko."
canonical: https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/coingecko/crypto-market-cap
markdown: https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/coingecko/crypto-market-cap.md
language: python
source: https://github.com/QuantConnect/Documentation/tree/master/03%20Writing%20Algorithms/14%20Datasets/10%20CoinGecko/01%20Crypto%20Market%20Cap
modified: 2026-10-30
index: https://www.quantconnect.com/llms.txt
---

# Crypto Market Cap

[Documentation](https://www.quantconnect.com/docs/v2.md) > [Writing Algorithms](https://www.quantconnect.com/docs/v2/writing-algorithms.md) > Datasets > [CoinGecko](https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/coingecko.md) > Crypto Market Cap

> Code examples are shown in Python. Append `?lang=csharp` to this URL for the C# version of this page.

## Introduction

The Crypto Market Cap dataset by CoinGecko tracks the market cap of cryptocurrencies. The data covers 620 cryptocurrencies that are supported by QuantConnect, starts in 28 April 2013, and is delivered on a daily frequency. This dataset is created by scraping CoinGecko's Market Chart.

For more information about the Crypto Market Cap dataset, including CLI commands and pricing, see the [dataset listing](https://www.quantconnect.com/datasets/coingecko-crypto-marketcap).

## About the Provider

[CoinGecko](https://www.coingecko.com/) was founded in 2014 by TM Lee (CEO) and Bobby Ong (COO) with the mission to democratize the access of crypto data and empower users with actionable insights. We also deep dive into the crypto space to deliver valuable insights to our users through our cryptocurrency reports, as well as our publications, newsletter, and more.

## Getting Started

The following snippet demonstrates how to request data from the CoinGecko Crypto Market Cap dataset:

```python
self.btc = self.add_data(CoinGecko, "BTC").symbol
self._universe = self.add_universe(CoinGeckoUniverse, self.universe_selection)
```

## Data Summary

The following table describes the dataset properties:

| Property | Value |
| --- | --- |
| Start Date | 28 April 2013 |
| Asset Coverage | 620 cryptocurrencies |
| Resolution | Daily |
| Timezone | UTC |

## Requesting Data

To add CoinGecko Crypto Market Cap data to your algorithm, call the `add_data` method. Save a reference to the dataset `Symbol` so you can access the data later in your algorithm.

```python
from AlgorithmImports import *

class CoinGeckoMarketCapDataAlgorithm(QCAlgorithm):
    def initialize(self) -> None:
        self.set_start_date(2019, 1, 1)
        self.set_end_date(2020, 6, 1)
        self.set_cash(100000)

        self.btcusd = self.add_crypto("BTCUSD", Resolution.DAILY).symbol
        self.dataset_symbol = self.add_data(CoinGecko, "BTC").symbol
```

## Accessing Data

To get the current Crypto Market Cap data, index the current [`Slice`](https://www.quantconnect.com/docs/v2/writing-algorithms/key-concepts/time-modeling/timeslices.md) with the dataset `Symbol`. `Slice` objects deliver unique events to your algorithm as they happen, but the `Slice` may not contain data for your dataset at every time step. To avoid issues, check if the `Slice` contains the data you want before you index it.

```python
def on_data(self, slice: Slice) -> None:
    if slice.contains_key(self.dataset_symbol):
        data_point = slice[self.dataset_symbol]
        self.log(f"{self.dataset_symbol} market cap::volume at {slice.time}: {data_point.market_cap}::{data_point.volume}")
```

To iterate through all of the dataset objects in the current `Slice`, call the `get` method.

```python
def on_data(self, slice: Slice) -> None:
    for dataset_symbol, data_point in slice.get(CoinGecko).items():
        self.log(f"{dataset_symbol} market cap::volume at {slice.time}: {data_point.market_cap}::{data_point.volume}")
```

## Historical Data

To get historical CoinGecko Crypto Market Cap data, call the `history` method with the dataset `Symbol`. If there is no data in the period you request, the history result is empty.

```python
# DataFrame
history_df = self.history(self.dataset_symbol, 100, Resolution.DAILY)

# Dataset objects
history_bars = self.history[CoinGecko](self.dataset_symbol, 100, Resolution.DAILY)
```

For more information about historical data, see [History Requests](https://www.quantconnect.com/docs/v2/writing-algorithms/historical-data/history-requests.md).

## Universe Selection

To select a dynamic universe of Cryptos based on CoinGecko Crypto Market Cap data, call the `add_universe` method with the `CoinGeckoUniverse` class and a selection function. Note that the filtered output is a list of names of the coins. If corresponding tradable crypto pairs are preferred, call `create_symbol(market, quoteCurrency)` method for each output item.

```python
class CryptoMarketCapUniverseAlgorithm(QCAlgorithm):

    def initialize(self) -> None:
        self.set_account_currency("USD")
        self._market = Market.COINBASE
        self._market_pairs = [
            x.key.symbol
            for x in self.symbol_properties_database.get_symbol_properties_list(self._market)
            if x.value.quote_currency == self.account_currency
        ]
        self._universe = self.add_universe(CoinGeckoUniverse, 'CoinGeckoUniverse', Resolution.DAILY, self._select_assets)

    def _select_assets(self, data: List[CoinGecko]) -> List[Symbol]:
        for datum in data:
            self.debug(f'{datum.coin},{datum.market_cap},{datum.price}')

        # Select the coins that our brokerage supports and have a quote currency that matches
        # our account currency.
        tradable_coins = [d for d in data if d.coin + self.account_currency in self._market_pairs]
        # Select the largest coins and create their Symbol objects.
        return [
            c.create_symbol(self._market, self.account_currency)
            for c in sorted(tradable_coins, key=lambda x: x.market_cap)[-10:]
        ]
```

For more information about dynamic universes, see [Universes](https://www.quantconnect.com/docs/v2/writing-algorithms/universes/key-concepts.md).

## Universe History

You can get historical universe data in an algorithm and in the Research Environment.

### Historical Universe Data in Algorithms

To get historical universe data in an algorithm, call the `history` method with the `Universe` object and the lookback period. If there is no data in the period you request, the history result is empty.

```python
# DataFrame example where the columns are the CoinGeckoUniverse attributes:
history_df = self.history(self._universe, 30, Resolution.DAILY, flatten=True)

# Series example where the values are lists of CoinGeckoUniverse objects:
universe_history = self.history(self._universe, 30, Resolution.DAILY)
for (_, time), coins in universe_history.items():
    for coin in coins:
        self.log(f"{coin.symbol.value} market cap at {coin.end_time}: {coin.market_cap}")
```

### Historical Universe Data in Research

To get historical universe data in research, call the `universe_history` method with the `Universe` object, a start date, and an end date. This method returns the filtered universe. If there is no data in the period you request, the history result is empty.

```python
# DataFrame example where the columns are the CoinGeckoUniverse attributes:
history_df = qb.universe_history(universe, qb.time-timedelta(30), qb.time, flatten=True)

# Series example where the values are lists of CoinGeckoUniverse objects:
universe_history = qb.universe_history(universe, qb.time-timedelta(30), qb.time)
for (_, time), coins in universe_history.items():
    for coin in coins:
        print(f"{coin.symbol.value} market cap at {coin.end_time}: {coin.market_cap}")
```

You can call the `history` method in Research.

## Remove Subscriptions

To remove your subscription to CoinGecko Crypto Market Cap data, call the `remove_security` method.

```python
self.remove_security(self.dataset_symbol)
```

## Supported Assets

The following table shows the available Cryptocurrencies:

| Supported Cryptocurrency |  |  |  |  |  |
| --- | --- | --- | --- | --- | --- |
| 1INCH | AAA | AAPL | AAVE | ACA | ACH |
| ACM | ADA | ADX | AE | AERGO | AGIX |
| AGLD | AION | AKRO | ALBT | ALCX | ALEPH |
| ALGO | ALICE | ALPACA | ALPHA | ALPINE | AMB |
| AMC | AMP | AMPL | ANC | ANKR | ANT |
| ANY | APE | API3 | APPC | APT | AR |
| ARDR | ARK | ARPA | ASD | ASM | ASR |
| AST | ASTR | ATA | ATLAS | ATM | ATOM |
| AUCTION | AUDIO | AURY | AUTO | AVA | AVAX |
| AVT | AXS | B21 | BADGER | BAKE | BAL |
| BAND | BAO | BAR | BAT | BB | BCC |
| BCD | BCH | BCN | BCPT | BDOT | BEAM |
| BEL | BEST | BETA | BETH | BFT | BICO |
| BIDR | BIFI | BIT | BITO | BLT | BLZ |
| BMI | BNB | BNT | BNTX | BNX | BOBA |
| BOND | BOSON | BOT | BRD | BRL | BRZ |
| BSV | BSW | BTC | BTCB | BTCST | BTG |
| BTRST | BTS | BTSE | BTT | BULL | BURGER |
| BUSD | BVOL | BYND | BZRX | C98 | CAKE |
| CCD | CDT | CEL | CELO | CELR | CFX |
| CGC | CHAT | CHESS | CHEX | CHR | CHSB |
| CHZ | CITY | CKB | CLO | CLOAK | CLV |
| CMT | CND | CNHT | COCOS | COIN | COMP |
| CONV | COPE | COS | COTI | COVAL | COVER |
| CQT | CREAM | CRO | CRON | CRV | CTK |
| CTSI | CTX | CTXC | CUSDT | CVC | CVP |
| CVX | DAI | DAR | DASH | DATA | DAWN |
| DCR | DDX | DEGO | DENT | DESO | DEXE |
| DF | DFL | DGB | DGD | DIA | DLT |
| DMG | DNT | DOCK | DODO | DOGE | DORA |
| DOT | DREP | DUSK | DVF | DYDX | EDEN |
| EGLD | ELF | EMB | ENG | ENJ | ENS |
| EOS | EPS | EPX | ERN | ESS | ETC |
| ETH | ETH2 | ETHE | ETP | EURS | EURT |
| EVX | EWT | EXO | EZ | FARM | FB |
| FCL | FET | FIDA | FIL | FIO | FIRO |
| FIS | FLM | FLOW | FLUX | FOR | FORTH |
| FOX | FRONT | FTM | FTT | FUEL | FUN |
| FX | FXS | GAL | GALA | GAS | GENE |
| GFI | GHST | GLD | GLM | GLMR | GLXY |
| GME | GMT | GMX | GNO | GNT | GO |
| GODS | GOG | GOT | GRS | GRT | GT |
| GTC | GTO | GTX | GVT | GYEN | HARD |
| HBAR | HC | HEGIC | HFT | HGET | HIGH |
| HIVE | HMT | HNT | HOLY | HOOK | HOT |
| HT | HUM | HXRO | ICE | ICN | ICP |
| ICX | ID | IDEX | IDRT | ILV | IMX |
| INJ | INS | INTER | INV | IOST | IOTX |
| IQ | IRIS | JASMY | JET | JOE | JST |
| JUV | KAI | KAN | KAR | KAVA | KDA |
| KEEP | KEY | KIN | KLAY | KMD | KNC |
| KP3R | KRL | KSHIB | KSM | LAZIO | LCX |
| LDO | LEND | LEO | LEVER | LINA | LINK |
| LIT | LOKA | LOOKS | LOOM | LPT | LQTY |
| LRC | LSK | LTC | LTO | LUA | LUN |
| LUNA | LUNC | LYM | MAGIC | MANA | MAPS |
| MASK | MATH | MATIC | MBL | MBOX | MBS |
| MC | MCB | MCO | MCO2 | MDA | MDT |
| MDX | MEDIA | MER | MFT | MIM | MINA |
| MIR | MITH | MKR | MLN | MNGO | MOB |
| MOD | MOVR | MPL | MSOL | MSTR | MTA |
| MTH | MTL | MULTI | MUSD | NAS | NAV |
| NBS | NCASH | NCT | NEAR | NEBL | NEO |
| NEXO | NKN | NMR | NPXS | NU | NULS |
| NXS | OAX | OCEAN | ODE | OG | OGN |
| OKB | OM | OMG | OMNI | ONE | ONG |
| ONT | OOKI | OP | ORBS | ORCA | ORN |
| ORS | OSMO | OST | OXT | OXY | PASS |
| PAXG | PEOPLE | PERL | PERP | PHA | PHB |
| PHX | PIVX | PLA | PLANETS | PLU | PNG |
| PNK | PNT | POA | POE | POLIS | POLS |
| POLY | POLYX | POND | PORT | PORTO | POWR |
| PPT | PRISM | PRO | PROM | PROS | PSG |
| PTU | PUNDIX | PYR | QI | QKC | QLC |
| QNT | QRDO | QSP | QTF | QTUM | QUICK |
| RAD | RAI | RAMP | RARE | RARI | RAY |
| RBN | RBTC | RCN | RDN | REAL | REEF |
| REI | REN | RENBTC | REP | REQ | RGT |
| RIF | RLC | RLY | RNDR | RON | ROOK |
| ROSE | RRT | RSR | RUNE | RVN | SALT |
| SAN | SAND | SANTOS | SC | SCRT | SFP |
| SGB | SHIB | SHPING | SKL | SKY | SLND |
| SLP | SLRS | SNGLS | SNM | SNT | SNX |
| SNY | SOL | SOS | SPARTA | SPELL | SPY |
| SRM | SSV | STARS | STEEM | STEP | STETH |
| STG | STMX | STORJ | STORM | STPT | STRAX |
| STSOL | STX | SUB | SUKU | SUN | SUPER |
| SUSD | SUSHI | SWRV | SXP | SYS | T |
| TBTC | TCT | TFUEL | THETA | TKO | TLM |
| TLOS | TNB | TNT | TOMO | TORN | TRAC |
| TRADE | TRB | TRIBE | TROY | TRU | TRX |
| TRYB | TSLA | TULIP | TUSD | TVK | TWT |
| UFT | UMA | UNFI | UNI | UOS | UPI |
| USDC | USDP | USDS | USDT | USTC | UTK |
| VAI | VEE | VELO | VEN | VET | VGX |
| VIA | VIB | VIBE | VIDT | VITE | VOXEL |
| VTHO | WABI | WAN | WAVES | WAXP | WBTC |
| WCFG | WILD | WIN | WING | WINGS | WNCG |
| WNDR | WNXM | WOO | WPR | WRX | WTC |
| XAUT | XCHF | XDC | XDG | XEC | XEM |
| XLM | XMR | XNO | XRA | XRD | XRP |
| XTZ | XVG | XVS | XYO | YFI | YFII |
| YGG | ZCN | ZEC | ZEN | ZIL | ZM |
| ZMT | ZRX |  |  |  |  |

## Example Applications

The CoinGecko Crypto Market Cap dataset provides information on the size of the crypto coin and can be used to compare the size of one coin to another. Examples include the following strategies:

- Construct a major crypto index fund.
- Invest in the cryptos with the fastest growth in market size.
- Red flag stop when there might be a crypto bank run.

### Classic Algorithm Example

The following example algorithm buy BTCUSD when the market cap of BTC is rising, while sell it when the market cap of BTC is dropping.

```python
from AlgorithmImports import *

class CoinGeckoAlgorithm(QCAlgorithm):

    def initialize(self) -> None:
        self.set_start_date(2024, 9, 1)
        self.set_end_date(2024, 12, 31)
        # Request BTCUSD crypto data for trading.
        self._crypto = self.add_crypto("BTCUSD")
        # Request CoinGecko market cap data of BTC for trade signal generation.
        self._custom_data_symbol = self.add_data(CoinGecko, "BTC").symbol
        # Save the last two market cap values for capital flow analysis.
        self._window = RollingWindow(2)

    def on_data(self, data: Slice) -> None:
        # Trade based on updated market cap data.
        market_cap_data = data.get(CoinGecko)
        if not market_cap_data or self._custom_data_symbol not in market_cap_data:
            return
        # Update the window only when fresh CoinGecko data arrives.
        self._window.add(market_cap_data[self._custom_data_symbol])
        if not self._window.is_ready:
            return
        # Buy BTCUSD when BTC market cap is increasing and capital is flowing in.
        if self._window[0].market_cap > self._window[1].market_cap:
            self.set_holdings(self._crypto, 1)
        # Sell when capital is flowing out of BTC.
        else:
            self.set_holdings(self._crypto, -0.5)

    def on_order_event(self, order_event: OrderEvent) -> None:
        if order_event.status == OrderStatus.FILLED:
            self.debug(f"Purchased Crypto: {order_event.symbol}")
```

### Framework Algorithm Example

The following example algorithm buy BTCUSD when the market cap of BTC is rising, while sell it when the market cap of BTC is dropping with framework implementation.

```python
from AlgorithmImports import *

class CoinGeckoAlgorithm(QCAlgorithm):

    def initialize(self) -> None:
        self.set_start_date(2024, 9, 1)
        self.set_end_date(2024, 12, 31)

        # Request CoinGecko Market Cap data of BTC for trade signal generation
        symbol = self.add_data(CoinGecko, "BTC").symbol
        # Request BTCUSD crypto data for trading
        crypto = self.add_crypto("BTCUSD", market=Market.COINBASE).symbol
        symbol_dict = {symbol: crypto}
        # Use RollingWindow to save the last 2 market cap data for capital flow analysis
        window = {symbol: RollingWindow[CoinGecko](2)}

        # Custom alpha model that emit insights based on updated market cap data
        self.add_alpha(CoinGeckoAlphaModel(symbol_dict, window))
        # Equal invest to evenly dissipate capital concentration risk from non-systematic individual risky event
        self.set_portfolio_construction(InsightWeightingPortfolioConstructionModel())

class CoinGeckoAlphaModel(AlphaModel):

    def __init__(self, symbol_dict: Dict[Symbol, Symbol], window: Dict[Symbol, RollingWindow[CoinGecko]]) -> None:
        self.symbol_dict = symbol_dict
        self.window = window

    def update(self, algorithm: QCAlgorithm, slice: Slice) -> List[Insight]:
        insights = []

        # Trade based on updated market cap data
        data = slice.get(CoinGecko)
        for dataset_symbol, crypto_symbol in self.symbol_dict.items():
            if not data.contains_key(dataset_symbol):
                continue

            # Update RollingWindow for updated comparison
            self.window[dataset_symbol].add(data[dataset_symbol])

            # Can only compare market cap if the RollingWindow is ready
            window = self.window[dataset_symbol]
            if not window.is_ready:
                continue

            # Buy BTCUSD if the market cap of BTC is increasing, which suggests the capital flow towards BTC market and drive up the demand
            if window[0].market_cap > window[1].market_cap:
                insight = Insight.price(crypto_symbol, timedelta(1), InsightDirection.UP, weight=1)
                insights.append(insight)
            # Sell otherwise, since the capital is flowing out and the demand of BTC lowered
            else:
                insight = Insight.price(crypto_symbol, timedelta(1), InsightDirection.DOWN, weight=0.25)
                insights.append(insight)

        return insights
```

### Research Example

The following example lists US Equities having the highest 7-day sentiment.

```python
qb = QuantBook()

# Requesting Data
symbol = qb.add_data(CoinGecko, "BTC").symbol

# Historical data
history = qb.history(CoinGecko, symbol, 30, Resolution.DAILY)
for (symbol, time), row in history.iterrows():
    print(f"{symbol} sentiment at {time}: {row['marketcap']}")

# Add Universe Selection
def universe_selection(alt_coarse: List[CoinGeckoUniverse]) -> List[Symbol]:
    return [d.symbol for d in sorted([x for x in alt_coarse if x.market_cap],
        key=lambda x: x.market_cap, reverse=True)[:10]]

universe = qb.add_universe(CoinGeckoUniverse, universe_selection)

# Historical Universe data
universe_history = qb.universe_history(universe, qb.time-timedelta(10), qb.time)
for (_, time), coins in universe_history.items():
    for coin in coins:
        print(f"{coin.symbol.value} market cap at {coin.end_time}: {coin.market_cap}")
```

## Data Point Attributes

The Crypto Market Cap dataset provides `CoinGecko` and `CoinGeckoUniverse` objects.

### CoinGecko Attributes

`CoinGecko` objects have the following attributes:

*Members of `QuantConnect.DataSource.CoinGecko` (JSON): https://www.quantconnect.com/services/inspector?type=T:QuantConnect.DataSource.CoinGecko&language=python*

### CoinGeckoUniverse Attributes

`CoinGeckoUniverse` objects have the following attributes:

*Members of `QuantConnect.DataSource.CoinGeckoUniverse` (JSON): https://www.quantconnect.com/services/inspector?type=T:QuantConnect.DataSource.CoinGeckoUniverse&language=python*
