Overall Statistics
Total Orders
4
Average Win
0.18%
Average Loss
-0.25%
Compounding Annual Return
-0.787%
Drawdown
0.100%
Expectancy
-0.125
Start Equity
100000
End Equity
99938
Net Profit
-0.062%
Sharpe Ratio
-65.394
Sortino Ratio
-49.276
Probabilistic Sharpe Ratio
0.015%
Loss Rate
50%
Win Rate
50%
Profit-Loss Ratio
0.75
Alpha
-0.059
Beta
0.004
Annual Standard Deviation
0.001
Annual Variance
0
Information Ratio
1.38
Tracking Error
0.11
Treynor Ratio
-14.842
Total Fees
$0.00
Estimated Strategy Capacity
$520000.00
Lowest Capacity Asset
TQQQ 32BINNWRRXQKM|TQQQ UK280CGTCB51
Portfolio Turnover
0.04%
from AlgorithmImports import *

class TQQQOptionBullPutSpreadAlgorithm(QCAlgorithm):

    def initialize(self):
        self.set_start_date(2023, 9, 13)
        self.set_end_date(2023, 10, 11)
        self.set_cash(100000)
        self.ticker = "TQQQ"
        tqqq    = self.add_equity(self.ticker, Resolution.MINUTE).symbol
        option  = self.add_option(tqqq, self.ticker, Resolution.MINUTE)
        option.set_filter(lambda x: x.IncludeWeeklys()
                                     .Strikes(-100, 0).PutsOnly()
                                     .Expiration(20, 30))

        self.option_symbol = option.symbol
        self.tickets = []

        self.Schedule.On(self.DateRules.On(2023, 9, 13), 
                         self.TimeRules.At(9, 35), 
                         self.OpenSpread)

        self.Schedule.On(self.DateRules.On(2023, 10, 2), 
                         self.TimeRules.At(9, 33), 
                         self.Liquidate)

        self.SetSecurityInitializer(CompositeSecurityInitializer(self.SecurityInitializer, FuncSecurityInitializer(self.CustomSecurityInitializer)))

    def CustomSecurityInitializer(self, security):
        security.SetMarketPrice(self.GetLastKnownPrice(security))        
        security.SetOptionAssignmentModel(NullOptionAssignmentModel())
        security.SetFeeModel(ConstantFeeModel(0))

    def OpenSpread(self) -> None:
        
        if not any([self.portfolio[x.symbol].invested for x in self.tickets]):
            chain = self.current_slice.option_chains.get(self.option_symbol)
            if chain:
                try:
                    shortPut = [i for i in chain if "231006P00039500" in i.Symbol.Value ][0]
                    longPut  = [i for i in chain if "231006P00039000" in i.Symbol.Value ][0]
                    # if len(puts) < 2: return

                    # Buy the bull put spread
                    bull_call_spread = OptionStrategies.bull_put_spread(self.option_symbol, shortPut.strike, longPut.strike, longPut.expiry)
                    self.tickets = self.buy(bull_call_spread, 1)
                except:
                    pass