_WithMutability#

class rateslib.curves._WithMutability(nodes, *, interpolation=NoInput.blank, t=NoInput.blank, endpoints=NoInput.blank, id=NoInput.blank, convention=NoInput.blank, modifier=NoInput.blank, calendar=NoInput.blank, ad=0, index_base=NoInput.blank, index_lag=NoInput.blank, collateral=NoInput.blank, credit_discretization=NoInput.blank, credit_recovery_rate=NoInput.blank, **kwargs)#

Bases: object

This class is designed as a mixin for the methods for Curve Pricing Objects, i.e. the Curve and LineCurve.

It permits initialization, configuration of nodes and meta and mutability when interacting with a Solver, when getting and setting nodes, as well as user update methods, spline interpolation solving and state validation.

Methods Summary

csolve()

Solves and sets the coefficients, c, of the PPSpline.

to_json()

Serialize this object to JSON format.

update([nodes])

Update a curves nodes with new, manually input values.

update_meta(key, value)

Update a single meta value on the Curve.

update_node(key, value)

Update a single node value on the Curve.

Methods Documentation

csolve()#

Solves and sets the coefficients, c, of the PPSpline.

Return type:

None

Notes

Only impacts curves which have a knot sequence, t, and a PPSpline. Only solves if c not given at curve initialisation.

Uses the spline_endpoints attribute on the class to determine the solving method.

to_json()#

Serialize this object to JSON format.

The object can be deserialized using the from_json() method.

Return type:

str

Notes

Some Curves will not be serializable, for example those that possess user defined interpolation functions.

update(nodes=NoInput.blank)#

Update a curves nodes with new, manually input values.

For arguments see Curve. Any value not given will not change the underlying Curve.

Parameters:

nodes (dict[datetime, DualTypes], optional) – New nodes to assign to the curve.

Return type:

None

Notes

Warning

Rateslib is an object-oriented library that uses complex associations. Although Python may not object to directly mutating attributes of a Curve instance, this should be avoided in rateslib. Only use official update methods to mutate the values of an existing Curve instance. This class is labelled as a mutable on update object.

update_meta(key, value)#

Update a single meta value on the Curve.

Parameters:
  • key (datetime) – The meta descriptor to update. Must be a documented attribute of _CurveMeta.

  • value (Any) – Value to update on the Curve.

Return type:

None

update_node(key, value)#

Update a single node value on the Curve.

Parameters:
  • key (datetime) – The node date to update. Must exist in nodes.

  • value (float, Dual, Dual2, Variable) – Value to update on the Curve.

Return type:

None

Notes

Warning

Rateslib is an object-oriented library that uses complex associations. Although Python may not object to directly mutating attributes of a Curve instance, this should be avoided in rateslib. Only use official update methods to mutate the values of an existing Curve instance. This class is labelled as a mutable on update object.