Overall Statistics |
Total Orders 550 Average Win 0.14% Average Loss -0.04% Compounding Annual Return 52.867% Drawdown 17.900% Expectancy 2.617 Start Equity 100000 End Equity 188153.55 Net Profit 88.154% Sharpe Ratio 1.679 Sortino Ratio 2.09 Probabilistic Sharpe Ratio 83.969% Loss Rate 20% Win Rate 80% Profit-Loss Ratio 3.50 Alpha 0.07 Beta 1.727 Annual Standard Deviation 0.185 Annual Variance 0.034 Information Ratio 1.943 Tracking Error 0.088 Treynor Ratio 0.18 Total Fees $548.00 Estimated Strategy Capacity $1400000.00 Lowest Capacity Asset BMY R735QTJ8XC9X Portfolio Turnover 0.77% |
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, 2 * 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])