|
From: Ben W. <ben...@ma...> - 2023-09-14 20:58:06
|
This is from the python documentation
import QuantLib as ql
import numpy as np
import matplotlib.pyplot as plt
X = [1., 2., 3., 4., 5.]
Y = [0.5, 0.6, 0.7, 0.8, 0.9]
methods = {
'Linear Interpolation': ql.LinearInterpolation(X, Y),
'LogLinearInterpolation': ql.LogLinearInterpolation(X, Y),
'CubicNaturalSpline': ql.CubicNaturalSpline(X, Y),
'LogCubicNaturalSpline': ql.LogCubicNaturalSpline(X, Y),
'ForwardFlatInterpolation': ql.ForwardFlatInterpolation(X, Y),
'BackwardFlatInterpolation': ql.BackwardFlatInterpolation(X, Y),
'LogParabolic': ql.LogParabolic(X, Y)
}
xx = np.linspace(1, 10)
fig = plt.figure(figsize=(15,4))
plt.scatter(X, Y, label='Original Data')
for name, i in methods.items():
yy = [i(x, allowExtrapolation=True) for x in xx]
plt.plot(xx, yy, label=name);
plt.legend();
On Fri, 15 Sept 2023, 4:34 am Michael (DataDriven portal), <
mi...@da...> wrote:
> Hi All,
>
> I am looking for some QuantLib examples on how to calculate bond's I
> spread that match Bloomberg calculations (as described below).
>
> Any help is greatly appreciated!
>
> Bloomberg's I-spread is calculated like this: find the 2 swap rate quotes
> nearest the bond maturity. Linearly interpolate to get the swap rate at the
> bond's maturity. (Unless you happen to have a swap rate quote exactly at
> the bond's maturity.) I-spread = interpolated swap rate - the bond's
> conventional yield
>
> Thanks,
>
> Michael
> _______________________________________________
> QuantLib-users mailing list
> Qua...@li...
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>
|