Skip to main content

BondSpec

Struct BondSpec 

Source
pub struct BondSpec {
    pub face_value: f64,
    pub coupon_rate: f64,
    pub frequency: u32,
    pub issue: Date,
    pub maturity: Date,
    pub day_count: DayCountConvention,
    pub stub: ScheduleStub,
    pub business_day_convention: BusinessDayConvention,
}
Expand description

The terms a consumer supplies so this crate can build a bond’s schedule and value it.

This is the data contract between a consuming application and kestrel-chartkit, and it is drawn along one line: the consumer owns what the instrument is, this crate owns what follows from it. A consumer reads these fields from wherever its product master lives and hands them over; it does not compute coupon dates, accrual or prices itself, and this crate does not go looking for instrument data.

What is deliberately not in here:

  • Holidays. They are market data with their own validity — announced, moved and revised per market and year — so they are passed to BondSpec::build as a BusinessCalendar rather than frozen into the instrument’s terms.
  • Currency, multiplier and quantity steps. Those belong to ContractSpec. Repeating them here would create a second truth about the same instrument.
  • Market prices and yields. They are observations, not terms, and are passed per valuation.

The day count has no default: it decides every coupon amount and every accrual, and a silently assumed one would be wrong more often than right.

Fields§

§face_value: f64

Redeemed at maturity, and the base of every coupon.

§coupon_rate: f64

Annual coupon rate as a fraction, e.g. 0.05 for 5%.

§frequency: u32

Coupon payments per year; must divide 12 evenly.

§issue: Date

Start of the first accrual period — usually the issue or dated date, not the settlement of a later trade.

§maturity: Date§day_count: DayCountConvention

Governs coupon amounts, accrued interest and discounting alike.

§stub: ScheduleStub

Where an irregular period sits, if the dates do not divide evenly.

§business_day_convention: BusinessDayConvention

How payment dates move off non-business days. The accrual dates never move.

Implementations§

Source§

impl BondSpec

Source

pub fn new( face_value: f64, coupon_rate: f64, frequency: u32, issue: Date, maturity: Date, day_count: DayCountConvention, ) -> Self

The terms every bond needs. Stub placement and business-day handling take their documented defaults (ScheduleStub::ShortFirst, BusinessDayConvention::Unadjusted) and are set with BondSpec::with_stub and BondSpec::with_business_day_convention.

Source

pub fn with_stub(self, stub: ScheduleStub) -> Self

Source

pub fn with_business_day_convention( self, convention: BusinessDayConvention, ) -> Self

Source

pub fn schedule( &self, calendar: &BusinessCalendar, ) -> Result<CouponSchedule, FinanceError>

The coupon schedule these terms describe, against the holidays of the market it trades in.

Source

pub fn build( &self, calendar: &BusinessCalendar, ) -> Result<FixedRateBond, FinanceError>

The valuable instrument these terms describe. Rejects the same inputs CouponSchedule::generate and FixedRateBond::new reject, so a consumer finds a bad product record here rather than in a price.

Trait Implementations§

Source§

impl Clone for BondSpec

Source§

fn clone(&self) -> BondSpec

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

impl Debug for BondSpec

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for BondSpec

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for BondSpec

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl Serialize for BondSpec

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for BondSpec

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.