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 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 |
class DynamicCalibratedContainmentField(QCAlgorithm): frontContract = None futureSma = None def Initialize(self): self.SetStartDate(2019, 9, 3) # Set Start Date self.SetEndDate(2019, 9, 4) #Set End Date self.SetCash(50000) futureES = self.AddFuture("ES", Resolution.Minute) futureES.SetFilter(timedelta(0), timedelta(182)) def OnData(self, data): # If we haven't already stored the front contract, we need to find it if self.frontContract is None: # Get front month symbol for chain in data.FutureChains: # Get contracts expiring no earlier than in 90 days contracts = list(filter(lambda x: x.Expiry > self.Time + timedelta(90), chain.Value)) # If there is any contract, store the front month contract if len(contracts) == 0: continue self.frontContract = sorted(contracts, key = lambda x: x.Expiry, reverse=True)[0] self.Log(f"Front month contract found: {self.frontContract.Symbol}") # If we haven't already created the SMA, we need to create it if self.futureSma is None and self.frontContract is not None: self.futureSma = self.SMA(self.frontContract.Symbol, 2, Resolution.Minute) self.Log("SMA created") # If our SMA is defined but isn't ready yet, we can't continue if self.futureSma is not None and self.futureSma.IsReady: self.Log(f"Value: {self.futureSma.Current}")