Overall Statistics
Total Orders
832
Average Win
0.78%
Average Loss
-1.39%
Compounding Annual Return
-30.968%
Drawdown
49.600%
Expectancy
-0.072
Start Equity
100000
End Equity
62708.12
Net Profit
-37.292%
Sharpe Ratio
-1.172
Sortino Ratio
-1.327
Probabilistic Sharpe Ratio
0.265%
Loss Rate
41%
Win Rate
59%
Profit-Loss Ratio
0.56
Alpha
-0.117
Beta
-1.556
Annual Standard Deviation
0.222
Annual Variance
0.049
Information Ratio
-1.149
Tracking Error
0.306
Treynor Ratio
0.167
Total Fees
$3850.97
Estimated Strategy Capacity
$890000.00
Lowest Capacity Asset
BGU U7EC123NWZTX
Portfolio Turnover
180.61%
from AlgorithmImports import *

class MyAlgorithm(QCAlgorithm):
    def Initialize(self):
        self.SetStartDate(2023, 1, 29)
        self.SetCash(100000)
        self.spxl = self.AddEquity("SPXL", Resolution.Minute).Symbol
        
        # Initialize RSI indicator with a period of 14 (default)
        self.rsi = self.RSI(self.spxl, 14, MovingAverageType.Wilders, Resolution.Minute)
        
        self.is_invested = False

    def OnData(self, data: Slice):
        if not self.rsi.IsReady:
            return
        
        current_rsi = self.rsi.Current.Value

        if not self.Portfolio.Invested and current_rsi > 70:  # Example threshold for shorting
            self.SetHoldings(self.spxl, -1)  # Short SPXL
            self.is_invested = True
        elif self.is_invested and current_rsi < 30:  # Example threshold for exiting
            self.Liquidate(self.spxl)  # Exit short position
            self.is_invested = False