Overall Statistics
Total Trades
2
Average Win
0%
Average Loss
0%
Compounding Annual Return
4.318%
Drawdown
33.700%
Expectancy
0
Net Profit
2.154%
Sharpe Ratio
0.307
Probabilistic Sharpe Ratio
29.013%
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
0.148
Beta
-0.269
Annual Standard Deviation
0.408
Annual Variance
0.167
Information Ratio
0.066
Tracking Error
0.654
Treynor Ratio
-0.467
Total Fees
$2.53
class DynamicOptimizedCoreWave(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2020, 1, 21)  # Set Start Date
        self.SetCash(100000)  # Set Strategy Cash
        self.AddEquity("SPY", Resolution.Daily)
        
        self.high_water_mark = -1
        self.tolerance = .01

    def OnData(self, data):
        if data["SPY"].Close > self.high_water_mark:
            self.high_water_mark = data["SPY"].Close
            return  # since this means the price is going up, 
                    #   we return because this isn't at a peak yet
            
        if 1-self.tolerance < data["SPY"].Close/self.high_water_mark < 1+self.tolerance:
            self.SetHoldings("SPY", 1)