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 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 $0.00 Estimated Strategy Capacity $0 |
from QuantConnect.Data.Consolidators import CalendarInfo class QTrendswconsoldata(QCAlgorithm): # Set parameters # Backtest Portfolio Parameters cash = 100000 startyyyy, startm, startd = 2020, 1, 5 endyyyy, endm, endd = 2020, 3, 15 symbol = "GOOG" def Initialize(self): # self.SetBenchmark(self.secticker) self.SetBrokerageModel(BrokerageName.InteractiveBrokersBrokerage, AccountType.Margin) self.SetStartDate(self.startyyyy, self.startm, self.startd) # Set Start Date self.SetEndDate(self.endyyyy, self.endm, self.endd) # Set End Date self.SetCash(self.cash) # Set Strategy Cash self.lookback = 30 # Set number of days to look back self.Transactions.MarketOrderFillTimeout = timedelta(seconds=30) self.AddEquity(self.symbol, Resolution.Minute) # Set security hourlyConsolidator = TradeBarConsolidator(self.Custom) # consolidate 1-hour bars hourlyConsolidator.DataConsolidated += self.OnDataConsolidated self.SubscriptionManager.AddConsolidator(self.symbol, hourlyConsolidator) self.Securities[self.symbol].SetDataNormalizationMode(DataNormalizationMode.Raw) # set start and end time for bars def Custom(self, dt): period = timedelta(hours=1) start = dt.replace(minute=30) if start > dt: start -= period return CalendarInfo(start, period) def OnDataConsolidated(self, sender, tradebar): symbol = tradebar.Symbol.Value sec = self.Securities[symbol] sopen= tradebar.Open close = tradebar.Close high = tradebar.High low = tradebar.Low self.Log(f"{self.Time} {symbol} O {sopen} H {high} L {low} C {close}")