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::buildas aBusinessCalendarrather 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: f64Redeemed at maturity, and the base of every coupon.
coupon_rate: f64Annual coupon rate as a fraction, e.g. 0.05 for 5%.
frequency: u32Coupon payments per year; must divide 12 evenly.
issue: DateStart of the first accrual period — usually the issue or dated date, not the settlement of a later trade.
maturity: Date§day_count: DayCountConventionGoverns coupon amounts, accrued interest and discounting alike.
stub: ScheduleStubWhere an irregular period sits, if the dates do not divide evenly.
business_day_convention: BusinessDayConventionHow payment dates move off non-business days. The accrual dates never move.
Implementations§
Source§impl BondSpec
impl BondSpec
Sourcepub fn new(
face_value: f64,
coupon_rate: f64,
frequency: u32,
issue: Date,
maturity: Date,
day_count: DayCountConvention,
) -> Self
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.
pub fn with_stub(self, stub: ScheduleStub) -> Self
pub fn with_business_day_convention( self, convention: BusinessDayConvention, ) -> Self
Sourcepub fn schedule(
&self,
calendar: &BusinessCalendar,
) -> Result<CouponSchedule, FinanceError>
pub fn schedule( &self, calendar: &BusinessCalendar, ) -> Result<CouponSchedule, FinanceError>
The coupon schedule these terms describe, against the holidays of the market it trades in.
Sourcepub fn build(
&self,
calendar: &BusinessCalendar,
) -> Result<FixedRateBond, FinanceError>
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.