Overall Statistics
Total Trades
17
Average Win
8.27%
Average Loss
-1.10%
Compounding Annual Return
16.001%
Drawdown
14.800%
Expectancy
2.655
Net Profit
16.032%
Sharpe Ratio
0.81
Probabilistic Sharpe Ratio
38.896%
Loss Rate
57%
Win Rate
43%
Profit-Loss Ratio
7.53
Alpha
-0.032
Beta
0.552
Annual Standard Deviation
0.145
Annual Variance
0.021
Information Ratio
-1.117
Tracking Error
0.138
Treynor Ratio
0.213
Total Fees
$319.55
Estimated Strategy Capacity
$13000000.00
Lowest Capacity Asset
IEF SGNKIKYGE9NP
# Simple RSI portfolio

from AlgorithmImports import *

class SimpleRSIportfolio(QCAlgorithm):   
    def Initialize(self):
        self.SetStartDate(2020, 6, 1) 
        self.SetEndDate(2021, 6, 1) 
        self.SetCash(1000000)
        self.stock = self.AddEquity("AAPL", Resolution.Minute).Symbol
        self.bond = self.AddEquity("IEF", Resolution.Minute).Symbol
        self.rsi = self.RSI(self.stock, 40, MovingAverageType.Simple, Resolution.Daily)          
        self.SetWarmUp(50, Resolution.Daily) 

        
    def OnData(self, data):
        if self.IsWarmingUp: return
        if self.Time.time() != time(10, 1): return
        if not self.rsi.IsReady: return        

        if self.rsi.Current.Value >= 50:
            if not self.Portfolio[self.stock].IsLong:
                self.SetHoldings(self.stock, 0.5)
                self.SetHoldings(self.bond, 0.5) 

        elif self.rsi.Current.Value < 50:
            if self.Portfolio[self.stock].IsLong:
                self.Liquidate(self.stock, "rsi below threshold")