Overall Statistics
Total Orders
4
Average Win
0%
Average Loss
0%
Compounding Annual Return
-13.826%
Drawdown
0.900%
Expectancy
0
Start Equity
100000
End Equity
99161
Net Profit
-0.839%
Sharpe Ratio
-3.86
Sortino Ratio
-2.572
Probabilistic Sharpe Ratio
0.860%
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
-0.112
Beta
0.047
Annual Standard Deviation
0.03
Annual Variance
0.001
Information Ratio
-0.673
Tracking Error
0.062
Treynor Ratio
-2.456
Total Fees
$4.00
Estimated Strategy Capacity
$3900000.00
Lowest Capacity Asset
GOOCV 30JDODOEFOQTI|GOOCV VP83T1ZUHROL
Portfolio Turnover
0.37%
# region imports
from AlgorithmImports import *
# endregion

class LongButteflyOptionStrategy(QCAlgorithm):

    def initialize(self):
        self.set_start_date(2017, 4, 1)
        self.set_end_date(2017, 4, 23)
        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):
        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

        iron_butterfly = OptionStrategies.iron_butterfly(self._symbol, otm_put_strike, atm_strike, otm_call_strike, expiry)
        self.buy(iron_butterfly, 1)