Vasicek Curve¶
quantflow.rates.vasicek.VasicekCurve
pydantic-model
¶
Bases: YieldCurve
Yield curve derived from the Vasicek short-rate model.
The Vasicek model describes the short rate as a mean-reverting Ornstein-Uhlenbeck process:
The model admits a closed-form discount factor; see discount_factor.
Throughout, the auxiliary quantity is:
Fields:
-
ref_date(datetime) -
curve_type(Literal['vasicek_curve']) -
rate(DecimalNumber) -
kappa(DecimalNumber) -
theta(DecimalNumber) -
sigma(DecimalNumber)
calibrator
¶
Return a VasicekCurveCalibration wrapping this curve.
process
¶
Return the underlying Vasicek process corresponding to this curve.
Source code in quantflow/rates/vasicek.py
instantaneous_forward_rate
¶
Calculate the instantaneous forward rate for the Vasicek model.
Source code in quantflow/rates/vasicek.py
discount_factor
¶
Calculate the discount factor using the Vasicek closed-form solution.
The discount factor is:
where:
Source code in quantflow/rates/vasicek.py
jacobian
¶
Analytical Jacobian of discount factors w.r.t. \([r_0, \kappa, \theta, \sigma]\). Returns shape (len(ttm), 4).
Source code in quantflow/rates/vasicek.py
continuously_compounded_rate
¶
Calculate the continuously compounded rate for a given time to maturity.
The continuously compounded rate is related to the discount factor by the following formula:
where \(D(\tau)\) is the discount factor for a given time to maturity \(\tau\).
Accepts a scalar float or a float array. Returns a scalar float for scalar input and a numpy float array for array input.
| PARAMETER | DESCRIPTION |
|---|---|
ttm
|
Time to maturity in years
TYPE:
|
Source code in quantflow/rates/yield_curve.py
plot
¶
Plot the continuously compounded rate vs time to maturity.
Requires plotly to be installed.
| PARAMETER | DESCRIPTION |
|---|---|
ttm_max
|
Maximum time to maturity in years
TYPE:
|
n
|
Number of points to evaluate
TYPE:
|
Source code in quantflow/rates/yield_curve.py
register_curve_types
classmethod
¶
Register a yield curve subclass for deserialization.
Source code in quantflow/rates/yield_curve.py
curve_types
classmethod
¶
get_curve_class
classmethod
¶
quantflow.rates.vasicek.VasicekCurveCalibration
pydantic-model
¶
Bases: YieldCurveCalibration[VasicekCurve]
Calibration wrapper for a Vasicek yield curve.
Fields:
-
yield_curve(Y)
get_params
¶
set_params
¶
Source code in quantflow/rates/vasicek.py
get_bounds
¶
calibrate
¶
Fit the Vasicek curve to continuously compounded rates via least squares.
| PARAMETER | DESCRIPTION |
|---|---|
ttm
|
Times to maturity in years.
TYPE:
|
rates
|
Continuously compounded rates, same length as ttm.
TYPE:
|
Source code in quantflow/rates/vasicek.py
calibrate_df
¶
Fit the yield curve to target discount factors.
Converts discount factors to continuously compounded rates then calls [calibrate][quantflow.rates.vasicek.VasicekCurveCalibration.calibrate_df.calibrate].
| PARAMETER | DESCRIPTION |
|---|---|
ttm
|
Times to maturity in years.
TYPE:
|
target
|
Target discount factors, same length as ttm.
TYPE:
|