Option Strategies
Short Iron Condor
Introduction
The Short Iron Condor is an Option strategy that consists of four contracts. All the contracts have the same underlying Equity and expiration, but the order of strike prices is $A>B>C>D$. The following table describes the strike prices of each contract:
Position | Strike |
---|---|
-1 far-OTM call | $A$ |
1 near-OTM call | $B, where B > underlying\ price$ |
1 near-OTM put | $C, where C < underlying\ price$ |
-1 far-OTM put | $D, where C-D = A-B$ |
The short iron condor consists of selling a far OTM call, selling a far OTM put, buying a near OTM call, and buying a near OTM put. This strategy profits from a increase in price movement (implied volatility).
Implementation
Follow these steps to implement the short iron condor strategy:
- In the
Initialize
initialize
method, set the start date, end date, cash, and Option universe. - In the
OnData
on_data
method, select the contracts in the strategy legs. - In the
OnData
on_data
method, place the orders.
private Symbol _symbol; public override void Initialize() { SetStartDate(2017, 2, 1); SetEndDate(2017, 3, 1); SetCash(500000); UniverseSettings.Asynchronous = true; var option = AddOption("GOOG"); _symbol = option.Symbol; option.SetFilter(universe => universe.IncludeWeeklys().IronCondor(30, 5, 10)); }
def initialize(self) -> None: self.set_start_date(2017, 2, 1) self.set_end_date(2017, 3, 1) self.set_cash(500000) self.universe_settings.asynchronous = True option = self.add_option("GOOG") self._symbol = option.symbol option.set_filter(lambda universe: universe.include_weeklys().iron_condor(30, 5, 10))
The IronCondor
iron_condor
filter narrows the universe down to just the four contracts you need to form a short iron condor.
public override void OnData(Slice slice) { if (Portfolio[_symbol.Underlying].Invested) { Liquidate(); } if (Portfolio.Invested || !IsMarketOpen(_symbol) || !slice.OptionChains.TryGetValue(_symbol, out var chain)) { return; } // Find put and call contracts with the farthest expiry var expiry = chain.Max(x => x.Expiry); var contracts = chain.Where(x => x.Expiry == expiry).OrderBy(x => x.Strike); var putContracts = contracts.Where(x => x.Right == OptionRight.Put).ToArray(); var callContracts = contracts.Where(x => x.Right == OptionRight.Call).ToArray(); if (putContracts.Length < 2 || callContracts.Length < 2) return; // Select the strategy legs var farPut = putContracts[0]; var nearPut = putContracts[1]; var nearCall = callContracts[0]; var farCall = callContracts[1];
def on_data(self, slice: Slice) -> None: if self.portfolio[self._symbol.underlying].invested: self.liquidate() if self.portfolio.invested or not self.is_market_open(self._symbol): return chain = slice.option_chains.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) < 2 or len(put_contracts) < 2: return # Select the strategy legs far_put = put_contracts[0] near_put = put_contracts[1] near_call = call_contracts[0] far_call = call_contracts[1]
Approach A: Call the OptionStrategies.ShortIronCondor
OptionStrategies.short_iron_condor
method with the details of each leg and then pass the result to the Buy
buy
method.
var shortIronCondor = OptionStrategies.ShortIronCondor( _symbol, farPut.Strike, nearPut.Strike, nearCall.Strike, farCall.Strike, expiry); Buy(shortIronCondor, 2);
short_iron_condor = OptionStrategies.short_iron_condor( self._symbol, far_put.strike, near_put.strike, near_call.strike, far_call.strike, expiry) self.buy(short_iron_condor, 2)
Approach B: Create a list of Leg
objects and then call the Combo Market Ordercombo_market_order, Combo Limit Ordercombo_limit_order, or Combo Leg Limit Ordercombo_leg_limit_order method.
var legs = new List<Leg>() { Leg.Create(farPut.Symbol, -1), Leg.Create(nearPut.Symbol, 1), Leg.Create(farCall.Symbol, -1), Leg.Create(nearCall.Symbol, 1) }; ComboMarketOrder(legs, 1);
legs = [ Leg.create(far_put.symbol, -1), Leg.create(near_put.symbol, 1), Leg.create(far_call.symbol, -1), Leg.create(near_call.symbol, 1) ] self.combo_market_order(legs, 1)
Strategy Payoff
This is a limited-reward-limited-risk strategy. The payoff is
$$ \begin{array}{rcll} C^{far}_T & = & (S_T - K^C_{far})^{+}\\ C^{near}_T & = & (S_T - K^C_{near})^{+}\\ P^{far}_T & = & (K^P_{far} - S_T)^{+}\\ P^{near}_T & = & (K^P_{near} - S_T)^{+}\\ P_T & = & (C^{near}_T + P^{near}_T - C^{far}_T - P^{far}_T - C^{near}_0 - P^{near}_0 + C^{far}_0 + P^{far}_0)\times m - fee \end{array} $$ $$ \begin{array}{rcll} \textrm{where} & C^{far}_T & = & \textrm{Far OTM call value at time T}\\ & C^{near}_T & = & \textrm{Near OTM call value at time T}\\ & P^{far}_T & = & \textrm{Far OTM put value at time T}\\ & P^{near}_T & = & \textrm{Near ATM put value at time T}\\ & S_T & = & \textrm{Underlying asset price at time T}\\ & K^C_{far} & = & \textrm{Far OTM call strike price}\\ & K^C_{near} & = & \textrm{Near OTM call strike price}\\ & K^P_{far} & = & \textrm{Far OTM put strike price}\\ & K^P_{near} & = & \textrm{Near OTM put strike price}\\ & P_T & = & \textrm{Payout total at time T}\\ & C^{far}_0 & = & \textrm{Far OTM call value at position opening (credit received)}\\ & C^{near}_0 & = & \textrm{Near OTM call value at position opening (debit paid)}\\ & P^{far}_0 & = & \textrm{Far OTM put value at position opening (credit received)}\\ & P^{near}_0 & = & \textrm{Near OTM put value at position opening (debit paid)}\\ & m & = & \textrm{Contract multiplier}\\ & T & = & \textrm{Time of expiration} \end{array} $$The following chart shows the payoff at expiration:
![Strategy payoff decomposition and analysis of short iron condor](https://cdn.quantconnect.com/i/tu/short-iron-condor.png)
The maximum profit is $K^C_{far} - K^C_{near} - C^{near}_0 - P^{near}_0 + C^{far}_0 + P^{far}_0$, where $K^P_{OTM} > S_T$ or $S_T > K^C_{OTM}$.
The maximum loss is the net debit paid: $C^{far}_0 + P^{far}_0 - C^{near}_0 - P^{near}_0$, where $K^P_{OTM} < S_T < K^C_{OTM}$.
If the Option is American Option, there is a risk of early assignment on the contracts you sell.
Example
The following table shows the price details of the assets in the algorithm:
Asset | Price ($) | Strike ($) |
---|---|---|
Far-OTM call | 1.05 | 857.50 |
Far-OTM put | 2.15 | 815.00 |
Near-OTM call | 2.75 | 852.50 |
Near-OTM put | 4.80 | 820.00 |
Underlying Equity at expiration | 843.25 | - |
Therefore, the payoff is
$$ \begin{array}{rcll} C^{far}_T & = & (S_T - K^C_{far})^{+}\\ & = & (843.25-857.50)^{+}\\ & = & 0\\ C^{near}_T & = & (S_T - K^C_{near})^{+}\\ & = & (843.25-852.50)^{+}\\ & = & 0\\ P^{far}_T & = & (K^P_{far} - S_T)^{+}\\ & = & (815.00-843.25)^{+}\\ & = & 0\\ P^{near}_T & = & (K^P_{near} - S_T)^{+}\\ & = & (820.00-843.25)^{+}\\ & = & 0\\ P_T & = & (C^{near}_T + P^{near}_T - C^{far}_T - P^{far}_T - C^{near}_0 - P^{near}_0 + C^{far}_0 + P^{far}_0)\times m - fee\\ & = & (0+0-0-0-2.75-4.80+1.05+2.15)\times100-1\times4\\ & = & -439 \end{array} $$So, the strategy loses $439.
The following algorithm implements a short iron condor Option strategy: