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 |
# QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals. # Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation. # from clr import AddReference AddReference("System") AddReference("QuantConnect.Algorithm") AddReference("QuantConnect.Common") from System import * from QuantConnect import * from QuantConnect.Algorithm import * from QuantConnect.Securities.Option import OptionPriceModels from datetime import timedelta class atmCallDeltaExample(QCAlgorithm): def Initialize(self): self.SetStartDate(2018, 11, 1) self.SetEndDate(2019, 3, 10) self.SetCash(100000) option = self.AddOption("NVDA",Resolution.Minute) self.option_symbol = option.Symbol # set our strike/expiry filter for this option chain option.SetFilter(-1, 4, timedelta(21), timedelta(40)) option.PriceModel = OptionPriceModels.CrankNicolsonFD() self.SetWarmUp(5) def OnData(self,slice): if self.Portfolio.Invested: return # Loop through the option chain at the end of day if not (self.Time.hour == 10 and self.Time.minute == 00): return for kvp in slice.OptionChains: if kvp.Key != self.option_symbol: continue chain = kvp.Value # Retrieve call options call = [i for i in chain if i.Right == OptionRight.Call] if len(call) == 0: continue # Retrieve the call ATM option contract, at the furthest date within our filtered universe of options contracts = sorted(sorted(call, key=lambda x: x.Expiry, reverse=False), key=lambda x: abs(x.UnderlyingLastPrice - x.Strike)) atm_contract = contracts[0] is_tradable=self.Securities[atm_contract.Symbol].IsTradable if not is_tradable: self.Log("Not tradable") else: self.Log("Tradable") delta = atm_contract.Greeks.Delta # Print out the delta value for the ATM call option contract if abs(delta) > 0: self.Log(str(atm_contract) + " - Delta: " + str(atm_contract.Greeks.Delta)) def OnOrderEvent(self, orderEvent): self.Log(str(orderEvent))