Overall Statistics |
Total Trades 13 Average Win 0.71% Average Loss 0% Compounding Annual Return 26.792% Drawdown 27.700% Expectancy 0 Net Profit 44.871% Sharpe Ratio 1.248 Probabilistic Sharpe Ratio 54.325% Loss Rate 0% Win Rate 100% Profit-Loss Ratio 0 Alpha 0.057 Beta 0.867 Annual Standard Deviation 0.245 Annual Variance 0.06 Information Ratio 0.335 Tracking Error 0.056 Treynor Ratio 0.354 Total Fees $13.00 Estimated Strategy Capacity $120000000.00 Lowest Capacity Asset QQQ RIWIV7K5Z9LX |
class FocusedSkyBlueGalago(QCAlgorithm): def Initialize(self): self.SetStartDate(2020, 1, 1) #self.SetEndDate(2018, 1, 3) self.InitCash = 10000 self.SetCash(self.InitCash) self.AddEquity("SPY", Resolution.Minute) self.SetWarmUp(5) # ETF's for options =================================== spy = self.AddEquity("SPY", Resolution.Minute) qqq = self.AddEquity("QQQ", Resolution.Minute) spy.SetDataNormalizationMode(DataNormalizationMode.Raw) qqq.SetDataNormalizationMode(DataNormalizationMode.Raw) self.spy = spy.Symbol self.qqq = qqq.Symbol # Rebalance beginning of every month ======================= self.Schedule.On(self.DateRules.MonthStart("SPY"), self.TimeRules.AfterMarketOpen("SPY", 1), self.monthlyRebalance) self.Schedule.On(self.DateRules.EveryDay("SPY"), self.TimeRules.AfterMarketOpen("SPY", 1), self.captureSpy) #Variables used in stoploss================================= self.stoplosshold = 0 self.dailythresh = 0 def OnData(self, data): ''' OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here. Arguments: data: Slice object keyed by symbol containing the stock data ''' if self.IsWarmingUp: return if not self.Portfolio.Invested: self.SetHoldings(self.spy, .55) self.SetHoldings(self.qqq, .35) if self.stoplosshold == 1: #One for stoploss hold means the stoploss has been hit, hold till next day pass else: self.stoploss(data) # change 2 ## OLD # def captureSpy(self, data): # ''' # captureSpy logic: # 1. Grab the opening value of spy # 2. Reset the daily stoploss indicator to 0 # ''' # self.dailythresh = self.data['SPY'].Open # NEW def captureSpy(self): if self.CurrentSlice.Bars.ContainsKey(self.spy): self.dailythresh = self.CurrentSlice[self.spy].Open def monthlyRebalance(self): ''' Now I need to rebalance portfolio on a monthly basis ''' if self.IsWarmingUp: return self.SetHoldings(self.spy, 0.55) self.SetHoldings(self.qqq, 0.35) return def stoploss(self, data): ''' Stoploss logic: 1. If spy drops more than 5% liquidate entire equity portfolio 2. Change stoplosshold value to 1, this indicates that the portfolios SL has been hit and were going to hold until the next trading day if (self.dailythresh - currentslicespy)/currentslicespy < -.08: self.SetHoldings(self.spy, 0) self.SetHoldings(self.QQQ, 0) ''' pass