package com.smppw.core.reta.calc;


import com.smppw.common.pojo.dto.DateValue;
import com.smppw.common.pojo.enums.Indicator;
import com.smppw.core.reta.IndicatorFactory;
import com.smppw.core.reta.Rate;

import java.util.List;

/**
 * @author zhengsongliang
 */
public class PerformanceConsistency extends Rate {

	// 切换到 Hurst 指标计算
	@Override
	public Double calc(List<DateValue> dateValues) {
		Rate rate = IndicatorFactory.getInstance().get(Indicator.HURST);
		return rate.calc(dateValues);
	}

	/*@Override
	public Double calc(List<CompoundRet> list, Frequency frequency, boolean ifAnnualized) {
		if (list.isEmpty())
			return null;
		List<Integer> levels = new ArrayList<>();
		for (CompoundRet mv : list) {
			if (mv.getRetOfFund() == null || mv.getRetOfStg() == null)
				continue;
			Double premiumRate = mv.getRetOfFund() / mv.getRetOfStg() - 1;
			int level = 1;
			if (premiumRate >= 1)
				level = 5;
			else if (premiumRate >= 0.9)
				level = 4;
			else if (premiumRate >= 0.75)
				level = 3;
			else if (premiumRate >= 0.5)
				level = 2;
			levels.add(level);
		}
		double markSum = 0D;
		for (int i = 1; i < levels.size(); i++) {
			if (levels.get(i) >= levels.get(i - 1))
				markSum += 5;
			else
				markSum += 5 - (levels.get(i - 1) - levels.get(i));
		}
		if (levels.isEmpty())
			return null;
		return markSum / levels.size();
	}*/

	public static String convert2Word(Double consistency) {
		if(consistency == null){
			return "无法判断";
		}
		if (consistency >= 0 && consistency <= 3.5)
			return "不明显";
		else if (consistency > 3.5 && consistency <= 3.8)
			return "一般";
		else if (consistency > 3.8 && consistency <= 4.1)
			return "强";
		else if (consistency > 4.1 && consistency <= 4.4)
			return "比较强";
		else if (consistency > 4.4)
			return "非常强";
		return "无法判断";
	}

}
