Result of m.fx#
- class boki.model.FxPair(base, quote, closing, average, opening)#
Read-only exchange-rate record returned by Model.fx.
Rates are quoted as units of quote currency for one unit of base currency. Use Model.fx to validate and register a pair with a model; it normalizes each rate input to a Series.
- Parameters:
- baseUnit
Unit represented by one unit in each rate. Use a currency unit for a currency pair. Required; no default.
- quoteUnit
Unit measured by each rate. Use a currency unit for a currency pair. Required; no default.
- closingSeries
Closing exchange rate in quote units per base unit. Model.fx accepts a scalar, Quantity, Series, a dict keyed by period, or a list or tuple with one value per model period. Required; no default.
- averageSeries
Average exchange rate in quote units per base unit. It accepts the same forms as closing through Model.fx. Required; no default.
- openingSeries
Single opening exchange rate in quote units per base unit. Model.fx accepts a scalar, Quantity, or scalar Series. Required; no default.
- Attributes:
- baseUnit
Base currency unit.
- quoteUnit
Quote currency unit.
- closingSeries
Closing exchange-rate series.
- averageSeries
Average exchange-rate series.
- openingSeries
Scalar opening exchange rate.
- Raises:
- TypeError
At construction through Model.fx, if base or quote is not a Unit, or if opening is not scalar.
- ValueError
At construction through Model.fx, if base and quote have the same dimensions or the pair already exists in the model.
- UnitError
At construction through Model.fx, if a rate uses units other than quote currency per base currency.
- CheckFailed
At evaluation by Model.render, if any exchange rate is not positive.
See also
boki.Model.fxAdd and register an exchange-rate pair with a model.
Notes
Use distinct currency units for base and quote. Numeric rate inputs are dimensionless and receive quote-per- base units from Model.fx. opening applies before the first model period. closing and average provide period-specific rates.
Examples
Register a pair with monthly closing and average rates:
>>> import boki as b >>> from boki.units import JPY, USD >>> m = b.Model("FX", start="2027-01", periods=2, step=b.month) >>> pair = m.fx(JPY, USD, closing=[0.0067, 0.0068], average=[0.0066, 0.0067], opening=0.0065) >>> r = m.render() >>> r.value(pair.closing, "2027-02") 0.0068