Overall Statistics |
Total Orders 451 Average Win 1.25% Average Loss -0.64% Compounding Annual Return 201.593% Drawdown 31.600% Expectancy 0.546 Start Equity 100000 End Equity 173379.93 Net Profit 73.380% Sharpe Ratio 2.321 Sortino Ratio 3.468 Probabilistic Sharpe Ratio 63.329% Loss Rate 48% Win Rate 52% Profit-Loss Ratio 1.95 Alpha 2.1 Beta -1.286 Annual Standard Deviation 0.776 Annual Variance 0.602 Information Ratio 1.949 Tracking Error 0.804 Treynor Ratio -1.399 Total Fees $722.29 Estimated Strategy Capacity $40000000.00 Lowest Capacity Asset MEDS XC03HZ3KX3L1 Portfolio Turnover 24.59% |
from AlgorithmImports import * from QuantConnect.DataSource import * class MorningStarDataAlgorithm(QCAlgorithm): def initialize(self) -> None: self.set_start_date(2021, 1, 1) self.set_end_date(2021, 7, 1) self.set_cash(100000) # Requesting data self.universe_settings.resolution = Resolution.DAILY self.universe_size = 10 self.add_universe(self.fundamental_selection_function) def fundamental_selection_function(self, fundamental: List[Fundamental]) -> List[Symbol]: selected = [f for f in fundamental if f.has_fundamental_data and f.price > 1 and not np.isnan(f.valuation_ratios.pe_ratio)] sorted_by_dollar_volume = sorted(selected, key=lambda f: f.dollar_volume, reverse=True)[:100] sorted_by_pe_ratio = sorted(sorted_by_dollar_volume, key=lambda f: f.valuation_ratios.pe_ratio, reverse=True)[:self.universe_size] return [ f.symbol for f in sorted_by_pe_ratio ] def on_data(self, slice: Slice) -> None: # if we have no changes, do nothing if self._changes is None: return # liquidate removed securities for security in self._changes.removed_securities: if security.invested: self.liquidate(security.symbol) # we want 1/N allocation in each security in our universe for security in self._changes.added_securities: self.set_holdings(security.symbol, 1 / self.universe_size) self._changes = None def on_securities_changed(self, changes: SecurityChanges) -> None: self._changes = changes for security in changes.added_securities: # Historical data history = self.history(security.symbol, 7, Resolution.DAILY) self.debug(f"We got {len(history)} from our history request for {security.symbol}")