Overall Statistics |
Total Trades 0 Average Win 0% Average Loss 0% Compounding Annual Return 0% Drawdown 0% Expectancy 0 Net Profit 0% 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 $0.00 |
from clr import AddReference AddReference("System.Core") AddReference("System.Collections") AddReference("QuantConnect.Common") AddReference("QuantConnect.Algorithm") from System import * from QuantConnect import * from QuantConnect.Algorithm import QCAlgorithm from QuantConnect.Data.UniverseSelection import * class StatelessCoarseUniverseSelectionBenchmark(QCAlgorithm): def Initialize(self): self.UniverseSettings.Resolution = Resolution.Daily self.SetStartDate(2017, 11, 1) self.SetEndDate(2018, 1, 1) self.SetCash(50000) self.AddUniverse(self.CoarseSelectionFunction) self.numberOfSymbols = 250 # sort the data by daily dollar volume and take the top 'NumberOfSymbols' def CoarseSelectionFunction(self, coarse): selected = [x for x in coarse if (x.HasFundamentalData)] # sort descending by daily dollar volume sortedByDollarVolume = sorted(selected, key=lambda x: x.DollarVolume, reverse=True) # return the symbol objects of the top entries from our sorted collection return [ x.Symbol for x in sortedByDollarVolume[:self.numberOfSymbols] ] def OnSecuritiesChanged(self, changes): # if we have no changes, do nothing if changes is None: return # liquidate removed securities for security in changes.RemovedSecurities: if security.Invested: self.Liquidate(security.Symbol) for security in changes.AddedSecurities: self.SetHoldings(security.Symbol, 0.001)