Overall Statistics
Total Trades
208
Average Win
2.64%
Average Loss
-0.03%
Compounding Annual Return
38.640%
Drawdown
45.300%
Expectancy
77.334
Net Profit
2992.267%
Sharpe Ratio
1.468
Probabilistic Sharpe Ratio
74.788%
Loss Rate
3%
Win Rate
97%
Profit-Loss Ratio
79.64
Alpha
0.212
Beta
1.572
Annual Standard Deviation
0.31
Annual Variance
0.096
Information Ratio
1.691
Tracking Error
0.178
Treynor Ratio
0.29
Total Fees
$209.48
# Inspired by the theory here:
# https://seekingalpha.com/article/4299701-leveraged-etfs-for-long-term-investing

class Investment(object):
    def __init__(self, symbol, weight):
        self.symbol = symbol
        self.weight = weight

class MultidimensionalTransdimensionalPrism(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2010, 3, 1)
        self.SetCash(1600)
        self.AddEquity("SPY", Resolution.Hour)
        
        self.cashToAdd = 0
        self.investments = [
            Investment("TQQQ", 0.6),
            Investment("TLT", 0.4),
        ]
        
        # Add symbols
        for investment in self.investments:
            self.AddEquity(investment.symbol, Resolution.Hour)
        
        # Schedules
        self.Schedule.On(self.DateRules.MonthStart("SPY"), self.TimeRules.AfterMarketOpen("SPY", 150), self.Rebalance)
        self.Schedule.On(self.DateRules.MonthStart("SPY"), self.TimeRules.AfterMarketOpen("SPY", 140), self.AddCash)

    def OnData(self, data):
        pass       
        
    def Rebalance(self):
        for investment in self.investments:
            self.SetHoldings(investment.symbol, investment.weight)
            
    def AddCash(self):
        self.Portfolio.SetCash(self.Portfolio.Cash + self.cashToAdd)