Skip to main content

Repo

Struct Repo 

pub struct Repo {
Show 14 fields pub terms: RepoTerms, pub cash: f64, pub collateral: FixedRateBond, pub nominal: f64, pub repo_keys: Vec<String>, pub coupons: CouponTreatment, pub counterparty: Option<String>, pub discount: CollateralSpec, pub floating: Option<OvernightCoupon>, pub window: Vec<WindowCoupon>, pub interest_dates: Vec<NaiveDate>, pub interest_strips: Vec<OvernightCoupon>, pub fx_rate: Option<f64>, pub collateral_discount: Option<CollateralSpec>,
}
Expand description

A repo, reverse repo or buy/sell-back on one bond.

Fields§

§terms: RepoTerms

The shared terms.

§cash: f64

The near-leg cash amount.

§collateral: FixedRateBond

The collateral bond.

§nominal: f64

The collateral’s face amount.

§repo_keys: Vec<String>

The repo keys tried in order: the security’s, its group’s, the currency’s general collateral. The first the market holds prices; a trade naming one key holds that key alone.

§coupons: CouponTreatment

What happens to a coupon inside the term.

§counterparty: Option<String>

The counterparty, for reporting.

§discount: CollateralSpec

The discount key the seam needs; the cash leg reads the repo curve.

§floating: Option<OvernightCoupon>

For a floating repo, the compounding strip over [start, end], at unit notional and carrying the spread.

§window: Vec<WindowCoupon>

The collateral’s coupons paid in (start, end].

§interest_dates: Vec<NaiveDate>

Interim dates the cash leg pays its interest on, strictly inside the term. Empty pays it all at the far date with the principal.

§interest_strips: Vec<OvernightCoupon>

For a scheduled floating repo, the compounding strip of each interim period, in order; the last period’s is floating.

§fx_rate: Option<f64>

For a cross-currency repo, the contract FX rate the cash and the collateral were sized at: cash-currency units per collateral-currency unit. None when the two share a currency.

§collateral_discount: Option<CollateralSpec>

For a cross-currency repo, the collateral currency’s cash collateral: the curve its bond is valued on for margin.

Implementations§

§

impl Repo

pub fn from_cash( terms: RepoTerms, collateral: FixedRateBond, cash: f64, price: f64, ) -> Result<Self, RepoError>

A repo on cash, with the collateral nominal that covers it at the margin ratio and price (per 100, on the margin basis).

§Errors

RepoError as from_collateral.

pub fn from_collateral( terms: RepoTerms, collateral: FixedRateBond, nominal: f64, price: f64, ) -> Result<Self, RepoError>

A repo on nominal face of collateral at price (per 100, on the margin basis): cash = nominal·price/100/margin_ratio.

§Errors

RepoError::MixedCurrencies when the collateral or a floating index is not in the cash currency; RepoError::Malformed for an end not after the start, a non-positive amount, price or margin ratio, a collateral maturing inside the term, or an index the registry does not hold as an overnight index.

pub fn cross_currency_from_cash( terms: RepoTerms, collateral: FixedRateBond, cash: f64, price: f64, fx_rate: f64, ) -> Result<Self, RepoError>

A cross-currency repo on cash, the collateral in its own currency covering it at the margin ratio, price (per 100, in the collateral’s currency, on the margin basis) and the contract fx_rate (cash units per collateral unit): nominal = cash·margin_ratio·100/(price·fx_rate). Classic: the collateral’s coupons are manufactured in its currency.

§Errors

RepoError::Malformed for an FX rate that is not positive and finite, a collateral in the cash currency, or as from_collateral.

pub fn cross_currency_from_collateral( terms: RepoTerms, collateral: FixedRateBond, nominal: f64, price: f64, fx_rate: f64, ) -> Result<Self, RepoError>

A cross-currency repo on nominal face of collateral at price (per 100, in its own currency) and the contract fx_rate: cash = nominal·price·fx_rate/100/margin_ratio.

§Errors

As cross_currency_from_cash.

fn build( terms: RepoTerms, collateral: FixedRateBond, cash: f64, nominal: f64, fx_rate: Option<f64>, ) -> Result<Self, RepoError>

pub fn with_interest_dates( self, dates: Vec<NaiveDate>, ) -> Result<Self, RepoError>

The same repo paying its interest on dates: each period’s cash · r · τ on its end date, the last with the principal at the far date. A floating repo compounds its index over each period on its own strip.

§Errors

RepoError::Malformed on a buy/sell-back (whose coupons net at the far date), or dates not strictly ascending inside the open term.

pub fn interest_periods(&self) -> Vec<(NaiveDate, NaiveDate, f64)>

The cash leg’s interest periods as (start, end, τ): one over the whole term, or one per interim date and the last to the far date.

pub fn financed_on(self, key: impl Into<String>) -> Self

Financed on key alone: a missing curve under it is refused naming it.

pub fn financed_on_security(self, isin: &str, group: Option<&str>) -> Self

Financed on the security’s own key, its repo group’s, then the currency’s general collateral — the special-to-GC cascade. A missing special prices as GC; a missing GC is refused naming it.

pub fn with_coupons(self, treatment: CouponTreatment) -> Self

This repo with treatment for the coupons inside its term.

pub fn with_counterparty(self, counterparty: impl Into<String>) -> Self

This repo facing counterparty.

pub fn sign(&self) -> f64

+1 for the cash lender, −1 for the borrower.

pub fn year_fraction(&self) -> f64

The accrual over [start, end] in the repo’s day count.

pub fn accrued_strip(&self, to: NaiveDate) -> Option<OvernightCoupon>

For a floating repo started before to, the strip from the start to to — what the cash has accrued by then.

pub fn haircut(&self) -> f64

The haircut the margin ratio implies: 1 − 1/margin_ratio (GMRA), so 102% margin is a 1.96% haircut, not 2%.

§

impl Repo

fn priced_curve<'v, 'a, R: Scalar>( &self, view: &'v PricingView<'a, R>, ) -> Result<(&'v ResolvedCurve<'a, R>, usize), PricingError>

The repo curve that prices and the tier it came from, counting the cascade from the security (0) to the general collateral (last).

pub fn repo_curve_of<'v, 'a, R: Scalar>( &self, view: &'v PricingView<'a, R>, ) -> Result<&'v ResolvedCurve<'a, R>, PricingError>

The repo curve that prices this repo on view.

§Errors

As Priceable::npv.

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

The tier of the cascade that prices this repo on view: the security (0), its group (1), or the general collateral (the last).

§Errors

As Priceable::npv.

fn accrual<R: Scalar>( &self, from: NaiveDate, strip: Option<&OvernightCoupon>, view: &PricingView<'_, R>, ) -> Result<R, PricingError>

The accrual I over the strip from from to the far date: r·τ for a fixed rate, the compounded index plus the spread times τ for a floating one.

pub fn coupon_growth<R: Scalar>( &self, coupon: &WindowCoupon, view: &PricingView<'_, R>, ) -> Result<R, PricingError>

What one unit of coupon is worth at the far date: grown at the repo’s own rate from its payment date, 1 + I(t_c, end) — or, paid after the far date, carried back, 1 − I(end, t_c), the simple period run in reverse.

§Errors

As Priceable::npv.

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

The far amount the contract fixes: N·(1 + I), less — for a buy/sell-back — each coupon the lender is entitled to over the term, carried to the far date at the repo’s own rate.

§Errors

As Priceable::npv.

pub fn interim_periods<R: Scalar>( &self, view: &PricingView<'_, R>, ) -> Result<Vec<(NaiveDate, NaiveDate, f64, R)>, PricingError>

The interim periods still unpaid as (start, end, τ, rate): the fixed rate, or the period’s compounded index plus spread on its own strip.

§Errors

Whatever the projection and fixings report.

fn interim_interest<R: Scalar>( &self, view: &PricingView<'_, R>, curve: &dyn YieldCurve<R>, ) -> Result<R, PricingError>

The interim interest payments still owed, each cash · r · τ discounted on curve from its own date; zero on an unscheduled repo.

fn unpaid_annuity<R: Scalar>( &self, view: &PricingView<'_, R>, curve: &dyn YieldCurve<R>, ) -> Result<R, PricingError>

cash · Σ DF(tᵢ) τᵢ over the periods still unpaid, the last included, each τ the one its interest accrues on.

fn scheduled_terms(&self) -> Result<(), PricingError>

A schedule booked and the coupons switched to buy/sell-back after it: the far amount nets coupons a periodic leg has no place for.

fn far_slope(&self) -> f64

How the far amount moves per unit of rate (fixed) or spread (floating): N·τ less each netted coupon’s c·τ_c.

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

The rate (fixed) or spread (floating) at which the cash leg is worth nothing: the far amount that repays the cash at the repo curve’s own forward, reached from the trade’s along the far amount’s slope.

§

impl Repo

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

The trade with its collateral: the cash leg plus the bond received, less the bond returned at its repo forward, less — classic — the coupons manufactured back. The forwards are financed and discounted on the repo curve, the spot on the trade’s discount curve. A foreign bond (a cross-currency repo) is valued in its own currency on its own discount curve — no repo curve of the cash currency finances it — and converted at spot, as its margin is.

§Errors

As Priceable::npv, and a cross-currency repo without the collateral currency’s discount curve.

pub fn package_value(&self, market: &MarketContext) -> Result<f64, PricingError>

package_value_with against market.

§Errors

As Priceable::npv.

pub fn margin(&self, market: &MarketContext) -> Result<RepoMargin, PricingError>

The margin position on market, the collateral priced off its curves on the margin basis.

§Errors

As Priceable::npv.

pub fn margin_at( &self, market: &MarketContext, price: f64, ) -> Result<RepoMargin, PricingError>

The margin position on market with the collateral at a quoted price per 100 on the margin basis — a screen mark.

§Errors

As Priceable::npv.

fn margin_on( &self, view: &PricingView<'_, f64>, price: f64, ) -> Result<RepoMargin, PricingError>

fn priced_passive<T>( &self, market: &MarketContext, measure: impl FnOnce(&Self, &PricingView<'_, f64>) -> Result<T, PricingError>, ) -> Result<T, PricingError>

Trait Implementations§

§

impl Clone for Repo

§

fn clone(&self) -> Repo

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 Repo

§

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

Formats the value using the given formatter. Read more
§

impl PartialEq for Repo

§

fn eq(&self, other: &Repo) -> 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 Repo

§

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

sign · CashLeg on the repo curve: F·P(end) − N·P(start) before the start, F·P(end) after it, nothing from the far date on — the deposit’s three datings, with the far amount the contract fixes.

§

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

The fixed simple rate at which this repo, under its own coupon treatment, is worth nothing. A floating repo quotes a par spread.

§

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

Fixed: the trade’s rate less the par rate. Floating: the spread over the compounded index at which the repo is worth nothing.

§

impl PricingRiskFactors for Repo

§

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

Financed on the cascade’s last key — the currency’s general collateral, or the one key named — which must resolve, and on the tiers before it, which may be absent; discounted by its own currency for the seam; and, floating, projecting its overnight index.

§

impl Product for Repo

§

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 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_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 Repo

Auto Trait Implementations§

§

impl !RefUnwindSafe for Repo

§

impl !UnwindSafe for Repo

§

impl Freeze for Repo

§

impl Send for Repo

§

impl Sync for Repo

§

impl Unpin for Repo

§

impl UnsafeUnpin for Repo

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.