| Overall Statistics |
|
Total Orders 0 Average Win 0% Average Loss 0% Compounding Annual Return 0% Drawdown 0% Expectancy 0 Start Equity 100000 End Equity 100000 Net Profit 0% Sharpe Ratio 0 Sortino Ratio 0 Probabilistic Sharpe Ratio 0% Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0 Beta 0 Annual Standard Deviation 0 Annual Variance 0 Information Ratio -0.769 Tracking Error 0.174 Treynor Ratio 0 Total Fees $0.00 Estimated Strategy Capacity $0 Lowest Capacity Asset Portfolio Turnover 0% |
from AlgorithmImports import *
class CryptoMarketCapUniverseAlgorithm(QCAlgorithm):
def initialize(self) -> None:
self.set_start_date(2020, 1, 1)
self.set_start_date(2020, 3, 1)
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, self._select_assets)
def _select_assets(self, data: List[CoinGeckoUniverse]) -> 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:]
]
# class GeekyLightBrownPigeon(QCAlgorithm):
# def initialize(self) -> None:
# # Setup
# self.set_start_date(2021, 1, 1)
# self.set_end_date(2021, 3, 1)
# self.set_account_currency("USD")
# self.set_cash(100_000)
# self.set_brokerage_model(BrokerageName.COINBASE, AccountType.CASH)
# # Universe
# self.universe_settings.resolution = Resolution.HOUR
# 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.debug(f"Market pairs {self._market_pairs}")
# self._universe = self.add_universe(CoinGeckoUniverse, self._select_assets)
# # Init
# self._data_symbol = {}
# def _select_assets(self, data: List[CoinGeckoUniverse]) -> 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.
# [self.debug(f"Coin {d.coin}") for d in data]
# 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)[-50:]
# ]
# # 2
# # selected = sorted(data, key=lambda x: x.market_cap, reverse=True)[:5]
# # # Use the CreateSymbol method to generate the Symbol object for
# # return [x.create_symbol(Market.BINANCE, "USD") for x in selected]
# def on_securities_changed(self, changes):
# for security in changes.added_securities:
# symbol = security.symbol
# if symbol not in self._data_symbol:
# self._data_symbol[symbol] = SymbolData(symbol, self)
# self.debug("Symbol added {symbol}")
# for security in chagnes.removed_securities:
# symbol = security.symbol
# self.debug("Symbol removed {symbol}")
# def on_data(self, data: Slice):
# self.debug("Time {self.time}")
# for x in self.active_securities.values:
# symbol = x.symbol
# self.set_holdings(symbol, 0.02)
# for x in self._universe:
# symbol = x.symbol
# self.set_holdings(symbol, 0.02)
# symbols = [symbol for symbol in self._universe.selected if self.securities[symbol].price]
# for s in symbols:
# self.debug(f"Symbol {symbol}")
# self.set_holdings(symbol, 0.02)
# class SymbolData(object):
# def __init__(self, symbol, algo):
# self.symbol = symbol
# self.algo = algo
# history_df = self.algo.history(self.symbol, 30, Resolution.HOUR, flatten=True)
# # self.debug(f"history {history_df}")