package com.smppw.core.reta.calc;


import com.smppw.common.pojo.dto.DateValue;
import com.smppw.utils.CalcUtils;
import com.smppw.core.reta.Rate;

import java.util.List;

public class MaxDrawdown extends Rate {

	@Override
	public Double calc(List<DateValue> dateValues) {
		Double maxDrawdown = CalcUtils.maxDrawdown(dateValues);
		if (maxDrawdown == null) {
			return null;
		} else if (maxDrawdown == 0.0) {
			return 0.0;
		} else {
			return -maxDrawdown;
		}
	}
}
