API Reference#

Indices and tables#

Defaults#

These objects are used to set values for missing parameters globally: for a list see Defaults.

Classes#

Defaults()

The defaults object used by initialising objects.

Enums#

Objects to define parameter settings across different objects throughout the libary.

Classes#

FloatFixingMethod(*values)

Enumerable type to define floating period rate fixing methods.

SpreadCompoundMethod(*values)

Enumerable type to define spread compounding methods for floating rates.

IndexMethod(*values)

Enumerable type to define determining the index value on some reference value date.

FXDeltaMethod(*values)

Enumerable type to define the delta expression of an FX option.

FXOptionMetric(*values)

Enumerable type for FXOption metrics.

LegMtm(*values)

Enumerable type to define FXFixing dates for non-deliverable Legs.

NoInput(*values)

Enumerable type to handle setting default values.

Ok(value)

Standard result class indicating success and containing some value.

Err(exception)

Standard result class indicating failure and containing some Exception type.

Fixings#

For interaction with financial fiixngs and data loading, see Fixings.

Classes#

Fixings()

Object to store and load fixing data to populate Leg and Period calculations.

DefaultFixingsLoader()

The _BaseFixingsLoader implemented by default.

_BaseFixingsLoader()

Abstract base class to allow custom implementations of a fixings data loader.

Classes#

FloatRateSeries(lag, calendar, modifier, ...)

Define the general parameters of multiple tenors of an interest rate series.

FloatRateIndex(frequency, series)

Define the parameters of a specific interest rate index.

RFRFixing(*, rate_index, accrual_start, ...)

A rate fixing value representing an RFR type calculating involving multiple RFR publications.

IBORFixing(*, rate_index, accrual_start[, ...])

A rate fixing value referencing a tenor-IBOR type calculation.

IBORStubFixing(*, rate_series, ...[, value, ...])

A rate fixing value referencing an interpolated tenor-IBOR type calculation.

IndexFixing(*, index_lag, index_method, date)

An index fixing value for settlement of indexed cashflows.

FXIndex(pair, calendar, settle[, ...])

Define the parameters of a specific FX pair and fixing index.

FXFixing(fx_index[, publication, delivery, ...])

An FX fixing value for cross-currency or non-deliverable settlement.

_FXFixingMajor(fx_index[, publication, ...])

An FX fixing value for cross currency settlement.

_UnitFixing(*, date[, value, identifier])

A _BaseFixing permanently adopting value 1.0.

_BaseFixing(*, date[, value, identifier])

Abstract base class for core financial fixing implementation.

Scheduling#

Functions#

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

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

get_calendar(calendar[, named])

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

get_imm([month, year, code, definition])

Return an IMM date for a specified month.

next_imm(start[, definition])

Return the next IMM date after the given start date.

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

Calculate the day count fraction of a period.

Classes#

Schedule(effective, termination, frequency, *)

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

Cal(holidays, week_mask)

A business day calendar defined by weekends and a holiday list.

NamedCal(name)

A wrapped UnionCal constructed with a string parsing syntax.

UnionCal(calendars[, settlement_calendars])

A calendar defined by a business day intersection of multiple Cal objects.

Adjuster(args)

Enumerable type for date adjustment rules.

Convention(variant)

Specifier for day count conventions

Frequency(args)

Enumerable type for a scheduling frequency.

Imm(item)

Enumerable type for International Money-Market (IMM) date definitions.

RollDay(args)

Enumerable type for roll days.

StubInference(item)

Enumerable type for Schedule stub inference.

Curves#

Functions#

average_rate(effective, termination, ...)

Return the geometric, 1-day, average simple rate for a given simple period rate.

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

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

index_value(index_lag, index_method[, ...])

Determine an index value from a reference date using combinations of known fixings and forecast from a Curve.

Classes#

Curve(*args, **kwargs)

A _BaseCurve with DF parametrisation at given node dates with interpolation.

LineCurve(*args, **kwargs)

A _BaseCurve with value parametrisation at given node dates with interpolation.

CompositeCurve(curves[, id, _no_validation])

A dynamic composition of a sequence of other _BaseCurve.

MultiCsaCurve(curves[, id])

A dynamic composition of a sequence of other _BaseCurve.

ProxyCurve(cashflow, collateral, fx_forwards)

A _BaseCurve which returns dynamic DFs from an FXForwards object and FX parity.

CreditImpliedCurve([risk_free, credit, ...])

Imply a _BaseCurve from credit components.

RolledCurve(curve, roll_days[, id])

Create a new _BaseCurve type by translating the rate space of an input curve horizontally in time.

ShiftedCurve(curve, shift[, id])

Create a new _BaseCurve type by compositing an input with another flat curve of a set number of basis points.

TranslatedCurve(curve, start[, id])

Create a new _BaseCurve type by maintaining the rate space of an input curve but shifting the initial node date forwards in time.

_BaseCurve()

An ABC defining the base methods of a Curve.

_WithOperations()

Provides automatic implementation of the curve operations required on a _BaseCurve.

_WithMutability(nodes, *[, interpolation, ...])

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

_CurveMeta(_calendar, _convention, ...)

A container of meta data associated with a _BaseCurve used to make calculations.

_CurveType(*values)

Enumerable type to define the difference between a discount factor (DF) based and values based _BaseCurve.

_CurveSpline(t, endpoints)

A container for data relating to interpolating _CurveNodes using a cubic PPSpline.

_CurveInterpolator(local, t, endpoints, ...)

A container for data relating to interpolating _CurveNodes.

_CurveNodes(_nodes)

An immutable container for the pricing parameters of a _BaseCurve.

_ProxyCurveInterpolator(_fx_forwards, _cash, ...)

A container for data relating to interpolating the DFs of a ProxyCurve.

Class Inheritance Diagram#

Inheritance diagram of rateslib.curves.Curve, rateslib.curves.LineCurve, rateslib.curves.CompositeCurve, rateslib.curves.MultiCsaCurve, rateslib.curves.ProxyCurve, rateslib.curves._BaseCurve, rateslib.curves._WithMutability, rateslib.curves.CreditImpliedCurve, rateslib.curves.TranslatedCurve, rateslib.curves.RolledCurve, rateslib.curves.ShiftedCurve

Academic Curves#

Classes#

NelsonSiegelCurve(dates, parameters[, id, ...])

A Nelson-Siegel curve defined by discount factors.

NelsonSiegelSvenssonCurve(dates, parameters)

A Nelson-Siegel-Svensson curve defined by discount factors.

SmithWilsonCurve(nodes, ufr[, solve_alpha, ...])

A Smith-Wilson style Curve defined by discount factors.

Instruments#

Objects#

Classes#

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

An interest rate swap (IRS) composing a FixedLeg and a FloatLeg.

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

A forward rate agreement (FRA) compositing a FixedLeg and FloatLeg.

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

A single currency basis swap (SBS) composing a FloatLeg and a FloatLeg.

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

A short term interest rate (STIR) future compositing a FixedLeg and FloatLeg.

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

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

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

A cross-currency swap (XCS) composing either FixedLeg and/or FloatLeg in different currencies.

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

A non-deliverable cross-currency swap (XCS) composing either FixedLeg and/or FloatLeg in different currencies.

NDF(settlement, pair, *[, currency, ...])

A non-deliverable FX forward (NDF), composing two CustomLeg of individual Cashflow.

FXSwap(effective, termination, pair, *[, ...])

An FX swap composing two CustomLeg of individual Cashflow of different currencies.

FXForward(settlement, pair[, fx_rate, ...])

A dated FX exchange composing two CustomLeg of individual Cashflow of different currencies.

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

An indexed zero coupon swap (ZCIS) composing a ZeroFixedLeg and a ZeroIndexLeg.

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

An indexed interest rate swap (IIRS) composing a FixedLeg and a FloatLeg.

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

A credit default swap (CDS) composing a CreditPremiumLeg and a CreditProtectionLeg.

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

A fixed rate bond composed of a FixedLeg.

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

A floating rate note (FRN) composed of a FloatLeg.

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

An index-linked fixed rate bond composed of a FixedLeg.

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

A bond future derivative containing a basket of FixedRateBond.

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

A bill, or discount security, composed of a FixedLeg.

FXPut(*args, **kwargs)

An FX Put option.

FXCall(*args, **kwargs)

An FX Call option.

FXRiskReversal(expiry, strike[, pair, ...])

An FX Risk Reversal _BaseFXOptionStrat.

FXStraddle(expiry, strike[, pair, notional, ...])

An FX Straddle _BaseFXOptionStrat.

FXStrangle(expiry, strike[, pair, notional, ...])

An FX Strangle _BaseFXOptionStrat.

FXBrokerFly(expiry, strike[, pair, ...])

An FX BrokerFly _BaseFXOptionStrat.

Portfolio(instruments)

A collection of _BaseInstrument.

Fly(instrument1, instrument2, instrument3)

A Butterfly of _BaseInstrument.

Spread(instrument1, instrument2)

A Spread of _BaseInstrument.

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

A pseudo Instrument used to calibrate a Curve within a Solver.

FXVolValue(index_value[, expiry, metric, vol])

A pseudo Instrument used to calibrate an FX Vol Object within a Solver.

BondCalcMode(settle_accrual, ytm_accrual, ...)

Define calculation conventions for FixedRateBond, IndexFixedRateBond and FloatRateNote types.

BillCalcMode(price_type, ytm_clone_kwargs)

Define calculation conventions for Bill type.

_BaseInstrument(*args, **kwargs)

Abstract base class used in the construction of Instruments.

_BaseBondInstrument(*args, **kwargs)

Abstract base class used in the construction of bond type Instruments

_BaseFXOption(expiry, strike[, pair, ...])

An abstract base class for implementing FXOptions.

_BaseFXOptionStrat(options, rate_weight, ...)

A custom option strategy composed of a list of _BaseFXOption, or other _BaseFXOptionStrat objects, of the same currency pair.

Protocols#

Classes#

_KWArgs(user_args[, default_args, ...])

Class to manage keyword argument population of Leg based Instruments.

_WithNPV(*args, **kwargs)

Protocol to establish value of any Instrument type.

_WithRate(*args, **kwargs)

Protocol to establish a rate pricing metric of any Instrument type.

_WithCashflows(*args, **kwargs)

Protocol to determine cashflows for any Instrument type.

_WithFixings(*args, **kwargs)

Protocol for determining fixing sensitivity for a Period with AD.

_WithAnalyticDelta(*args, **kwargs)

Protocol to determine the analytic rate delta of a particular Leg of an Instrument.

_WithAnalyticRateFixings(*args, **kwargs)

Protocol to determine the analytic rate fixings' sensitivity of a particular Instrument.

_WithSensitivities(*args, **kwargs)

Protocol to establish delta and gamma calculations using a Solver of any Instrument type.

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.

FX Volatility#

Classes#

FXSabrSmile(nodes, eval_date, expiry[, ...])

Create an FX Volatility Smile at a given expiry indexed by strike using SABR parameters.

FXSabrSurface(expiries, node_values, eval_date)

Create an FX Volatility Surface parametrised by cross-sectional Smiles at different expiries.

FXDeltaVolSurface(delta_indexes, expiries, ...)

Create an FX Volatility Surface parametrised by cross-sectional Smiles at different expiries.

FXDeltaVolSmile(nodes, eval_date, expiry, ...)

Create an FX Volatility Smile at a given expiry indexed by delta percent.

_BaseSmile()

_FXDeltaVolSurfaceMeta(_eval_date, ...)

An immutable container of meta data associated with a FXDeltaVolSurface used to make calculations.

_FXSmileMeta(_eval_date, _expiry, ...)

_FXDeltaVolSpline(t)

A container for data relating to interpolating the nodes of a FXDeltaVolSmile using a cubic PPSpline.

_FXDeltaVolSmileNodes(nodes, meta)

A container for data relating to interpolating the nodes of a FXDeltaVolSmile.

_FXSabrSurfaceMeta(_eval_date, _pair, ...)

An immutable container of meta data associated with a FXSabrSurface used to make calculations.

_FXSabrSmileNodes(_alpha, _beta, _rho, _nu)

A container for data relating to the SABR parameters of a FXSabrSmile.

Legs#

Link to the Legs section in the user guide.

Objects#

Classes#

FixedLeg(schedule, *[, notional, ...])

A Leg containing FixedPeriod.

FloatLeg(schedule, *[, notional, ...])

A Leg containing FloatPeriod.

ZeroFixedLeg(schedule, *[, convention, ...])

A zero coupon Leg composed of a single ZeroFixedPeriod .

ZeroFloatLeg(schedule, *[, float_spread, ...])

A zero coupon Leg composed of a single ZeroFloatPeriod.

ZeroIndexLeg(schedule, *[, convention, ...])

A Leg composed of indexed Cashflow at termination, and possibly effective.

CreditPremiumLeg(schedule, *[, fixed_rate, ...])

Define a Leg containing CreditPremiumPeriod.

CreditProtectionLeg(schedule, *[, notional, ...])

Create a credit protection leg composed of CreditProtectionPeriod s.

CustomLeg(periods)

A Leg containing user specified _BasePeriod.

Amortization(n, initial[, amortization])

An amortization schedule for any _BaseLeg.

_BaseLeg(*args, **kwargs)

Abstract base class used in the construction of Legs.

Protocols#

Classes#

_WithNPV(*args, **kwargs)

Protocol to establish value of any Leg type.

_WithCashflows(*args, **kwargs)

Protocol to generate cashflows of any Leg type.

_WithFixings(*args, **kwargs)

Protocol for determining fixing sensitivity for a Period with AD.

_WithAnalyticDelta(*args, **kwargs)

Protocol to calculate analytical rate delta sensitivities of any Leg type.

_WithAnalyticRateFixings(*args, **kwargs)

Protocol to calculate analytical rate fixing sensitivities of any Leg type.

_WithExDiv(*args, **kwargs)

Protocol to determine if a Leg is ex-dividend on a given settlement.

Periods#

Link to the Periods section in the user guide.

Objects#

Classes#

FixedPeriod(*[, fixed_rate, notional, ...])

A Period defined by a fixed interest rate.

FloatPeriod(*[, float_spread, rate_fixings, ...])

A Period defined by a floating interest rate.

ZeroFixedPeriod(*[, fixed_rate, notional, ...])

A Period defined by a fixed interest rate, as a representation of multiple compounded Periods.

ZeroFloatPeriod(*[, float_spread, ...])

A Period defined by compounded floating rate Periods.

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

A Period defined by a specific amount.

MtmCashflow(*, payment, notional, pair, start)

A Period defined by a specific amount calculated from the difference between two FXFixing.

CreditPremiumPeriod(*, payment[, notional, ...])

A Period defined by a fixed interest rate and contingent credit event.

CreditProtectionPeriod(*, payment[, ...])

A Period defined by a credit event and contingent notional payment.

FXCallPeriod(*, delivery, pair, expiry[, ...])

A Period defined by a European FX call option.

FXPutPeriod(*, delivery, pair, expiry[, ...])

A Period defined by a European FX put option.

_BasePeriod(*args, **kwargs)

Abstract base class for Period types.

_BasePeriodStatic(*args, **kwargs)

Abstract base class for Static Period types.

_BaseFXOptionPeriod(*, direction, delivery, ...)

Abstract base class for FXOptionPeriods types.

Protocols#

Period protocols establish common functionality and methods that all Periods share consistently.

Classes#

_WithNPV(*args, **kwargs)

Protocol to define value of any Period type.

_WithCashflows(*args, **kwargs)

Protocol for parameter and calculation display for the Period.

_WithFixings(*args, **kwargs)

Protocol for determining fixing sensitivity for a Period with AD.

_WithAnalyticDelta(*args, **kwargs)

Protocol to establish analytical sensitivity to rate type metrics.

_WithAnalyticRateFixings(*args, **kwargs)

Protocol to derive a rate fixings sensitivity DataFrame.

_WithAnalyticFXOptionGreeks(*args, **kwargs)

Protocol to derive analytic FXOption greeks.

_WithNPVStatic(*args, **kwargs)

Protocol to establish value of any Static Period type.

_WithCashflowsStatic(*args, **kwargs)

Protocol for parameter and calculation display for the Static Period.

_WithAnalyticDeltaStatic(*args, **kwargs)

Protocol to establish analytical sensitivity to rate type metrics for Static Period types.

_WithAnalyticRateFixingsStatic(*args, **kwargs)

Protocol to derive an analytic rate fixings sensitivity DataFrame from pricing Curves.

_WithIndexingStatic(*args, **kwargs)

Protocol to provide indexation for Static Period types.

_WithNonDeliverableStatic(*args, **kwargs)

Protocol to provide non-deliverable conversion for Static Period types.

Parameters#

Period parameters define containers for input values used in the construction of functionality.

Classes#

_IndexParams(*, _index_method, _index_lag, ...)

Parameters for Period cashflows adjusted under some indexation.

_SettlementParams(_currency, _notional, ...)

Parameters for settlement of Period cashflows.

_PeriodParams(_start, _end, _frequency, ...)

Parameters of Period cashflows associated with some Schedule.

_FixedRateParams(_fixed_rate)

Parameters for a Period containing a fixed rate.

_FloatRateParams(*, _fixing_method, ...)

Parameters for a Period containing a floating rate.

_NonDeliverableParams(_currency, _fx_index, ...)

Parameters for determination of non-deliverable Period cashflows.

_CreditParams(_premium_accrued)

Parameters for Period cashflows associated with credit events.

_MtmParams(_fx_fixing_start, _fx_fixing_end, ...)

Parameters for Period cashflows associated with multiple FXFixing.

_FXOptionParams(_direction, _expiry, ...)

Parameters for FX Option Period cashflows.

Solver#

Classes#

Gradients()

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

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

A numerical solver to determine node values on multiple pricing objects simultaneously.

Class Inheritance Diagram#

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

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 at x.

evaluate(spline, x[, m])

Evaluate a single x-axis data point, or a derivative value, on a Spline.

Classes#

PPSplineDual(k, t[, c])

Piecewise polynomial spline composed of float-64 values on the x-axis and Dual values on the y-axis.

PPSplineDual2(k, t[, c])

Piecewise polynomial spline composed of float-64 values on the x-axis and Dual2 values on the y-axis.

PPSplineF64(k, t[, c])

Piecewise polynomial spline composed of float-64 values on the x-axis and float-64 values on the y-axis.

Dual (for AD)#

Functions#

dual_log(x[, base])

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

dual_exp(x)

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

dual_solve(A, b[, allow_lsq, types])

Solve a linear system of equations involving dual number data types.

dual_norm_pdf(x)

Return the standard normal probability density function.

dual_norm_cdf(x)

Return the cumulative standard normal distribution for given value.

dual_inv_norm_cdf(x)

Return the inverse cumulative standard normal distribution for given value.

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

Return derivatives of a dual number.

set_order_convert(val, order, tag[, vars_from])

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

set_order(val, order)

Changes the order of a Dual or Dual2 and a sets a Variable.

newton_ndim(f, g0[, max_iter, func_tol, ...])

Use the Newton-Raphson algorithm to determine a function root searching many variables.

newton_1dim(f, g0[, max_iter, func_tol, ...])

Use the Newton-Raphson algorithm to determine the root of a function searching one variable.

ift_1dim(s, s_tgt, h[, ini_h_args, ...])

Use the inverse function theorem to determine a function value of one variable.

quadratic_eqn(a, b, c, x0[, raise_on_fail])

Solve the quadratic equation, \(ax^2 + bx +c = 0\), with error reporting.

Classes#

ADOrder(ad)

Defines the order of gradients available in a calculation with AD.

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.

Variable(real[, vars, dual])

A user defined, exogenous variable that automatically converts to a Dual or Dual2 type dependent upon the overall AD calculation order.

Serialization#

Functions#

from_json(json)

Create an object from JSON string.

Cookbook#

Please see here for the cookbook index.