| Overall Statistics |
|
Total Trades 334 Average Win 0.65% Average Loss -0.40% Compounding Annual Return 9.495% Drawdown 9.500% Expectancy 1.418 Net Profit 171.420% Sharpe Ratio 1.831 Probabilistic Sharpe Ratio 99.651% Loss Rate 8% Win Rate 92% Profit-Loss Ratio 1.63 Alpha 0.08 Beta 0.11 Annual Standard Deviation 0.053 Annual Variance 0.003 Information Ratio -0.366 Tracking Error 0.162 Treynor Ratio 0.879 Total Fees $919.61 |
import numpy as np
syms = ['RHS','FDN','EFZ','CYB','TFI','FXF','AGG','PZA','SUB','GSY','GBF','CZA','LQD','UUP','EUM','PCY','CMF','BIV','PZT','BSV',
'AGZ','PWZ','RECS','RYH','SPIP','SH','EUO','PVI','XLY','SPTI','SHM','MUB','MYY','AOK','JNK','NYF','TIP','BIL','TLH','RWM','VGT']
class MultidimensionalModulatedRegulators(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2010, 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.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.00804295, 0.03900719, 0.02942488, 0.02070469, 0.01916339, 0.01905802,
0.02649537, 0.02173771, 0.03434027, 0.01406504, 0.03252464, 0.01799447,
0.02871560, 0.04110242, 0.03393579, 0.01583645, 0.01656219, 0.00996907,
0.03387620, 0.01743698, 0.03956412, 0.01889766, 0.01254530, 0.01385734,
0.01640994, 0.02678624, 0.03706501, 0.02603432, 0.04656506, 0.01275349,
0.02654265, 0.02035014, 0.03365334, 0.02864399, 0.02726106, 0.02285904,
0.02313888, 0.01343120, 0.02560550, 0.00750572, 0.04053675])
self.constant_weights /= np.sum(np.abs(self.constant_weights))
self.leverage = 2.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.16:
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)