Yield Curve API
Yield curve construction and interpolation functions.
construct_yield_curve(maturities, rates, interpolation_method='cubic', extrapolate=False)
Construct a yield curve from observed market rates.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
maturities
|
list of float
|
Maturities in years for the observed rates |
required |
rates
|
list of float
|
Observed interest rates (as decimals) |
required |
interpolation_method
|
str
|
Method for interpolation ('linear', 'cubic', 'monotonic'), by default 'cubic' |
'cubic'
|
extrapolate
|
bool
|
Whether to allow extrapolation beyond observed maturities, by default False |
False
|
Returns:
Type | Description |
---|---|
dict
|
Yield curve object and details |
Raises:
Type | Description |
---|---|
ValueError
|
If inputs are invalid or maturities are not in ascending order If interpolation method is not valid |
interpolate_rate(yield_curve, maturity)
Interpolate interest rate at a specific maturity from a yield curve.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
yield_curve
|
dict
|
Yield curve object from construct_yield_curve |
required |
maturity
|
float
|
Maturity in years for which to interpolate the rate |
required |
Returns:
Type | Description |
---|---|
float
|
Interpolated interest rate |
Raises:
Type | Description |
---|---|
ValueError
|
If yield_curve is not a valid yield curve object If maturity is not positive |