Overall Statistics |
Total Trades 54 Average Win 5.29% Average Loss -3.33% Compounding Annual Return 170.626% Drawdown 19.800% Expectancy 0.608 Net Profit 67.812% Sharpe Ratio 3.013 Probabilistic Sharpe Ratio 82.401% Loss Rate 38% Win Rate 62% Profit-Loss Ratio 1.59 Alpha 0.995 Beta 0.647 Annual Standard Deviation 0.378 Annual Variance 0.143 Information Ratio 2.464 Tracking Error 0.372 Treynor Ratio 1.758 Total Fees $0.00 Estimated Strategy Capacity $3700000.00 Lowest Capacity Asset BTCUSD XJ Portfolio Turnover 21.56% |
from AlgorithmImports import * class RetrospectiveYellowGreenAlligator(QCAlgorithm): def Initialize(self): # INITIALIZE self.SetStartDate(2023, 1, 1) self.SetEndDate(2023, 7, 9) self._cash = 100000 self.SetCash(self._cash) self.ticker = "BTCUSD" self.AddCrypto(self.ticker, Resolution.Daily, Market.GDAX).Symbol # SET BENCHMARK AND PREPARE COMPARATIVE PLOT self.reference_ticker = self.History(self.Symbol(self.ticker), 10, Resolution.Daily)['close'] self._initialValue_ticker = self.reference_ticker.iloc[0] # SET Candlestick patterns self.hammer = self.CandlestickPatterns.Hammer(self.ticker, Resolution.Daily) self.hangingman = self.CandlestickPatterns.HangingMan(self.ticker, Resolution.Daily) # Risk management self.AddRiskManagement(TrailingStopRiskManagementModel(0.06)) self.Debug("Stop loss hit") self.AddRiskManagement(MaximumDrawdownPercentPerSecurity(0.05)) self.Debug("Drawdown limit hit") def OnData(self, data): price = self.Securities[self.ticker].Close if self.hangingman.Current.Value == -1: self.SetHoldings(self.ticker, -1) self.Debug("Hanging man candle") if self.hammer.Current.Value == 1: self.SetHoldings(self.ticker, 1) self.Debug("Hammer candle") elif self.Portfolio[self.ticker].UnrealizedProfitPercent > 0.1: self.Liquidate(self.ticker) self.Debug("Take profit triggered") else: self.SetHoldings(self.ticker, 1) self.Plot("Strategy Equity", str(self.ticker), self._cash * self.Securities[self.ticker].Close / self._initialValue_ticker) self.Plot("Strategy Equity", 'Portfolio Value', self.Portfolio.TotalPortfolioValue) self.Plot("Hammer", "value", self.hammer.Current.Value) self.Plot("HangingMan", "hangingman", self.hangingman.Current.Value)