Struct PyIndex
pub(crate) struct PyIndex {
inner: AnyIndex,
code: Option<String>,
constructed: bool,
}Expand description
An interest-rate, price or FX index: the conventions it carries and the rate it quotes.
Fields§
§inner: AnyIndex§code: Option<String>The registry code this index resolved under, where one could be determined.
constructed: boolWhether this index was built from conventions rather than resolved. A constructed index was never registered, which is the whole point of being able to build one.
Implementations§
§impl PyIndex
impl PyIndex
pub(crate) fn fixing_name(&self) -> String
pub(crate) fn fixing_name(&self) -> String
The key this index’s fixings are published under — what a product names to read them.
fn code_of(spelling: &str) -> Option<String>
fn code_of(spelling: &str) -> Option<String>
The registry code the caller’s spelling resolved to.
Matched against the code column first and the name column second — the
order PyIndex::new resolves in. Matching on the display name alone
would be ambiguous: every EURIBOR tenor is registered under the one name,
so a 3M lookup would have reported whichever tenor the table listed first.
fn untaught<T>(&self, accessor: &str) -> PyResult<T>
fn untaught<T>(&self, accessor: &str) -> PyResult<T>
Refuses an accessor the resolved kind does not carry. An index kind this reading has not been taught, as distinct from one that carries no such thing.
AnyIndex is an open set, so a kind added after a reading was written
reaches that reading’s wildcard arm. Refusing it with the by-design
message would claim a fact about the kind that nobody has established;
this says what is actually true, which is that the reading is behind.
fn not_on_this_kind<T>(&self, accessor: &str) -> PyResult<T>
§impl PyIndex
impl PyIndex
fn new(spelling: &str) -> PyResult<Self>
fn new(spelling: &str) -> PyResult<Self>
Resolves an index from its registry code ("EUR-EURIBOR-3M") or its
display name ("EURIBOR").
fn __repr__(&self) -> String
fn codes() -> Vec<(String, String, String)>
fn codes() -> Vec<(String, String, String)>
Every registered index, as (kind, name, code).
The set a rejection names, obtainable rather than only readable inside an error message.
name is the index’s display name — what Index.name() returns and
what its fixings are stored under. The core’s own table carries the
accessor name in that position, which is a Rust identifier no Python
caller can use for anything, so each row is resolved to report the name a
caller can actually match on.
fn ibor(
name: &str,
currency: &str,
tenor: &str,
day_count: Named<DayCountFraction>,
fixing_calendar: &PyCalendar,
fixing_lag_days: u16,
business_day_convention: Option<Named<BusinessDayConvention>>,
end_of_month: bool,
) -> PyResult<Self>
fn ibor( name: &str, currency: &str, tenor: &str, day_count: Named<DayCountFraction>, fixing_calendar: &PyCalendar, fixing_lag_days: u16, business_day_convention: Option<Named<BusinessDayConvention>>, end_of_month: bool, ) -> PyResult<Self>
Builds a term (IBOR-style) index from its conventions.
Registers nothing. The result is a value to pass explicitly; what any other index resolves to is unchanged, and no other caller can observe that this was built.
fn inflation(
name: &str,
region: &str,
currency: &str,
publication_frequency: Named<Frequency>,
observation_lag_months: u32,
interpolation: &str,
) -> PyResult<Self>
fn inflation( name: &str, region: &str, currency: &str, publication_frequency: Named<Frequency>, observation_lag_months: u32, interpolation: &str, ) -> PyResult<Self>
Builds a price (inflation) index from its conventions. Registers nothing,
on the same terms as PyIndex::ibor and PyIndex::overnight.
Spelled inflation, not price: the surface already calls this store
by that word — with_inflation_curve, inflation_curve, and the
("inflation", "US-CPI-U") a linked product declares — so a caller who
has seen any of those will guess it. price is also a retired
present-value spelling the naming harness refuses on sight, and the
sweep cannot tell a constructor from a verb.
publication_frequency and interpolation take exactly the spellings
Index.publication_frequency() and Index.interpolation() print — that
identity is what makes the round trip one rather than a conversion. The
observation lag is whole months, as the struct holds it and
Index.observation_lag_months() reports it.
fn overnight(
name: &str,
currency: &str,
day_count: Named<DayCountFraction>,
fixing_calendar: &PyCalendar,
publication_lag_days: u16,
business_day_convention: Option<Named<BusinessDayConvention>>,
end_of_month: bool,
) -> Self
fn overnight( name: &str, currency: &str, day_count: Named<DayCountFraction>, fixing_calendar: &PyCalendar, publication_lag_days: u16, business_day_convention: Option<Named<BusinessDayConvention>>, end_of_month: bool, ) -> Self
Builds an overnight (RFR) index from its conventions. Registers nothing,
on the same terms as PyIndex::ibor.
fn fx(
base: &str,
quote: &str,
fixing_calendar: &PyCalendar,
fixing_lag_days: u8,
settlement: Option<&PyCalendar>,
) -> PyResult<Self>
fn fx( base: &str, quote: &str, fixing_calendar: &PyCalendar, fixing_lag_days: u8, settlement: Option<&PyCalendar>, ) -> PyResult<Self>
Builds an FX index for the pair base/quote — fixings are quote per
one base — fixing on fixing_calendar with fixing_lag_days business
days between the fixing date and the value date. Registers nothing,
on the same terms as PyIndex::ibor; its name, FX-BASEQUOTE, is
the key its fixings are published under and the settlement index a
non-deliverable forward names. settlement, when given, is a second
calendar every value date must also be a business day of — the USD
spot rule, settlement=Calendar("USNY").
fn value_date(&self, fixing_date: NaiveDate) -> PyResult<NaiveDate>
fn value_date(&self, fixing_date: NaiveDate) -> PyResult<NaiveDate>
The value date an FX fixing on fixing_date settles on: the fixing
date advanced by the index’s lag on its calendar. FX indices only.
fn code(&self) -> PyResult<String>
fn code(&self) -> PyResult<String>
The registry code this index resolved under.
A constructed index has none, and says so rather than inventing one.
fn fixing_calendar(&self) -> PyResult<PyCalendar>
fn fixing_calendar(&self) -> PyResult<PyCalendar>
The calendar the index’s fixings are published on.
The same calendar object the engine resolves, so a caller stepping dates on it steps them the way the index’s own arithmetic does.
fn fixing_lag_days(&self) -> PyResult<u16>
fn fixing_lag_days(&self) -> PyResult<u16>
The fixing lag, in good business days.
fn business_day_convention(&self) -> PyResult<String>
fn business_day_convention(&self) -> PyResult<String>
The index’s conventional business-day convention.
fn end_of_month(&self) -> PyResult<bool>
fn end_of_month(&self) -> PyResult<bool>
The index’s conventional end-of-month rule.
fn reference_month(&self, date: NaiveDate) -> PyResult<NaiveDate>
fn reference_month(&self, date: NaiveDate) -> PyResult<NaiveDate>
How often a price index publishes.
The first day of the lagged reference month for date — that date’s
month shifted back by this index’s observation lag, snapped to the
first.
The date calibration.inflation names. Its instruction puts each
rung’s pillar at the swap’s lagged observation, and until this crossed
a caller had no way to find one: the lag rule lives here, so computing
it in caller code would be this library’s knowledge written down a
second time.
A zero-coupon inflation swap helper turns the same date into a
choice: it takes the inflation period containing the lagged maturity
and places its pillar at one of that period’s two ends. This is the
first of them; dates.last_day_of_month reaches the other.
fn publication_frequency(&self) -> PyResult<String>
fn publication_frequency(&self) -> PyResult<String>
How often a price index publishes, as a frequency code (1M for a
monthly CPI). Refused for a rate index, which fixes daily.
fn observation_lag_months(&self) -> PyResult<u32>
fn observation_lag_months(&self) -> PyResult<u32>
A price index’s availability lag, in whole months.
fn interpolation(&self) -> PyResult<String>
fn interpolation(&self) -> PyResult<String>
How a price index maps a coupon date onto its monthly prints.
fn fixing_date(&self, accrual_start: NaiveDate) -> PyResult<NaiveDate>
fn fixing_date(&self, accrual_start: NaiveDate) -> PyResult<NaiveDate>
The publication date for a rate observed against accrual_start.
The accrual anchor stepped back by the index’s lag. The inverse
direction to forecast, which takes the date a quoted
period starts.
fn maturity_date(&self, value_date: NaiveDate) -> PyResult<NaiveDate>
fn maturity_date(&self, value_date: NaiveDate) -> PyResult<NaiveDate>
The end of the window a rate valued on value_date covers: the value
date advanced by the index’s tenor under its own conventions.
Not the coupon’s accrual end: a schedule’s business-day convention may have moved a boundary, and the index still quotes its tenor.
fn forecast(
&self,
curve: &PyDiscountCurve,
value_date: NaiveDate,
) -> PyResult<f64>
fn forecast( &self, curve: &PyDiscountCurve, value_date: NaiveDate, ) -> PyResult<f64>
The rate this index quotes for a period starting on value_date,
projected off curve.
The simple forward over the index’s own window, on the index’s own day count — the same expression the engine applies to an unfixed coupon, so this reproduces the rate a priced instrument reports.
Not DiscountCurve.forward_rate, which is continuously compounded on
ACT/365 and is a property of the curve rather than of any index. For an
ACT/360 index the two differ.
A price or FX index refuses: each forecasts through a different seam.
Trait Implementations§
impl DerefToPyAny for PyIndex
§impl PyClassImpl for PyIndex
impl PyClassImpl for PyIndex
§const IS_BASETYPE: bool = false
const IS_BASETYPE: bool = false
§const IS_SUBCLASS: bool = false
const IS_SUBCLASS: bool = false
§const IS_MAPPING: bool = false
const IS_MAPPING: bool = false
§const IS_SEQUENCE: bool = false
const IS_SEQUENCE: bool = false
§type ThreadChecker = SendablePyClass<PyIndex>
type ThreadChecker = SendablePyClass<PyIndex>
§type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::ImmutableChild
type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::ImmutableChild
§type BaseNativeType = PyAny
type BaseNativeType = PyAny
PyAny by default, and when you declare
#[pyclass(extends=PyDict)], it’s PyDict.fn items_iter() -> PyClassItemsIter
fn lazy_type_object() -> &'static LazyTypeObject<Self>
fn dict_offset() -> Option<isize>
fn weaklist_offset() -> Option<isize>
§impl PyClassNewTextSignature<PyIndex> for PyClassImplCollector<PyIndex>
impl PyClassNewTextSignature<PyIndex> for PyClassImplCollector<PyIndex>
fn new_text_signature(self) -> Option<&'static str>
§impl PyMethods<PyIndex> for PyClassImplCollector<PyIndex>
impl PyMethods<PyIndex> for PyClassImplCollector<PyIndex>
fn py_methods(self) -> &'static PyClassItems
§impl PyTypeInfo for PyIndex
impl PyTypeInfo for PyIndex
§fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
§fn type_object_bound(py: Python<'_>) -> Bound<'_, PyType>
fn type_object_bound(py: Python<'_>) -> Bound<'_, PyType>
§fn is_type_of_bound(object: &Bound<'_, PyAny>) -> bool
fn is_type_of_bound(object: &Bound<'_, PyAny>) -> bool
object is an instance of this type or a subclass of this type.§fn is_exact_type_of_bound(object: &Bound<'_, PyAny>) -> bool
fn is_exact_type_of_bound(object: &Bound<'_, PyAny>) -> bool
object is an instance of this type.