Overall Statistics
Total Trades
616
Average Win
0.00%
Average Loss
0.00%
Compounding Annual Return
2.111%
Drawdown
0.500%
Expectancy
20.807
Net Profit
12.581%
Sharpe Ratio
3.075
Probabilistic Sharpe Ratio
100.000%
Loss Rate
12%
Win Rate
88%
Profit-Loss Ratio
23.64
Alpha
0.019
Beta
0.013
Annual Standard Deviation
0.007
Annual Variance
0
Information Ratio
-0.654
Tracking Error
0.183
Treynor Ratio
1.642
Total Fees
$694.30
import numpy as np

syms = ['IEI', 'ERX', 'XLB', 'XLE', 'GDX', 'XLU', 'FDN', 'TLT', 'XES', 'BIL',
       'SLV', 'TBT', 'IAU', 'VDE', 'UNG', 'XLK', 'TECL', 'XLV', 'XLP', 'XOP',
       'SHV', 'ICLN', 'XLI', 'UCO', 'ERY', 'SPTL', 'AGQ', 'SCO', 'QQQ', 'XLF',
       'GLD', 'IGV', 'FXL', 'IEF', 'SHY', 'QTEC', 'USO', 'TLH', 'TAN', 'TECS']
        
class MultidimensionalModulatedRegulators(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2015, 1, 1)
        self.SetCash(1000000)
        self.symbols = []
        for i in range(len(syms)):
            self.symbols.append(Symbol.Create(syms[i], SecurityType.Equity, Market.USA))
        self.SetUniverseSelection( ManualUniverseSelectionModel(self.symbols) )
        self.UniverseSettings.Resolution = Resolution.Hour
        
        self.AddEquity('SPY', Resolution.Hour)
        self.SetBenchmark('SPY')
        self.SetBrokerageModel(AlphaStreamsBrokerageModel())

    def OnData(self, data):
        self.constant_weights = np.array([9.34755988e-03, 3.81794689e-06, 2.73189398e-05, 3.73349467e-05,
         6.17753358e-06, 1.13753122e-04, 4.86071862e-04, 2.15727603e-04,
         1.12426060e-05, 3.03697258e-01, 8.25903226e-06, 4.41784832e-05,
         6.33423188e-05, 3.29151699e-05, 1.04393821e-05, 1.05330686e-03,
         2.23151346e-06, 6.45845709e-03, 7.63766002e-03, 1.47287337e-05,
         3.30812722e-01, 8.52190078e-06, 1.35812705e-04, 7.23709218e-06,
         1.28564043e-05, 7.77560694e-04, 1.58797218e-06, 1.00353282e-05,
         3.67849553e-03, 2.23107927e-05, 6.87888314e-05, 2.34894051e-05,
         3.30419498e-05, 2.45390972e-03, 3.31439734e-01, 3.45058681e-04,
         2.07255653e-05, 8.54378450e-04, 6.37257517e-06, 1.55947491e-05])
        
        self.constant_weights /= np.sum(self.constant_weights)
                    
        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.0025: 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] * 1.5)