interpolate#
- rateslib.curves.interpolate(x, x_1, y_1, x_2, y_2, interpolation, start=None)#
Perform local interpolation between two data points.
- Parameters:
x (Any with topology) – The x-value for which the interpolated y-value is sought.
x_1 (same type as
x
) – The left bound for the local interpolation.x_2 (same type as
x
) – The right bound for the local interpolation.interpolation (str) – The interpolation rule to use in {“linear”, “log_linear”, “linear_zero_rate”, “flat_forward”, “flat_backward”}.
start (datetime) – Used only if
interpolation
is “linear_zero_rate” to identify the start date of a curve.
- Return type:
Notes
If
x
is outside the region[x_1, x_2]
this function will extrapolate instead of interpolate using the same mathematical formula.Examples
In [1]: interpolate(50, 0, 10, 100, 50, "linear") Out[1]: 30.0 In [2]: interpolate(dt(2000, 1, 6), dt(2000, 1, 1), 10, dt(2000, 1, 11), 50, "linear") Out[2]: 30.0