Overall Statistics |
Total Trades 542 Average Win 1.37% Average Loss 0% Compounding Annual Return 37.680% Drawdown 23.400% Expectancy 0 Net Profit 4599.017% Sharpe Ratio 2.172 Probabilistic Sharpe Ratio 99.741% Loss Rate 0% Win Rate 100% Profit-Loss Ratio 0 Alpha 0.256 Beta 0.86 Annual Standard Deviation 0.185 Annual Variance 0.034 Information Ratio 2.311 Tracking Error 0.101 Treynor Ratio 0.466 Total Fees $4835.51 |
import numpy as np syms = ['DPZ', 'AAPL', 'MKTX', 'NFLX', 'MO', 'DLTR', 'ORLY', 'HRL', 'AZO', 'AMZN', 'ROST', 'TJX', 'NI', 'MA', 'TYL', 'CMS', 'ISRG', 'BKNG', 'SWKS', 'NVDA', 'IDXX', 'TDG', 'DXCM', 'BR', 'MCD', 'FDN'] class MultidimensionalModulatedRegulators(QCAlgorithm): def Initialize(self): self.SetStartDate(2009, 1, 1) self.SetCash(1000000) 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('SPY', Resolution.Hour) self.SetBenchmark('SPY') self.SetBrokerageModel(AlphaStreamsBrokerageModel()) self.constant_weights = np.array([0.15127148, 0.14096956, 0.11464883, 0.08053819, 0.07183724, 0.0689432 , 0.0593862 , 0.04365404, 0.03406639, 0.02905478, 0.02853938, 0.02340857, 0.02157884, 0.01870045, 0.01373184, 0.01336607, 0.01219164, 0.01180656, 0.01143535, 0.01089439, 0.01046122, 0.00775818, 0.00726694, 0.00591355, 0.00452038, 0.00405665]) self.constant_weights /= np.sum(np.abs(self.constant_weights)) self.leverage = 1.0 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.155: rebalance = True if rebalance: for i, sym in enumerate(self.symbols): curr = (self.Securities[sym].Holdings.HoldingsValue/self.Portfolio.TotalHoldingsValue) if self.constant_weights[i] < curr: self.SetHoldings(sym, self.constant_weights[i] * self.leverage) for i, sym in enumerate(self.symbols): curr = (self.Securities[sym].Holdings.HoldingsValue/self.Portfolio.TotalHoldingsValue) if self.constant_weights[i] > curr: self.SetHoldings(sym, self.constant_weights[i] * self.leverage) else: for i, sym in enumerate(self.symbols): self.SetHoldings(sym, self.constant_weights[i] * self.leverage)