Overall Statistics
Total Trades
1692
Average Win
0.14%
Average Loss
-0.14%
Compounding Annual Return
24.658%
Drawdown
13.300%
Expectancy
0.336
Net Profit
50.380%
Sharpe Ratio
1.771
Probabilistic Sharpe Ratio
77.364%
Loss Rate
32%
Win Rate
68%
Profit-Loss Ratio
0.95
Alpha
0.219
Beta
0.152
Annual Standard Deviation
0.146
Annual Variance
0.021
Information Ratio
-0.015
Tracking Error
0.261
Treynor Ratio
1.704
Total Fees
$2396.06
import numpy as np

syms     = ['UCC', 'UYM', 'UCO', 'SSO', 'SPXL', 'TECL', 'YCL', 'ROM', 'DDM', 'AGQ', 'UPW', 'ULE', 'QLD', 
'UGL', 'UWM', 'DIG', 'MVV', 'UXI', 'EDC', 'SAA', 'RXL', 'UYG', 'USD', 'URE', 'TNA', 'FAS', 'ERX']

neg_syms = ['SCC', 'SMN', 'SCO', 'SDS', 'SPXS', 'TECS', 'YCS', 'REW', 'DXD', 'ZSL', 'SDP', 'EUO', 'QID', 
'GLL', 'TWM', 'DUG', 'MZZ', 'SIJ', 'EDZ', 'SDD', 'RXD', 'SKF', 'SSG', 'SRS', 'TZA', 'FAZ', 'ERY']

        
static_weights = [0.03706180, -0.03707334, -0.03707561,  0.03706536,  0.03707422,
         -0.03707530, -0.03700968,  0.03706650,  0.03706156,  0.03707561,
          0.03706913, -0.03699909,  0.03705006,  0.03706984, -0.03640344,
         -0.03707560,  0.03706748,  0.03707518, -0.03700378,  0.03707037,
          0.03707295,  0.03707349,  0.03707537, -0.03706927, -0.03706570,
         -0.03704468, -0.03707559]
        
class MultidimensionalModulatedRegulators(QCAlgorithm):
    def Initialize(self):
        self.SetStartDate(2019, 1, 1)  # Set Start Date
        self.SetCash(1000000)  # Set Strategy Cash
        self.SetExecution(VolumeWeightedAveragePriceExecutionModel())
 
        self.symbols = []
        for i in range(len(syms)):
            if static_weights[i] < 0: syms[i] = neg_syms[i]
            self.symbols.append(Symbol.Create(syms[i], SecurityType.Equity, Market.USA))
            static_weights[i] = np.abs(static_weights[i])
            #self.Debug(syms[i])
            
        self.SetUniverseSelection( ManualUniverseSelectionModel(self.symbols) )
        self.UniverseSettings.Resolution = Resolution.Hour
        
        self.AddEquity('SPY', Resolution.Hour)
        self.SetBenchmark('SPY')

        self.SetBrokerageModel(AlphaStreamsBrokerageModel())
        
        self.constant_weights = np.abs([0.03706180, -0.03707334, -0.03707561,  0.03706536,  0.03707422,
         -0.03707530, -0.03700968,  0.03706650,  0.03706156,  0.03707561,
          0.03706913, -0.03699909,  0.03705006,  0.03706984, -0.03640344,
         -0.03707560,  0.03706748,  0.03707518, -0.03700378,  0.03707037,
          0.03707295,  0.03707349,  0.03707537, -0.03706927, -0.03706570,
         -0.03704468, -0.03707559])

        self.constant_weights /= np.sum(self.constant_weights)
        self.leverage = 1.5

    def OnData(self, data):
                
        rebalance = False
        
        if self.Portfolio.TotalHoldingsValue > 0:
            total = 0.0
            for i, sym in enumerate(self.symbols):
                curr = (self.Securities[sym].Holdings.HoldingsValue/self.Portfolio.TotalHoldingsValue)
                diff = self.constant_weights[i] - curr
                total += np.abs(diff)
            if total > 0.08: 
                rebalance = True

        if rebalance or (not self.Portfolio.Invested):
            for i, sym in enumerate(self.symbols):
                if self.constant_weights[i] != 0:
                    self.SetHoldings(sym, self.constant_weights[i] * self.leverage)