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;

/**
 * 最好月份收益，取时间区段内收益最高得一个
 * @date 2022/3/29 9:49
 */
public class BestRet extends Rate {

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