package com.smppw.core.reta.calc;


import com.smppw.common.pojo.dto.CompoundRet;
import com.smppw.common.pojo.enums.Frequency;
import com.smppw.core.reta.Rate;

import java.util.List;

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

	@Override
	public Double calc(List<CompoundRet> list, Frequency frequency, boolean ifAnnualized) {
		double sum = 0;
		for (CompoundRet value : list) {
			if (value.getRetOfFund() != null) {
				sum += value.getRetOfFund();
			}
		}
		return sum / (list.size() - 1) * frequency.getNum();
	}

}
