Overall Statistics |
Total Trades 165 Average Win 12.96% Average Loss -2.10% Compounding Annual Return 33.338% Drawdown 49.900% Expectancy 1.927 Net Profit 2605.935% Sharpe Ratio 1.112 Probabilistic Sharpe Ratio 39.386% Loss Rate 59% Win Rate 41% Profit-Loss Ratio 6.16 Alpha 0.366 Beta 0.496 Annual Standard Deviation 0.402 Annual Variance 0.162 Information Ratio 0.705 Tracking Error 0.402 Treynor Ratio 0.9 Total Fees $19525.10 Estimated Strategy Capacity $570000.00 Lowest Capacity Asset BGU U7EC123NWZTX |
class FocusedSkyBlueSalmon(QCAlgorithm): def Initialize(self): self.SetStartDate(2010, 1, 1) # Set Start and End Date self.SetEndDate(2021, 6, 15) 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, Resolution.Daily) #Indicator Simple Moving Average 200 days self.SetWarmup(200) #Warmup Indicator self.rebal = 1 #Rebalance self.rebalTimer = self.rebal - 1 self.flag1 = 0 self.Schedule.On(self.DateRules.EveryDay("SPXL"), self.TimeRules.AfterMarketOpen("SPXL", 150), self.Rebalance) # Set 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