Skip to main content

Loan

Struct Loan 

pub struct Loan {
    pub currency: Currency,
    pub drawdown: Leg,
    pub servicing: Leg,
    pub collateral: CollateralSpec,
    pub issuer: Option<CreditCurveId>,
    pub index: Option<String>,
}
Expand description

A loan as two legs, one per direction of cash: the drawdown, and the servicing — the interest and the repayment.

Fields§

§currency: Currency

The loan’s currency.

§drawdown: Leg

The principal drawn on the first schedule date.

§servicing: Leg

The interest on each period and the principal repaid on the last date.

§collateral: CollateralSpec

The discounting collateral.

§issuer: Option<CreditCurveId>

The borrower’s credit, when the servicing is valued risky: survival weights the borrower’s promises, and default recovers on the principal still outstanding. The drawdown stays risk-free.

§index: Option<String>

The index the interest floats on, by registry code; None for a fixed-rate loan.

Implementations§

§

impl Loan

pub fn new( schedule: &Schedule, currency: Currency, notional: f64, fixed_rate: f64, day_count: DayCountFraction, borrower: bool, ) -> Self

A loan of notional over schedule at fixed_rate on day_count, each period’s interest paid on its accrual end. borrower takes the drawdown and pays the servicing; a lender the reverse.

§Panics

If schedule has fewer than two dates.

pub fn floating( schedule: &Schedule, currency: Currency, notional: f64, index_code: &str, margin: f64, day_count: DayCountFraction, borrower: bool, ) -> Result<Self, String>

A loan whose interest is the index index_code (a registry code, term or overnight) plus margin: a term index projected as the IBOR leg does, an overnight one compounded as the OIS leg does.

§Errors

An index the registry does not know, or one that is not a rate.

§Panics

If schedule has fewer than two dates.

pub fn issued_by(self, credit: CreditCurveId) -> Self

Tags the loan to its borrower’s credit, whichever side books it.

pub fn with_rate(&self, rate: f64) -> Self

This loan restruck at rate: every fixed coupon’s rate replaced.

pub fn with_margin(&self, margin: f64) -> Self

This loan restruck at margin: every floating coupon’s spread replaced.

fn restruck(&self, edit: impl FnMut(&mut AnyCoupon)) -> Self

pub fn notional(&self) -> f64

The principal drawn.

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

The principal still owed on date: the drawdown less every repayment paid on or before it.

pub fn start(&self) -> NaiveDate

The drawdown date.

pub fn maturity(&self) -> NaiveDate

The last servicing payment date.

pub fn amortising_straight_line(self) -> Self

This loan amortising to zero in a straight line (Amortisation::StraightLine): over n periods, period i’s interest accrues on N − i·N/n, and N/n is repaid at each period’s end.

§

impl Loan

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

The interest accrued on date in the period containing it, on that period’s outstanding: nothing on a period’s first day.

§

impl Loan

fn risky_servicing<R: Scalar>( &self, view: &PricingView<'_, R>, ) -> Result<R, PricingError>

The servicing’s risky value from the booked side: the borrower’s promises, signed as the lender receives them, survival-weighted with recovery on the outstanding, then turned to the side that books it — so a lender and a borrower see one credit and exact negatives.

Trait Implementations§

§

impl Clone for Loan

§

fn clone(&self) -> Loan

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 Debug for Loan

§

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

Formats the value using the given formatter. Read more
§

impl PartialEq for Loan

§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl<R: Scalar> Priceable<R> for Loan

§

fn npv(&self, view: &PricingView<'_, R>) -> Result<R, PricingError>

The drawdown and the servicing, each leg on the discount curve; a tagged loan’s servicing survival-weighted, the drawdown risk-free.

§

fn par_rate(&self, view: &PricingView<'_, R>) -> Result<R, PricingError>

The fixed rate at which the loan, otherwise unchanged, is worth nothing — risky when tagged. The value is affine in the rate, so two restrikes give it exactly: −V(0) / (V(1) − V(0)).

§

fn par_spread(&self, view: &PricingView<'_, R>) -> Result<R, PricingError>

The margin over its index at which a floating loan is worth nothing, by the same two restrikes.

§

impl PricingRiskFactors for Loan

§

fn risk_factors(&self) -> Result<RiskFactors<'_>, PricingError>

The collateral’s discount curve, and a floating loan’s index; a tagged loan also its borrower’s credit and a market recovery.

§

impl Product for Loan

§

fn currency(&self) -> Currency

The currency the product pays in. An FX product values in its quote currency; a book converts.
§

fn contract_dates(&self) -> Vec<(&'static str, NaiveDate)>

The contract dates the product resolved to, as (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>>

The legs the product itself holds, in a declared order, or 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>

The date of the product’s final payment, where a calibration rung can be built on it; None for a product no ladder is built from.
§

fn restruck_at_rate(&self, _rate: f64) -> Option<AnyInstrument>

This product re-struck at the par rate 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>

This product re-struck at the basis spread spread on its spread leg, or None for a product that quotes none.
§

impl StructuralPartialEq for Loan

Auto Trait Implementations§

§

impl Freeze for Loan

§

impl RefUnwindSafe for Loan

§

impl Send for Loan

§

impl Sync for Loan

§

impl Unpin for Loan

§

impl UnsafeUnpin for Loan

§

impl UnwindSafe for Loan

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.