Defaults#

This page is an overview of all of the default values that rateslib will apply where no other inputs are supplied. And it provides an entry point to examine all of the different spec (specification) arguments that have been added to the library to date.

Argument input management#

The rateslib.default module is provided to give the user global control over a lot of parameters that are set by default when the user provides no input to those arguments.

Since financial instrument specification usually contains a large number of parameters (for example a cross-currency basis swap (XCS) has around 50 possible arguments to initialise the swap with), argument management is a key part of the design philosophy of rateslib.

The easiest way to construct conventional instruments is to use the spec argument. A number of market conventions have already been pre-added to rateslib, and if defining an Instrument that allows the spec argument a host of arguments will be pre-populated. The table below outlines all of the existing spec arguments.

Warning

When using the spec argument, arguments for leg2 which might normally inherit from leg1 might be defined specifically, and will no longer inherit. If overwriting an instrument that has been directly specified, ensure to overwrite both legs.

Derivatives

Securities

Currency

FixedRateBond

Bill

IndexFixedRateBond

FloatRateNote

BondFuture

USD

us_gb, us_gb_tsy, us_corp, us_muni

us_gbb

us_gb_2y, us_gb_3y, us_gb_5y, us_gb_10y, us_gb_30y

EUR

de_gb, fr_gb, it_gb, nl_gb

de_gb_2y, de_gb_5y, de_gb_10y, de_gb_30y, fr_gb_5y, fr_gb_10y, sp_gb_10y

GBP

uk_gb

uk_gbb

CHF

ch_gb

ch_gb_10y

SEK

se_gb

se_gbb

NOK

no_gb

CAD

ca_gb

JPY

AUD

NZD

The NoInput argument#

Warning

When an argument is not provided this actually assumes a defined datatype in rateslib called NoInput. Never use None as an entry to an argument unless it is known to be an allowed option, this will typically create downstream errors. It is better to omit the argument entry entirely and let rateslib control the NoInput value.

There are 3 types of NoInput that work behind the scenes:

  • NoInput.blank: this specifies the user has provided no input for this argument and if there is a default value that will be used instead. For example, not providing a convention will result in the value of defaults.convention being used.

  • NoInput.inherit: this specifies that the user has provided no input for this argument and its value will be inherited from the equivalent attribute on leg1. For example the value leg2_payment_lag has a value of NoInput.inherit meaning its value will be obtained from the value of payment_lag whether that is taken by default or set by a user.

  • NoInput.negate: this is similar to NoInput.inherit except it negates the value. This is useful for notional and amortization when 2 legs commonly take opposite values.

In the below code snippet one can observe how these NoInputs are operating in the initialisation of a swap to infer what a user might expect when just inputting a small subset of parameters.

In [1]: from rateslib import IRS

In [2]: irs = IRS(
   ...:     effective=dt(2000, 1, 1),
   ...:     termination="1Y",
   ...:     frequency="S",
   ...:     payment_lag=4,
   ...:     notional=50e6,
   ...:     amortization=10e6
   ...: )
   ...: 

In [3]: irs.leg1.schedule.frequency
Out[3]: 'S'

In [4]: irs.leg1.notional
Out[4]: 50000000.0

In [5]: irs.leg1.amortization
Out[5]: 10000000.0

In [6]: irs.leg2.schedule.frequency  # <- Inherited
Out[6]: 'S'

In [7]: irs.leg2.notional  # <- Inherited with negate
Out[7]: -50000000.0

In [8]: irs.leg2.amortization  # <- Inherited with negate
Out[8]: -10000000.0

Defaults#

The defaults object is a global instance of the Defaults class. Its purpose is to provide necessary values when a user does not supply inputs. In the above swap the user provided no convention, modifier or currency. These have been set by default.

In [9]: irs.leg1.schedule.modifier
Out[9]: <rl.Adjuster.ModifiedFollowing at 0x121fcf340>

In [10]: irs.leg1.convention
Out[10]: 'ACT360'

In [11]: irs.leg1.currency
Out[11]: 'usd'

The defaults values can be seen by calling its print() method.

In [12]: from rateslib import defaults

In [13]: print(defaults.print())
Scheduling:

	stub: SHORTFRONT
	stub_length: SHORT
	modifier: MF
	eom: False
	eom_fx: True
	eval_mode: swaps_align

Instruments:

	convention: ACT360
	payment_lag: 2
	payment_lag_exchange: 0
	payment_lag_specific: {'IRS': 2, 'STIRFuture': 0, 'IIRS': 2, 'ZCS': 2, 'ZCIS': 0, 'FXSwap': 0, 'SBS': 2, 'Swap': 2, 'XCS': 2, 'FixedRateBond': 0, 'IndexFixedRateBond': 0, 'FloatRateNote': 0, 'Bill': 0, 'FRA': 0, 'CDS': 0, 'NDF': 2}
	notional: 1000000.0
	fixing_method: rfr_payment_delay
	fixing_method_param: {'rfr_payment_delay': 0, 'rfr_observation_shift': 2, 'rfr_lockout': 2, 'rfr_lookback': 2, 'rfr_payment_delay_avg': 0, 'rfr_observation_shift_avg': 2, 'rfr_lockout_avg': 2, 'rfr_lookback_avg': 2, 'ibor': 2}
	spread_compound_method: none_simple
	base_currency: usd
	fx_delivery_lag: 2
	fx_delta_type: spot
	fx_option_metric: pips
	cds_premium_accrued: True
	cds_recovery_rate: 0.4
	cds_protection_discretization: 23

Curves:

	interpolation: {'dfs': 'log_linear', 'values': 'linear'}
	endpoints: natural
	multi_csa_steps: [2, 5, 10, 20, 30, 50, 77, 81, 86, 91, 96, 103, 110, 119, 128, 140, 153, 169, 188, 212, 242, 281, 332, 401, 498, 636, 835, 1104, 1407, 1646, 1766, 1808, 1821, 1824, 1825]
	curve_caching: True

Solver:

	algorithm: levenberg_marquardt
	tag: v
	curve_not_in_solver: ignore

Miscellaneous:

	headers: {'type': 'Type', 'stub_type': 'Period', 'u_acc_start': 'Unadj Acc Start', 'u_acc_end': 'Unadj Acc End', 'a_acc_start': 'Acc Start', 'a_acc_end': 'Acc End', 'payment': 'Payment', 'convention': 'Convention', 'dcf': 'DCF', 'df': 'DF', 'notional': 'Notional', 'currency': 'Ccy', 'rate': 'Rate', 'spread': 'Spread', 'npv': 'NPV', 'cashflow': 'Cashflow', 'fx': 'FX Rate', 'npv_fx': 'NPV Ccy', 'real_cashflow': 'Real Cashflow', 'index_value': 'Index Val', 'index_ratio': 'Index Ratio', 'index_base': 'Index Base', 'collateral': 'Collateral', 'pair': 'Pair', 'expiry': 'Expiry', 't_e': 'Time to Expiry', 'delivery': 'Delivery', 'model': 'Model', 'vol': 'Vol', 'strike': 'Strike', 'survival': 'Survival', 'recovery': 'Recovery'}
	no_fx_fixings_for_xcs: warn
	pool: 1

These values can also be set:

In [14]: defaults.convention = "ACT365F"

In [15]: defaults.base_currency = "gbp"

In [16]: irs = IRS(effective=dt(2022, 1, 1), termination="1Y", frequency="A")

In [17]: irs.leg1.convention  # <- uses new default value
Out[17]: 'ACT365F'

In [18]: irs.leg1.currency  # <- uses new default value
Out[18]: 'gbp'
In [19]: defaults.reset_defaults()  # <- reverse the changes.
In [20]: defaults.base_currency
Out[20]: 'gbp'