API Reference#

Indices and tables#

Notation#

\[\begin{split}d \quad \text{or} \quad d_i =& \text{DCF of period} \; (i) \\ m \quad \text{or} \quad m_i =& \text{Maturity date of period} \; (i) \\ v(m) =& \text{DF of period payment date,} \; m \\ N \quad \text{or} \quad N_i =& \text{Notional of period} \; (i) \\ R =& \text{Fixed rate of period or leg} \\ z =& \text{Floating period spread} \\ r(r_i, z) =& \text{Floating rate of period as a function of fixings,} \; (r_i) \\ C =& \text{Cashflow} \\ P =& \text{Net present value} \\ I(m) =& \text{Index ratio applicable at maturity,} \; m \\\end{split}\]

Defaults#

Classes#

Defaults()

The defaults object used by initialising objects.

Fixings()

Class to lazy load fixing data from CSV files.

NoInput(value[, names, module, qualname, ...])

Enumerable type to handle setting default values.

Calendars#

Functions#

add_tenor(start, tenor, modifier[, ...])

Add a tenor to a given date under specific modification rules and holiday calendar.

create_calendar(rules[, weekmask])

Create a calendar with specific business and holiday days defined.

dcf(start, end, convention[, termination, ...])

Calculate the day count fraction of a period.

get_calendar(calendar[, kind])

Returns a calendar object either from an available set or a user defined input.

Scheduling#

Classes#

Schedule(effective, termination, frequency)

Generate a schedule of dates according to a regular pattern and calendar inference.

Highlighted private functions#

rateslib.scheduling._check_regular_swap(...)

Tests whether the given the parameters define a regular leg schedule without stubs.

rateslib.scheduling._infer_stub_date(...)

Attempts to infer either a front or back stub in an unspecified schedule.

Piecewise Polynomial Splines#

Functions#

bspldnev_single(x, i, k, t, m[, org_k])

Calculate the m th order derivative from the right of an indexed b-spline at x.

bsplev_single(x, i, k, t[, org_k])

Calculate the value of an indexed b-spline of the pp at the coordinate x.

Classes#

PPSpline(k, t[, c])

Implements a data site instructed piecewise polynomial (pp) spline using b-splines.

PPSplineDual

alias of PPSpline

PPSplineDual2

alias of PPSpline

PPSplineF64

alias of PPSpline

Dual (for AD)#

Functions#

dual_exp(x)

Calculate the exponential value of a regular int or float or a dual number.

dual_log(x[, base])

Calculate the logarithm of a regular int or float or a dual number.

dual_solve(A, b[, allow_lsq])

Solve the linear system Ax=b.

gradient(dual[, vars, order, keep_manifold])

Return derivatives of a dual number.

set_order(val, order)

Changes the order of a Dual or Dual2 leaving floats and ints unchanged.

set_order_convert(val, order, tag)

Convert a float, Dual or Dual2 type to a specified alternate type.

Classes#

Dual(real[, vars, dual])

Dual number data type to perform first derivative automatic differentiation.

Dual2(real[, vars, dual, dual2])

Dual number data type to perform second derivative automatic differentiation.

DualBase(real[, vars])

Base class for dual number implementation.

Class Inheritance Diagram#

Inheritance diagram of rateslib.dual.dual.Dual, rateslib.dual.dual.Dual2, rateslib.dual.dual.DualBase

Curves#

Functions#

average_rate(effective, termination, ...)

Return the geometric, 1 calendar day, average rate for the rate in a period.

index_left(list_input, list_length, value[, ...])

Return the interval index of a value from an ordered input list on the left side.

interpolate(x, x_1, y_1, x_2, y_2, interpolation)

Perform local interpolation between two data points.

Classes#

CompositeCurve(curves[, id])

A dynamic composition of a sequence of other curves.

Curve(nodes, *[, interpolation, t, c, ...])

Curve based on DF parametrisation at given node dates with interpolation.

IndexCurve(*args[, index_base, index_lag])

A subclass of Curve with an index_base value for index calculations.

LineCurve(*args, **kwargs)

Curve based on value parametrisation at given node dates with interpolation.

MultiCsaCurve(curves[, id, ...])

A dynamic composition of a sequence of other curves.

PPSplineDual

alias of PPSpline

PPSplineDual2

alias of PPSpline

PPSplineF64

alias of PPSpline

ProxyCurve(cashflow, collateral, fx_forwards)

A subclass of Curve which returns dynamic DFs based on other curves related via FXForwards parity.

Class Inheritance Diagram#

Inheritance diagram of rateslib.curves.CompositeCurve, rateslib.curves.Curve, rateslib.curves.IndexCurve, rateslib.curves.LineCurve, rateslib.curves.MultiCsaCurve, rateslib.curves.ProxyCurve

FX#

Functions#

forward_fx(date, curve_domestic, ...[, ...])

Return a forward FX rate based on interest rate parity.

Classes#

FXForwards(fx_rates, fx_curves[, base])

Class for storing and calculating FX forward rates.

FXRates(fx_rates[, settlement, base])

Object to store and calculate FX rates for a consistent settlement date.

Periods#

Link to the Periods section in the user guide.

Classes#

BasePeriod(start, end, payment, frequency[, ...])

Abstract base class with common parameters for all Period subclasses.

Cashflow(notional, payment[, currency, ...])

Create a single cashflow amount on a payment date (effectively a CustomPeriod).

FixedPeriod(*args[, fixed_rate])

Create a period defined with a fixed rate.

FloatPeriod(*args[, float_spread, fixings, ...])

Create a period defined with a floating rate index.

IndexCashflow(*args, index_base[, ...])

Create a cashflow defined with a real rate adjusted by an index.

IndexFixedPeriod(*args[, index_base, ...])

Create a period defined with a real rate adjusted by an index.

IndexMixin()

Abstract base class to include methods and properties related to indexed Periods.

Class Inheritance Diagram#

Inheritance diagram of rateslib.periods.BasePeriod, rateslib.periods.Cashflow, rateslib.periods.FixedPeriod, rateslib.periods.FloatPeriod, rateslib.periods.IndexCashflow, rateslib.periods.IndexFixedPeriod, rateslib.periods.IndexMixin

Legs#

Link to the Legs section in the user guide.

Classes#

BaseLeg(effective, termination, frequency, *)

Abstract base class with common parameters for all Leg subclasses.

BaseLegMtm(*args[, fx_fixings, ...])

Abstract base class with common parameters for all LegMtm subclasses.

CustomLeg(periods)

Create a leg contained of user specified Periods.

FixedLeg(*args[, fixed_rate])

Create a fixed leg composed of FixedPeriod s.

FixedLegMixin()

Add the functionality to add and retrieve fixed_rate on FixedPeriod s.

FixedLegMtm(*args[, fixed_rate])

Create a leg of FixedPeriod s and initial, mtm and final Cashflow s.

FloatLeg(*args[, float_spread, fixings, ...])

Create a floating leg composed of FloatPeriod s.

FloatLegMixin()

Add the functionality to add and retrieve float_spread on FloatPeriod s and a fixings_table().

FloatLegMtm(*args[, float_spread, fixings, ...])

Create a leg of FloatPeriod s and initial, mtm and final Cashflow s.

IndexFixedLeg(*args, index_base[, ...])

Create a leg of IndexFixedPeriod s and initial and final IndexCashflow s.

IndexLegMixin()

ZeroFixedLeg(*args[, fixed_rate])

Create a zero coupon fixed leg composed of a single FixedPeriod .

ZeroFloatLeg(*args[, float_spread, fixings, ...])

Create a zero coupon floating leg composed of FloatPeriod s.

ZeroIndexLeg(*args[, index_base, ...])

Create a zero coupon index leg composed of a single IndexFixedPeriod and a Cashflow.

Class Inheritance Diagram#

Inheritance diagram of rateslib.legs.BaseLeg, rateslib.legs.BaseLegMtm, rateslib.legs.CustomLeg, rateslib.legs.FixedLeg, rateslib.legs.FixedLegMixin, rateslib.legs.FixedLegMtm, rateslib.legs.FloatLeg, rateslib.legs.FloatLegMixin, rateslib.legs.FloatLegMtm, rateslib.legs.IndexFixedLeg, rateslib.legs.IndexLegMixin, rateslib.legs.ZeroFixedLeg, rateslib.legs.ZeroFloatLeg, rateslib.legs.ZeroIndexLeg

Instruments#

Classes#

BaseDerivative([effective, termination, ...])

Abstract base class with common parameters for many Derivative subclasses.

BaseMixin()

Bill([effective, termination, modifier, ...])

Create a discount security.

BondFuture(coupon, delivery, basket[, ...])

Create a bond future derivative.

BondMixin()

FRA([effective, termination, frequency, ...])

Create a forward rate agreement composing single period FixedLeg and FloatLeg valued in a customised manner.

FXExchange(settlement, currency, leg2_currency)

Create a simple exchange of two currencies.

FXSwap(*args[, fx_fixings, points, ...])

Create an FX swap simulated via a Fixed-Fixed XCS.

FixedRateBond([effective, termination, ...])

Create a fixed rate bond security.

FloatRateNote([effective, termination, ...])

Create a floating rate note (FRN) security.

Fly(instrument1, instrument2, instrument3)

A butterfly instrument which is, mechanically, the spread of two spread instruments.

IIRS(*args[, fixed_rate, index_base, ...])

Create an indexed interest rate swap (IIRS) composing an IndexFixedLeg and a FloatLeg.

IRS(*args[, fixed_rate, leg2_float_spread, ...])

Create an interest rate swap composing a FixedLeg and a FloatLeg.

IndexFixedRateBond([effective, termination, ...])

Create an indexed fixed rate bond security.

Portfolio(instruments)

Create a collection of Instruments to group metrics

SBS(*args[, float_spread, ...])

Create a single currency basis swap composing two FloatLeg s.

STIRFuture(*args[, price, contracts, ...])

Create a short term interest rate (STIR) future.

Sensitivities()

Base class to add risk sensitivity calculations to an object with an npv() method.

Spread(instrument1, instrument2)

A spread instrument defined as the difference in rate between two Instruments.

Value(effective[, convention, metric, curves])

A null Instrument which can be used within a Solver to directly parametrise a Curve node, via some calculated value.

XCS(*args[, fixed, payment_lag_exchange, ...])

Create a cross-currency swap (XCS) composing relevant fixed or floating Legs.

ZCIS(*args[, fixed_rate, leg2_index_base, ...])

Create a zero coupon index swap (ZCIS) composing an ZeroFixedLeg and a ZeroIndexLeg.

ZCS(*args[, fixed_rate, leg2_float_spread, ...])

Create a zero coupon swap (ZCS) composing a ZeroFixedLeg and a ZeroFloatLeg.

Class Inheritance Diagram#

Inheritance diagram of rateslib.instruments.BaseDerivative, rateslib.instruments.BaseMixin, rateslib.instruments.Bill, rateslib.instruments.BondFuture, rateslib.instruments.BondMixin, rateslib.instruments.FRA, rateslib.instruments.FXExchange, rateslib.instruments.FXSwap, rateslib.instruments.FixedRateBond, rateslib.instruments.FloatRateNote, rateslib.instruments.Fly, rateslib.instruments.IIRS, rateslib.instruments.IRS, rateslib.instruments.IndexFixedRateBond, rateslib.instruments.Portfolio, rateslib.instruments.SBS, rateslib.instruments.STIRFuture, rateslib.instruments.Sensitivities, rateslib.instruments.Spread, rateslib.instruments.Value, rateslib.instruments.XCS, rateslib.instruments.ZCIS, rateslib.instruments.ZCS

Solver#

Classes#

Gradients()

A catalogue of all the gradients used in optimisation routines and risk sensitivties.

Solver([curves, instruments, s, weights, ...])

A numerical solver to determine node values on multiple curves simultaneously.

Class Inheritance Diagram#

Inheritance diagram of rateslib.solver.Gradients, rateslib.solver.Solver

Cookbook#