Skip to main content

PyIndex

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: bool

Whether 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

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>

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>

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

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)>

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>

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>

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

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>

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 pair(&self) -> PyResult<String>

The pair an FX index names, as BASEQUOTE. FX indices only.

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 kind(&self) -> &'static str

Which kind of index this is: "Overnight", "Ibor", "Fx" or "Price".

fn name(&self) -> &str

The index’s display name — the key its fixings are stored under.

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 currency(&self) -> PyResult<String>

The ISO 4217 currency the index quotes in.

fn tenor(&self) -> PyResult<String>

The index’s tenor, as a tenor string ("3M"). Term indices only.

fn day_count(&self) -> PyResult<String>

The index’s accrual day count.

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>

The fixing lag, in good business days.

fn business_day_convention(&self) -> PyResult<String>

The index’s conventional business-day convention.

fn end_of_month(&self) -> PyResult<bool>

The index’s conventional end-of-month rule.

fn region(&self) -> PyResult<String>

The region a price index covers.

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>

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>

A price index’s availability lag, in whole months.

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>

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>

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>

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 Clone for PyIndex

§

fn clone(&self) -> PyIndex

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl DerefToPyAny for PyIndex

§

impl IntoPy<Py<PyAny>> for PyIndex

§

fn into_py(self, py: Python<'_>) -> PyObject

Performs the conversion.
§

impl PyClass for PyIndex

§

type Frozen = True

Whether the pyclass is frozen. Read more
§

impl PyClassImpl for PyIndex

§

const IS_BASETYPE: bool = false

#[pyclass(subclass)]
§

const IS_SUBCLASS: bool = false

#[pyclass(extends=…)]
§

const IS_MAPPING: bool = false

#[pyclass(mapping)]
§

const IS_SEQUENCE: bool = false

#[pyclass(sequence)]
§

type BaseType = PyAny

Base class
§

type ThreadChecker = SendablePyClass<PyIndex>

This handles following two situations: Read more
§

type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::ImmutableChild

Immutable or mutable
§

type Dict = PyClassDummySlot

Specify this class has #[pyclass(dict)] or not.
§

type WeakRef = PyClassDummySlot

Specify this class has #[pyclass(weakref)] or not.
§

type BaseNativeType = PyAny

The closest native ancestor. This is PyAny by default, and when you declare #[pyclass(extends=PyDict)], it’s PyDict.
§

fn items_iter() -> PyClassItemsIter

§

fn doc(py: Python<'_>) -> PyResult<&'static CStr>

Rendered class doc
§

fn lazy_type_object() -> &'static LazyTypeObject<Self>

§

fn dict_offset() -> Option<isize>

§

fn weaklist_offset() -> Option<isize>

§

impl PyClassNewTextSignature<PyIndex> for PyClassImplCollector<PyIndex>

§

fn new_text_signature(self) -> Option<&'static str>

§

impl<'a, 'py> PyFunctionArgument<'a, 'py> for &'a PyIndex

§

type Holder = Option<PyRef<'py, PyIndex>>

§

fn extract( obj: &'a Bound<'py, PyAny>, holder: &'a mut Self::Holder, ) -> PyResult<Self>

§

impl PyMethods<PyIndex> for PyClassImplCollector<PyIndex>

§

fn py_methods(self) -> &'static PyClassItems

§

impl PyTypeInfo for PyIndex

§

const NAME: &'static str = "Index"

Class name.
§

const MODULE: Option<&'static str>

Module name, if any.
§

fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject

Returns the PyTypeObject instance for this type.
§

fn type_object_bound(py: Python<'_>) -> Bound<'_, PyType>

Returns the safe abstraction over the type object.
§

fn is_type_of_bound(object: &Bound<'_, PyAny>) -> bool

Checks if object is an instance of this type or a subclass of this type.
§

fn is_exact_type_of_bound(object: &Bound<'_, PyAny>) -> bool

Checks if object is an instance of this type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromPyObject<'_> for T
where T: PyClass + Clone,

§

fn extract_bound(obj: &Bound<'_, PyAny>) -> Result<T, PyErr>

Extracts Self from the bound smart pointer obj. Read more
§

impl<'py, T> FromPyObjectBound<'_, 'py> for T
where T: FromPyObject<'py>,

§

fn from_py_object_bound(ob: Borrowed<'_, 'py, PyAny>) -> Result<T, PyErr>

Extracts Self from the bound smart pointer obj. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> PyErrArguments for T
where T: IntoPy<Py<PyAny>> + Send + Sync,

§

fn arguments(self, py: Python<'_>) -> Py<PyAny>

Arguments for exception
§

impl<T> PyTypeCheck for T
where T: PyTypeInfo,

§

const NAME: &'static str = <T as PyTypeInfo>::NAME

Name of self. This is used in error messages, for example.
§

fn type_check(object: &Bound<'_, PyAny>) -> bool

Checks if object is an instance of Self, which may include a subtype. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Ungil for T
where T: Send,