I am confusted about the following.

1) can we set dynamic strike price in a future based on its equity performanace.as of now i know is by using setfilter(-6,6).

2) i have tried a lot on how to do put and call based o the condition.

The condition is based on the future underlying asset performing in 2 consecutive  30 min bar at the opening of market.I need to liquidate the contract at the end.

class NadionTachyonProcessor(QCAlgorithm): def Initialize(self): self.SetStartDate(2019, 11, 4) # Set Start Date self.SetCash(100000) # Set Strategy Cash self.AddEquity("SPY", Resolution.Minute) self.future = self.AddFuture(Futures.Indices.SP500EMini) self.future.SetFilter(-6,6,timedelta(0), timedelta(182)) # self.Schedule.On(self.DateRules.EveryDay("SPY"), self.TimeRules.BeforeMarketClose("SPY", 10), self.ClosePositions) def OnData(self, slice): '''OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here. Arguments: data: Slice object keyed by symbol containing the stock data ''' if self.Portfolio.Invested or self.openingBar is None or self.secondaryBar is None: return for kvp in slice.OptionChains: if kvp.Key != self.option_symbol: continue chain = kvp.Value contracts = sorted(sorted(sorted(chain, \ key = lambda x: abs(chain.Underlying.Price - x.Strike)), \ key = lambda x: x.Expiry, reverse=True), \ key = lambda x: x.Right, reverse=True) if (self.secondaryBar.Close > self.openingBar.High) and (self.openingBar.High>self.secondaryBar.Low>self.openingBar.High): #call at price self.openingBar.Low if (self.secondaryBar.Close < self.openingBar.Low) and (self.openingBar.High>self.secondaryBar.High>self.openingBar.High): #call at price self.openingBar.High def OnDataConsolidated(self, bar): if bar.Time.hour == 9 and bar.Time.minute == 30: self.openingBar = bar if bar.Time.hour == 10 and bar.Time.minute == 0: self.secondaryBar = bar def ClosePositions(self): self.secondaryBar = None self.openingBar = None self.Liquidate("SPY")

I have tried to implement it,but facing problem while making a call and put.It will be highly apprecieted if you can help in this.

I am providing the code that i write till now.

Author