Overall Statistics |
Total Orders 235 Average Win 0.12% Average Loss -0.03% Compounding Annual Return 24.219% Drawdown 9.400% Expectancy 3.934 Start Equity 100000 End Equity 138046.32 Net Profit 38.046% Sharpe Ratio 1.224 Sortino Ratio 1.527 Probabilistic Sharpe Ratio 83.646% Loss Rate 8% Win Rate 92% Profit-Loss Ratio 4.39 Alpha -0.005 Beta 0.861 Annual Standard Deviation 0.092 Annual Variance 0.008 Information Ratio -0.907 Tracking Error 0.027 Treynor Ratio 0.131 Total Fees $235.00 Estimated Strategy Capacity $7800000.00 Lowest Capacity Asset MRK R735QTJ8XC9X Portfolio Turnover 0.31% |
from AlgorithmImports import * class FactorSectorRotationAlgorithm(QCAlgorithm): def initialize(self): self.set_start_date(2023, 2, 26) self.universe_settings.schedule.on(self.date_rules.month_start()) self._universe = self.add_universe(lambda fundamental: [f.symbol for f in sorted(fundamental, key=lambda f: f.market_cap, reverse=True)[:50]]) self.schedule.on(self.date_rules.month_start(), self.time_rules.at(9, 30), self.rebalance) def rebalance(self): factor_scores = {sector_code: [0, 0] for sector_code in [101, 102, 103, 104, 205, 206, 207, 308, 309, 310, 311]} factors = self.history[KavoutCompositeFactorBundle](list(self._universe.members.keys), 1, Resolution.DAILY) for row in factors: for data in row: factor_scores[self.securities[data.key].fundamentals.asset_classification.morningstar_sector_code][0] += data.value.growth + data.value.value_factor \ + data.value.quality + data.value.momentum + data.value.low_volatility factor_scores[self.securities[data.key].fundamentals.asset_classification.morningstar_sector_code][1] += 1 factor_scores_sum = sum(abs(x[0]) for x in factor_scores.values()) self.set_holdings([PortfolioTarget(x.key, factor_scores[x.value.fundamentals.asset_classification.morningstar_sector_code][0] / factor_scores_sum \ / factor_scores[x.value.fundamentals.asset_classification.morningstar_sector_code][1]) for x in self._universe.members])