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: f64The compounding periods per year.
compounding: CompoundingHow 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
impl YieldBasis
pub fn compounded_at(per_year: f64) -> Self
pub fn compounded_at(per_year: f64) -> Self
A yield compounding per_year times a year.
pub fn compounded(frequency: Frequency) -> Self
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
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
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
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
impl Clone for YieldBasis
§fn clone(&self) -> YieldBasis
fn clone(&self) -> YieldBasis
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more