Overall Statistics |
Total Trades 1 Average Win 0% Average Loss 0% Compounding Annual Return -50.556% Drawdown 38.400% Expectancy 0 Net Profit -5.442% Sharpe Ratio 0.021 Probabilistic Sharpe Ratio 37.432% Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0 Beta 0 Annual Standard Deviation 1.033 Annual Variance 1.068 Information Ratio 0.021 Tracking Error 1.033 Treynor Ratio 0 Total Fees BUSD0.10 Estimated Strategy Capacity BUSD79000.00 Lowest Capacity Asset MATICBUSD 18N |
# region imports from AlgorithmImports import * from datetime import datetime, timedelta # endregion class SquareYellowGreenAnguilline(QCAlgorithm): fast_lookback = 9 slow_lookback = 25 rsi_lookback = 14 def Initialize(self): self.SetStartDate(2022, 2, 1) # Set Start Date self.SetEndDate(2022, 3, 1) self.SetAccountCurrency('BUSD') #set account currency self.SetCash(100) # Set Strategy Cash self.SetBenchmark('BTCBUSD') self.crypto_currency = self.AddCrypto('MATICBUSD', Resolution.Hour, market=Market.Binance) self.SetBrokerageModel(BrokerageName.Binance, AccountType.Margin) #create a 4hr consolidator event fourHourConsolidator = TradeBarConsolidator(timedelta(hours=4)) #attach to event handler fourHourConsolidator.DataConsolidated += self.fourHourHandler # this call adds our 30-minute consolidator to # the manager to receive updates from the engine self.SubscriptionManager.AddConsolidator(self.crypto_currency.Symbol, fourHourConsolidator) #register indicators self.fast_indicator = self.EMA(self.crypto_currency.Symbol, self.fast_lookback, Resolution.Hour) self.slow_indicator = self.EMA(self.crypto_currency.Symbol, self.slow_lookback, Resolution.Hour) self.rsi = self.RSI(self.crypto_currency.Symbol, self.rsi_lookback, MovingAverageType.Wilders, Resolution.Hour) #warmup indicators self.SetWarmup(self.fast_lookback, Resolution.Hour) def fourHourHandler(self, sender, bar): pass def OnData(self, data: Slice): self.Log(f'{data.Time}') if self.IsWarmingUp: return if not self.fast_indicator.IsReady and not self.slow_indicator.IsReady and self.rsi.IsReady: return if (self.slow_indicator.Current.Value > self.fast_indicator.Current.Value) and self.rsi.Current.Value >=60: #check for signal if not self.Portfolio[self.crypto_currency.Symbol].IsLong: self.Liquidate() self.SetHoldings(self.crypto_currency.Symbol, 1, tag='Long Position') elif (self.slow_indicator.Current.Value < self.fast_indicator.Current.Value) and self.rsi.Current.Value <=40: if not self.Portfolio[self.crypto_currency.Symbol].IsShort: self.Liquidate() self.SetHoldings(self.crypto_currency.Symbol, -1, tag='Short Position') #charts self.Plot('Benchmark', 'Price', self.Securities[self.crypto_currency.Symbol].Price) self.Plot('Benchmark', 'FastEMA', self.fast_indicator.Current.Value) self.Plot('Benchmark', 'ShortEMA', self.slow_indicator.Current.Value) self.Plot('rsi', 'RSI', self.rsi.Current.Value)