我在使用 c# IRR 函数时遇到问题我收到“参数无效”异常,我在给定项目中每年都有一组 netcash:
public double IRR
{
get
{
var operatingYears =
EntProject.ResultYearSet.Where(p => p.YearType == YearTypeEnum.Operating)
.Select(x => (double)x.NetCash)
.ToArray();
return NavitasFormulae.GetInternalRateofReturn(operatingYears);
}
内部收益率函数:
public static double GetInternalRateofReturn(double[] values,double guess = 0.0001)
{
try
{
return Financial.IRR(ref values);
}
catch (ArgumentException)
{
// throw new BusinessException(BusinessExceptionEnum.Operational,
// "Cannot calculate IRR from the yearly values");
return 0; //If the series of values are not suitable, then the function will return zero.
}
catch (Exception)
{
throw new BusinessException(BusinessExceptionEnum.Operational,
"The IRR Function encountered an error");
}
}
我试图将猜测更改为不同的值,并在数组中传递了一个负数(每年总成本的总和),但仍然没有运气?