Iron Butterfly Options Strategy#

Understand this code: Read our step-by-step explanation of this notebook: guided walkthrough.

Restricted data: You will only have access to the data used in this notebook if your organisation has specifically purchased it. To check your current data access, view Data. If you would like to access more data, please contact sales@sigtech.com.

Changes will not be saved: Edits made to SigTech’s example notebooks like this will only persist for the duration of your session. When you restart the research environment, this notebook will have been restored to its original state, and any changes you have made will have been lost. To make permanent changes, copy and paste the content to a new notebook in one of your workspaces.

Environment#

[ ]:
import sigtech.framework as sig

import datetime as dtm
import seaborn as sns

sns.set(rc={'figure.figsize': (18, 6)})
env = sig.init(env_date=dtm.date(2024, 2, 22))

Define the investment universe#

[ ]:
straddle_dir = 'SHORT'
strangle_dir = 'LONG'
maturity = '1M'
delta_strangle = 0.05
option_grp = sig.obj.get('SPX INDEX OTC OPTION GROUP')
[ ]:
start_date = dtm.datetime(2010, 1, 4)

Create the strategy#

[ ]:
atm_straddle = sig.RollingStraddleOptionStrategy(
    # Specify the currency the strategy will be denominated in
    currency='USD',

    # Start date of the strategy
    start_date=start_date,

    # Name of the option group to trade options for
    group_name=option_grp.name,

    # Strike type set to ATM of the underlying
    strike_type='SPOT',

    # Maturity or tenor of underlying options
    maturity=maturity,

    # Set roll dates date of the strategy
    rolling_frequencies=[maturity],

    # Target Quantity to trade at wach roll (denoted in contracts)
    target_quantity=-1 if straddle_dir == 'SHORT' else 1,

    # Name of strategy
    ticker=f'{straddle_dir} SPX OTC STRADDLE ATM'
)
[ ]:
oom_strangle = sig.RollingStrangleOptionStrategy(
    # Specify the currency the strategy will be denominated in
    currency='USD',

    # Start date of the strategy
    start_date=start_date,

    # Name of the option group to trade options for
    group_name=option_grp.name,

    # Strike type of the underlying options
    strike_type='Delta',

    # Strike of Call (in delta)
    call_strike=delta_strangle,

     # Strike of Put (in delta)
    put_strike=-1 * delta_strangle,

    # Maturity or tenor of underlying options
    maturity=maturity,

    # Set roll dates date of the strategy
    rolling_frequencies=[maturity],

    # Target Quantity to trade at wach roll (denoted in contracts)
    target_quantity=1 if strangle_dir == 'LONG' else -1,

    # Name of strategy
    ticker=f'{strangle_dir} SPX OTC STRANGLE {delta_strangle}',
)
[ ]:
strategies = [atm_straddle, oom_strangle]

Construct the portfolio#

[ ]:
roll_ds = sig.SchedulePeriodic(
    # Start date of custom roll table
    start_date=start_date,

    # End date of custom roll table, which is
    # taken from the environment variable
    end_date=env.asofdate,

    # Holidays
    holidays=option_grp.holidays,

    # Business day count
    bdc=sig.calendar.BDC_FOLLOWING,

    # Frequency
    frequency="1M",
).all_data_dates()[1:]
[ ]:
basket_strategy = sig.BasketStrategy(
    # Specify the currency the strategy will be denominated in
    currency="USD",

    # List of constituent tickers
    constituent_names=[
        strategy.name for strategy in strategies
    ],

    # Start date of strategy
    start_date=start_date,

    # List of constituents weights expressed as floats.
    weights=[1/len(strategies)] * len(strategies),

    # List of customised roll dates
    rebalance_dates=roll_ds,

    # Name of strategy
    ticker=f'IRON BUTTERFLY'
)
[ ]:
basket_strategy.history().plot(title='IRON BUTTERFLY');

Generate the performance report#

[ ]:
strategies.append(basket_strategy)
sig.PerformanceReport(
    strategies,
    cash=sig.CashIndex.from_currency('USD')
).report()