Overall Statistics |
Total Trades 39 Average Win 0.56% Average Loss -0.95% Compounding Annual Return 10.921% Drawdown 2.300% Expectancy 0.507 Net Profit 10.911% Sharpe Ratio 1.527 Probabilistic Sharpe Ratio 71.505% Loss Rate 5% Win Rate 95% Profit-Loss Ratio 0.59 Alpha 0 Beta 0 Annual Standard Deviation 0.05 Annual Variance 0.002 Information Ratio 1.527 Tracking Error 0.05 Treynor Ratio 0 Total Fees $39.00 Estimated Strategy Capacity $370000000.00 Lowest Capacity Asset SPY R735QTJ8XC9X |
#region imports from AlgorithmImports import * #endregion from QuantConnect.Indicators import * import decimal as d class BBAlgorithm(QCAlgorithm): def Initialize(self): self.SetStartDate(2021, 1, 1) self.SetEndDate(2022, 1, 1) self.SetCash(778) #Set Strategy Cash self.ticker = 'SPY' self.symbol = self.AddEquity(self.ticker, Resolution.Hour).Symbol self.SetBrokerageModel(BrokerageName.InteractiveBrokersBrokerage, AccountType.Margin) x=25 period_BB = 25 self.Bolband = self.BB(self.ticker, period_BB, 2, MovingAverageType.Simple, Resolution.Hour) self.SetWarmUp(x) self.Schedule.On(self.DateRules.EveryDay(self.ticker), self.TimeRules.AfterMarketOpen(self.ticker,10), self.EveryDayAfterMarketOpen) def EveryDayAfterMarketOpen(self): self.turn_trading_on = True def OnData(self, data): if self.IsWarmingUp != False: return holdings = self.Portfolio[self.ticker].Quantity price = self.Securities[self.ticker].Close quantity=1 if holdings <= 0: if price <= self.Bolband.LowerBand.Current.Value: self.MarketOrder(self.ticker, quantity) if holdings > 0: if price >= self.Bolband.UpperBand.Current.Value: self.MarketOrder(self.ticker, quantity*-1)