_FXFixingMajor#

class rateslib.data.fixings._FXFixingMajor(fx_index, publication=NoInput.blank, delivery=NoInput.blank, value=NoInput.blank, identifier=NoInput.blank)#

Bases: _BaseFixing

An FX fixing value for cross currency settlement.

Examples

In [1]: fixings.add("Custom_CADSEK", Series(index=[dt(1999, 12, 29)], data=[8.7]))

In [2]: fxfix = _FXFixingMajor(
   ...:     delivery=dt(2000, 1, 4),
   ...:     fx_index=FXIndex(
   ...:         pair="cadsek",
   ...:         calendar="tro,stk|fed",
   ...:         settle=2,
   ...:         isda_mtm_calendar="tro,stk,ldn,nyc",
   ...:         isda_mtm_settle=-2,
   ...:     ),
   ...:     identifier="Custom"
   ...: )
   ...: 

In [3]: fxfix.publication  #  <--  derived from isda attributes
Out[3]: datetime.datetime(1999, 12, 29, 0, 0)

In [4]: fxfix.value        #  <--  should be 8.7
Out[4]: np.float64(8.7)
Parameters:
  • fx_index (FXIndex, str, required) – The FXIndex defining the FX pair and its conventions.

  • publication (datetime, optional) – The publication date of the fixing. If not given, must provide delivery in order to derive the publication date.

  • delivery (datetime, optional) – The settlement delivery date of the cashflow. Can be used to derive the publication date. If not given is derived from the publication.

  • value (float, Dual, Dual2, Variable, optional) – The initial value for the fixing to adopt. Most commonly this is not given and it is determined from a timeseries of published FX rates.

  • identifier (str, optional) – The string name of the series to be loaded by the Fixings object. Will be appended with “_{pair}” to derive the full timeseries key.

Notes

The FXFixingMajor is a class designed to lookup and return FX fixings directly from a Series in either the FX pair directly, or its inverse. This function depends upon what is populated to the datastore. That is, if ‘GBPMXN’ is an available dataseries then ‘MXNGBP’ would also be calculable as the inverse of ‘GBPMXN’.

When forecasting the fixing from an FXForwards object, the rate pair will be looked up directly according to the delivery date.

The use of the name major, does not imply that only FX majors can be used by this class. I.e. that it is only suitable for ‘EURUSD’ and ‘EURSEK’, for example. Rather, the name major implies that this object treats the given FX pair as a major and does not perform any type of cross. This is, in fact, a sub-component of the more featureful FXFixing class which adheres to the allow_cross argument on the FXIndex in order to automatically handle different types of required behaviour.

Attributes Summary

date

The date of relevance for the fixing, e.g. the publication date of an IBORFixing.

delivery

The settlement delivery date of the fixing as specified directly, or implied from the FXIndex.

fx_index

The FXIndex for the FX fixing.

identifier

The string name of the timeseries to be loaded by the Fixings object.

pair

The currency pair related to the FX fixing.

publication

The publication date of the fixing as specified directly, or implied from the FXIndex.

value

The fixing value.

Methods Summary

reset([state])

Sets the value attribute to NoInput, which allows it to be redetermined from a timeseries.

try_value_or_forecast(fx)

Return the determined value of the fixing or forecast it if not available.

value_or_forecast(fx)

Return the determined value of the fixing or forecast it if not available.

Attributes Documentation

date#

The date of relevance for the fixing, e.g. the publication date of an IBORFixing.

delivery#

The settlement delivery date of the fixing as specified directly, or implied from the FXIndex.

fx_index#

The FXIndex for the FX fixing.

identifier#

The string name of the timeseries to be loaded by the Fixings object.

pair#

The currency pair related to the FX fixing.

publication#

The publication date of the fixing as specified directly, or implied from the FXIndex.

value#

Methods Documentation

reset(state=NoInput.blank)#

Sets the value attribute to NoInput, which allows it to be redetermined from a timeseries.

Examples

In [5]: fx_fixing1 = FXFixing(publication=dt(2021, 1, 1), fx_index="eurusd", identifier="A")

In [6]: fx_fixing2 = FXFixing(publication=dt(2021, 1, 1), fx_index="gbpusd", identifier="B")

In [7]: fixings.add("A_eurusd", Series(index=[dt(2021, 1, 1)], data=[1.1]), state=100)

In [8]: fixings.add("B_gbpusd", Series(index=[dt(2021, 1, 1)], data=[1.4]), state=200)

# data is populated from the available Series
In [9]: fx_fixing1.value
Out[9]: np.float64(1.1)

In [10]: fx_fixing2.value
Out[10]: np.float64(1.4)

# fixings are reset according to the data state
In [11]: fx_fixing1.reset(state=100)

In [12]: fx_fixing2.reset(state=100)

# only the private data for fixing1 is removed because of its link to the data state
In [13]: fx_fixing1._value
Out[13]: <NoInput.blank: 0>

In [14]: fx_fixing2._value
Out[14]: np.float64(1.4)
Parameters:

state (int, optional) – If given only fixings whose state matches this value will be reset. If no state is given then the value will be reset.

Return type:

None

try_value_or_forecast(fx)#

Return the determined value of the fixing or forecast it if not available.

Parameters:

fx (FXForwards, optional) – The FXForwards object to forecast the forward FX rate.

Return type:

Result[float, Dual, Dual2, Variable]

value_or_forecast(fx)#

Return the determined value of the fixing or forecast it if not available.

Parameters:

fx (FXForwards, optional) – The FXForwards object to forecast the forward FX rate.

Return type:

float, Dual, Dual2, Variable