Overall Statistics |
Total Trades 10 Average Win 0% Average Loss -0.42% Compounding Annual Return -62.447% Drawdown 2.100% Expectancy -1 Net Profit -2.080% Sharpe Ratio -13.014 Probabilistic Sharpe Ratio 0% Loss Rate 100% Win Rate 0% Profit-Loss Ratio 0 Alpha -0.483 Beta 0.157 Annual Standard Deviation 0.068 Annual Variance 0.005 Information Ratio 9.263 Tracking Error 0.178 Treynor Ratio -5.602 Total Fees $10.00 |
class BasicTemplateOptionsAlgorithm(QCAlgorithm): def Initialize(self): self.SetStartDate(2016, 1, 1) self.SetEndDate(2016, 1, 10) self.SetCash(100000) option = self.AddOption("GOOG") self.option_symbol = option.Symbol # set our strike/expiry filter for this option chain option.SetFilter(-2, +2, timedelta(0), timedelta(180)) # use the underlying equity as the benchmark self.SetBenchmark("GOOG") self.Schedule.On( self.DateRules.EveryDay(option.Symbol), self.TimeRules.At(10,00), self.BuyCall) def BuyCall(self): if self.Portfolio.Invested: return for kvp in self.CurrentSlice.OptionChains: if kvp.Key != self.option_symbol: continue chain = kvp.Value # we sort the contracts to find at the money (ATM) contract with farthest expiration 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) # if found, trade it if len(contracts) == 0: continue symbol = contracts[0].Symbol self.MarketOrder(symbol, 1) self.MarketOnCloseOrder(symbol, -1)