_FXFixingMajor#
- class rateslib.data.fixings._FXFixingMajor(fx_index, publication=NoInput.blank, delivery=NoInput.blank, value=NoInput.blank, identifier=NoInput.blank)#
Bases:
_BaseFixingAn 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
FXIndexdefining the FX pair and its conventions.publication (datetime, optional) – The publication date of the fixing. If not given, must provide
deliveryin 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
FXForwardsobject, the rate pair will be looked up directly according to thedeliverydate.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
FXFixingclass which adheres to theallow_crossargument on theFXIndexin order to automatically handle different types of required behaviour.Attributes Summary
The date of relevance for the fixing, e.g. the publication date of an IBORFixing.
The settlement delivery date of the fixing as specified directly, or implied from the
FXIndex.The
FXIndexfor the FX fixing.The string name of the timeseries to be loaded by the Fixings object.
The currency pair related to the FX fixing.
The publication date of the fixing as specified directly, or implied from the
FXIndex.The fixing value.
Methods Summary
reset([state])Sets the
valueattribute toNoInput, which allows it to be redetermined from a timeseries.Return the determined value of the fixing or forecast it if not available.
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.
- identifier#
The string name of the timeseries to be loaded by the Fixings object.
- pair#
The currency pair related to the FX fixing.
- value#
Methods Documentation
- reset(state=NoInput.blank)#
Sets the
valueattribute toNoInput, 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
FXForwardsobject to forecast the forward FX rate.- Return type:
- value_or_forecast(fx)#
Return the determined value of the fixing or forecast it if not available.
- Parameters:
fx (FXForwards, optional) – The
FXForwardsobject to forecast the forward FX rate.- Return type: