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 -61.089 Tracking Error 0.777 Treynor Ratio 0 Total Fees $0.00 |
from datetime import timedelta class SupportandResistance (QCAlgorithm): def Initialize(self): self.SetStartDate(2020, 11, 3) self.SetEndDate(2020, 12, 3) self.SetCash(600000) equity = self.AddEquity("AAL", Resolution.Minute) option = self.AddOption("AAL", Resolution.Minute) self.symbol = option.Symbol # set our strike/expiry filter for this option chain #option.SetFilter(1, 2, timedelta(0), timedelta(30)) option.SetFilter(lambda universe: universe.IncludeWeeklys().Strikes(1, 2).Expiration(timedelta(0), timedelta(360))) # use the underlying equity GOOG as the benchmark self.SetBenchmark(equity.Symbol) self.Schedule.On(self.DateRules.EveryDay(self.symbol), \ self.TimeRules.AfterMarketOpen(self.symbol, 30), \ Action(self.EveryMarketOpen)) def OnData(self,slice): self.optionchain = slice.OptionChains for i in slice.OptionChains: if i.Key != self.symbol: continue chains = i.Value contract_list = [x for x in chains] # if there is no contracts in this optionchain, pass the instance if (slice.OptionChains.Count == 0) or (len(contract_list) == 0): return def EveryMarketOpen(self): if not self.Portfolio.Invested: for i in self.optionchain: if i.Key != self.symbol: continue chain = i.Value expiry = sorted(chain,key = lambda x: x.Expiry, reverse=True)[0].Expiry call = [i for i in chain if i.Expiry == expiry and i.Right == 0] call_contracts = sorted(call,key = lambda x: x.Strike) if len(call_contracts) == 0: continue self.call_low = call_contracts[0] self.lowexpiry = call_contracts[0].Expiry self.lowstrike = call_contracts[0].Strike def OnOrderEvent(self, orderEvent): self.Log(str(orderEvent))