Option Strategies

Iron Condor

Introduction

Warning: There is currently no OptionStrategies method for Iron Condor orders, so this tutorial manually orders the individual legs in the strategy. If you manually place multi-leg orders one at a time while there is no liquidity at a strike price, you can get stuck in an unhedged position.
The 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:

PositionStrike
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 iron condor can be long or short.

Long Iron Condor

The long iron condor consists of selling an OTM call, selling an OTM put, buying an ATM call, and buying an ATM put. This strategy profits from a decrease in price movement (implied volatility).

Short Iron Condor

The short iron condor consists of buying an OTM call, buying an OTM put, selling an ATM call, and selling an ATM put. This strategy profits from an increase in price movement (implied volatility) and time decay since ATM options decay sharper.

Implementation

Follow these steps to implement the long iron condor strategy:

  1. In the Initialize method, set the start date, end date, cash, and Option universe.
  2. private Symbol _symbol;
    
    public override void Initialize()
    {
        SetStartDate(2017, 2, 1);
        SetEndDate(2017, 3, 1);
        SetCash(100000);
    
        var option = AddOption("GOOG", Resolution.Minute);
        _symbol = option.Symbol;
        option.SetFilter(universe => universe.Strikes(-10, 10)
                                             .Expiration(TimeSpan.FromDays(0), TimeSpan.FromDays(30)));
    }
    def Initialize(self) -> None:
        self.SetStartDate(2017, 2, 1)
        self.SetEndDate(2017, 3, 1)
        self.SetCash(300000)
    
        option = self.AddOption("GOOG", Resolution.Minute)
        self.symbol = option.Symbol
        option.SetFilter(-10, 10, timedelta(0), timedelta(30))
  3. In the OnData method, select the contracts in the strategy legs.
  4. public override void OnData(Slice slice)
    {
        if (Portfolio.Invested) return;
    
        // Get the OptionChain
        var chain = slice.OptionChains.get(_symbol, null);
        if (chain == null || chain.Count() == 0) return;
    
        // Separate the call and put contracts
        var calls = chain.Where(x => x.Right == OptionRight.Call);
        var puts = chain.Where(x => x.Right == OptionRight.Put);
        if (calls.Count() == 0 || puts.Count() == 0) return;
    
        // Sort the contracts by their strike prices
        var callContracts = calls.OrderByDescending(x => x.Strike);
        var putContracts = puts.OrderBy(x => x.Strike);
    
        // Select the contracts in the strategy legs
        var farCallContract = callContracts.First();
        var farPutContract = putContracts.First();
        var nearCallContract = callContracts.Skip(2).First();
        var nearPutContract = putContracts.Skip(2).First();
    def OnData(self, slice: Slice) -> None:
        if self.Portfolio.Invested: return
    
        # Get the OptionChain
        chain = slice.OptionChains.get(self.symbol, None)
        if not chain: return
    
        # Separate the call and put contracts
        call = [i for i in chain if i.Right == 0]
        put = [i for i in chain if i.Right == 1]
        if len(call) == 0 or len(put) == 0 : return
    
        # Sort the contracts by their strike prices
        call_contracts = sorted(call, key = lambda x: x.Strike)
        put_contracts = sorted(put, key = lambda x: x.Strike)
    
        # Select the contracts in the strategy legs
        near_put = call_contracts[-2]
        near_call = put_contracts[1]
        far_call = call_contracts[-1]
        far_put = put_contracts[0]
  5. In the OnData method, submit the orders.
  6. Sell(nearCallContract.Symbol, 1);
    Sell(nearPutContract.Symbol, 1);
    Buy(farCallContract.Symbol, 1);
    Buy(farPutContract.Symbol, 1);
    self.Buy(near_put.Symbol, 1)
    self.Buy(near_call.Symbol, 1)
    self.Sell(far_call.Symbol, 1)
    self.Sell(far_put.Symbol, 1)

Strategy Payoff

The iron condor can be long or short.

Long Iron Condor

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:

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 sold contracts.

Short Iron Condor

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^{far}_T + P^{far}_T - C^{near}_T - P^{near}_T - C^{far}_0 - P^{far}_0 + C^{near}_0 + P^{near}_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:

The maximum profit is the net credit received after commission when opening the trade, where $K^P_{OTM} < S_T < K^C_{OTM}$.

The maximum loss 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}$.

If the Option is American Option, there is risk of early assignment on the sold contracts.

Example

The following table shows the price details of the assets in the algorithm:

AssetPrice ($)Strike ($)
Far-OTM call1.85857.50
Far-OTM put2.75810.00
Near-OTM call1.35855.00
Near-OTM put2.15815.00
Underlying Equity at expiration851.20-

Therefore, the payoff is

$$ \begin{array}{rcll} C^{far}_T & = & (S_T - K^C_{far})^{+}\\ & = & (851.20-857.50)^{+}\\ & = & 0\\ C^{near}_T & = & (S_T - K^C_{near})^{+}\\ & = & (851.20-855.00)^{+}\\ & = & 0\\ P^{far}_T & = & (K^P_{far} - S_T)^{+}\\ & = & (815.00-851.20)^{+}\\ & = & 0\\ P^{near}_T & = & (K^P_{near} - S_T)^{+}\\ & = & (810.00-851.20)^{+}\\ & = & 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+1.35+2.15-1.85-2.75)\times100-1\times4\\ & = & -114 \end{array} $$

So, the strategy losses $114.

The following algorithm implements a long iron condor Option strategy:

You can also see our Videos. You can also get in touch with us via Discord.

Did you find this page helpful?

Contribute to the documentation: