17 using System.Collections.Generic;
31 private const int _numberOfSymbolsCoarse = 1000;
32 private const int _numberOfSymbolsFine = 500;
35 private int _lastMonth = -1;
36 private readonly Dictionary<Symbol, double> _dollarVolumeBySymbol =
new ();
51 : base(true, universeSettings)
63 if (algorithm.
Time.Month == _lastMonth)
68 var sortedByDollarVolume =
70 where x.HasFundamentalData && x.Volume > 0 && x.Price > 0
71 orderby x.DollarVolume descending
72 select x).Take(_numberOfSymbolsCoarse).ToList();
74 _dollarVolumeBySymbol.Clear();
75 foreach (var x
in sortedByDollarVolume)
77 _dollarVolumeBySymbol[x.Symbol] = x.DollarVolume;
82 if (_dollarVolumeBySymbol.Count == 0)
87 return _dollarVolumeBySymbol.Keys;
101 where x.CompanyReference.CountryId ==
"USA" &&
102 (x.CompanyReference.PrimaryExchangeID ==
"NYS" || x.CompanyReference.PrimaryExchangeID ==
"NAS") &&
103 (algorithm.
Time - x.SecurityReference.IPODate).Days > 180 &&
104 x.MarketCap > 500000000m
107 var count = filteredFine.Count;
117 _lastMonth = algorithm.
Time.Month;
119 var percent = _numberOfSymbolsFine / (double)count;
122 var topFineBySector =
123 (from x in filteredFine
125 group x by x.CompanyReference.IndustryTemplateCode into g
126 let y = from item in g
127 orderby _dollarVolumeBySymbol[item.Symbol] descending
129 let c = (int)Math.Ceiling(y.Count() * percent)
130 select
new { g.Key, Value = y.Take(c) }
131 ).ToDictionary(x => x.Key, x => x.Value);
133 return topFineBySector.SelectMany(x => x.Value)
134 .OrderByDescending(x => _dollarVolumeBySymbol[x.Symbol])
135 .Take(_numberOfSymbolsFine)
136 .Select(x => x.Symbol);