Overall Statistics
Total Trades
430
Average Win
0.09%
Average Loss
-0.02%
Compounding Annual Return
8.040%
Drawdown
20.200%
Expectancy
5.637
Net Profit
59.097%
Sharpe Ratio
0.837
Probabilistic Sharpe Ratio
31.723%
Loss Rate
3%
Win Rate
97%
Profit-Loss Ratio
5.84
Alpha
0.058
Beta
0.193
Annual Standard Deviation
0.103
Annual Variance
0.011
Information Ratio
-0.333
Tracking Error
0.177
Treynor Ratio
0.447
Total Fees
$3821.80
import numpy as np

syms = ['NXN', 'INSI', 'BKT']

static_weights = [0.09424385, 0.21781130, 0.68794489]
        
class MultidimensionalModulatedRegulators(QCAlgorithm):
    def Initialize(self):
        self.SetStartDate(2015, 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.array([0.09424385, 0.21781130, 0.68794489])

        self.constant_weights /= np.sum(np.abs(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.01: 
                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)