Overall Statistics
Total Trades
20
Average Win
0.10%
Average Loss
0%
Compounding Annual Return
10.007%
Drawdown
33.900%
Expectancy
0
Net Profit
172.377%
Sharpe Ratio
0.677
Probabilistic Sharpe Ratio
12.526%
Loss Rate
0%
Win Rate
100%
Profit-Loss Ratio
0
Alpha
-0.001
Beta
0.988
Annual Standard Deviation
0.173
Annual Variance
0.03
Information Ratio
-0.65
Tracking Error
0.004
Treynor Ratio
0.118
Total Fees
$23.38
class StopLoss(QCAlgorithm):

    def Initialize(self):
        
        self.SetStartDate(2010, 1, 1) 
        self.SetEndDate(2020, 7, 1) 
        self.SetCash(100000) 
        spy = self.AddEquity("SPY", Resolution.Hour)
        spy.SetDataNormalizationMode(DataNormalizationMode.Raw)
        self.lastOrderEvent = None
        
    def OnData(self, data):
    
        weight = self.SetHoldings("SPY", 0.99)
        
        close = self.Securities["SPY"].Close
        
        if not self.Portfolio.Invested:
            self.MarketOrder("SPY", weight)
            self.StopMarketOrder("SPY", -weight, 0.98 * close)