Overall Statistics |
Total Orders 512 Average Win 0.11% Average Loss -0.04% Compounding Annual Return 45.013% Drawdown 17.800% Expectancy 2.023 Start Equity 100000 End Equity 173231.15 Net Profit 73.231% Sharpe Ratio 1.493 Sortino Ratio 1.793 Probabilistic Sharpe Ratio 79.668% Loss Rate 24% Win Rate 76% Profit-Loss Ratio 2.95 Alpha 0.044 Beta 1.505 Annual Standard Deviation 0.173 Annual Variance 0.03 Information Ratio 1.274 Tracking Error 0.091 Treynor Ratio 0.172 Total Fees $510.00 Estimated Strategy Capacity $2300000.00 Lowest Capacity Asset NOB R735QTJ8XC9X Portfolio Turnover 0.75% |
from AlgorithmImports import * class FactorSectorRotationAlgorithm(QCAlgorithm): def initialize(self): self.set_start_date(2023, 3, 1) 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])