Overall Statistics
Total Trades
58
Average Win
169.08%
Average Loss
-6.32%
Compounding Annual Return
8.195%
Drawdown
39.800%
Expectancy
0.983
Net Profit
211.673%
Sharpe Ratio
0.535
Probabilistic Sharpe Ratio
2.748%
Loss Rate
93%
Win Rate
7%
Profit-Loss Ratio
26.76
Alpha
0.068
Beta
0.276
Annual Standard Deviation
0.19
Annual Variance
0.036
Information Ratio
-0.09
Tracking Error
0.233
Treynor Ratio
0.368
Total Fees
$139.50
Estimated Strategy Capacity
$520000000.00
Lowest Capacity Asset
SPY 31W0D6UNJVQIU|SPY R735QTJ8XC9X
class UncoupledTransdimensionalPrism(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2007, 1, 1)  # Set Start Date
        self.SetCash(10000)  # Set Strategy Cash
        spy = self.AddEquity("SPY", Resolution.Minute)
        spy.SetDataNormalizationMode(DataNormalizationMode.Raw)
        self.spy = spy.Symbol
        self.contract = None
        

    def OnData(self, data): 
        
        if not self.Portfolio[self.spy].Invested:
            self.SetHoldings(self.spy, 0.95)
            
        # DO HEDGE
        if self.contract is None:
            self.contract = self.GetContract()
            return
        
        if (self.contract.ID.Date - self.Time).days < 180:
            self.Liquidate(self.contract)
            self.RemoveSecurity(self.contract)
            self.contract = None
            return
        
        if not self.Portfolio[self.contract].Invested:
            self.SetHoldings(self.contract, 0.05)
        
        #Exercixe our optionns when they increase in value to 20% OTM
        if self.Securities[self.spy].Price < self.contract.ID.StrikePrice * 1.2:
            self.Liquidate(self.contract)
            self.RemoveSecurity(self.contract)
    
    def GetContract(self):
        # Set our target strike as 40% OTM put 
        targetStrike = (self.Securities[self.spy].Price * 0.6) - (self.Securities[self.spy].Price * 0.6)%5
        contracts = self.OptionChainProvider.GetOptionContractList(self.spy, self.Time)
        puts = [x for x in contracts if x.ID.OptionRight == OptionRight.Put]
        puts = sorted( sorted(puts, key = lambda x: x.ID.Date, reverse = True),
                       key = lambda x: x.ID.StrikePrice)
        puts = [x for x in puts if x.ID.StrikePrice == targetStrike]
        puts = [x for x in puts if 270 < (x.ID.Date - self.Time).days <= 420]
        if len(puts) == 0:
            self.Log("No Puts")
            return None
        self.AddOptionContract(puts[0], Resolution.Minute)
        return puts[0]