If you want a really easy answer, you can do the following:
Convert your futures prices into rates e.g. $100 - price = rate$.
Construct a LineCurve
in rateslib
:
from rateslib import *
curve = LineCurve(
nodes={
dt(2023, 9, 21): 3.92,
dt(2023, 12, 20): 4.01,
dt(2024, 3, 20): 3.96,
dt(2024, 6, 20): 3.83,
dt(2024, 9, 20): 3.62,
dt(2024, 12, 20): 3.42,
dt(2025, 3, 20): 3.25,
},
t=[
dt(2023, 9, 21), dt(2023, 9, 21), dt(2023, 9, 21), dt(2023, 9, 21),
dt(2023, 12, 20),
dt(2024, 3, 20),
dt(2024, 6, 20),
dt(2024, 9, 20),
dt(2024, 12, 20),
dt(2025, 3, 20), dt(2025, 3, 20), dt(2025, 3, 20), dt(2025, 3, 20),
]
)
curve.plot()
The t
parameter is the knot sequence which is needed to instruct a cubic spline. You can read about this in the rateslib docs
The curve
rate on 18th Jan 2024
>>> curve[dt(2024, 1, 18)]
4.008222134667067
The curve that is produced is a futures curves and it ignores convexity adjustments which are generally created by the presence of a swaps market.