Skip to main content

Scale

Enum Scale 

#[non_exhaustive]
pub enum Scale { Unit, Bp, Percent, VolPoint, Custom(Factor), }
Expand description

The unit a reading is reported in: the per-unit-quote derivative, multiplied by a factor.

A risk pass produces ∂V/∂q per unit of the quote. A desk reads it per basis point, per vol point, per recovery point — which is the same number times a constant, and a constant the caller should name rather than apply. Linear, so a par ladder read at any scale still sums to its par total read at that scale.

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.
§

Unit

Per unit of the quote: the derivative as the pass produced it.

§

Bp

Per basis point: × 1e-4.

§

Percent

Per point of a quote read in percent — a recovery or a correlation point: × 1e-2.

§

VolPoint

Per vol point of a lognormal vol: × 1e-2.

§

Custom(Factor)

Per any other stated multiple of the quote.

Implementations§

§

impl Scale

pub fn factor(self) -> f64

The multiplier a per-unit reading is taken by.

pub fn custom(value: f64) -> Option<Self>

A custom scale of value, or None where Factor::new refuses it.

fn parse_custom(s: &str) -> Option<Self>

x<factor>, the open tail of the vocabulary.

§

impl Scale

pub const ACCEPTED: &'static [&'static str]

Every spelling this vocabulary accepts, canonical forms first.

pub(crate) fn recognize(s: &str) -> Option<Self>

The value s spells, or None — the parse without its error, so probing a spelling that is not this vocabulary’s allocates nothing.

Trait Implementations§

§

impl Clone for Scale

§

fn clone(&self) -> Scale

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 Copy for Scale

§

impl Debug for Scale

§

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

Formats the value using the given formatter. Read more
§

impl Default for Scale

§

fn default() -> Scale

Returns the “default value” for a type. Read more
§

impl Display for Scale

The canonical spelling: a listed name, or x and the shortest decimal that parses back to the factor’s bits.

§

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

Formats the value using the given formatter. Read more
§

impl Eq for Scale

§

impl FromStr for Scale

§

type Err = VocabularyParseError

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 Scale

§

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 PartialEq for Scale

§

fn eq(&self, other: &Scale) -> 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 StructuralPartialEq for Scale

Auto Trait Implementations§

§

impl Freeze for Scale

§

impl RefUnwindSafe for Scale

§

impl Send for Scale

§

impl Sync for Scale

§

impl Unpin for Scale

§

impl UnsafeUnpin for Scale

§

impl UnwindSafe for Scale

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.