Universes

Crypto

Introduction

A Crypto universe lets you select a basket of Cryptocurrencies based on CryptoUniverse data.

Crypto Universes

To add a universe of Cryptocurrencies, in the Initializeinitialize method, pass a CryptoUniverse to the AddUniverseadd_universe method.

def initialize(self) -> None:
    self.universe_settings.asynchronous = True
    self.universe_settings.resolution = Resolution.DAILY
    self.set_brokerage_model(BrokerageName.COINBASE, AccountType.CASH)
    
    # Add crypto universe selection
    self._universe = self.add_universe(CryptoUniverse.coinbase(lambda universe_day: [c.symbol for c in universe_day]))
private Universe _universe;
public override void Initialize()
{
    UniverseSettings.Asynchronous = true;
    UniverseSettings.Resolution = Resolution.Daily;
    SetBrokerageModel(BrokerageName.Coinbase, AccountType.Cash);
    
    // Add crypto universe selection
    _universe = AddUniverse(CryptoUniverse.Coinbase(universeDay => from x in universeDay select x.Symbol));
}

The following table shows the helper methods to create Crypto universes for the supported exchanges:

Brokerage NameHelper MethodDataset page
BrokerageName.BinanceBINANCECryptoUniverse.BinancebinanceLearn more
BrokerageName.BinanceUSBINANCE_USCryptoUniverse.BinanceUSbinance_usLearn more
BrokerageName.BitfinexBITFINEXCryptoUniverse.BitfinexbitfinexLearn more
BrokerageName.BybitBYBITCryptoUniverse.BybitbybitLearn more
BrokerageName.CoinbaseCOINBASECryptoUniverse.CoinbasecoinbaseLearn more
BrokerageName.KrakenKRAKENCryptoUniverse.KrakenkrakenLearn more

The following table describes the CryptoUniverse method arguments:

ArgumentData TypeDescriptionDefault Value
selectorFunc<IEnumerable<CryptoUniverse>, IEnumerable<Symbol>>Callable[[List[CryptoUniverse]], List[Symbol]]A function to select some of the Cryptocurrencies for the universe.
universeSettingsuniverse_settingsUniverseSettingsThe universe settings.nullNone

The filter function receives CryptoUniverse objects, which represent one of the Cryptocurrencies in the market. The Symbol objects that the filter function returns represent the universe constituents. CryptoUniverse objects have the following attributes:

To perform thorough filtering on the CryptoUniverse objects, define an isolated filter method.

def initialize(self) -> None:
    self.universe_settings.asynchronous = True
    self.universe_settings.resolution = Resolution.DAILY
    self.set_brokerage_model(BrokerageName.COINBASE, AccountType.CASH)

    # Add crypto universe selection
    self._universe = self.add_universe(CryptoUniverse.coinbase(self.universe_filter))
def universe_filter(self, universe_day): # Define the universe selection function return [cf.symbol for cf in universe_day if cf.volume >= 100 and cf.volume_in_usd > 10000]
private Universe _universe;
public override void Initialize()
{
    UniverseSettings.Asynchronous = true;
    UniverseSettings.Resolution = Resolution.Daily;
    SetBrokerageModel(BrokerageName.Coinbase, AccountType.Cash);

    // Add crypto universe selection
    _universe = AddUniverse(CryptoUniverse.Coinbase(UniverseFilter));
}

private IEnumerable<Symbol> UniverseFilter(IEnumerable< CryptoUniverse> universeDay)
{
    return universeDay.Where(cf => cf.Volume >= 100m && cf.VolumeInUsd > 10000m).Select(x => x.Symbol);
}

Historical Data

To get historical Cryptocurrency universe data, call the Historyhistory method with the Universe object and the lookback period. The return type is a IEnumerable<BaseDataCollection> and you have to cast its items to CryptoUniverse.

To get historical Cryptocurrency universe data, call the Historyhistory method with the Universe object and the lookback period. The return type is a multi-index pandas.Series of CryptoUniverse list.

var history = History(_universe, 30, Resolution.Daily);
foreach (var universeDay in history)
{
    foreach (CryptoUniverse universeItem in universeDay)
    {
        Log($"{universeItem.Symbol} price at {universeItem.EndTime}: {universeItem.Close}");
    }
}
history = self.history(self.universe, 30, Resolution.DAILY)
for (univere_symbol, time), universe_day in history.items():
    for universe_item in universe_day:
        self.log(f"{universe_item.symbol} price at {universe_item.end_time}: {universe_item.close}")

For more information about Cryptocurrency data, see Crypto.

Alternative Data Universes

An alternative data universe lets you select a basket of Cryptocurrencies based on an alternative dataset that's linked to them. If you use an alternative data universe, you limit your universe to only the securities in the dataset, which avoids unnecessary subscriptions. Currently, only the Crypto Market Cap alternative dataset supports universe selection for Crypto.

Selection Frequency

Crypto universes run on a daily basis by default. To adjust the selection schedule, see Schedule.

Live Trading Considerations

In live mode, the pipeline has a 16-hour delay. Your algorithm receives the CryptoUniverse objects at around 16:00-16:30 Coordinated Universal Time (UTC) each day, depending on the data processing task.

You can also see our Videos. You can also get in touch with us via Discord.

Did you find this page helpful?

Contribute to the documentation: