using MarketData.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MarketData.Generator.Momentum
{
  public class MomentumRejectionStatistics
  {
    public MomentumRejectionStatistics()
    {
      TotalItems=0;
      SymbolHeldList=new List<String>();
      NoTradeListList=new List<String>();
      NoFundamentalList=new List<String>();
      MarketCapLimitList=new List<String>();
      EBITDAScreenList=new List<String>();
      PEScreenList=new List<String>();
      MaxPEScreenList=new List<String>();
      RevenuePerShareScreenList=new List<String>();
      FinancialSectorScreenList=new List<String>();
      OneDayPriceScreenList=new List<String>();
      PennyStockScreenList=new List<String>();
      TradeDateHistoricalPricingScreenList=new List<String>();
      LiquidityScreenList=new List<String>();
      LowSlopePricesScreenList=new List<String>();
      HighBetaBenchmarkSlopeScreenList=new List<String>();
      MACDWeakSellScreenList=new List<String>();
      MACDStrongSellScreenList=new List<String>();
      StochasticsStrongSellScreenList=new List<String>();
      StochasticsWeakSellScreenList=new List<String>();
      AnalystRatingsScreenList=new List<String>();
      StartDateOfReturnsHistoricalPricingScreenList=new List<String>();
      OutliersInReturnsScreenList=new List<String>();
      NegativeReturnsScreenList=new List<String>();
      OverExtendedScreenList=new List<String>();
    }
    public double TotalItems{get;set;}
    public List<String> SymbolHeldList{get;set;}
    public List<String> NoTradeListList{get;set;}
    public List<String> NoFundamentalList{get;set;}
    public List<String> MarketCapLimitList{get;set;}
    public List<String> EBITDAScreenList{get;set;}
    public List<String> PEScreenList{get;set;}
    public List<String> MaxPEScreenList{get;set;}
    public List<String> RevenuePerShareScreenList{get;set;}
    public List<String> FinancialSectorScreenList{get;set;}
    public List<String> OneDayPriceScreenList{get;set;}
    public List<String> PennyStockScreenList{get;set;}
    public List<String> TradeDateHistoricalPricingScreenList{get;set;}
    public List<String> LiquidityScreenList{get;set;}
    public List<String> LowSlopePricesScreenList{get;set;}
    public List<String> HighBetaBenchmarkSlopeScreenList{get;set;}
    public List<String> MACDWeakSellScreenList{get;set;}
    public List<String> MACDStrongSellScreenList{get;set;}
    public List<String> StochasticsStrongSellScreenList{get;set;}
    public List<String> StochasticsWeakSellScreenList{get;set;}
    public List<String> AnalystRatingsScreenList{get;set;}
    public List<String> StartDateOfReturnsHistoricalPricingScreenList{get;set;}
    public List<String> OutliersInReturnsScreenList{get;set;}
    public List<String> NegativeReturnsScreenList{get;set;}
    public List<String> OverExtendedScreenList { get; set; }

    public double Count(List<String> list)
    {
      return list.Count;
    }
    public void DisplayStatistics(bool displayDetail=false)
    {
      MDTrace.WriteLine(LogLevel.DEBUG,String.Format("**** Momentum Candidate Rejection Statistics ****"));
      MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Total Candidates,{0}",TotalItems));

      if(displayDetail)
      {
        MDTrace.WriteLine(LogLevel.DEBUG,String.Format("SymbolHeld,{0},{1}%,{2}",Utility.FormatNumber(Count(SymbolHeldList),0,true),Utility.FormatNumber((Count(SymbolHeldList)/TotalItems)*100,3),Utility.ListToString(SymbolHeldList)));
        MDTrace.WriteLine(LogLevel.DEBUG,String.Format("NoTradeList,{0},{1}%,{2}",Utility.FormatNumber(Count(NoTradeListList),0,true),Utility.FormatNumber((Count(NoTradeListList)/TotalItems)*100,3),Utility.ListToString(NoTradeListList)));      
        MDTrace.WriteLine(LogLevel.DEBUG,String.Format("NoFundamental,{0},{1}%,{2}",Utility.FormatNumber(Count(NoFundamentalList),0,true),Utility.FormatNumber((Count(NoFundamentalList)/TotalItems)*100,3),Utility.ListToString(NoFundamentalList)));
        MDTrace.WriteLine(LogLevel.DEBUG,String.Format("MarketCapLimit,{0},{1}%,{2}",Utility.FormatNumber(Count(MarketCapLimitList),0,true),Utility.FormatNumber((Count(MarketCapLimitList)/TotalItems)*100,3),Utility.ListToString(MarketCapLimitList)));
        MDTrace.WriteLine(LogLevel.DEBUG,String.Format("EBITDAScreen,{0},{1}%,{2}",Utility.FormatNumber(Count(EBITDAScreenList),0,true),Utility.FormatNumber((Count(EBITDAScreenList)/TotalItems)*100,3),Utility.ListToString(EBITDAScreenList)));
        MDTrace.WriteLine(LogLevel.DEBUG,String.Format("PEScreen,{0},{1}%,{2}",Utility.FormatNumber(Count(PEScreenList),0,true),Utility.FormatNumber((Count(PEScreenList)/TotalItems)*100,3),Utility.ListToString(PEScreenList)));
        MDTrace.WriteLine(LogLevel.DEBUG,String.Format("MaxPEScreen,{0},{1}%,{2}",Utility.FormatNumber(Count(MaxPEScreenList),0,true),Utility.FormatNumber((Count(MaxPEScreenList)/TotalItems)*100,3),Utility.ListToString(MaxPEScreenList)));
        MDTrace.WriteLine(LogLevel.DEBUG,String.Format("RevenuePerShareScreen,{0},{1}%,{2}",Utility.FormatNumber(Count(RevenuePerShareScreenList),0,true),Utility.FormatNumber((Count(RevenuePerShareScreenList)/TotalItems)*100,3),Utility.ListToString(RevenuePerShareScreenList)));
        MDTrace.WriteLine(LogLevel.DEBUG,String.Format("FinancialSectorScreen,{0},{1}%,{2}",Utility.FormatNumber(Count(FinancialSectorScreenList),0,true),Utility.FormatNumber((Count(FinancialSectorScreenList)/TotalItems)*100,3),Utility.ListToString(FinancialSectorScreenList)));
        MDTrace.WriteLine(LogLevel.DEBUG,String.Format("OneDayPriceScreen,{0},{1}%,{2}",Utility.FormatNumber(Count(OneDayPriceScreenList),0,true),Utility.FormatNumber((Count(OneDayPriceScreenList)/TotalItems)*100,3),Utility.ListToString(OneDayPriceScreenList)));
        MDTrace.WriteLine(LogLevel.DEBUG,String.Format("PennyStockScreen,{0},{1}%,{2}",Utility.FormatNumber(Count(PennyStockScreenList),0,true),Utility.FormatNumber((Count(PennyStockScreenList)/TotalItems)*100,3),Utility.ListToString(PennyStockScreenList)));
        MDTrace.WriteLine(LogLevel.DEBUG,String.Format("TradeDateHistoricalPricingScreen,{0},{1}%,{2}",Utility.FormatNumber(Count(TradeDateHistoricalPricingScreenList),0,true),Utility.FormatNumber((Count(TradeDateHistoricalPricingScreenList)/TotalItems)*100,3),Utility.ListToString(TradeDateHistoricalPricingScreenList)));
        MDTrace.WriteLine(LogLevel.DEBUG,String.Format("LiquidityScreen,{0},{1}%,{2}",Utility.FormatNumber(Count(LiquidityScreenList),0,true),Utility.FormatNumber((Count(LiquidityScreenList)/TotalItems)*100,3),Utility.ListToString(LiquidityScreenList)));
        MDTrace.WriteLine(LogLevel.DEBUG,String.Format("LowSlopePricesScreen,{0},{1}%,{2}",Utility.FormatNumber(Count(LowSlopePricesScreenList),0,true),Utility.FormatNumber((Count(LowSlopePricesScreenList)/TotalItems)*100,3),Utility.ListToString(LowSlopePricesScreenList)));
        MDTrace.WriteLine(LogLevel.DEBUG,String.Format("HighBetaBenchmarkSlopeScreen,{0},{1}%,{2}",Utility.FormatNumber(Count(HighBetaBenchmarkSlopeScreenList),0,true),Utility.FormatNumber((Count(HighBetaBenchmarkSlopeScreenList)/TotalItems)*100,3),Utility.ListToString(HighBetaBenchmarkSlopeScreenList)));
        MDTrace.WriteLine(LogLevel.DEBUG,String.Format("MACDWeakSellScreen,{0},{1}%,{2}",Utility.FormatNumber(Count(MACDWeakSellScreenList),0,true),Utility.FormatNumber((Count(MACDWeakSellScreenList)/TotalItems)*100,3),Utility.ListToString(MACDWeakSellScreenList)));
        MDTrace.WriteLine(LogLevel.DEBUG,String.Format("MACDStrongSellScreen,{0},{1}%,{2}",Utility.FormatNumber(Count(MACDStrongSellScreenList),0,true),Utility.FormatNumber((Count(MACDStrongSellScreenList)/TotalItems)*100,3),Utility.ListToString(MACDStrongSellScreenList)));
        MDTrace.WriteLine(LogLevel.DEBUG,String.Format("StochasticsStrongSellScreen,{0},{1}%,{2}",Utility.FormatNumber(Count(StochasticsStrongSellScreenList),0,true),Utility.FormatNumber((Count(StochasticsStrongSellScreenList)/TotalItems)*100,3),Utility.ListToString(StochasticsStrongSellScreenList)));
        MDTrace.WriteLine(LogLevel.DEBUG,String.Format("StochasticsWeakSellScreen,{0},{1}%,{2}",Utility.FormatNumber(Count(StochasticsWeakSellScreenList),0,true),Utility.FormatNumber((Count(StochasticsWeakSellScreenList)/TotalItems)*100,3),Utility.ListToString(StochasticsWeakSellScreenList)));
        MDTrace.WriteLine(LogLevel.DEBUG,String.Format("AnalystRatingsScreen,{0},{1}%,{2}",Utility.FormatNumber(Count(AnalystRatingsScreenList),0,true),Utility.FormatNumber((Count(AnalystRatingsScreenList)/TotalItems)*100,3),Utility.ListToString(AnalystRatingsScreenList)));
        MDTrace.WriteLine(LogLevel.DEBUG,String.Format("StartDateOfReturnsHistoricalPricingScreen,{0},{1}%,{2}",Utility.FormatNumber(Count(StartDateOfReturnsHistoricalPricingScreenList),0,true),Utility.FormatNumber((Count(StartDateOfReturnsHistoricalPricingScreenList)/TotalItems)*100,3),Utility.ListToString(StartDateOfReturnsHistoricalPricingScreenList)));
        MDTrace.WriteLine(LogLevel.DEBUG,String.Format("OutliersInReturnsScreen,{0},{1}%,{2}",Utility.FormatNumber(Count(OutliersInReturnsScreenList),0,true),Utility.FormatNumber((Count(OutliersInReturnsScreenList)/TotalItems)*100,3),Utility.ListToString(OutliersInReturnsScreenList)));
        MDTrace.WriteLine(LogLevel.DEBUG,String.Format("NegativeReturnsScreen,{0},{1}%,{2}",Utility.FormatNumber(Count(NegativeReturnsScreenList),0,true),Utility.FormatNumber((Count(NegativeReturnsScreenList)/TotalItems)*100,3),Utility.ListToString(NegativeReturnsScreenList)));
        MDTrace.WriteLine(LogLevel.DEBUG,String.Format("OverExtendedScreen,{0},{1}%,{2}",Utility.FormatNumber(Count(OverExtendedScreenList),0,true),Utility.FormatNumber((Count(OverExtendedScreenList)/TotalItems)*100,3),Utility.ListToString(OverExtendedScreenList)));
      }
      else
      {
        MDTrace.WriteLine(LogLevel.DEBUG,String.Format("SymbolHeld,{0},{1}%",Utility.FormatNumber(Count(SymbolHeldList),0,true),Utility.FormatNumber((Count(SymbolHeldList)/TotalItems)*100,3)));
        MDTrace.WriteLine(LogLevel.DEBUG,String.Format("NoTradeList,{0},{1}%",Utility.FormatNumber(Count(NoTradeListList),0,true),Utility.FormatNumber((Count(NoTradeListList)/TotalItems)*100,3)));      
        MDTrace.WriteLine(LogLevel.DEBUG,String.Format("NoFundamental,{0},{1}%",Utility.FormatNumber(Count(NoFundamentalList),0,true),Utility.FormatNumber((Count(NoFundamentalList)/TotalItems)*100,3)));
        MDTrace.WriteLine(LogLevel.DEBUG,String.Format("MarketCapLimit,{0},{1}%",Utility.FormatNumber(Count(MarketCapLimitList),0,true),Utility.FormatNumber((Count(MarketCapLimitList)/TotalItems)*100,3)));
        MDTrace.WriteLine(LogLevel.DEBUG,String.Format("EBITDAScreen,{0},{1}%",Utility.FormatNumber(Count(EBITDAScreenList),0,true),Utility.FormatNumber((Count(EBITDAScreenList)/TotalItems)*100,3)));
        MDTrace.WriteLine(LogLevel.DEBUG,String.Format("PEScreen,{0},{1}%",Utility.FormatNumber(Count(PEScreenList),0,true),Utility.FormatNumber((Count(PEScreenList)/TotalItems)*100,3)));
        MDTrace.WriteLine(LogLevel.DEBUG,String.Format("MaxPEScreen,{0},{1}%",Utility.FormatNumber(Count(MaxPEScreenList),0,true),Utility.FormatNumber((Count(MaxPEScreenList)/TotalItems)*100,3)));
        MDTrace.WriteLine(LogLevel.DEBUG,String.Format("RevenuePerShareScreen,{0},{1}%",Utility.FormatNumber(Count(RevenuePerShareScreenList),0,true),Utility.FormatNumber((Count(RevenuePerShareScreenList)/TotalItems)*100,3)));
        MDTrace.WriteLine(LogLevel.DEBUG,String.Format("FinancialSectorScreen,{0},{1}%",Utility.FormatNumber(Count(FinancialSectorScreenList),0,true),Utility.FormatNumber((Count(FinancialSectorScreenList)/TotalItems)*100,3)));
        MDTrace.WriteLine(LogLevel.DEBUG,String.Format("OneDayPriceScreen,{0},{1}%",Utility.FormatNumber(Count(OneDayPriceScreenList),0,true),Utility.FormatNumber((Count(OneDayPriceScreenList)/TotalItems)*100,3)));
        MDTrace.WriteLine(LogLevel.DEBUG,String.Format("PennyStockScreen,{0},{1}%",Utility.FormatNumber(Count(PennyStockScreenList),0,true),Utility.FormatNumber((Count(PennyStockScreenList)/TotalItems)*100,3)));
        MDTrace.WriteLine(LogLevel.DEBUG,String.Format("TradeDateHistoricalPricingScreen,{0},{1}%",Utility.FormatNumber(Count(TradeDateHistoricalPricingScreenList),0,true),Utility.FormatNumber((Count(TradeDateHistoricalPricingScreenList)/TotalItems)*100,3)));
        MDTrace.WriteLine(LogLevel.DEBUG,String.Format("LiquidityScreen,{0},{1}%",Utility.FormatNumber(Count(LiquidityScreenList),0,true),Utility.FormatNumber((Count(LiquidityScreenList)/TotalItems)*100,3)));
        MDTrace.WriteLine(LogLevel.DEBUG,String.Format("LowSlopePricesScreen,{0},{1}%",Utility.FormatNumber(Count(LowSlopePricesScreenList),0,true),Utility.FormatNumber((Count(LowSlopePricesScreenList)/TotalItems)*100,3)));
        MDTrace.WriteLine(LogLevel.DEBUG,String.Format("HighBetaBenchmarkSlopeScreen,{0},{1}%",Utility.FormatNumber(Count(HighBetaBenchmarkSlopeScreenList),0,true),Utility.FormatNumber((Count(HighBetaBenchmarkSlopeScreenList)/TotalItems)*100,3)));
        MDTrace.WriteLine(LogLevel.DEBUG,String.Format("MACDWeakSellScreen,{0},{1}%",Utility.FormatNumber(Count(MACDWeakSellScreenList),0,true),Utility.FormatNumber((Count(MACDWeakSellScreenList)/TotalItems)*100,3)));
        MDTrace.WriteLine(LogLevel.DEBUG,String.Format("MACDStrongSellScreen,{0},{1}%",Utility.FormatNumber(Count(MACDStrongSellScreenList),0,true),Utility.FormatNumber((Count(MACDStrongSellScreenList)/TotalItems)*100,3)));
        MDTrace.WriteLine(LogLevel.DEBUG,String.Format("StochasticsStrongSellScreen,{0},{1}%",Utility.FormatNumber(Count(StochasticsStrongSellScreenList),0,true),Utility.FormatNumber((Count(StochasticsStrongSellScreenList)/TotalItems)*100,3)));
        MDTrace.WriteLine(LogLevel.DEBUG,String.Format("StochasticsWeakSellScreen,{0},{1}%",Utility.FormatNumber(Count(StochasticsWeakSellScreenList),0,true),Utility.FormatNumber((Count(StochasticsWeakSellScreenList)/TotalItems)*100,3)));
        MDTrace.WriteLine(LogLevel.DEBUG,String.Format("AnalystRatingsScreen,{0},{1}%",Utility.FormatNumber(Count(AnalystRatingsScreenList),0,true),Utility.FormatNumber((Count(AnalystRatingsScreenList)/TotalItems)*100,3)));
        MDTrace.WriteLine(LogLevel.DEBUG,String.Format("StartDateOfReturnsHistoricalPricingScreen,{0},{1}%",Utility.FormatNumber(Count(StartDateOfReturnsHistoricalPricingScreenList),0,true),Utility.FormatNumber((Count(StartDateOfReturnsHistoricalPricingScreenList)/TotalItems)*100,3)));
        MDTrace.WriteLine(LogLevel.DEBUG,String.Format("OutliersInReturnsScreen,{0},{1}%",Utility.FormatNumber(Count(OutliersInReturnsScreenList),0,true),Utility.FormatNumber((Count(OutliersInReturnsScreenList)/TotalItems)*100,3)));
        MDTrace.WriteLine(LogLevel.DEBUG,String.Format("NegativeReturnsScreen,{0},{1}%",Utility.FormatNumber(Count(NegativeReturnsScreenList),0,true),Utility.FormatNumber((Count(NegativeReturnsScreenList)/TotalItems)*100,3)));
        MDTrace.WriteLine(LogLevel.DEBUG,String.Format("OverExtendedScreen,{0},{1}%",Utility.FormatNumber(Count(OverExtendedScreenList),0,true),Utility.FormatNumber((Count(OverExtendedScreenList)/TotalItems)*100,3)));
      }
    }
  }
}
