Skip to content

Commit 949c70b

Browse files
pcaspersjenkins
authored andcommitted
QPR-12528 add some log interpolations
1 parent 5e5a928 commit 949c70b

4 files changed

Lines changed: 105 additions & 7 deletions

File tree

Docs/UserGuide/curve_configurations/yieldcurves.tex

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,18 @@ \subsubsection{Yield Curves}
8383
\hline
8484
Linear & Linear interpolation \\ \hline
8585
LogLinear & Linear interpolation on the natural log of the interpolation variable \\ \hline
86-
NaturalCubic & Monotonic Kruger cubic interpolation with second derivative at left and right \\ \hline
87-
FinancialCubic & Monotonic Kruger cubic interpolation with second derivative at left and
88-
first derivative at right \\ \hline
86+
NaturalCubic & Monotonic Kruger cubic interpolation with zero second derivative at left and right \\ \hline
87+
FinancialCubic & Monotonic Kruger cubic interpolation with zero second derivative at left and
88+
zero first derivative at right \\ \hline
8989
ConvexMonotone & Convex Monotone Interpolation (Hagan, West) \\ \hline
9090
Quadratic & Quadratic interpolation \\ \hline
9191
LogQuadratic & Quadratic interpolation on the natural log of the interpolation variable \\ \hline
92+
LogNaturalCubic & Monotonic Kruger cubic interpolation with zero second derivative at left and right \\hline
93+
LogFinancialCubic & Monotonic Kruger cubic interpolation with zero second derivative at left and
94+
zero first derivative at right \\hline
95+
LogCubicSpline & Non-monotonic cubic spline interpolation with zero second derivative at left and right \\hline
9296
Hermite & Hermite cubic spline interpolation \\ \hline
93-
CubicSpline & Non-monotonic cubic spline interpolation with second derivative at left and right \\ \hline
97+
CubicSpline & Non-monotonic cubic spline interpolation with zero second derivative at left and right \\ \hline
9498
DefaultLogMixedLinearCubic & Mixed interpolation, first linear, then monotonic Kruger cubic spline \\ \hline
9599
MonotonicLogMixedLinearCubic & Mixed interpolation, first linear, then monotonic natural cubic spline \\ \hline
96100
KrugerLogMixedLinearCubic & Mixed interpolation, first linear, then non-monotonic Kruger cubic spline \\ \hline

OREData/ored/marketdata/yieldcurve.cpp

Lines changed: 91 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,12 @@ YieldCurve::InterpolationMethod parseYieldCurveInterpolationMethod(const string&
194194
return YieldCurve::InterpolationMethod::Quadratic;
195195
else if (s == "LogQuadratic")
196196
return YieldCurve::InterpolationMethod::LogQuadratic;
197+
else if (s == "LogNaturalCubic")
198+
return YieldCurve::InterpolationMethod::LogNaturalCubic;
199+
else if (s == "LogFinancialCubic")
200+
return YieldCurve::InterpolationMethod::LogFinancialCubic;
201+
else if (s == "LogCubicSpline")
202+
return YieldCurve::InterpolationMethod::LogCubicSpline;
197203
else if (s == "Hermite")
198204
return YieldCurve::InterpolationMethod::Hermite;
199205
else if (s == "CubicSpline")
@@ -242,6 +248,12 @@ std::ostream& operator<<(std::ostream& out, const YieldCurve::InterpolationMetho
242248
return out << "Quadratic";
243249
else if (m == YieldCurve::InterpolationMethod::LogQuadratic)
244250
return out << "LogQuadratic";
251+
else if (m == YieldCurve::InterpolationMethod::LogNaturalCubic)
252+
return out << "LogNaturalCubic";
253+
else if (m == YieldCurve::InterpolationMethod::LogFinancialCubic)
254+
return out << "LogFinancialCubic";
255+
else if (m == YieldCurve::InterpolationMethod::LogCubicSpline)
256+
return out << "LogCubicSpline";
245257
else if (m == YieldCurve::InterpolationMethod::Hermite)
246258
return out << "Hermite";
247259
else if (m == YieldCurve::InterpolationMethod::CubicSpline)
@@ -442,9 +454,10 @@ YieldCurve::piecewisecurve(vector<QuantLib::ext::shared_ptr<RateHelper>> instrum
442454
typedef PiecewiseYieldCurve<ZeroYield, Cubic, QuantExt::IterativeBootstrap> my_curve;
443455
yieldts = QuantLib::ext::make_shared<my_curve>(
444456
asofDate_, instruments, zeroDayCounter_,
445-
Cubic(CubicInterpolation::Spline, false, CubicInterpolation::SecondDerivative, 0.0, CubicInterpolation::SecondDerivative, 0.0),
446-
my_curve::bootstrap_type(accuracy, globalAccuracy, dontThrow, maxAttempts, maxFactor,
447-
minFactor, dontThrowSteps));
457+
Cubic(CubicInterpolation::Spline, false, CubicInterpolation::SecondDerivative, 0.0,
458+
CubicInterpolation::SecondDerivative, 0.0),
459+
my_curve::bootstrap_type(accuracy, globalAccuracy, dontThrow, maxAttempts, maxFactor, minFactor,
460+
dontThrowSteps));
448461
} break;
449462
case InterpolationMethod::Quadratic: {
450463
typedef PiecewiseYieldCurve<ZeroYield, QuantExt::Quadratic, QuantExt::IterativeBootstrap> my_curve;
@@ -461,6 +474,31 @@ YieldCurve::piecewisecurve(vector<QuantLib::ext::shared_ptr<RateHelper>> instrum
461474
my_curve::bootstrap_type(accuracy, globalAccuracy, dontThrow, maxAttempts, maxFactor,
462475
minFactor, dontThrowSteps));
463476
} break;
477+
case InterpolationMethod::LogNaturalCubic: {
478+
typedef PiecewiseYieldCurve<ZeroYield, LogCubic, QuantExt::IterativeBootstrap> my_curve;
479+
yieldts = QuantLib::ext::make_shared<my_curve>(
480+
asofDate_, instruments, zeroDayCounter_, LogCubic(CubicInterpolation::Kruger, true),
481+
my_curve::bootstrap_type(accuracy, globalAccuracy, dontThrow, maxAttempts, maxFactor,
482+
minFactor, dontThrowSteps));
483+
} break;
484+
case InterpolationMethod::LogFinancialCubic: {
485+
typedef PiecewiseYieldCurve<ZeroYield, LogCubic, QuantExt::IterativeBootstrap> my_curve;
486+
yieldts = QuantLib::ext::make_shared<my_curve>(
487+
asofDate_, instruments, zeroDayCounter_,
488+
LogCubic(CubicInterpolation::Kruger, true, CubicInterpolation::SecondDerivative, 0.0,
489+
CubicInterpolation::FirstDerivative),
490+
my_curve::bootstrap_type(accuracy, globalAccuracy, dontThrow, maxAttempts, maxFactor, minFactor,
491+
dontThrowSteps));
492+
} break;
493+
case InterpolationMethod::LogCubicSpline: {
494+
typedef PiecewiseYieldCurve<ZeroYield, LogCubic, QuantExt::IterativeBootstrap> my_curve;
495+
yieldts = QuantLib::ext::make_shared<my_curve>(
496+
asofDate_, instruments, zeroDayCounter_,
497+
LogCubic(CubicInterpolation::Spline, false, CubicInterpolation::SecondDerivative, 0.0,
498+
CubicInterpolation::SecondDerivative, 0.0),
499+
my_curve::bootstrap_type(accuracy, globalAccuracy, dontThrow, maxAttempts, maxFactor, minFactor,
500+
dontThrowSteps));
501+
} break;
464502
case InterpolationMethod::DefaultLogMixedLinearCubic: {
465503
typedef PiecewiseYieldCurve<ZeroYield, DefaultLogMixedLinearCubic, QuantExt::IterativeBootstrap> my_curve;
466504
yieldts = QuantLib::ext::make_shared<my_curve>(
@@ -565,6 +603,31 @@ YieldCurve::piecewisecurve(vector<QuantLib::ext::shared_ptr<RateHelper>> instrum
565603
my_curve::bootstrap_type(accuracy, globalAccuracy, dontThrow, maxAttempts, maxFactor,
566604
minFactor, dontThrowSteps));
567605
} break;
606+
case InterpolationMethod::LogNaturalCubic: {
607+
typedef PiecewiseYieldCurve<Discount, LogCubic, QuantExt::IterativeBootstrap> my_curve;
608+
yieldts = QuantLib::ext::make_shared<my_curve>(
609+
asofDate_, instruments, zeroDayCounter_, LogCubic(CubicInterpolation::Kruger, true),
610+
my_curve::bootstrap_type(accuracy, globalAccuracy, dontThrow, maxAttempts, maxFactor,
611+
minFactor, dontThrowSteps));
612+
} break;
613+
case InterpolationMethod::LogFinancialCubic: {
614+
typedef PiecewiseYieldCurve<Discount, LogCubic, QuantExt::IterativeBootstrap> my_curve;
615+
yieldts = QuantLib::ext::make_shared<my_curve>(
616+
asofDate_, instruments, zeroDayCounter_,
617+
QuantLib::LogCubic(CubicInterpolation::Kruger, true, CubicInterpolation::SecondDerivative, 0.0,
618+
CubicInterpolation::FirstDerivative),
619+
my_curve::bootstrap_type(accuracy, globalAccuracy, dontThrow, maxAttempts, maxFactor, minFactor,
620+
dontThrowSteps));
621+
} break;
622+
case InterpolationMethod::LogCubicSpline: {
623+
typedef PiecewiseYieldCurve<Discount,LogCubic, QuantExt::IterativeBootstrap> my_curve;
624+
yieldts = QuantLib::ext::make_shared<my_curve>(
625+
asofDate_, instruments, zeroDayCounter_,
626+
LogCubic(CubicInterpolation::Spline, false, CubicInterpolation::SecondDerivative, 0.0,
627+
CubicInterpolation::SecondDerivative, 0.0),
628+
my_curve::bootstrap_type(accuracy, globalAccuracy, dontThrow, maxAttempts, maxFactor, minFactor,
629+
dontThrowSteps));
630+
} break;
568631
case InterpolationMethod::DefaultLogMixedLinearCubic: {
569632
typedef PiecewiseYieldCurve<Discount, DefaultLogMixedLinearCubic, QuantExt::IterativeBootstrap> my_curve;
570633
yieldts = QuantLib::ext::make_shared<my_curve>(
@@ -669,6 +732,31 @@ YieldCurve::piecewisecurve(vector<QuantLib::ext::shared_ptr<RateHelper>> instrum
669732
my_curve::bootstrap_type(accuracy, globalAccuracy, dontThrow, maxAttempts, maxFactor,
670733
minFactor, dontThrowSteps));
671734
} break;
735+
case InterpolationMethod::LogNaturalCubic: {
736+
typedef PiecewiseYieldCurve<ForwardRate, LogCubic, QuantExt::IterativeBootstrap> my_curve;
737+
yieldts = QuantLib::ext::make_shared<my_curve>(
738+
asofDate_, instruments, zeroDayCounter_, LogCubic(CubicInterpolation::Kruger, true),
739+
my_curve::bootstrap_type(accuracy, globalAccuracy, dontThrow, maxAttempts, maxFactor, minFactor,
740+
dontThrowSteps));
741+
} break;
742+
case InterpolationMethod::LogFinancialCubic: {
743+
typedef PiecewiseYieldCurve<ForwardRate, LogCubic, QuantExt::IterativeBootstrap> my_curve;
744+
yieldts = QuantLib::ext::make_shared<my_curve>(
745+
asofDate_, instruments, zeroDayCounter_,
746+
LogCubic(CubicInterpolation::Kruger, true, CubicInterpolation::SecondDerivative, 0.0,
747+
CubicInterpolation::FirstDerivative),
748+
my_curve::bootstrap_type(accuracy, globalAccuracy, dontThrow, maxAttempts, maxFactor, minFactor,
749+
dontThrowSteps));
750+
} break;
751+
case InterpolationMethod::LogCubicSpline: {
752+
typedef PiecewiseYieldCurve<ForwardRate, LogCubic, QuantExt::IterativeBootstrap> my_curve;
753+
yieldts = QuantLib::ext::make_shared<my_curve>(
754+
asofDate_, instruments, zeroDayCounter_,
755+
LogCubic(CubicInterpolation::Spline, false, CubicInterpolation::SecondDerivative, 0.0,
756+
CubicInterpolation::SecondDerivative, 0.0),
757+
my_curve::bootstrap_type(accuracy, globalAccuracy, dontThrow, maxAttempts, maxFactor, minFactor,
758+
dontThrowSteps));
759+
} break;
672760
case InterpolationMethod::DefaultLogMixedLinearCubic: {
673761
typedef PiecewiseYieldCurve<ForwardRate, DefaultLogMixedLinearCubic, QuantExt::IterativeBootstrap> my_curve;
674762
yieldts = QuantLib::ext::make_shared<my_curve>(

OREData/ored/marketdata/yieldcurve.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ class YieldCurve {
7272
ConvexMonotone,
7373
Quadratic,
7474
LogQuadratic,
75+
LogNaturalCubic,
76+
LogFinancialCubic,
77+
LogCubicSpline,
7578
Hermite,
7679
CubicSpline,
7780
DefaultLogMixedLinearCubic,

xsd/ore_types.xsd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,9 @@
480480
<xs:enumeration value="Hermite"/>
481481
<xs:enumeration value="Quadratic"/>
482482
<xs:enumeration value="LogQuadratic"/>
483+
<xs:enumeration value="LogNaturalCubic"/>
484+
<xs:enumeration value="LogFinancialCubic"/>
485+
<xs:enumeration value="LogCubicSpline"/>
483486
<xs:enumeration value="CubicSpline"/>
484487
<xs:enumeration value="LinearFlat"/>
485488
<xs:enumeration value="LogLinearFlat"/>

0 commit comments

Comments
 (0)