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;

/**
 * 算术超额区间收益
 */
public class ExcessAriIntervalReturn extends Rate {

    @Override
    public Double calc(List<CompoundRet> list, Frequency frequency, boolean ifAnnualized) {
        Double fundRet = 1.0;
        Double bmkRet = 1.0;
        if (list.size() == 0 || list == null) {
            return null;
        }
        for (CompoundRet compoundRet : list) {
            if (compoundRet.getRetOfFund() == null || compoundRet.getRetOfBmk() == null) {
                continue;
            }
            fundRet = fundRet * (compoundRet.getRetOfFund() + 1);
            bmkRet = bmkRet * (compoundRet.getRetOfBmk() + 1);
        }

        return fundRet - bmkRet;
    }
}
