Overall Statistics
Total Orders
4
Average Win
0%
Average Loss
0%
Compounding Annual Return
-14.590%
Drawdown
1.000%
Expectancy
0
Start Equity
100000
End Equity
99111
Net Profit
-0.889%
Sharpe Ratio
-3.738
Sortino Ratio
-2.174
Probabilistic Sharpe Ratio
1.017%
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
-0.117
Beta
0.057
Annual Standard Deviation
0.032
Annual Variance
0.001
Information Ratio
-0.755
Tracking Error
0.063
Treynor Ratio
-2.136
Total Fees
$4.00
Estimated Strategy Capacity
$2500000.00
Lowest Capacity Asset
GOOCV 30JDODOEFOQTI|GOOCV VP83T1ZUHROL
Portfolio Turnover
0.37%
# region imports
from AlgorithmImports import *
# endregion

class ShortButteflyOptionStrategy(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

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