Overall Statistics |
Total Trades 175 Average Win 11.43% Average Loss -6.86% Compounding Annual Return 49.507% Drawdown 55.800% Expectancy 0.866 Net Profit 8087.392% Sharpe Ratio 1.443 Probabilistic Sharpe Ratio 64.114% Loss Rate 30% Win Rate 70% Profit-Loss Ratio 1.67 Alpha 0.502 Beta 1.025 Annual Standard Deviation 0.458 Annual Variance 0.209 Information Ratio 1.2 Tracking Error 0.422 Treynor Ratio 0.644 Total Fees $60673.72 Estimated Strategy Capacity $310000.00 Lowest Capacity Asset TMF UBTUG7D0B7TX |
class FocusedSkyBlueSalmon(QCAlgorithm): def Initialize(self): self.SetStartDate(2010, 1, 1) # Set Start and End Date self.SetEndDate(2020, 12, 12) self.SetCash(100000) #Set Cash self.SpySymbol = self.AddEquity("SPXL", Resolution.Minute) #Request Data self.TMFSymbol = self.AddEquity("TMF", Resolution.Minute) self.GLDSymbol = self.AddEquity("GLD", Resolution.Minute) self.SmaSpy = self.SMA("SPXL", 200) #Indicator Simple Moving Average 200 days self.SetWarmup(200) #Warmup Indicator self.rebal = 4 #Rebalance self.rebalTimer = self.rebal - 1 self.flag1 = 0 self.Schedule.On(self.DateRules.WeekStart("SPXL"), self.TimeRules.AfterMarketOpen("SPXL", 150), self.Rebalance) # Set Rebalance #self.Schedule.On(self.DateRules.MonthStart("SPXL"), \ # self.TimeRules.AfterMarketOpen("SPXL"), \ # self.Rebalance) def OnData(self, data): # When each data point comes in if self.flag1 != 1: return if self.SmaSpy.IsReady: # When Warm Up is done self.Debug("Ready!") if self.SmaSpy is None or not self.SmaSpy.IsReady: #Final Check That Everything is ready return if self.SmaSpy.Current.Value < self.Securities["SPXL"].Close: # check to see if closing spy value is greater than the simple moving average self.Liquidate("TMF") # liquidate tmf self.SetHoldings("SPXL", 1) # buy 100% of portfolio into SPXL else: self.Liquidate("SPXL") #if not then sell all of SPXL self.SetHoldings("TMF", 1) # then buy into TMF self.rebalTimer = 0 self.flag1 = 0 def OnOrderEvent(self, orderEvent): # Make sure that orders are going through if orderEvent.Status == OrderStatus.Filled: self.lastOrderEvent = orderEvent self.Debug(str(self.lastOrderEvent.OrderId)) def Rebalance(self): # Code the Rebalance self.rebalTimer +=1 if self.rebalTimer == self.rebal: self.flag1 = 1