Overall Statistics |
Total Trades 0 Average Win 0% Average Loss 0% Compounding Annual Return 0% Drawdown 0% Expectancy 0 Net Profit 0% Sharpe Ratio 0 Sortino 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 9.739 Tracking Error 0.064 Treynor Ratio 0 Total Fees $0.00 Estimated Strategy Capacity $0 Lowest Capacity Asset Portfolio Turnover 0% |
# region imports from AlgorithmImports import * # endregion class SleepySkyBlueKoala(QCAlgorithm): def Initialize(self): self.SetStartDate(2024, 1, 1) self.SetCash(100000) self.asset = "AAPL" self.ticker = self.AddEquity(self.asset, Resolution.Minute).Symbol self.rollingWindow = RollingWindow[TradeBar](2) self.Consolidate(self.ticker, timedelta(minutes=30), self.consolidation_handler) self.Schedule.On(self.DateRules.EveryDay(self.ticker), self.TimeRules.At(10, 5), self.BuyOnOpen) self.SetWarmup(10) def OnData(self, data: Slice): if data.Bars.ContainsKey(self.ticker): bar = data.Bars[self.ticker] self.rollingWindow.Add(bar) def BuyOnOpen(self): if not self.rollingWindow.IsReady and self.IsWarmingUp: return self.first_half_hour_return = self.CalculateReturn(self.rollingWindow) time = self.rollingWindow[0].Time timePrev = self.rollingWindow[1].EndTime self.Debug(f"Date: {self.Time} | First Half-Hour Return: {self.first_half_hour_return}") def CalculateReturn(self, bar): if bar[0].Close is not None and bar[1].Close is not None: return (bar[0].Close / bar[1].Close) - 1 else: return 0 def consolidation_handler(self, consolidated_bar: TradeBar) -> None: pass