package com.smppw.core.reta;

import com.smppw.common.pojo.enums.Indicator;
import com.smppw.core.reta.calc.*;

import java.util.HashMap;
import java.util.Map;

public class IndicatorFactory {
    private static IndicatorFactory instance = new IndicatorFactory();

    private static Map<Indicator, Rate> rateMap = new HashMap<>();

    static {
        rateMap.put(Indicator.IntervalReturn, new IntervalReturn());
        rateMap.put(Indicator.HURST, new Hurst());
        rateMap.put(Indicator.XIRR, new XIRR());
        rateMap.put(Indicator.AnnualReturn, new AnnualReturn());
        rateMap.put(Indicator.AnnualReturnAlg, new AnnualReturnAlg());
        rateMap.put(Indicator.ExcessReturn, new ExcessReturnDynamic());
        rateMap.put(Indicator.ExcessReturnRealTimeCalc, new ExcessReturnRealTimeCalc());
        rateMap.put(Indicator.ExcessReturnSharpeRatioExtra, new ExcessReturnSharpeRatioExtra());
        rateMap.put(Indicator.ExcessReturnAnnualStdDevExtra, new ExcessReturnAnnualStdDevExtra());
        rateMap.put(Indicator.ExcessReturnMaxDrawdownRecureDateExtra, new ExcessReturnMaxDrawdownRecureDateExtra());
        rateMap.put(Indicator.ExcessReturnMaxDrawdownRecureIntervalExtra, new ExcessReturnMaxDrawdownRecureIntervalExtra());
//		rateMap.put(Indicator.ExcessReturn, new ExcessReturn());
        rateMap.put(Indicator.AnnualStdDev, new AnnualStdDev());
        rateMap.put(Indicator.Beta, new Beta());
        rateMap.put(Indicator.Alpha, new Alpha());
        rateMap.put(Indicator.DownCaptureRatio, new DownCaptureRatio());
        rateMap.put(Indicator.DownCaptureReturn, new DownCaptureReturn());
        rateMap.put(Indicator.UpCaptureRatio, new UpCaptureRatio());
        rateMap.put(Indicator.UpCaptureReturn, new UpCaptureReturn());
        rateMap.put(Indicator.DownsideStdDev, new DownsideStdDev());
        rateMap.put(Indicator.InformationRatio, new InformationRatio());
        rateMap.put(Indicator.Kappa, new Kappa());
        rateMap.put(Indicator.Kurtosis, new Kurtosis());
        rateMap.put(Indicator.Omega, new Omega());
        rateMap.put(Indicator.RangeReturn, new RangeReturn());
        rateMap.put(Indicator.SharpeRatio, new SharpeRatio());
        rateMap.put(Indicator.Skewness, new Skewness());
        rateMap.put(Indicator.SortinoRatio, new SortinoRatio());
        rateMap.put(Indicator.SortinoRatioMAR, new SortinoRatioMAR());
        rateMap.put(Indicator.TreynorRatio, new TreynorRatio());
        rateMap.put(Indicator.MaxDrawdown, new MaxDrawdown());
        rateMap.put(Indicator.MaxDrawdownInterval, new MaxDrawdownInterval());
        rateMap.put(Indicator.MaxDrawdownRecureDate, new MaxDrawdownRecureDate());
        rateMap.put(Indicator.MaxDrawdownRecureInterval, new MaxDrawdownRecureInterval());
        rateMap.put(Indicator.MaxDrawdownRecureIntervalDays, new MaxDrawdownRecureIntervalDays());
        rateMap.put(Indicator.MaxDrawdownPeakDate, new MaxDrawdownPeakDate());
        rateMap.put(Indicator.MaxDrawdownValleyDate, new MaxDrawdownValleyDate());
        rateMap.put(Indicator.CalmarRatio, new CalmarRatio());
        rateMap.put(Indicator.SMDDVaR, new SMDDVaR());
        rateMap.put(Indicator.SMDDCVaR, new SMDDCVaR());
        rateMap.put(Indicator.HistoricalVaR, new HistoricalVaR());
        rateMap.put(Indicator.HistoricalCVaR, new HistoricalCVaR());
        rateMap.put(Indicator.SMDDLPM1, new SMDDLPM1());
        rateMap.put(Indicator.SMDDLPM2, new SMDDLPM2());
        rateMap.put(Indicator.DownsideDeviation, new DownsideDeviation());
        rateMap.put(Indicator.Jensen, new Jensen());
        rateMap.put(Indicator.M2, new M2());
        rateMap.put(Indicator.TrackingError, new TrackingError());
        rateMap.put(Indicator.PerformanceConsistency, new PerformanceConsistency());
        rateMap.put(Indicator.WinRate, new WinRate());
        rateMap.put(Indicator.WinRateWithZero, new WinRateWithZero());
        rateMap.put(Indicator.SingleMaxDrawdown, new SingleMaxDrawdown());
        rateMap.put(Indicator.MaxContinuouslyDrawdownCount, new MaxContinuouslyDrawdownCount());
        rateMap.put(Indicator.ExcessReturnMaxDrawdown, new ExcessReturnMaxDrawdownNav());
        rateMap.put(Indicator.ExcessReturnSharpeRatio, new ExcessReturnSharpeRatio());
        rateMap.put(Indicator.BestRetMonthly, new BestRet());
        rateMap.put(Indicator.BestRetWeekly, new BestRet());
        rateMap.put(Indicator.WorstRetMonthly, new WorstRet());
        rateMap.put(Indicator.WorstRetWeekly, new WorstRet());
        rateMap.put(Indicator.ProfitLossRatio, new ProfitLossRatio());
        rateMap.put(Indicator.HistoricalVaR90, new HistoricalVaR(0.1D));
        rateMap.put(Indicator.HistoricalVaR95, new HistoricalVaR(0.05D));
        rateMap.put(Indicator.HistoricalVaR99, new HistoricalVaR(0.01D));
        rateMap.put(Indicator.HistoricalCVaR90, new HistoricalCVaR(0.1D));
        rateMap.put(Indicator.HistoricalCVaR95, new HistoricalCVaR(0.05D));
        rateMap.put(Indicator.HistoricalCVaR99, new HistoricalCVaR(0.01D));
        rateMap.put(Indicator.LongestNoNewHighDays, new LongestNoNewHighDays());
        rateMap.put(Indicator.ExcessReturnAnnualized, new ExcessReturnAnnualized());
        rateMap.put(Indicator.ExcessReturnLongestNoNewHighDays, new ExcessReturnLongestNoNewHighDays());
        rateMap.put(Indicator.ExcessReturnCalmarRatio, new ExcessReturnCalmarRatio());
        rateMap.put(Indicator.ExcessReturnSortinoRatio, new ExcessReturnSortinoRatio());
        rateMap.put(Indicator.ExcessReturnDownsideStdDev, new ExcessReturnDownsideStdDev());
    }

    private IndicatorFactory() {
    }

    public static IndicatorFactory getInstance() {
        return instance;
    }

    public Rate get(Indicator indicator) {
        return rateMap.get(indicator);
    }

}
