Overall Statistics
Total Orders
4
Average Win
3.70%
Average Loss
-4.76%
Compounding Annual Return
-20.672%
Drawdown
1.200%
Expectancy
-0.112
Start Equity
5000
End Equity
4938
Net Profit
-1.240%
Sharpe Ratio
-8.575
Sortino Ratio
-7.686
Probabilistic Sharpe Ratio
0.025%
Loss Rate
50%
Win Rate
50%
Profit-Loss Ratio
0.78
Alpha
-0.134
Beta
0.116
Annual Standard Deviation
0.022
Annual Variance
0
Information Ratio
2.971
Tracking Error
0.094
Treynor Ratio
-1.616
Total Fees
$0.00
Estimated Strategy Capacity
$530000.00
Lowest Capacity Asset
TQQQ 32BINNWRRXQKM|TQQQ UK280CGTCB51
Portfolio Turnover
1.04%
from AlgorithmImports import *

class TQQQOptionBullPutSpreadAlgorithm(QCAlgorithm):

    def initialize(self):
        self.set_start_date(2023, 9, 13)
        self.set_end_date(2023, 10, 2)
        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.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:        
        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)