Overall Statistics |
Total Trades 1 Average Win 0% Average Loss 0% Compounding Annual Return 1.592% Drawdown 0.200% Expectancy 0 Net Profit 0.372% Sharpe Ratio 1.749 Probabilistic Sharpe Ratio 66.692% Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0.005 Beta -0.02 Annual Standard Deviation 0.006 Annual Variance 0 Information Ratio 1.578 Tracking Error 0.208 Treynor Ratio -0.549 Total Fees $1.00 Estimated Strategy Capacity $4300000.00 Lowest Capacity Asset MSFT X1B3PFLLX65I|MSFT R735QTJ8XC9X |
from AlgorithmImports import * class Coveredc(QCAlgorithm): def Initialize(self): self.SetStartDate(2018, 10, 7) # Set Start Date self.SetEndDate(2019, 1, 1) # Set End Date self.SetCash(100000) # Set Strategy Cash #equity=self.AddEquity("MSFT", Resolution.Minute) #equity.SetDataNormalizationMode(DataNormalizationMode.Raw) #self.equity = equity.Symbol #self.SetBenchmark(self.equity) option = self.AddOption("MSFT",Resolution.Minute) self.symbol = option.Symbol option.SetFilter(-10, +10, timedelta(0), timedelta(180)) def OnData(self, slice): """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 we have already sold a call if self.Portfolio.Invested:return for kvp in slice.OptionChains: if kvp.Key != self.symbol: continue optionchain = kvp.Value # Filter call options from optionchain call = [x for x in optionchain if x.Right == OptionRight.Call] # price of underlying stock price = optionchain.Underlying.Price # Filtering OTM contracts contracts = [x for x in call if price - x.Strike < 0] # Sorting OTM contracts as per their expiry contracts = sorted(contracts, key = lambda x: x.Expiry, reverse = True) if len(contracts) == 0: return symbol = contracts[0].Symbol self.MarketOrder(symbol, -1) self.Log("Underlying price at time of selling option: {0}".format(price))