Overall Statistics |
Total Orders 9 Average Win 0% Average Loss 0% Compounding Annual Return -60.975% Drawdown 0.700% Expectancy 0 Start Equity 20000 End Equity 19880.06 Net Profit -0.600% Sharpe Ratio 0 Sortino Ratio 0 Probabilistic Sharpe Ratio 0% Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0 Beta 0 Annual Standard Deviation 0 Annual Variance 0 Information Ratio 0 Tracking Error 0 Treynor Ratio 0 Total Fees $9.00 Estimated Strategy Capacity $580000.00 Lowest Capacity Asset LECO R735QTJ8XC9X Portfolio Turnover 28.40% |
from AlgorithmImports import * from QuantConnect.DataSource import * import pandas as pd class PrinsBrainMLAlgorithm(QCAlgorithm): def Initialize(self): self.SetStartDate(2024, 4, 1) self.SetEndDate(2024, 4, 3) self.SetCash(20000) self.SetBrokerageModel(BrokerageName.InteractiveBrokersBrokerage, AccountType.Margin) self.Settings.DataSubscriptionLimit = 1000 self.universe = self.AddUniverse(BrainStockRankingUniverse, self.UniverseSelection) self.UniverseSettings.Resolution = Resolution.Hour # Set the custom security initializer self.SetSecurityInitializer(lambda x: x.SetMarketPrice(self.GetLastKnownPrice(x))) self.SetWarmup(200) def UniverseSelection(self, alt_coarse: List[BrainStockRankingUniverse]) -> List[Symbol]: filtered_symbols = [x for x in alt_coarse if x.Rank21Days > 0 and not str(x.Symbol.ID).endswith('2T')] # Filter symbols with a positive rank and sort them by their rank in descending order ranked_symbols = sorted(filtered_symbols, key=lambda x: x.Rank21Days, reverse=True) self.selections = [x.Symbol for x in ranked_symbols[:10]] return self.selections def OnSecuritiesChanged(self, changes: SecurityChanges) -> None: for x in changes.RemovedSecurities: pass for x in changes.AddedSecurities: pass def OnData(self, slice: Slice) -> None: if self.IsWarmingUp: self.Debug(str("Warming up")) return if not self.Portfolio.Invested: for symbol in self.selections: self.SetHoldings(symbol, 0.10)