private CurvePoint ResolveMaturity(Maturity maturity, IEnumerable <CurvePoint> points) { var alreadyExistingPoint = points.FirstOrDefault(p => p.Maturity == maturity); if (alreadyExistingPoint != null) { return(alreadyExistingPoint); } var minPoint = points .OrderBy(p => p.Maturity) .First(); if (maturity < minPoint.Maturity) { return(ExtrapolationShort.Solve(minPoint, maturity)); } var maxPoint = points .OrderBy(p => p.Maturity) .Last(); if (maturity > maxPoint.Maturity) { return(ExtrapolationLong.Solve(maxPoint, maturity)); } var before = points .Where(p => p.Maturity < maturity) .OrderBy(p => p.Maturity) .Last(); var after = points .Where(p => p.Maturity > maturity) .OrderBy(p => p.Maturity) .First(); return(Interpolation.Solve(before, after, maturity)); }