Skip to main content

CollateralSpec

Enum CollateralSpec 

#[non_exhaustive]
pub enum CollateralSpec { Currency(Currency), Named(String), }
Expand description

Which discount curve a product is collateralised against.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Currency(Currency)

The standard curve for a currency — cash collateral in that currency.

§

Named(String)

A named curve, for anything the currency default does not describe.

Implementations§

§

impl CollateralSpec

pub fn under_csa(currency: Currency, collateral: Currency) -> Self

The discount key for cash flows in currency collateralised in collateral: the currency’s own key when the two coincide, the named key "{currency}-CSA-{collateral}" otherwise. The one spelling a cross-currency template’s foreign leg and a market pin agree on.

pub fn parts(&self) -> Option<(&str, &str)>

The cashflow and collateral currency codes this key names, or None where it names no pair.

Currency(c) is own-currency cash collateral and answers (c, c); a Named key of the form "X-CSA-Y" decomposes to (X, Y). Anything else — a CSA agreement name, an implied-curve label, any string a caller chose to pin under — answers None, because it names no pair.

This is the fallible half of the key: the recipe registry is keyed by currency pairs, and a key outside that space simply has no recipe.

pub fn cashflow_ccy(&self) -> Option<&str>

The cashflow currency code — the currency a trade pays in — where this key names a currency pair.

pub fn collateral_ccy(&self) -> Option<&str>

The collateral currency code — the currency the CSA posts in — where this key names a currency pair.

pub fn is_own_collateral(&self) -> bool

Whether this is own-currency cash collateral — the cashflow currency and the collateral currency are the same.

A key naming no currency pair is not own-collateral: it is not a statement about collateral currencies at all.

fn key(&self) -> (u8, &str)

The spelling a store keys and sorts this by.

Trait Implementations§

§

impl Clone for CollateralSpec

§

fn clone(&self) -> CollateralSpec

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 Debug for CollateralSpec

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
§

impl Display for CollateralSpec

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
§

impl Eq for CollateralSpec

§

impl FromStr for CollateralSpec

The inverse of Display, so an emitted key round-trips: a valid currency code reads as currency collateral, anything else as a named curve. Total — every string names some collateral — which is why the error is Infallible.

§

type Err = Infallible

The associated error which can be returned from parsing.
§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
§

impl Hash for CollateralSpec

§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
§

impl Ord for CollateralSpec

Ordered by the arm and then the code, the way CurrencyPair is, and for the same reason: a market keyed by collateral must enumerate its curves in a fixed order so two risk vectors over the same market compare row by row. Currency itself carries no order — it is a validated three-byte code.

§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
§

impl PartialEq for CollateralSpec

§

fn eq(&self, other: &CollateralSpec) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl PartialOrd for CollateralSpec

§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
§

impl StructuralPartialEq for CollateralSpec

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.

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.

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.