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 lizhuang
 * @Title: ${file_name}
 * @Package ${package_name}
 * @Description: ${todo}
 * @date 2022/3/29 10:10
 */
public class WorstRet extends Rate {

    @Override
    public Double calc(List<CompoundRet> list, Frequency frequency, boolean ifAnnualized) {
        if(list == null || list.isEmpty()){
            return null;
        }
        double worstRet = 0D;
        for (CompoundRet compoundRet : list) {
            if(compoundRet.getRetOfFund() == null){
                continue;
            }
            double retOfFund = compoundRet.getRetOfFund();
            if(retOfFund < worstRet){
                worstRet = retOfFund;
            }
        }
        return worstRet;
    }
}
