Overall Statistics
Total Orders
4
Average Win
0%
Average Loss
0%
Compounding Annual Return
-14.209%
Drawdown
1.000%
Expectancy
0
Start Equity
100000
End Equity
99136
Net Profit
-0.864%
Sharpe Ratio
-3.634
Sortino Ratio
-2.498
Probabilistic Sharpe Ratio
2.172%
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
-0.118
Beta
0.001
Annual Standard Deviation
0.033
Annual Variance
0.001
Information Ratio
-0.678
Tracking Error
0.066
Treynor Ratio
-223.648
Total Fees
$4.00
Estimated Strategy Capacity
$200000.00
Lowest Capacity Asset
GOOCV 30JDOCPZQ7Y3Q|GOOCV VP83T1ZUHROL
Portfolio Turnover
0.43%
# region imports
from AlgorithmImports import *
# endregion

class JellyRollOptionStrategy(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])

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