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.297 Tracking Error 0.167 Treynor Ratio 0 Total Fees $0.00 |
import datetime class MorningBreakOut(QCAlgorithm): def Initialize(self): self.SetStartDate(2020, 8, 1) # Set Start Date self.SetCash(100000) # Set Strategy Cash self.SetTimeZone("Europe/Berlin") self.SetBrokerageModel(BrokerageName.OandaBrokerage) symbols = [Symbol.Create("DE30EUR", SecurityType.Cfd, Market.Oanda)] self.SetUniverseSelection(ManualUniverseSelectionModel(symbols)) #2. Set the resolution of the universe assets to daily resolution self.UniverseSettings.Resolution = Resolution.Minute # holds {"symbol": symbolData} instance for each symbol self.symbolDataBySymbol = {} self.SetPortfolioConstruction( EqualWeightingPortfolioConstructionModel() ) self.SetExecution( ImmediateExecutionModel() ) def OnDataConsolidated(self, sender, quoteBar): self.Log("OnDataConsolidated called on " + str(self.Time)) self.Log(str(quoteBar)) def OnSecuritiesChanged(self, changes): self.Debug("SecuritiesChanged"); # Initialize SymbolData for each symbol for added in changes.AddedSecurities: symbolData = self.symbolDataBySymbol.get(added.Symbol) if symbolData is None: symbolData = SymbolData(added, self) symbolData.RegisterConsolidator(self, minutes=60) self.symbolDataBySymbol[added.Symbol] = symbolData class SymbolData: '''Contains data specific to a symbol required by this model''' def __init__(self, security, algorithm): self.Security = security self.algorithm = algorithm self.Symbol = security.Symbol self._openingBar = None self.oneR = None def OnDataConsolidated(self, quoteBar): if quoteBar.Time.hour == 9: self.openingBar = quoteBar self.algorithm.Plot("OpeningBar", "Open", self._openingBar.Open) self.oneR = abs(self.openingBar.High - self.openingBar.Low) def RegisterConsolidator(self, algorithm, minutes=60): openRangeCons = algorithm.Consolidate(self.Symbol, timedelta(minutes=minutes), self.OnDataConsolidated) algorithm.SubscriptionManager.AddConsolidator(self.Symbol, openRangeCons) @property def openingBar(self): return self._openingBar @openingBar.setter def openingBar(self, value): self._openingBar = value