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 -1.487 Tracking Error 0.169 Treynor Ratio 0 Total Fees $0.00 |
# QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals. # Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from datetime import date, timedelta ### <summary> ### Basic template futures framework algorithm uses framework components ### to define an algorithm that trades futures. ### </summary> class BasicTemplateFuturesFrameworkAlgorithm(QCAlgorithm): def Initialize(self): self.UniverseSettings.Resolution = Resolution.Minute self.SetStartDate(2020, 7, 20) #self.SetEndDate(2020, 7, 21) self.SetCash(100000) ES = self.AddFuture(Futures.Indices.SP500EMini, Resolution.Minute) ES.SetFilter(lambda x: x.FrontMonth().OnlyApplyFilterAtMarketOpen()) self.consolidators = dict() def OnDataConsolidated(self, sender, quoteBar): # This should be called every 90 minutes, after consolidating a minute # interval. How do I access the slice object or otherwise discover a # front-month contract to now begin analyzing/trading? pass def OnSecuritiesChanged(self, changes): for security in changes.AddedSecurities: consolidator = QuoteBarConsolidator(timedelta(minutes=90)) consolidator.DataConsolidated += self.OnDataConsolidated self.SubscriptionManager.AddConsolidator(security.Symbol, consolidator) self.consolidators[security.Symbol] = consolidator for security in changes.RemovedSecurities: consolidator = self.consolidators.pop(security.Symbol) self.SubscriptionManager.RemoveConsolidator(security.Symbol, consolidator) consolidator.DataConsolidated -= self.OnDataConsolidated