我遇到了c# IRR函数的问题,我得到了“参数无效”异常,在给定的项目中,我每年都有一个净现金数组:
public double IRR
{
get
{
var operatingYears =
EntProject.ResultYearSet.Where(p => p.YearType == YearTypeEnum.Operating)
.Select(x => (double)x.NetCash)
.ToArray();
return NavitasFormulae.GetInternalRateofReturn(operatingYears);
} IRR函数:
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");
}
}我尝试将猜测更改为不同的值,并在数组中传递了一个负数(每年总成本的总和),但仍然没有成功?
发布于 2017-09-09 05:02:54
希望还来得及。在处理此问题时,我将IRR方法的猜测值更改为0.00000001。
IRR的结果永远不会是零。因此,猜测值表示IRR结果接近于零的程度。
rate = Microsoft.VisualBasic.Financial.IRR(ref values, 0.00000001);我从C#调用此函数
https://stackoverflow.com/questions/17829627
复制相似问题