MultiCsaCurve#

class rateslib.curves.MultiCsaCurve(curves, id=NoInput.blank, multi_csa_min_step=1, multi_csa_max_step=1825)#

Bases: CompositeCurve

A dynamic composition of a sequence of other curves.

Note

Can only combine curves of the type: Curve. Other curve parameters such as modifier, and convention must also match.

Warning

Intrinsic MultiCsaCurves, by definition, are not natively AD safe, due to having discontinuities and no available derivatives in certain cases. See discontinuous MultiCsaCurves.

Parameters:
  • curves (sequence of Curve) – The curves to be composited.

  • id (str, optional, set by Default) – The unique identifier to distinguish between curves in a multi-curve framework.

  • multi_csa_min_step (int, optional) – The minimum calculation step between subsequent DF evaluations to determine a multi-CSA curve term DF. Higher numbers make faster calculations but are less accurate. Should be in [1, max_step].

  • multi_csa_max_step (int, optional) – The minimum calculation step between subsequent DF evaluations to determine a multi-CSA curve term DF. Higher numbers make faster calculations but are less accurate. Should be in [min_step, 1825].

Notes

A MultiCsaCurve uses a different calculation methodology than a CompositeCurve for determining the rate by selecting the curve within the collection with the highest rate.

Attributes Summary

ad

Int in {0,1,2} describing the AD order associated with the Curve.

id

A str identifier to name the Curve used in Solver mappings.

interpolator

An instance of _CurveInterpolator.

meta

An instance of _CurveMeta.

nodes

An instance of _CurveNodes.

Methods Summary

copy(*args, **kwargs)

Not implemented on CompositeCurve types.

csolve(*args, **kwargs)

Not implemented on CompositeCurve types.

from_json(*args, **kwargs)

Not implemented on CompositeCurve types.

index_value(date, index_lag[, interpolation])

Calculate the accrued value of the index from the index_base, which is taken as index_base of the first composited curve given.

plot(tenor[, right, left, comparators, ...])

Plot given forward tenor rates from the curve.

plot_index([right, left, comparators, ...])

Plot given index values on a curve.

rate(effective, termination[, modifier])

Calculate the cheapest-to-deliver (CTD) rate on the curve.

roll(tenor)

Create a new curve with its shape translated in time

shift(spread[, id, collateral, composite])

Create a new curve by vertically adjusting the curve by a set number of basis points.

to_json(*args, **kwargs)

Not implemented on CompositeCurve types.

translate(start[, t])

Create a new curve with an initial node date moved forward keeping all else constant.

update(*args, **kwargs)

Not implemented on CompositeCurve types.

update_meta(key, value)

Not implemented on CompositeCurve types.

update_node(*args, **kwargs)

Not implemented on CompositeCurve types.

Attributes Documentation

ad#

Int in {0,1,2} describing the AD order associated with the Curve.

id#

A str identifier to name the Curve used in Solver mappings.

interpolator#

An instance of _CurveInterpolator.

meta#

An instance of _CurveMeta.

nodes#

An instance of _CurveNodes.

Methods Documentation

copy(*args, **kwargs)#

Not implemented on CompositeCurve types.

csolve(*args, **kwargs)#

Not implemented on CompositeCurve types.

from_json(*args, **kwargs)#

Not implemented on CompositeCurve types.

index_value(date, index_lag, interpolation='curve')#

Calculate the accrued value of the index from the index_base, which is taken as index_base of the first composited curve given.

See Curve.index_value()

plot(tenor, right=NoInput.blank, left=NoInput.blank, comparators=NoInput.blank, difference=False, labels=NoInput.blank)#

Plot given forward tenor rates from the curve. See notes.

Parameters:
  • tenor (str) – The tenor of the forward rates to plot, e.g. “1D”, “3M”.

  • right (datetime or str, optional) – The right bound of the graph. If given as str should be a tenor format defining a point measured from the initial node date of the curve. Defaults to the final node of the curve minus the tenor.

  • left (datetime or str, optional) – The left bound of the graph. If given as str should be a tenor format defining a point measured from the initial node date of the curve. Defaults to the initial node of the curve.

  • comparators (list[Curve]) – A list of curves which to include on the same plot as comparators.

  • difference (bool) – Whether to plot as comparator minus base curve or outright curve levels in plot. Default is False.

  • labels (list[str]) – A list of strings associated with the plot and comparators. Must be same length as number of plots.

Returns:

(fig, ax, line)

Return type:

Matplotlib.Figure, Matplotplib.Axes, Matplotlib.Lines2D

Notes

This function plots single-period, simple interest curve rates, which are defined as:

\[1 + r d = \frac{v_{start}}{v_{end}}\]

where d is the day count fraction determined using the convention associated with the Curve.

This function does not plot swap rates, which is impossible since the Curve object contains no information regarding the parameters of the ‘swap’ (e.g. its frequency or its convention etc.). If tenors longer than one year are sought results may start to deviate from those one might expect. See Issue 246.

plot_index(right=NoInput.blank, left=NoInput.blank, comparators=NoInput.blank, difference=False, labels=NoInput.blank, interpolation='curve')#

Plot given index values on a curve.

Parameters:
  • tenor (str) – The tenor of the forward rates to plot, e.g. “1D”, “3M”.

  • right (datetime or str, optional) – The right bound of the graph. If given as str should be a tenor format defining a point measured from the initial node date of the curve. Defaults to the final node of the curve minus the tenor.

  • left (datetime or str, optional) – The left bound of the graph. If given as str should be a tenor format defining a point measured from the initial node date of the curve. Defaults to the initial node of the curve.

  • comparators (list[Curve]) – A list of curves which to include on the same plot as comparators.

  • difference (bool) – Whether to plot as comparator minus base curve or outright curve levels in plot. Default is False.

  • labels (list[str]) – A list of strings associated with the plot and comparators. Must be same length as number of plots.

  • interpolation (str in {"curve", "daily", "monthly"}) – The type of index interpolation method to use.

Returns:

(fig, ax, line)

Return type:

Matplotlib.Figure, Matplotplib.Axes, Matplotlib.Lines2D

rate(effective, termination, modifier=NoInput.inherit)#

Calculate the cheapest-to-deliver (CTD) rate on the curve.

If rates are sought for dates prior to the initial node of the curve None will be returned.

Parameters:
  • effective (datetime) – The start date of the period for which to calculate the rate.

  • termination (datetime or str) – The end date of the period for which to calculate the rate.

  • modifier (str, optional) – The day rule if determining the termination from tenor. If False is determined from the Curve modifier.

Return type:

Dual, Dual2 or float

roll(tenor)#

Create a new curve with its shape translated in time

This curve adjustment is a simulation of a future state of the market where forward rates are assumed to have moved so that the present day’s curve shape is reflected in the future (or the past). This is often used in trade strategy analysis.

Parameters:

tenor (datetime or str) – The date or tenor by which to roll the curve. If a tenor, as str, will derive the datetime as measured from the initial node date. If supplying a negative tenor, or a past datetime, there is a limit to how far back the curve can be rolled - it will first roll backwards and then attempt to translate() forward to maintain the initial node date.

Return type:

MultiCsaCurve

shift(spread, id=NoInput.blank, collateral=NoInput.blank, composite=True)#

Create a new curve by vertically adjusting the curve by a set number of basis points.

See Curve.shift()

to_json(*args, **kwargs)#

Not implemented on CompositeCurve types.

translate(start, t=False)#

Create a new curve with an initial node date moved forward keeping all else constant.

This curve adjustment preserves forward curve expectations as time evolves. This method is suitable as a way to create a subsequent opening curve from a previous day’s closing curve.

Parameters:
  • start (datetime) – The new initial node date for the curve, must be in the domain: (node_date[0], node_date[1]]

  • t (bool) – Set to True if the initial knots of the knot sequence should be translated forward.

Return type:

MultiCsaCurve

update(*args, **kwargs)#

Not implemented on CompositeCurve types.

update_meta(key, value)#

Not implemented on CompositeCurve types.

update_node(*args, **kwargs)#

Not implemented on CompositeCurve types.