Overall Statistics
Total Orders
5
Average Win
6.65%
Average Loss
-3.84%
Compounding Annual Return
-21.482%
Drawdown
1.400%
Expectancy
0.823
Start Equity
5000
End Equity
4932
Net Profit
-1.360%
Sharpe Ratio
-7.818
Sortino Ratio
-6.252
Probabilistic Sharpe Ratio
0.008%
Loss Rate
33%
Win Rate
67%
Profit-Loss Ratio
1.73
Alpha
-0.145
Beta
0.091
Annual Standard Deviation
0.025
Annual Variance
0.001
Information Ratio
3.44
Tracking Error
0.102
Treynor Ratio
-2.147
Total Fees
$1.00
Estimated Strategy Capacity
$530000.00
Lowest Capacity Asset
TQQQ 32BINNWRRXQKM|TQQQ UK280CGTCB51
Portfolio Turnover
7.89%
from AlgorithmImports import *

class TQQQOptionBullPutSpreadAlgorithm(QCAlgorithm):

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

        self.option_symbol = option.symbol
        
        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.Exercise)

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

    def Exercise(self):
        for symbol, security in self.securities.items():
            if security.invested:
                self.exercise_option(symbol, -security.holdings.quantity)
        self.liquidate()

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

    def OpenSpread(self) -> None:  
        if self.portfolio.invested:
            return      
        chain = self.current_slice.option_chains.get(self.option_symbol)

        if chain:
            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]
            bull_call_spread = OptionStrategies.bull_put_spread(self.option_symbol, shortPut.strike, longPut.strike, longPut.expiry)
            self.buy(bull_call_spread, 1)