Overall Statistics
Total Trades
359
Average Win
0.37%
Average Loss
-0.03%
Compounding Annual Return
26.273%
Drawdown
31.800%
Expectancy
11.436
Net Profit
155.324%
Sharpe Ratio
0.852
Probabilistic Sharpe Ratio
29.378%
Loss Rate
7%
Win Rate
93%
Profit-Loss Ratio
12.34
Alpha
0.051
Beta
1.006
Annual Standard Deviation
0.248
Annual Variance
0.062
Information Ratio
1.216
Tracking Error
0.043
Treynor Ratio
0.21
Total Fees
$361.69
Estimated Strategy Capacity
$37000000.00
Lowest Capacity Asset
SNPS R735QTJ8XC9X
#region imports
from AlgorithmImports import *
#endregion
##########################################
#Kamer Ali Yuksel linkedin.com/in/kyuksel#
##########################################

import numpy as np

syms = ['MSFT', 'AAPL', 'TXN', 'ASML', 'ADBE', 'CRM', 'SBUX', 'MCHP', 'MA', 'ADI', 'SWKS', 'SNPS', 'KLAC']

class MultidimensionalModulatedRegulators(QCAlgorithm):
    def Initialize(self):
        self.SetStartDate(2019, 1, 1)
        self.SetCash(100000)
        self.SetExecution(VolumeWeightedAveragePriceExecutionModel())
 
        self.symbols = []
        for i in range(len(syms)):
            self.symbols.append(Symbol.Create(syms[i], SecurityType.Equity, Market.USA))
            self.Debug(syms[i])
            
        self.SetUniverseSelection(ManualUniverseSelectionModel(self.symbols) )
        self.UniverseSettings.Resolution = Resolution.Hour
        
        self.AddEquity('VGT', Resolution.Hour)
        self.SetBenchmark('VGT')
        self.SetBrokerageModel(AlphaStreamsBrokerageModel())

        self.constant_weights = np.array([0.28535828, 0.23993727, 0.12635303, 0.05360154, 0.04681825, 0.04518177, 0.04505873, 0.04194283, 0.03757035, 0.03131177, 0.02168459, 0.0151392 , 0.01004238])
        self.constant_weights = self.constant_weights / np.sum(np.abs(self.constant_weights))

    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.TotalPortfolioValue)
                diff = self.constant_weights[i] - curr
                total += np.abs(diff)
                
            if total > 0.05: 
                rebalance = True
                
            if rebalance:
                for i, sym in enumerate(self.symbols):
                    curr = (self.Securities[sym].Holdings.HoldingsValue/self.Portfolio.TotalPortfolioValue)
                    if self.constant_weights[i] < curr:
                        self.SetHoldings(sym, self.constant_weights[i])
                for i, sym in enumerate(self.symbols):
                    curr = (self.Securities[sym].Holdings.HoldingsValue/self.Portfolio.TotalPortfolioValue)                       
                    if self.constant_weights[i] > curr:
                        self.SetHoldings(sym, self.constant_weights[i])
        else:
            for i, sym in enumerate(self.symbols):
                    self.SetHoldings(sym, self.constant_weights[i])