| Overall Statistics |
|
Total Trades 4 Average Win 0% Average Loss 0% Compounding Annual Return -0.771% Drawdown 0.200% Expectancy 0 Net Profit -0.061% Sharpe Ratio 1.785 Probabilistic Sharpe Ratio 58.582% Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0.055 Beta -0.075 Annual Standard Deviation 0.008 Annual Variance 0 Information Ratio -7.804 Tracking Error 0.069 Treynor Ratio -0.182 Total Fees $4.00 Estimated Strategy Capacity $3500000.00 Lowest Capacity Asset GOOCV WIQJ61J2NVQE|GOOCV VP83T1ZUHROL Portfolio Turnover 0.06% |
#region imports
from AlgorithmImports import *
#endregion
class IronCondorAlgorithm(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2017, 2, 1)
self.SetEndDate(2017, 3, 1)
self.SetCash(500000)
option = self.AddOption("GOOG")
self.symbol = option.Symbol
option.SetFilter(lambda universe:
universe.IncludeWeeklys().Strikes(-15, 15).Expiration(0, 40))
# use the underlying equity GOOG as the benchmark
self.SetBenchmark(self.symbol.Underlying)
def OnData(self,slice):
# If there is underlying assets in portfolio at expiration, liquidate the stocks in order to roll into new contracts
if self.Portfolio[self.symbol.Underlying].Invested:
self.Liquidate()
if self.Portfolio.Invested or not self.IsMarketOpen(self.symbol):
return
chain = slice.OptionChains.get(self.symbol)
if not chain:
return
# Find put and call contracts with the farthest expiry
expiry = max([x.Expiry for x in chain])
chain = sorted([x for x in chain if x.Expiry == expiry], key = lambda x: x.Strike)
put_contracts = [x for x in chain if x.Right == OptionRight.Put]
call_contracts = [x for x in chain if x.Right == OptionRight.Call]
if len(call_contracts) < 10 or len(put_contracts) < 10:
return
# Select the strikes in the strategy legs
far_put = put_contracts[0].Strike
near_put = put_contracts[10].Strike
near_call = call_contracts[-10].Strike
far_call = call_contracts[-1].Strike
iron_condor = OptionStrategies.IronCondor(
self.symbol,
far_put,
near_put,
near_call,
far_call,
expiry)
self.Buy(iron_condor, 2)