Struct ZeroCouponBond
pub struct ZeroCouponBond {
pub currency: Currency,
pub collateral: CollateralSpec,
pub settlement: NaiveDate,
pub maturity: NaiveDate,
pub face: f64,
pub discount_yield: f64,
pub day_count: DayCountFraction,
pub calc_method: u16,
pub quote_method: YieldQuoteMethod,
pub side: f64,
}Expand description
A short-dated zero-coupon government security quoted on a discount basis.
It holds the discount yield, because that is what the contract is struck on; the price and the other two quotes are read off it.
Fields§
§currency: CurrencyThe zero’s currency.
collateral: CollateralSpecWhat the zero is discounted against. A zero names no index and no spread: this is the only curve it reads.
settlement: NaiveDateThe date the quote is struck from — the settlement the discount accrues over.
maturity: NaiveDateThe date the face is paid.
face: f64The face amount paid at maturity.
discount_yield: f64The discount yield, as a decimal, on the face.
day_count: DayCountFractionThe accrual day count. Per-security data: the registered method for every discount row declines to impose one.
calc_method: u16The vendor calc-type code the conventions were resolved from, kept so a zero can say which row it books under.
quote_method: YieldQuoteMethodThe quote convention, resolved from calc_method rather than
supplied.
side: f64+1 holds the zero; −1 is short.
Implementations§
§impl ZeroCouponBond
impl ZeroCouponBond
pub fn new(
currency: Currency,
calc_method: u16,
settlement: NaiveDate,
maturity: NaiveDate,
face: f64,
discount_yield: f64,
day_count: DayCountFraction,
) -> Result<Self, CalcMethodError>
pub fn new( currency: Currency, calc_method: u16, settlement: NaiveDate, maturity: NaiveDate, face: f64, discount_yield: f64, day_count: DayCountFraction, ) -> Result<Self, CalcMethodError>
A zero booked under the registered calculation method calc_method.
§Errors
CalcMethodError if the code is not in the registry, or if it is a
row that imposes a coupon basis — a zero has no coupon, so a method that
books one is not a zero’s method, and the refusal names the code rather
than pricing a note’s convention onto a discount security.
pub fn short(self) -> Self
pub fn short(self) -> Self
The short side.
pub fn year_fraction(&self) -> f64
pub fn year_fraction(&self) -> f64
The year fraction the discount is taken over, on the zero’s own basis.
pub fn price(&self) -> f64
pub fn price(&self) -> f64
The price per unit of face: 1 − d·τ.
On the face, which is what makes a discount yield not a yield: the discount is subtracted from what is repaid, not earned on what is paid.
pub fn discount_yield_from_price(&self, price: f64) -> f64
pub fn discount_yield_from_price(&self, price: f64) -> f64
The discount yield a price implies: (1 − P)/τ, on the face.
pub fn money_market_yield(&self) -> f64
pub fn money_market_yield(&self) -> f64
The money-market yield at this zero’s price: (1 − P)/(P·τ).
On the price — what a lender of P earns — which is why it exceeds
the discount yield at the same price whenever the zero trades below par.
Computed through the crate’s own rate/discount-factor conversion rather
than by writing the ratio out again.
pub fn money_market_yield_from_price(&self, price: f64) -> f64
pub fn money_market_yield_from_price(&self, price: f64) -> f64
The money-market yield a price implies.
pub fn price_from_money_market_yield(&self, rate: f64) -> f64
pub fn price_from_money_market_yield(&self, rate: f64) -> f64
The price a money-market yield implies — the inverse of
money_market_yield_from_price.
pub fn bond_equivalent_yield(&self) -> f64
pub fn bond_equivalent_yield(&self) -> f64
The bond-equivalent yield: the semi-annually compounded ACT/365F yield that reprices the zero, so it stands beside a coupon note’s yield.
pub fn bond_equivalent_yield_from_price(&self, price: f64) -> f64
pub fn bond_equivalent_yield_from_price(&self, price: f64) -> f64
The bond-equivalent yield a price implies.
pub fn price_from_bond_equivalent_yield(&self, yield_: f64) -> f64
pub fn price_from_bond_equivalent_yield(&self, yield_: f64) -> f64
The price a bond-equivalent yield implies.
pub fn quoted_yield(&self) -> f64
pub fn quoted_yield(&self) -> f64
The quoted yield under the registered convention: the money-market yield where the method quotes simple interest, the compounded yield where it quotes compound.
This is the number the market prints. It reads the method rather than a list written here, so a row whose convention is corrected in the registry changes this without anything in this file moving.
pub fn price_from_quoted_yield(&self, yield_: f64) -> f64
pub fn price_from_quoted_yield(&self, yield_: f64) -> f64
The price the quoted yield implies, under the same registered convention.
fn quote_convention(&self) -> RateConvention
fn quote_convention(&self) -> RateConvention
The rate convention the registered method resolves to.
The three quote methods a discount row can carry map onto compounding; the two that describe a coupon bond’s own kernels are not reachable from a discount row and compound like the default rather than being turned away here, where a refusal would be about a row that cannot occur.
fn bond_equivalent_tau(&self) -> f64
fn bond_equivalent_tau(&self) -> f64
The year fraction the bond-equivalent yield is annualised over — on its own ACT/365F basis, never the zero’s.
Trait Implementations§
§impl Clone for ZeroCouponBond
impl Clone for ZeroCouponBond
§fn clone(&self) -> ZeroCouponBond
fn clone(&self) -> ZeroCouponBond
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for ZeroCouponBond
impl Debug for ZeroCouponBond
§impl PartialEq for ZeroCouponBond
impl PartialEq for ZeroCouponBond
§impl<R: Scalar> Priceable<R> for ZeroCouponBond
impl<R: Scalar> Priceable<R> for ZeroCouponBond
§fn npv(&self, view: &PricingView<'_, R>) -> Result<R, PricingError>
fn npv(&self, view: &PricingView<'_, R>) -> Result<R, PricingError>
side · N · (DF(maturity) − P·DF(settlement)), wholly off the discount
curve, where P = 1 − d·τ is the quoted price per unit of face.
The deposit’s shape, and for the deposit’s reasons. A zero is a purchase: money out at settlement, the face back at maturity. Valuing it as the face alone would report a number that could not be zero and so admits no par rate; valuing it as the price discounted would report the present value of what was paid, which is not a position in anything.
Three datings, the middle one as the deposit’s: past the settlement the money has gone out and only the redemption is still owed; past the maturity there is nothing.
Nothing is read from the fixing store. A zero names no index; a published rate on its dates belongs to some other instrument.
§fn par_rate(&self, view: &PricingView<'_, R>) -> Result<R, PricingError>
fn par_rate(&self, view: &PricingView<'_, R>) -> Result<R, PricingError>
The fair discount yield: (1 − DF(maturity)/DF(settlement))/τ, at which
the zero is worth nothing.
The same expression the value is built from, solved for the rate rather than for the money — so the quote and the valuation cannot disagree about what par means. A rate on the face, like the quote it inverts.
§fn par_spread(&self, _view: &PricingView<'_, R>) -> Result<R, PricingError>
fn par_spread(&self, _view: &PricingView<'_, R>) -> Result<R, PricingError>
Unsupported: a zero has no floating side for a margin to sit on, so a breakeven spread would be a number with no contract behind it — the money-market deposit refuses for the same reason.
§impl PricingRiskFactors for ZeroCouponBond
impl PricingRiskFactors for ZeroCouponBond
§fn risk_factors(&self) -> Result<RiskFactors<'_>, PricingError>
fn risk_factors(&self) -> Result<RiskFactors<'_>, PricingError>
§impl Product for ZeroCouponBond
impl Product for ZeroCouponBond
§fn currency(&self) -> Currency
fn currency(&self) -> Currency
§fn contract_dates(&self) -> Vec<(&'static str, NaiveDate)>
fn contract_dates(&self) -> Vec<(&'static str, NaiveDate)>
(name, date) pairs —
exactly the dates its stated constructor takes, so a product built
through a derived form can be read back and rebuilt through the stated
one. Empty for a product with no stated form. No default: every
product states which it is — see AnyInstrument::contract_dates.§fn legs(&self) -> Option<Vec<&Leg>>
fn legs(&self) -> Option<Vec<&Leg>>
None
for a product that holds none — see AnyInstrument::legs. No
default: every product states which it is.§fn final_payment_date(&self) -> Option<NaiveDate>
fn final_payment_date(&self) -> Option<NaiveDate>
None for a product no ladder is built from.§fn restruck_at_rate(&self, _rate: f64) -> Option<AnyInstrument>
fn restruck_at_rate(&self, _rate: f64) -> Option<AnyInstrument>
rate — the scalar a par
calibration rung on it is quoted in — or None for a product that
carries no such scalar. What a quote scenario moves a rung to.§fn restruck_at_spread(&self, _spread: f64) -> Option<AnyInstrument>
fn restruck_at_spread(&self, _spread: f64) -> Option<AnyInstrument>
spread on its spread
leg, or None for a product that quotes none.