Skip to main content

PyFixedRateBond

Struct PyFixedRateBond 

pub struct PyFixedRateBond {
    pub(crate) inner: FixedRateBond,
}
Expand description

A fixed-rate bullet bond — the underlying a callable, a forward and a total-return swap are written on. Not an instrument: the core values a plain bond only through the products written on it.

Fields§

§inner: FixedRateBond

Implementations§

§

impl PyFixedRateBond

pub(crate) fn new( currency: &str, issue: NaiveDate, maturity: NaiveDate, coupon: f64, frequency: Named<Frequency>, day_count: Named<DayCountFraction>, face: f64, ) -> PyResult<Self>

A bullet paying coupon at frequency (a period such as "6M") on day_count, redeeming face at maturity.

§

impl PyFixedRateBond

fn with_first_coupon(&self, first_coupon: NaiveDate) -> PyResult<Self>

This bond with its first coupon on first_coupon: a long first period where it falls more than a period after issue, accruing by the ICMA split under ACT/ACT ICMA.

fn with_penultimate_coupon(&self, penultimate: NaiveDate) -> PyResult<Self>

This bond with its last regular coupon on penultimate: the grid anchored there and a short or long final period to maturity, accruing by the ICMA split (notional periods forward from penultimate) under ACT/ACT ICMA.

fn with_end_of_month(&self, end_of_month: bool) -> Self

This bond with its coupon grid rolled on the calendar end of the month, which takes effect only when the maturity is a month end.

fn __repr__(&self) -> String

The call that built this bond, with typed spellings, so the repr reads back: fixed_rate_bond("USD", datetime.date(2025, 5, 15), …, frequency=Frequency.SemiAnnual, day_count=DayCountFraction.ActActIcma).

fn with_ex_div(&self, days: u16, day_type: Named<ExDivDayType>) -> Self

This bond trading ex-dividend days before each coupon, counted in day_type days (Business on the currency’s settlement calendar, or Calendar): a buyer settling strictly after a coupon’s ex-dividend date forgoes it, and accrued turns negative. Settlement on the ex-dividend date is still cum-dividend.

fn ex_div_date(&self, coupon_date: NaiveDate) -> Option<NaiveDate>

The ex-dividend date of the coupon paying on coupon_date, or None for a bond with no ex-dividend rule.

fn forgone_coupon_date(&self, settlement: NaiveDate) -> Option<NaiveDate>

The coupon date a buyer settling on settlement forgoes, or None when the bond trades cum-dividend then.

fn is_ex_div(&self, settlement: NaiveDate) -> bool

Whether the bond trades ex-dividend at settlement.

pub(crate) fn currency(&self) -> String

The bond’s currency code.

pub(crate) fn maturity(&self) -> Option<NaiveDate>

The redemption date.

pub(crate) fn coupon(&self) -> f64

The annual coupon rate.

pub(crate) fn face(&self) -> f64

The face amount.

pub(crate) fn instrument(&self) -> PyInstrument

This bond as an instrument — the callable with an empty exercise schedule — so a bullet books, values and tables without naming the callable. callable_bond(bond, []) is the same instrument.

fn issued_by(&self, issuer: &str) -> PyResult<PyInstrument>

This bond as an instrument valued risky on issuer’s credit — survival-weighted flows plus recovery of face; callable_bond(bond, [], issuer=) is the same.

fn npv(&self, py: Python<'_>, market: &PyMarket) -> PyResult<f64>

The bond’s value against market, through instrument: a bullet reaches a curve without composing a product around it.

fn cashflow_records( &self, py: Python<'_>, market: &PyMarket, ) -> PyResult<PyRecords>

The bond’s cashflow table against market, through its instrument.

pub(crate) fn with_payment_calendar( &self, calendar: &PyCalendar, business_day_convention: Named<BusinessDayConvention>, ) -> Self

This bond paying on calendar under business_day_convention — the payment calendar and payment convention, both separate from the accrual schedule.

The accrual does not move: every period still accrues over its unadjusted boundaries, which is what keeps the clean price continuous across a coupon date. Only the date each flow is paid and discounted on rolls, which is the street’s bond.

pub(crate) fn with_settlement_lag( &self, days: i32, calendar: &PyCalendar, ) -> Self

This bond settling days business days on calendar after it trades, bonds.z_spread reads it.

pub(crate) fn settlement_date(&self, trade_date: NaiveDate) -> NaiveDate

The date a trade on trade_date settles on: the settlement lag walked from it, never before issue.

pub(crate) fn with_accrual_adjustment( &self, calendar: &PyCalendar, business_day_convention: Named<BusinessDayConvention>, ) -> Self

This bond accruing over boundaries rolled on calendar under business_day_convention — issue, every coupon date and maturity. Opt-in: the default accrues unadjusted. Kept on the bond, so a schedule built afterwards rolls too; set it before with_amortisation.

pub(crate) fn payment_date(&self, accrual_end: NaiveDate) -> NaiveDate

The date an accrual ending on accrual_end is paid.

pub(crate) fn with_amortisation(&self, outstanding: Vec<f64>) -> PyResult<Self>

This bond with a notional profile: one fraction of the original face per coupon period, starting at 1, positive and never rising. Every price and flow stays per 100 of the original face; per_current_face restates one as the market’s per-current-face quote.

pub(crate) fn is_amortising(&self) -> bool

Whether any principal is repaid before maturity.

pub(crate) fn outstanding_fraction(&self, date: NaiveDate) -> f64

The fraction of the original face alive on date.

pub(crate) fn current_face(&self, date: NaiveDate) -> f64

The face alive on date.

pub(crate) fn per_current_face( &self, amount: f64, date: NaiveDate, ) -> PyResult<f64>

An amount per 100 of the original face restated per 100 of the face alive on date — the market’s quote for an amortiser, the identity for a bullet. Refused at or after maturity, when nothing is alive.

pub(crate) fn per_original_face(&self, amount: f64, date: NaiveDate) -> f64

The inverse: an amount per 100 of the face alive on date restated per 100 of the original face, which the pricing methods take.

fn flows( &self, settlement: NaiveDate, day_count: Option<Named<DayCountFraction>>, ) -> PyRecords

The flows still to pay after settlement, per 100 face, as a table: each flow’s accrual_end (the period that earned it), payment_date, time from settlement — on the bond’s own axis, in its periods under ACT/ACT ICMA, or on day_count where one is named — and amount (coupons and the redemption, a forgone coupon removed).

pub(crate) fn accrued(&self, settlement: NaiveDate) -> f64

The coupon accrued per 100 of face at settlement.

pub(crate) fn price( &self, yield_: f64, settlement: NaiveDate, price_basis: Named<PriceBasis>, yield_convention: Named<YieldQuoteConvention>, day_count: Option<Named<DayCountFraction>>, ) -> f64

The price per 100 face at yield_, on a named price basis and under a named yield convention.

basis is "clean" or "dirty". It defaults to clean, which is what a market means by a bond’s price; the all-in figure is basis="dirty" and differs by the accrued interest.

yield_convention names either a compounding basis — reaching the ordinary pricing body — or one of the two conventions that are not that body, "ise" and "jgb". The two axes are independent: every convention serves both bases.

pub(crate) fn yield_( &self, price: f64, settlement: NaiveDate, price_basis: Named<PriceBasis>, yield_convention: Named<YieldQuoteConvention>, day_count: Option<Named<DayCountFraction>>, ) -> PyResult<f64>

The yield price implies, read on a named price basis and under a named yield convention — the inverse of price.

Spelled with a trailing underscore because yield is a Python keyword.

pub(crate) fn yield_moments( &self, yield_: f64, settlement: NaiveDate, yield_convention: Named<YieldQuoteConvention>, day_count: Option<Named<DayCountFraction>>, ) -> PyResult<PyYieldMoments>

Modified duration at yield_: −P′/P. The price and its first two yield derivatives at yield_, from one second-order pricing pass; every yield-space measure is a reading of the three.

pub(crate) fn modified_duration( &self, yield_: f64, settlement: NaiveDate, yield_convention: Named<YieldQuoteConvention>, day_count: Option<Named<DayCountFraction>>, ) -> PyResult<f64>

The modified duration at yield_: the price’s relative sensitivity to the yield, −(1/P)·dP/dy, under the named yield convention.

pub(crate) fn macaulay_duration( &self, yield_: f64, settlement: NaiveDate, yield_convention: Named<YieldQuoteConvention>, day_count: Option<Named<DayCountFraction>>, ) -> PyResult<f64>

Macaulay duration at yield_: the PV-weighted mean time to the bond’s remaining flows.

pub(crate) fn convexity( &self, yield_: f64, settlement: NaiveDate, yield_convention: Named<YieldQuoteConvention>, day_count: Option<Named<DayCountFraction>>, ) -> PyResult<f64>

Convexity at yield_: P″/P.

pub(crate) fn dv01( &self, yield_: f64, settlement: NaiveDate, yield_convention: Named<YieldQuoteConvention>, day_count: Option<Named<DayCountFraction>>, ) -> PyResult<f64>

DV01 per 100 face at yield_.

pub(crate) fn money_dv01( &self, yield_: f64, settlement: NaiveDate, yield_convention: Named<YieldQuoteConvention>, day_count: Option<Named<DayCountFraction>>, ) -> PyResult<f64>

DV01 in money at the bond’s own face.

pub(crate) fn money_duration( &self, yield_: f64, settlement: NaiveDate, yield_convention: Named<YieldQuoteConvention>, day_count: Option<Named<DayCountFraction>>, ) -> PyResult<f64>

Money duration at the bond’s own face: modified duration times the money price.

Trait Implementations§

§

impl Clone for PyFixedRateBond

§

fn clone(&self) -> PyFixedRateBond

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 DerefToPyAny for PyFixedRateBond

§

impl IntoPy<Py<PyAny>> for PyFixedRateBond

§

fn into_py(self, py: Python<'_>) -> PyObject

Performs the conversion.
§

impl PyClass for PyFixedRateBond

§

type Frozen = True

Whether the pyclass is frozen. Read more
§

impl PyClassImpl for PyFixedRateBond

§

const IS_BASETYPE: bool = false

#[pyclass(subclass)]
§

const IS_SUBCLASS: bool = false

#[pyclass(extends=…)]
§

const IS_MAPPING: bool = false

#[pyclass(mapping)]
§

const IS_SEQUENCE: bool = false

#[pyclass(sequence)]
§

type BaseType = PyAny

Base class
§

type ThreadChecker = SendablePyClass<PyFixedRateBond>

This handles following two situations: Read more
§

type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::ImmutableChild

Immutable or mutable
§

type Dict = PyClassDummySlot

Specify this class has #[pyclass(dict)] or not.
§

type WeakRef = PyClassDummySlot

Specify this class has #[pyclass(weakref)] or not.
§

type BaseNativeType = PyAny

The closest native ancestor. This is PyAny by default, and when you declare #[pyclass(extends=PyDict)], it’s PyDict.
§

fn items_iter() -> PyClassItemsIter

§

fn doc(py: Python<'_>) -> PyResult<&'static CStr>

Rendered class doc
§

fn lazy_type_object() -> &'static LazyTypeObject<Self>

§

fn dict_offset() -> Option<isize>

§

fn weaklist_offset() -> Option<isize>

§

impl<'a, 'py> PyFunctionArgument<'a, 'py> for &'a PyFixedRateBond

§

type Holder = Option<PyRef<'py, PyFixedRateBond>>

§

fn extract( obj: &'a Bound<'py, PyAny>, holder: &'a mut Self::Holder, ) -> PyResult<Self>

§

impl PyMethods<PyFixedRateBond> for PyClassImplCollector<PyFixedRateBond>

§

fn py_methods(self) -> &'static PyClassItems

§

impl PyTypeInfo for PyFixedRateBond

§

const NAME: &'static str = "FixedRateBond"

Class name.
§

const MODULE: Option<&'static str>

Module name, if any.
§

fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject

Returns the PyTypeObject instance for this type.
§

fn type_object_bound(py: Python<'_>) -> Bound<'_, PyType>

Returns the safe abstraction over the type object.
§

fn is_type_of_bound(object: &Bound<'_, PyAny>) -> bool

Checks if object is an instance of this type or a subclass of this type.
§

fn is_exact_type_of_bound(object: &Bound<'_, PyAny>) -> bool

Checks if object is an instance of this type.

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.

§

impl<T> FromPyObject<'_> for T
where T: PyClass + Clone,

§

fn extract_bound(obj: &Bound<'_, PyAny>) -> Result<T, PyErr>

Extracts Self from the bound smart pointer obj. Read more
§

impl<'py, T> FromPyObjectBound<'_, 'py> for T
where T: FromPyObject<'py>,

§

fn from_py_object_bound(ob: Borrowed<'_, 'py, PyAny>) -> Result<T, PyErr>

Extracts Self from the bound smart pointer obj. Read more
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.

§

impl<T> PyErrArguments for T
where T: IntoPy<Py<PyAny>> + Send + Sync,

§

fn arguments(self, py: Python<'_>) -> Py<PyAny>

Arguments for exception
§

impl<T> PyTypeCheck for T
where T: PyTypeInfo,

§

const NAME: &'static str = <T as PyTypeInfo>::NAME

Name of self. This is used in error messages, for example.
§

fn type_check(object: &Bound<'_, PyAny>) -> bool

Checks if object is an instance of Self, which may include a subtype. Read more
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.
§

impl<T> Ungil for T
where T: Send,