Fixings#

class rateslib.data.loader.Fixings#

Bases: _BaseFixingsLoader

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

Warning

You must maintain and populate your own fixing data.

Rateslib does not come pre-packaged with accurate, nor upto date fixing data. 1) It does not have data licensing to distribute such data. 2) It is a statically uploaded code package will become immediately out of date.

Attention

This object is loaded once by rateslib and in its global module, under the attribute fixings. Only this object is referenced internally and other instantiations of this class will be ignored.

Notes

The loader is initialised as the DefaultFixingsLoader. This can be set as a user implemented _BaseFixingsLoader.

This class maintains a dictionary of financial fixing Series indexed by string identifiers.

Fixing Population

This dictionary can be populated in one of two ways:

  • Either by maintaining a set of CSV files in the source lookup directory (whose path is visible/settable by calling fixings.directory)

  • Or creating a pandas Series and using the add() to add this object to the dictionary.

Fixing Lookup

Lookup of a fixing Series is performed, for example using the get item pattern. If an object does not already exist in the dictionary it will be attempted to load from source CSV file. If neither exists it will raise a ValueError.

In [1]: cpi = Series(
   ...:     index=[dt(2000, 1, 1), dt(2000, 2, 1), dt(2000, 3, 1)],
   ...:     data=[100.0, 101.2, 102.2]
   ...: )
   ...: 

In [2]: fixings.add("MY_CPI", cpi)

In [3]: fixings["MY_CPI"]
Out[3]: 
(-4959934537218149954,
 reference_date
 2000-01-01    100.0
 2000-02-01    101.2
 2000-03-01    102.2
 Name: rate, dtype: float64,
 (Timestamp('2000-01-01 00:00:00'), Timestamp('2000-03-01 00:00:00')))
In [4]: try:
   ...:     fixings["NON_EXISTENT_SERIES"]
   ...: except ValueError as e:
   ...:     print(e)
   ...: 
Fixing data for the index 'NON_EXISTENT_SERIES' has been attempted, but there is no file:
'NON_EXISTENT_SERIES.csv' located in the search directory.
For further info see the documentation section regarding `Fixings`.

Attributes Summary

loader

Object responsible for fetching data from external sources.

Methods Summary

add(name, series[, state])

Add a Series to the Fixings object directly from Python

get_stub_ibor_fixings(value_start_date, ...)

Return the tenors available in the Fixings object for determining an IBOR type stub period.

pop(name)

Remove a Series from the Fixings object.

Attributes Documentation

loader#

Object responsible for fetching data from external sources.

Methods Documentation

add(name, series, state=NoInput.blank)#

Add a Series to the Fixings object directly from Python

Parameters:
  • name (str, required) – The string identifier key for the timeseries.

  • series (Series, required) – The timeseries indexed by datetime.

  • state (int, optional) – The state id to be used upon insertion of the Series.

Return type:

None

get_stub_ibor_fixings(value_start_date, value_end_date, fixing_date, fixing_calendar, fixing_modifier, fixing_identifier)#

Return the tenors available in the Fixings object for determining an IBOR type stub period.

Parameters:
  • value_start_date (datetime) – The value start date of the IBOR period.

  • value_end_date (datetime) – The value end date of the current stub period.

  • fixing_date (datetime) – The index date to examine from the fixing series.

  • fixing_calendar (Cal, UnionCal, NamedCal,) – The calendar to derive IBOR value end dates.

  • fixing_modifier (Adjuster) – The date adjuster to derive IBOR value end dates.

  • fixing_identifier (str) – The fixing name, prior to the addition of tenor, e.g. “EUR_EURIBOR”

Return type:

tuple of list[string tenors] and list[evaluated end dates]

pop(name)#

Remove a Series from the Fixings object.

Parameters:

name (str, required) – The string identifier key for the timeseries.

Return type:

Series, or None (if name not found)