Skip to main content

Bootstrap

Struct Bootstrap 

Source
pub struct Bootstrap {
    pub reference_date: Date,
    pub daycount: Daycount,
    pub config: BootstrapConfig,
}
Expand description

Sequential iterative bootstrap engine.

Constructs a DiscountCurve from a list of Instrument quotes by driving each instrument’s residual to zero against the in-progress curve. See the module-level documentation for the algorithm.

§Examples

use regit_curves::bootstrap::{Bootstrap, BootstrapConfig};
use regit_curves::instruments::{Deposit, Instrument};
use regit_curves::interpolation::Interpolation;
use regit_curves::types::{Date, Daycount};

let reference = Date::from_ymd(2024, 1, 2).unwrap();
let dep1 = Deposit::new(
    reference,
    Date::from_ymd(2024, 4, 2).unwrap(),
    0.05,
    Daycount::Act360,
)
.unwrap();
let dep2 = Deposit::new(
    reference,
    Date::from_ymd(2024, 7, 2).unwrap(),
    0.05,
    Daycount::Act360,
)
.unwrap();
let instruments = [Instrument::Deposit(dep1), Instrument::Deposit(dep2)];

let bootstrap = Bootstrap::new(reference, Daycount::Act360);
let curve = bootstrap
    .build(&instruments, Interpolation::LogLinear)
    .unwrap();
assert_eq!(curve.reference_date(), reference);

Fields§

§reference_date: Date

Curve anchor / reference date.

§daycount: Daycount

Day-count convention for the curve’s t-axis.

§config: BootstrapConfig

Solver configuration.

Implementations§

Source§

impl Bootstrap

Source

pub fn new(reference_date: Date, daycount: Daycount) -> Self

Constructs a bootstrap engine with BootstrapConfig::default.

§Examples
use regit_curves::bootstrap::Bootstrap;
use regit_curves::types::{Date, Daycount};

let reference = Date::from_ymd(2024, 1, 2).unwrap();
let bs = Bootstrap::new(reference, Daycount::Act360);
assert_eq!(bs.reference_date, reference);
assert_eq!(bs.daycount, Daycount::Act360);
Source

pub fn with_config(self, config: BootstrapConfig) -> Self

Returns the bootstrap engine with the supplied configuration.

§Examples
use regit_curves::bootstrap::{Bootstrap, BootstrapConfig};
use regit_curves::types::{Date, Daycount};

let reference = Date::from_ymd(2024, 1, 2).unwrap();
let cfg = BootstrapConfig {
    tolerance: 1e-10,
    ..BootstrapConfig::default()
};
let bs = Bootstrap::new(reference, Daycount::Act360).with_config(cfg);
assert!((bs.config.tolerance - 1e-10).abs() < 1e-18);
Source

pub fn build( &self, instruments: &[Instrument], method: Interpolation, ) -> Result<DiscountCurve, BootstrapError>

Builds a DiscountCurve that re-prices every instrument in instruments to within BootstrapConfig::tolerance.

Instruments must be ordered by Instrument::pillar, strictly increasing. The pillar of every instrument must lie strictly after Bootstrap::reference_date.

§Errors
§Examples
use regit_curves::bootstrap::Bootstrap;
use regit_curves::instruments::{Deposit, Instrument};
use regit_curves::interpolation::Interpolation;
use regit_curves::types::{Date, Daycount};

let reference = Date::from_ymd(2024, 1, 2).unwrap();
let dep = Deposit::new(
    reference,
    Date::from_ymd(2024, 4, 2).unwrap(),
    0.05,
    Daycount::Act360,
)
.unwrap();
let curve = Bootstrap::new(reference, Daycount::Act360)
    .build(&[Instrument::Deposit(dep)], Interpolation::LogLinear)
    .unwrap();
assert!(curve.discounts().len() == 2);

Trait Implementations§

Source§

impl Clone for Bootstrap

Source§

fn clone(&self) -> Bootstrap

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 Copy for Bootstrap

Source§

impl Debug for Bootstrap

Source§

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

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

impl PartialEq for Bootstrap

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Bootstrap

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.

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