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 |
from QuantConnect.Securities.Option import OptionPriceModels from datetime import timedelta class TestingIB(QCAlgorithm): def Initialize(self): # self.SetStartDate(2019, 3, 11) # Set Start Date # self.SetCash(100000) # Set Strategy Cash # self.AddEquity("SPY", Resolution.Minute) self.SetBrokerageModel(BrokerageName.InteractiveBrokersBrokerage) if self.LiveMode: self.Debug("Trading Live!") self.has_printed = False self.option_holdings = [this for this in self.Portfolio.Values \ if this.Invested and this.Type == SecurityType.Option] self.option_contract_securities = [] for option_holding in self.option_holdings: option_contract_security = self.AddOptionContract(option_holding.Symbol) option_contract_security.PriceModel = OptionPriceModels.CrankNicolsonFD() self.option_contract_securities.append(option_contract_security) self.SetWarmUp(TimeSpan.FromDays(4)) def OnData(self, data): '''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 not self.has_printed: for this_option_chain in data.OptionChains.Value: this_option_holding in self.option_holdings[0] this_option_contract = [oc for oc in this_option_chain if oc.Symbol == this_option_holding.Symbol][0] this_delta = this_option_contract.Greeks.Delta self.Debug("Sym: {}, Delta: {}".format(this_option_contract.Symbol, str(this_delta))) self.has_printed = True # these_option_holdings = [this for this in self.Portfolio.Values \ # if this.Invested and this.Type == SecurityType.Option] # if not self.Portfolio.Invested: # self.SetHoldings("SPY", 1)