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
namespace QuantConnect.Algorithm.CSharp
{
    public class NadionModulatedSplitter : QCAlgorithm
    {
    	private Dictionary<Symbol, decimal> dollarVolumeBySymbol;
    	private int lastMonth;
    	private int numberOfSymbolsCoarse;
    	private int numberOfSymbolsFine;

        public override void Initialize()
        {
            SetStartDate(2018, 10, 29);  //Set Start Date
            SetCash(100000);             //Set Strategy Cash
            
            dollarVolumeBySymbol = new Dictionary<Symbol, decimal>();
            lastMonth = -1;
            numberOfSymbolsCoarse = 300;
            numberOfSymbolsFine = 5;
            AddUniverseSelection(new FineFundamentalUniverseSelectionModel(SelectCoarse, SelectFine));
        }

        public override void OnData(Slice data)
        {
        }
        
        private IEnumerable<Symbol> SelectCoarse(IEnumerable<CoarseFundamental> coarse){
        	if (Time.Month == lastMonth){
        		return Universe.Unchanged;
        	}
        	var sortedByDollarVolume = (from x in coarse
        							   where x.HasFundamentalData && x.Volume > 0 && x.Price > 0
        							   orderby x.DollarVolume descending
        							   select x).Take(numberOfSymbolsCoarse);
        	List<Symbol> symbols = new List<Symbol>();
            dollarVolumeBySymbol = new Dictionary<Symbol, decimal>();
            foreach (var x in sortedByDollarVolume){
            	symbols.Add(x.Symbol);
            	dollarVolumeBySymbol[x.Symbol]=x.DollarVolume;
            }
            return symbols;
        							   
        }
        
        private IEnumerable<Symbol> SelectFine(IEnumerable<FineFundamental> fine){
        	if (Time.Month == lastMonth){
        		return Universe.Unchanged;
        	}
        	lastMonth = Time.Month;
			var filteredFine = fine.Where(x => x.AssetClassification.MorningstarIndustryGroupCode == MorningstarIndustryGroupCode.Banks);
			IEnumerable<Symbol> selected = filteredFine.OrderByDescending(x => dollarVolumeBySymbol[x.Symbol]).Select(x => x.Symbol).Take(numberOfSymbolsFine);
			return selected;
		}

    }
}