Overall Statistics |
Total Trades 1574 Average Win 0.42% Average Loss -0.54% Compounding Annual Return 13.021% Drawdown 28.900% Expectancy 0.045 Net Profit 21.063% Sharpe Ratio 0.662 Probabilistic Sharpe Ratio 31.702% Loss Rate 41% Win Rate 59% Profit-Loss Ratio 0.78 Alpha -0.089 Beta 0.889 Annual Standard Deviation 0.252 Annual Variance 0.063 Information Ratio -2.31 Tracking Error 0.052 Treynor Ratio 0.187 Total Fees $1574.00 Estimated Strategy Capacity $48000000.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 return else: self.stoploss(data) # change 2 def captureSpy(self): if self.CurrentSlice.Bars.ContainsKey(self.spy): self.dailythresh = self.CurrentSlice[self.spy].Open self.stoplosshold = 0 return 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.IsWarmingUp: return if self.CurrentSlice.Bars.ContainsKey(self.spy): self.Debug((self.dailythresh - self.CurrentSlice[self.spy].Close)/self.CurrentSlice[self.spy].Close) if (self.dailythresh - self.CurrentSlice[self.spy].Close)/self.CurrentSlice[self.spy].Close < .05: self.SetHoldings(self.spy, 0) self.SetHoldings(self.qqq, 0) self.stoplosshold = 1