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 -3.199 Tracking Error 0.08 Treynor Ratio 0 Total Fees $0.00 |
from QuantConnect.Securities.Option import OptionPriceModels from datetime import timedelta class LongStrangleAlgorithm(QCAlgorithm): def Initialize(self): self.SetStartDate(2020, 1, 2) self.SetEndDate(2020, 1, 14) self.SetCash(100000) equity = self.AddEquity("SPY", Resolution.Minute) equity.SetDataNormalizationMode(DataNormalizationMode.Raw) option = self.AddOption("SPY", Resolution.Minute) self.symbol = option.Symbol option.SetFilter(-1, 1, timedelta(45), timedelta(55)) option.PriceModel = OptionPriceModels.BlackScholes() # BlackScholes and Integral models return 0-value greeks self.SetWarmUp(155, Resolution.Daily) self.show = True def OnData(self,slice): if self.IsWarmingUp: return for i in slice.OptionChains: if i.Key != self.symbol: continue optionchain = i.Value options_by_type = [x for x in optionchain if x.Right == OptionRight.Call] contracts = sorted(options_by_type, key = lambda x: abs(x.Greeks.Delta), reverse=True) if len(contracts) == 0: return None #no option was found if self.show: self.show = False self.PrintOptionContract(contracts[0]) def PrintOptionContract(self, contract): self.Log(contract.Symbol.Value + ", strike: " + str(contract.Strike) + \ ", Gamma" + str(contract.Greeks.Gamma) + \ ", Rho" + str(contract.Greeks.Rho) + \ ", Delta: " + str(contract.Greeks.Delta) + \ ", Vega: " + str(contract.Greeks.Vega) +\ ", IV: " + str(contract.ImpliedVolatility) + \ ", AskPrice: " + str(contract.AskPrice) + \ ", Underlying Price: " + str(contract.UnderlyingLastPrice)) def OnEndOfDay(self): self.show = True