Overall Statistics
Total Trades
126
Average Win
6.15%
Average Loss
-2.59%
Compounding Annual Return
-9.213%
Drawdown
30.800%
Expectancy
0.018
Net Profit
-6.148%
Sharpe Ratio
0.066
Probabilistic Sharpe Ratio
18.178%
Loss Rate
70%
Win Rate
30%
Profit-Loss Ratio
2.37
Alpha
-0.131
Beta
1.044
Annual Standard Deviation
0.438
Annual Variance
0.192
Information Ratio
-0.292
Tracking Error
0.425
Treynor Ratio
0.028
Total Fees
$0.00
Estimated Strategy Capacity
$410000.00
Lowest Capacity Asset
BTCUSD XJ
class DeterminedRedCat(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2021, 5, 1)
        self.SetCash(100000)
        
        self.btc = self.AddCrypto("BTCUSD", Resolution.Minute, Market.GDAX).Symbol
        
        self.fourHourWindow = RollingWindow[TradeBar](2)
        
        fourHourConsolidator = TradeBarConsolidator(timedelta(hours=4))
        fourHourConsolidator.DataConsolidated += self.FourHourBarHandler
        self.SubscriptionManager.AddConsolidator(self.btc, fourHourConsolidator)
        
        self.macd = MovingAverageConvergenceDivergence(12, 26, 9, MovingAverageType.Exponential)
        self.RegisterIndicator(self.btc, self.macd, fourHourConsolidator)
        

    def OnData(self, data):
        if self.IsWarmingUp or self.btc not in data or not self.fourHourWindow.IsReady:
            return
        
        price = self.Securities[self.btc].Price
        entryQuantity = self.CalculateOrderQuantity(self.btc, 0.95)
        
        if self.macd.Histogram.Current.Value > 0 and not self.Portfolio.Invested:
            self.MarketOrder(self.btc, entryQuantity)
            self.Debug("quantity: " + str(entryQuantity) + " price: " + str(price) + " MACD: " + str(self.macd.Current.Value) + " Histogram: " + str(self.macd.Histogram.Current.Value))
            
        if self.macd.Histogram.Current.Value < 0 and self.Portfolio.Invested:
            self.Liquidate()
            self.Debug("liquidate price: " + str(price) + " MACD: " + str(self.macd.Current.Value) + " Histogram: " + str(self.macd.Histogram.Current.Value))
        
        

    def FourHourBarHandler(self, sender, bar):
        self.fourHourWindow.Add(bar)