# Option Strategies

## Iron Condor

### Introduction

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 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).

#### Short Iron Condor

The short iron condor consists of buying a far OTM call, buying a far OTM put, selling a near ATM call, and selling a near ATM put. This strategy profits from an decrease 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 Initializeinitialize 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(500000);

UniverseSettings.Asynchronous = true;
_symbol = option.Symbol;
option.SetFilter(universe => universe.IncludeWeeklys().Strikes(-15, 15).Expiration(0, 40));
}
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
self._symbol = option.symbol
option.set_filter(lambda universe: universe.include_weeklys().strikes(-15, 15).expiration(0, 40))
3. In the OnDataon_data method, select the contracts in the strategy legs.
4. 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 < 10 || putContracts.Length < 10) return;

// Select the strategy legs
var farPut = putContracts[0];
var nearPut = putContracts[10];
var nearCall = callContracts[^10];
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) < 10 or len(put_contracts) < 10:
return

# Select the strategy legs
far_put = put_contracts[0]
near_put = put_contracts[10]
near_call = call_contracts[-10]
far_call = call_contracts[-1]
5. In the OnDataon_data method, place the orders.
6. Approach A: Call the OptionStrategies.IronCondorOptionStrategies.iron_condor method with the details of each leg and then pass the result to the Buybuy method.

var ironCondor = OptionStrategies.IronCondor(
_symbol,
farPut.Strike,
nearPut.Strike,
nearCall.Strike,
nearCall.Strike,
expiry);

Buy(ironCondor, 2);
iron_condor = OptionStrategies.iron_condor(
self._symbol,
far_put.strike,
near_put.strike,
near_call.strike,
far_call.strike,
expiry)

self.buy(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

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 contracts you sell.

#### 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 a risk of early assignment on the contracts you sell.

### 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 loses \$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.