Skip to main content

YieldBasis

Struct YieldBasis 

pub struct YieldBasis {
    pub per_year: f64,
    pub compounding: Compounding,
    pub day_count: Option<DayCountFraction>,
}
Expand description

The basis a bond yield is quoted on: how often it compounds, and how.

Both halves of a quoting convention travel together. A compounding on its own does not determine a price/yield relationship — periodic compounding needs the frequency it compounds at, and a caller able to state one without the other can only get that pairing wrong silently. So every yield-space entry point takes this, never a bare Compounding.

per_year is a count rather than a Frequency because a street convention fixes it independently of any schedule: US Treasuries and UK gilts quote semiannually whatever the bond pays. Frequency answers “when does this bond pay”; this answers “how is its yield spoken”.

per_year is read only under Compounding::Compounded; the simple and continuous relationships do not compound and ignore it.

day_count is the basis the yield is spoken on, which a street convention fixes as independently as it fixes per_year: a bond may accrue on 30/360 and be quoted on an Act/360 money-market yield. None — every constructor’s answer, and every named market convention’s — is the street default: the yield is measured on whatever the bond accrues on.

Fields§

§per_year: f64

The compounding periods per year.

§compounding: Compounding

How the yield accrues between them.

§day_count: Option<DayCountFraction>

The day count the yield is measured on, or the bond’s own where absent.

Implementations§

§

impl YieldBasis

pub fn compounded_at(per_year: f64) -> Self

A yield compounding per_year times a year.

pub fn compounded(frequency: Frequency) -> Self

A yield compounding at a schedule’s own frequency — the bond’s payment frequency, which is the default street convention.

pub fn continuous() -> Self

A continuously compounded yield.

Takes no frequency, because it has none: exp(−y·t) compounds over no period. per_year is recorded as one so the field is never a lie, and nothing reads it.

pub fn simple() -> Self

A simple-interest (money-market) yield: no compounding at all — the zero-coupon and interest-at-maturity families, and the final period of the ISE convention.

Also takes no frequency. 1/(1 + y·t) annualises through t, not through a period count, so a frequency here would be an argument the arithmetic never reaches.

pub fn on(self, day_count: DayCountFraction) -> Self

The same basis, spoken on day_count rather than on the bond’s own accrual basis — a yield day counter of its own.

Naming one measures the time to every flow the yield discounts that way, so a bond quoted under ACT/ACT.ICMA no longer reads its anchor scheme: a caller asking for Act/360 is asking for Act/360, not for a period count.

Trait Implementations§

§

impl Clone for YieldBasis

§

fn clone(&self) -> YieldBasis

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 YieldBasis

§

impl Debug for YieldBasis

§

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

Formats the value using the given formatter. Read more
§

impl PartialEq for YieldBasis

§

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

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