Option Strategies
Short Iron Butterfly
Introduction
The Short Iron Butterfly is an option strategy which involves four Option contracts. All the contracts have the same underlying stock and expiration, but the order of strike prices for the four contracts is $A>B>C$. The following table describes the strike price of each contract:
| Position | Strike |
|---|---|
| 1 OTM call | $A$ |
| -1 ATM call | $B$ |
| -1 ATM put | $B$ |
| 1 OTM put | $C=B-(A-B)$ |
The short call butterfly 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 from time decay value since ATM options decay sharper.
Implementation
Follow these steps to implement the short iron butterfly strategy:
- In the
Initializeinitializemethod, set the start date, end date, cash, and Option universe. - In the
OnDataon_datamethod, select the contracts in the strategy legs. - In the
OnDataon_datamethod, select the contracts and place the orders.
private Symbol _symbol;
public override void Initialize()
{
SetStartDate(2024, 9, 1);
SetEndDate(2024, 12, 31);
SetCash(100000);
UniverseSettings.Asynchronous = true;
var option = AddOption("GOOG", Resolution.Minute);
_symbol = option.Symbol;
option.SetFilter(universe => universe.IncludeWeeklys().IronButterfly(30, 5));
} def initialize(self) -> None:
self.set_start_date(2024, 9, 1)
self.set_end_date(2024, 12, 31)
self.set_cash(100000)
self.universe_settings.asynchronous = True
option = self.add_option("GOOG", Resolution.MINUTE)
self._symbol = option.symbol
option.set_filter(lambda universe: universe.include_weeklys().iron_butterfly(30, 5));
The IronButterflyiron_butterfly filter narrows the universe down to just the four contracts you need to form a short iron butterly.
public override void OnData(Slice slice)
{
if (Portfolio.Invested ||
!slice.OptionChains.TryGetValue(_symbol, out var chain))
{
return;
}
// Select expiry
var expiry = chain.Max(x => x.Expiry);
// Separate the call and put contracts
var calls = chain.Where(x => x.Right == OptionRight.Call && x.Expiry == expiry);
var puts = chain.Where(x => x.Right == OptionRight.Put && x.Expiry == expiry);
if (calls.Count() == 0 || puts.Count() == 0) return;
// Get the ATM and OTM strike prices
var atmStrike = calls.OrderBy(x => Math.Abs(x.Strike - chain.Underlying.Price)).First().Strike;
var otmPutStrike = puts.Min(x => x.Strike);
var otmCallStrike = 2 * atmStrike - otmPutStrike; def on_data(self, slice: Slice) -> None:
if self.portfolio.invested:
return
# Get the OptionChain
chain = slice.option_chains.get(self._symbol, None)
if not chain:
return
# Select expiry
expiry = max([x.expiry for x in chain])
# Separate the call and put contracts
calls = [i for i in chain if i.right == OptionRight.CALL and i.expiry == expiry]
puts = [i for i in chain if i.right == OptionRight.PUT and i.expiry == expiry]
if not calls or not puts:
return
# Get the ATM and OTM strike prices
atm_strike = sorted(calls, key = lambda x: abs(chain.underlying.price - x.strike))[0].strike
otm_put_strike = min([x.strike for x in puts])
otm_call_strike = 2 * atm_strike - otm_put_strike
Approach A: Call the OptionStrategies.ShortIronButterflyOptionStrategies.short_iron_butterfly method with the details of each leg and then pass the result to the Buybuy method.
var shortIronButterfly = OptionStrategies.ShortIronButterfly(_symbol, otmPutStrike, atmStrike, otmCallStrike, expiry); Buy(shortIronButterfly, 2);
short_iron_butterfly = OptionStrategies.short_iron_butterfly(self._symbol, otm_put_strike, atm_strike, otm_call_strike, expiry) self.buy(short_iron_butterfly, 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.
// Select the contracts
var atmCall = calls.Single(x => x.Strike == atmStrike);
var atmPut = puts.Single(x => x.Strike == atmStrike);
var otmCall = calls.Single(x => x.Strike == otmCallStrike);
var otmPut = puts.Single(x => x.Strike == otmPutStrike);
var legs = new List<Leg>()
{
Leg.Create(atmCall.Symbol, 1),
Leg.Create(atmPut.Symbol, 1),
Leg.Create(otmCall.Symbol, -1),
Leg.Create(otmPut.Symbol, -1)
};
ComboMarketOrder(legs, 1); # Select the contracts
atm_call = [x for x in calls if x.strike == atm_strike][0]
atm_put = [x for x in puts if x.strike == atm_strike][0]
otm_call = [x for x in calls if x.strike == otm_call_strike][0]
otm_put = [x for x in puts if x.strike == otm_put_strike][0]
legs = [
Leg.create(atm_call.symbol, 1),
Leg.create(atm_put.symbol, 1),
Leg.create(otm_call.symbol, -1),
Leg.create(otm_put.symbol, -1)
]
self.combo_market_order(legs, 1)
Strategy Payoff
The short iron butterfly is a limited-reward-limited-risk strategy. The payoff is
$$ \begin{array}{rcll} C^{OTM}_T & = & (S_T - K^C_{OTM})^{+}\\ C^{ATM}_T & = & (S_T - K^C_{ATM})^{+}\\ P^{OTM}_T & = & (K^P_{OTM} - S_T)^{+}\\ P^{ATM}_T & = & (K^P_{ATM} - S_T)^{+}\\ P_T & = & (C^{ATM}_T + P^{ATM}_T - C^{OTM}_T - P^{OTM}_T - C^{ATM}_0 - P^{ATM}_0 + C^{OTM}_0 + P^{OTM}_0)\times m - fee \end{array} $$ $$ \begin{array}{rcll} \textrm{where} & C^{OTM}_T & = & \textrm{OTM call value at time T}\\ & C^{ATM}_T & = & \textrm{ATM call value at time T}\\ & P^{OTM}_T & = & \textrm{OTM put value at time T}\\ & P^{ATM}_T & = & \textrm{ATM put value at time T}\\ & S_T & = & \textrm{Underlying asset price at time T}\\ & K^C_{OTM} & = & \textrm{OTM call strike price}\\ & K^C_{ATM} & = & \textrm{ATM call strike price}\\ & K^P_{OTM} & = & \textrm{OTM put strike price}\\ & K^P_{ATM} & = & \textrm{ATM put strike price}\\ & P_T & = & \textrm{Payout total at time T}\\ & C^{OTM}_0 & = & \textrm{OTM call value at position opening (credit received)}\\ & C^{ATM}_0 & = & \textrm{ATM call value at position opening (debit paid)}\\ & P^{OTM}_0 & = & \textrm{OTM put value at position opening (credit received)}\\ & P^{ATM}_0 & = & \textrm{ATM 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_{OTM} - K^C_{ATM} - C^{ATM}_0 - P^{ATM}_0 + C^{OTM}_0 + P^{OTM}_0$. It occurs when the underlying price is below the OTM put strike price or above the OTM call strike price at expiration.
The maximum loss is the net debit paid, $C^{OTM}_0 + P^{OTM}_0 - C^{ATM}_0 - P^{ATM}_0$. It occurs when the underlying price stays the same as when you opened the trade.
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 ($) |
|---|---|---|
| OTM call | 2.35 | 855.00 |
| OTM put | 2.75 | 810.00 |
| ATM call | 8.10 | 832.50 |
| ATM put | 7.40 | 832.50 |
| Underlying Equity at expiration | 843.25 | - |
Therefore, the payoff is
$$ \begin{array}{rcll} C^{OTM}_T & = & (S_T - K^C_{OTM})^{+}\\ & = & (843.25-855.00)^{+}\\ & = & 0\\ C^{ATM}_T & = & (S_T - K^C_{ATM})^{+}\\ & = & (843.25-832.50)^{+}\\ & = & 10.75\\ P^{OTM}_T & = & (K^P_{OTM} - S_T)^{+}\\ & = & (810.00-843.25)^{+}\\ & = & 0\\ P^{ATM}_T & = & (K^P_{ATM} - S_T)^{+}\\ & = & (832.50.00-843.25)^{+}\\ & = & 0\\ P_T & = & (C^{OTM}_T + P^{OTM}_T - C^{ATM}_T - P^{ATM}_T - C^{OTM}_0 - P^{OTM}_0 + C^{ATM}_0 + P^{ATM}_0)\times m - fee\\ & = & (0+0-10.75-0-2.35-2.75+8.10+7.40)\times100-1\times4\\ & = & -39 \end{array} $$So, the strategy losses $39.
The following algorithm implements a short iron butterfly Option strategy:
public class ShortButterflyStrategy : QCAlgorithm
{
private Symbol _symbol;
public override void Initialize()
{
SetStartDate(2024, 9, 1);
SetEndDate(2024, 12, 31);
SetCash(100000);
var option = AddOption("GOOG", Resolution.Minute);
_symbol = option.Symbol;
option.SetFilter(universe => universe.IncludeWeeklys().IronButterfly(30, 5));
}
public override void OnData(Slice slice)
{
if (Portfolio.Invested ||
!slice.OptionChains.TryGetValue(_symbol, out var chain))
{
return;
}
// Select expiry
var expiry = chain.Max(x => x.Expiry);
// Separate the call and put contracts
var calls = chain.Where(x => x.Right == OptionRight.Call && x.Expiry == expiry);
var puts = chain.Where(x => x.Right == OptionRight.Put && x.Expiry == expiry);
if (calls.Count() == 0 || puts.Count() == 0) return;
// Get the ATM and OTM strike prices
var atmStrike = calls.OrderBy(x => Math.Abs(x.Strike - chain.Underlying.Price)).First().Strike;
var otmPutStrike = puts.Min(x => x.Strike);
var otmCallStrike = 2 * atmStrike - otmPutStrike;
// Order Strategy
var shortIronButterfly = OptionStrategies.ShortIronButterfly(_symbol, otmPutStrike, atmStrike, otmCallStrike, expiry);
Buy(shortIronButterfly, 1);
}
} class ShortButteflyOptionStrategy(QCAlgorithm):
def initialize(self) -> None:
self.set_start_date(2024, 9, 1)
self.set_end_date(2024, 12, 31)
self.set_cash(100000)
option = self.add_option("GOOG", Resolution.MINUTE)
self._symbol = option.symbol
# set our strike/expiry filter for this option chain
option.set_filter(lambda x: x.include_weeklys().iron_butterfly(30, 5))
def on_data(self, slice: Slice) -> None:
if self.portfolio.invested:
return
# Get the OptionChain
chain = slice.option_chains.get(self._symbol, None)
if not chain:
return
# Select expiry
expiry = max([x.expiry for x in chain])
# Separate the call and put contracts
calls = [i for i in chain if i.right == OptionRight.CALL and i.expiry == expiry]
puts = [i for i in chain if i.right == OptionRight.PUT and i.expiry == expiry]
if not calls or not puts:
return
# Get the ATM and OTM strike prices
atm_strike = sorted(calls, key = lambda x: abs(x.strike - chain.underlying.price))[0].strike
otm_put_strike = min([x.strike for x in puts])
otm_call_strike = 2 * atm_strike - otm_put_strike
short_iron_butterfly = OptionStrategies.short_iron_butterfly(self._symbol, otm_put_strike, atm_strike, otm_call_strike, expiry)
self.buy(short_iron_butterfly, 1)