libitofin 0.7.0

A ground-up Rust port of QuantLib: quantitative-finance primitives for pricing, risk, and numerical methods.
Documentation
//! Yield term structures.
//!
//! Port of `ql/termstructures/yield/` (named `yields` because `yield` is a
//! Rust keyword); concrete curves implementing
//! [`YieldTermStructure`](super::yieldtermstructure::YieldTermStructure).

mod bondhelpers;
mod discountcurve;
mod flatforward;
mod forwardcurve;
mod forwardspreadedtermstructure;
mod forwardstructure;
mod impliedtermstructure;
mod piecewiseyieldcurve;
mod ratehelpers;
mod zerocurve;
mod zerospreadedtermstructure;
mod zeroyieldstructure;

pub use bondhelpers::{BondHelper, FixedRateBondHelper};
pub use discountcurve::{DiscountCurve, InterpolatedDiscountCurve};
pub use flatforward::FlatForward;
pub use forwardcurve::{ForwardCurve, InterpolatedForwardCurve};
pub use forwardspreadedtermstructure::ForwardSpreadedTermStructure;
pub use forwardstructure::ForwardRateStructure;
pub use impliedtermstructure::ImpliedTermStructure;
pub use piecewiseyieldcurve::PiecewiseYieldCurve;
pub use ratehelpers::{
    DepositRateHelper, FraRateHelper, FuturesRateHelper, OISRateHelper, Pillar, SwapRateHelper,
};
pub use zerocurve::{InterpolatedZeroCurve, ZeroCurve};
pub use zerospreadedtermstructure::ZeroSpreadedTermStructure;
pub use zeroyieldstructure::ZeroYieldStructure;

use crate::handle::Handle;
use crate::termstructures::TermStructureBase;
use crate::termstructures::yieldtermstructure::YieldTermStructure;

/// Re-syncs a spreaded/implied curve's extrapolation flag to its underlying
/// curve's, shared by the adapters' `update()` observers.
pub(super) fn sync_extrapolation(
    base: &TermStructureBase,
    original: &Handle<dyn YieldTermStructure>,
) {
    if let Ok(original) = original.current_link() {
        if original.allows_extrapolation() {
            base.enable_extrapolation();
        } else {
            base.disable_extrapolation();
        }
    }
}