Overall Statistics |
Total Trades 1264 Average Win 0.18% Average Loss -0.14% Compounding Annual Return 37.247% Drawdown 13.300% Expectancy 0.341 Net Profit 30.929% Sharpe Ratio 2.009 Probabilistic Sharpe Ratio 73.148% Loss Rate 41% Win Rate 59% Profit-Loss Ratio 1.26 Alpha 0.364 Beta 0.155 Annual Standard Deviation 0.196 Annual Variance 0.038 Information Ratio 0.557 Tracking Error 0.356 Treynor Ratio 2.539 Total Fees $1816.79 |
from Execution.VolumeWeightedAveragePriceExecutionModel import VolumeWeightedAveragePriceExecutionModel 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(2020, 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)