Overall Statistics |
Total Trades 79 Average Win 1.22% Average Loss -0.91% Compounding Annual Return 18.960% Drawdown 9.000% Expectancy 0.264 Net Profit 9.184% Sharpe Ratio 1.331 Probabilistic Sharpe Ratio 58.550% Loss Rate 46% Win Rate 54% Profit-Loss Ratio 1.35 Alpha 0.057 Beta 0.464 Annual Standard Deviation 0.107 Annual Variance 0.011 Information Ratio -0.373 Tracking Error 0.109 Treynor Ratio 0.305 Total Fees $282.67 Estimated Strategy Capacity $20000000.00 Lowest Capacity Asset AAPL R735QTJ8XC9X |
class PensiveSkyBlueCormorant(QCAlgorithm): # 1 stock algo # 5 Minute resoultion # Buy if change from the open > 1% # Sell stop - 1 hour min # How to make it effective? openingBar = None def Initialize(self): self.SetStartDate(2021, 5, 24) # Set Start Date self.SetCash(100000) # Set Strategy Cash self.aapl = self.AddEquity("AAPL", Resolution.Minute) self.symbol = self.aapl.Symbol self.Securities[self.symbol].SetDataNormalizationMode(DataNormalizationMode.Raw) self.SetBenchmark("SPY") self.fh1min = 0 # self.SetBenchmark("QQQ") self.Consolidate(self.symbol, timedelta(minutes=5), self.OnDataConsolidated) def OnData(self, data): if not data.ContainsKey(self.symbol) or not data[self.symbol]: return # if current price greater than open at 1% - open long position if not self.Portfolio.Invested: if (self.openingBar is not None and data[self.symbol].Close > self.openingBar.Open*1.01): self.SetHoldings(self.symbol, 1) else: # close if current price less than 1HMin. if ((self.Time.hour==10 and self.Time.minute >=30) or (self.Time.hour>10)): if (data[self.symbol].Low < self.fh1min): self.Liquidate() # if not self.Portfolio.Invested: # self.SetHoldings(self.aapl.Symbol, 1) # Create a function OnDataConsolidator which saves the currentBar as bar def OnDataConsolidated(self, bar): # The first bar will be at 9h35. QC does not "repaint"... if bar.Time.hour == 9 and bar.Time.minute == 35: self.openingBar = bar self.fh1min = bar.Low self.Log("Open price: @" + str(self.openingBar.Open)) else: if (bar.Time.hour == 9 and bar.Time.minute >30) or (bar.Time.hour==10 and bar.Time.minute <=30): if (bar.Low < self.fh1min): fh1min = bar.Low