Overall Statistics
Total Trades
30
Average Win
51.23%
Average Loss
-6.30%
Compounding Annual Return
246.610%
Drawdown
37.000%
Expectancy
5.088
Net Profit
2608.917%
Sharpe Ratio
3.17
Probabilistic Sharpe Ratio
95.031%
Loss Rate
33%
Win Rate
67%
Profit-Loss Ratio
8.13
Alpha
1.742
Beta
-0.005
Annual Standard Deviation
0.548
Annual Variance
0.301
Information Ratio
1.076
Tracking Error
0.824
Treynor Ratio
-346.392
Total Fees
$0.00
Estimated Strategy Capacity
$12000000.00
Lowest Capacity Asset
ETHUSD XJ
class CalmAsparagusJackal(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2018, 10, 21)
        self.Settings.FreePortfolioValuePercentage = .005
        self.SetCash(6418)
        self.SetBenchmark(SecurityType.Crypto, "BTCUSD")
        self.AddCrypto("BTCUSD", Resolution.Daily).Symbol
        self.AddCrypto("ETHUSD", Resolution.Daily).Symbol
        self.btcma = self.EMA("BTCUSD", 2, Resolution.Daily)
        self.mama = self.EMA("ETHUSD", 2, Resolution.Daily)
        self.baseline = self.ALMA("BTCUSD", 200, Resolution.Daily)
        self.SetBenchmark("BTCUSD")
        self.btcma.Updated += self.btcmaUpdated
        self.btcWin = RollingWindow[IndicatorDataPoint](50)
        self.mama.Updated += self.mamaUpdated
        self.mamaWin = RollingWindow[IndicatorDataPoint](50)
        self.SetWarmUp(200, Resolution.Daily)
        
    def btcmaUpdated(self, sender, updated):
        self.btcWin.Add(updated)
        
    def mamaUpdated(self, sender, updated):
        self.mamaWin.Add(updated)
        
    def OnData(self, data):
        
        if not self.baseline.IsReady:
            return
        
        bp1 = self.btcWin[49].Value
        bp2 = self.btcWin[0].Value
        mp1 = self.mamaWin[49].Value
        mp2 = self.mamaWin[0].Value
        
        btc_pct = ((bp2 - bp1)/bp1)
        eth_pct = ((mp2 - mp1)/mp1)
        dif_1 = eth_pct - btc_pct
        dif_2 = btc_pct - eth_pct
        
        if not self.Portfolio.Invested:
            if self.Securities["BTCUSD"].Close > self.baseline.Current.Value*1.05:
                if dif_1 >= .01:
                    self.SetHoldings("ETHUSD", 1)
                elif dif_2 >= .01:
                    self.SetHoldings("BTCUSD", 1)
                else: return
            else: return
        else:
            if self.Securities["BTCUSD"].Close > self.baseline.Current.Value:
                if dif_1 >= .05:
                    limitPrice = round(self.Securities["BTCUSD"].Price * 1.01, 2)
                    quantity = self.Portfolio.CashBook["BTC"].Amount
                    self.LimitOrder("BTCUSD", -quantity, limitPrice)
                    self.SetHoldings("ETHUSD", 1)
                elif dif_2 >= .05:
                    limitPrice = round(self.Securities["ETHUSD"].Price * 1.01, 2)
                    quantity = self.Portfolio.CashBook["ETH"].Amount
                    self.LimitOrder("ETHUSD", -quantity, limitPrice)
                    self.SetHoldings("BTCUSD", 1)
                else: return
            else: self.Liquidate()