| Overall Statistics |
|
Total Trades 6 Average Win 0% Average Loss -0.37% Compounding Annual Return -0.818% Drawdown 4.000% Expectancy -1 Net Profit -0.132% Sharpe Ratio -0.082 Probabilistic Sharpe Ratio 30.295% Loss Rate 100% Win Rate 0% Profit-Loss Ratio 0 Alpha 0.004 Beta 0.385 Annual Standard Deviation 0.053 Annual Variance 0.003 Information Ratio 0.217 Tracking Error 0.084 Treynor Ratio -0.011 Total Fees $4.00 Estimated Strategy Capacity $210000.00 Lowest Capacity Asset IBM R735QTJ8XC9X |
#region imports
from AlgorithmImports import *
#endregion
from datetime import timedelta
class CoveredCallAlgorithm(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2014, 1, 1)
self.SetEndDate(2014, 3, 1)
self.SetCash(100000)
equity = self.AddEquity("IBM")
option = self.AddOption("IBM")
self.symbol = option.Symbol
# set strike/expiry filter for this option chain
option.SetFilter(-3, 3, 0, 30)
# use the underlying equity as the benchmark
self.SetBenchmark(equity.Symbol)
def OnData(self,slice):
if not self.Portfolio[self.symbol.Underlying].Invested:
# buy 100 shares of underlying stocks
self.MarketOrder(self.symbol.Underlying, 100)
chain = slice.OptionChains.get(self.symbol)
if not chain:
return
if any([x for x in self.Portfolio.Values
if x.Invested and x.Type == SecurityType.Option]):
return
calls = [x for x in chain if x.Right == OptionRight.Call]
if not calls:
return
# sorted the contracts according to their expiration dates and choose the ATM options
calls = sorted(sorted(calls, key=lambda x: abs(chain.Underlying.Price - x.Strike)),
key = lambda x: x.Expiry, reverse=True)
# short the call options
self.MarketOrder(calls[0].Symbol, 1)
def OnOrderEvent(self, orderEvent):
self.Log(f'{orderEvent}')