Overall Statistics
Total Orders
2
Average Win
0%
Average Loss
0%
Compounding Annual Return
-0.273%
Drawdown
0.100%
Expectancy
0
Start Equity
1000000
End Equity
999842.7
Net Profit
-0.016%
Sharpe Ratio
-10.428
Sortino Ratio
-9.393
Probabilistic Sharpe Ratio
25.521%
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
-0.017
Beta
0.002
Annual Standard Deviation
0.002
Annual Variance
0
Information Ratio
0.978
Tracking Error
0.058
Treynor Ratio
-10.434
Total Fees
$2.30
Estimated Strategy Capacity
$600000.00
Lowest Capacity Asset
GOOCV 30IZW3ETPM1D2|GOOCV VP83T1ZUHROL
Portfolio Turnover
0.01%
from AlgorithmImports import *

class BackspreadOptionStrategyAlgorithm(QCAlgorithm):

    def initialize(self) -> None:
        self.set_start_date(2017, 4, 1)
        self.set_end_date(2017, 4, 22)
        self.set_cash(1000000)

        self.universe_settings.asynchronous = True
        option = self.add_option("GOOG", Resolution.MINUTE)
        self._symbol = option.symbol
        option.set_filter(lambda universe: universe.include_weeklys().put_spread(20, 5))
        
    def on_data(self, slice: Slice) -> None:
        if self.portfolio.invested:
            return

        # Get the OptionChain
        chain = slice.option_chains.get(self._symbol, None)
        if not chain:
            return
        
        # Select the call Option contracts with the furthest expiry
        expiry = max([x.expiry for x in chain])
        puts = [i for i in chain if i.expiry == expiry]
        if not puts:
            return

        # Select the strike prices from the remaining contracts
        strikes = sorted(set(x.strike for x in puts))
        if len(strikes) < 2:
            return
        
        low_strike = strikes[0]
        high_strike = strikes[1]

        option_strategy = OptionStrategies.short_put_backspread(self._symbol, high_strike, low_strike, expiry)
        self.buy(option_strategy, 1)