Overall Statistics
Total Trades
26
Average Win
0.02%
Average Loss
-0.13%
Compounding Annual Return
-33.280%
Drawdown
1.000%
Expectancy
-0.883
Net Profit
-0.750%
Sharpe Ratio
-0.285
Sortino Ratio
-0.292
Probabilistic Sharpe Ratio
45.998%
Loss Rate
90%
Win Rate
10%
Profit-Loss Ratio
0.17
Alpha
0
Beta
0
Annual Standard Deviation
0.106
Annual Variance
0.011
Information Ratio
0.14
Tracking Error
0.106
Treynor Ratio
0
Total Fees
$267464.11
Estimated Strategy Capacity
$14000000.00
Lowest Capacity Asset
XRPUSDT 18N
Portfolio Turnover
28.76%
from AlgorithmImports import *

class CoinAPIDataAlgorithm(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2023, 1, 1)
        self.SetEndDate(2023, 1, 5)
        self.SetCash("BUSD", 100000)
        self.SetCash("BTC", 1000)

        # Kraken accepts both Cash and Margin type account.
        self.SetBrokerageModel(BrokerageName.Binance, AccountType.Margin)

        # Warm up the security with the last known price to avoid conversion error
        self.SetSecurityInitializer(lambda security: security.SetMarketPrice(self.GetLastKnownPrice(security)))
        
        self.UniverseSettings.Resolution = Resolution.Daily
        # Add universe selection of cryptos based on coarse fundamentals
        self.AddUniverse(CryptoCoarseFundamentalUniverse(Market.Binance, self.UniverseSettings, self.UniverseSelectionFilter))
        
        self.AddAlpha(ConstantAlphaModel(InsightType.Price, InsightDirection.Up, timedelta(days=1), 0.025, None))
        self.SetPortfolioConstruction(EqualWeightingPortfolioConstructionModel())

    def UniverseSelectionFilter(self, crypto_coarse):
        return [d.Symbol for d in sorted([x for x in crypto_coarse if x.VolumeInUsd], key=lambda x: x.VolumeInUsd, reverse=True)[:5]]

    def OnSecuritiesChanged(self, changes):
        for security in changes.AddedSecurities:
            # Historical data
            history = self.History(security.Symbol, 30, Resolution.Daily)
            self.Debug(f"We got {len(history)} items from our history request")

"""
from AlgorithmImports import *

class CryptoCoarseFundamentalUniverseSelectionAlgorithm(QCAlgorithm): 
    def Initialize(self):
        self.SetStartDate(2024, 1, 1)
        self.SetEndDate(2024, 1, 5)
        self.SetCash(100000)
        
        self.SetBrokerageModel(BrokerageName.Binance, AccountType.Cash)
        
        # Warm up the security with the last known price to avoid conversion error
        self.SetSecurityInitializer(lambda security: security.SetMarketPrice(self.GetLastKnownPrice(security)))

        self.UniverseSettings.Resolution = Resolution.Daily
        # Add universe selection of cryptos based on coarse fundamentals
        self.AddUniverse(CryptoCoarseFundamentalUniverse(Market.Binance, self.UniverseSettings, self.UniverseSelectionFilter))

    def UniverseSelectionFilter(self, data):
        filtered = [datum for datum in data
                if datum.Price >= 10 and datum.VolumeInUsd]
        sorted_by_volume_in_usd = sorted(filtered, key=lambda datum: datum.VolumeInUsd, reverse=True)[:10]

        return [datum.Symbol for datum in sorted_by_volume_in_usd]

    def OnData(self, data):
        for symbol in self.Securities.Keys:
            symbol_value = self.AddCrypto(symbol, Resolution.Daily).Symbol
            self.MarketOrder(symbol_value, 0.00001)

    def OnSecuritiesChanged(self, changes):
        for security in changes.RemovedSecurities:
            self.Liquidate(security.Symbol)
"""