Overall Statistics
Total Trades
139
Average Win
3.16%
Average Loss
-1.24%
Compounding Annual Return
5.205%
Drawdown
23.000%
Expectancy
0.338
Net Profit
28.899%
Sharpe Ratio
0.502
Probabilistic Sharpe Ratio
10.757%
Loss Rate
62%
Win Rate
38%
Profit-Loss Ratio
2.55
Alpha
0.049
Beta
-0.009
Annual Standard Deviation
0.094
Annual Variance
0.009
Information Ratio
-0.514
Tracking Error
0.173
Treynor Ratio
-5.183
Total Fees
$637.55
class RSIAlgorithm(QCAlgorithm):
    
    def Initialize(self):
        
        self.SetStartDate(2010, 1, 1)
        self.SetEndDate(2015, 1, 1)
        self.SetCash(100000)
        
        self.AddEquity("SPY", Resolution.Daily)

        self.SetBrokerageModel(BrokerageName.InteractiveBrokersBrokerage)
        
        RSI_Period      = 14
        
        self.RSI_SPY    = self.RSI("SPY", 14)

        self.SetWarmUp(52)
        
#----------------------------------------------------------------------------------------------------------------
#----------------------------------------------------------------------------------------------------------------

    def OnData(self, data):
        
        if self.IsWarmingUp:
            
            return

        if not self.Portfolio.Invested:
        
           if self.RSI_SPY.Current.Value > 50:
               self.SetHoldings("SPY", 1)
               
        if self.Portfolio.Invested:
            
            if self.RSI_SPY.Current.Value < 50:
                self.Liquidate("SPY")