Overall Statistics |
Total Orders 2537 Average Win 0.52% Average Loss -0.48% Compounding Annual Return -12.803% Drawdown 55.300% Expectancy -0.054 Start Equity 100000 End Equity 62038.95 Net Profit -37.961% Sharpe Ratio -0.378 Sortino Ratio -0.512 Probabilistic Sharpe Ratio 0.220% Loss Rate 55% Win Rate 45% Profit-Loss Ratio 1.10 Alpha -0.17 Beta 1.116 Annual Standard Deviation 0.243 Annual Variance 0.059 Information Ratio -0.868 Tracking Error 0.187 Treynor Ratio -0.082 Total Fees $3987.82 Estimated Strategy Capacity $2000.00 Lowest Capacity Asset FUSN XFO1EI476739 Portfolio Turnover 6.15% |
from AlgorithmImports import * from datetime import datetime, timedelta class FocusedYellowLemur(QCAlgorithm): def Initialize(self): self.SetStartDate(2021, 1, 1) # Set Start Date self.SetCash(100000) # Set Strategy Cash self.add_equity("SPY") # Set the risk-free interest rate model self.set_risk_free_interest_rate_model(InterestRateProvider()) # Now that the model is set, get the interest rate self.interest_rate = self.risk_free_interest_rate_model.get_interest_rate(self.time) self.universe_settings.asynchronous = True self.add_universe_selection(FundamentalUniverseSelectionModel(self.fundamental_filter_function)) self.schedule.on(self.date_rules.month_start("SPY"), self.time_rules.after_market_open("SPY"), self.rebalancing_code) def fundamental_filter_function(self, coarse: List[CoarseFundamental]) -> List[Symbol]: if self.interest_rate < 0.0025: amount = 50 else: amount = 10 selected = [c for c in coarse if c.has_fundamental_data] sorted_by_dollar_volume = sorted(selected, key=lambda c: c.dollar_volume, reverse=True) filtered = [f for f in sorted_by_dollar_volume if f.has_fundamental_data and f.price > 10 and not np.isnan(f.valuation_ratios.pe_ratio)] sorted_by_pe_ratio = sorted(filtered, key=lambda f: f.valuation_ratios.pe_ratio) fundamental_symbols = [f.symbol for f in sorted_by_pe_ratio[:amount]] return fundamental_symbols def rebalancing_code(self): self.interest_rate = self.risk_free_interest_rate_model.get_interest_rate(self.time) self.liquidate() for security in self.ActiveSecurities.Values: self.SetHoldings(security.Symbol, 1 / len(self.ActiveSecurities)) self.Plot("interest rate", "value", self.interest_rate)