Overall Statistics
Total Trades
75
Average Win
5.02%
Average Loss
-0.76%
Compounding Annual Return
12.069%
Drawdown
9.700%
Expectancy
3.340
Net Profit
140.271%
Sharpe Ratio
0.863
Probabilistic Sharpe Ratio
20.827%
Loss Rate
43%
Win Rate
57%
Profit-Loss Ratio
6.65
Alpha
0.091
Beta
-0.038
Annual Standard Deviation
0.101
Annual Variance
0.01
Information Ratio
-0.061
Tracking Error
0.189
Treynor Ratio
-2.276
Total Fees
$383.05
Estimated Strategy Capacity
$13000000.00
Lowest Capacity Asset
BIL TT1EBZ21QWKL
Portfolio Turnover
1.92%
from AlgorithmImports import *
from datetime import datetime, timedelta

class CustomDataWeighAlgorithm(QCAlgorithm):
    def Initialize(self):
        self.SetStartDate(2016,1, 1)
       # self.SetEndDate(2020,5, 1)
        self.SetCash(100000)
        self.symbols = "SPY", "SPXL", "UVXY", "SSO","BIL","TQQQ","QLD","USD","SOXL"
        self.rsi = {}
        self.bil_holdings = 0
        self.uvxy_holdings = 0
        self.sso_holdings = 0
        self.qld_holdings = 0
        self.usd_holdings = 0
        self.Settings.FreePortfolioValuePercentage = 0.10

        for symbol in self.symbols:
            equity = self.AddEquity(symbol, Resolution.Daily)
            self.rsi[symbol] = self.RSI(equity.Symbol, 11)

    def OnData(self, data):
        
        if not self.rsi["SPXL"].IsReady:
            return

        if self.rsi["SPXL"].Current.Value > 80 :
           self.Liquidate("BIL")
           self.SetHoldings("UVXY", 0.99)
     
        else:
           self.Liquidate("UVXY")
           self.SetHoldings("BIL", 0.99)