Overall Statistics
Total Orders
4
Average Win
0%
Average Loss
0%
Compounding Annual Return
-13.287%
Drawdown
0.900%
Expectancy
0
Start Equity
100000
End Equity
99196
Net Profit
-0.804%
Sharpe Ratio
-3.788
Sortino Ratio
-2.355
Probabilistic Sharpe Ratio
1.972%
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
-0.116
Beta
-0.059
Annual Standard Deviation
0.029
Annual Variance
0.001
Information Ratio
-0.563
Tracking Error
0.068
Treynor Ratio
1.891
Total Fees
$4.00
Estimated Strategy Capacity
$280000.00
Lowest Capacity Asset
GOOCV 30JDOCPZQ7Y3Q|GOOCV VP83T1ZUHROL
Portfolio Turnover
0.43%
# region imports
from AlgorithmImports import *
# endregion

class ShortJellyRollOptionStrategy(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().jelly_roll(5.0, 30, 60))

    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 an expiry date and ITM & OTM strike prices
        strike = sorted([x.strike for x in chain], key=lambda x: abs(x - chain.underlying.price))[0]
        contracts = [x for x in chain if x.strike == strike]
        far_expiry = max([x.expiry for x in contracts])
        near_expiry = min([x.expiry for x in contracts])

        short_jelly_roll = OptionStrategies.short_jelly_roll(self._symbol, strike, near_expiry, far_expiry)
        self.buy(short_jelly_roll, 1)