package com.smppw.core.reta.calc;


import com.smppw.constants.Consts;
import com.smppw.common.pojo.dto.CompoundRet;
import com.smppw.common.pojo.enums.Frequency;
import com.smppw.core.reta.Rate;
import com.smppw.utils.FunctionUtil;

import java.util.List;

/**
 * @author zhengsongliang
 * @datetime 2017年7月25日 上午10:10:58
 */
public class SMDDVaR extends Rate {

	@Override
	public Double calc(List<CompoundRet> list, Frequency frequency, boolean ifAnnualized) {
		List<Double> a = FunctionUtil.getFundRetList(list);
		Double sum = 0D;
		for (Double unit : a) {
			if (unit == null) {
				continue;
			}
			sum += unit;
		}
		if (list.size() <= 1 || sum == 0)
			return null;
		return FunctionUtil.getVaR(Consts.PROB, a);

	}

}
