Overall Statistics |
Total Trades 2 Average Win 0% Average Loss 0% Compounding Annual Return 0% Drawdown 0% Expectancy 0 Net Profit 0% Sharpe Ratio 0 Probabilistic Sharpe Ratio 0% Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0 Beta 0 Annual Standard Deviation 0 Annual Variance 0 Information Ratio 0 Tracking Error 0 Treynor Ratio 0 Total Fees $2.00 Estimated Strategy Capacity $89000000.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"), self.monthlyRebalance) self.Schedule.On(self.DateRules.EveryDay("SPY"), self.TimeRules.AfterMarketOpen("SPY"), 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() 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 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