Module pricers
Expand description
The pricers: one generic implementation per product.
Each impl block below is written once, against R: Scalar, and serves
every pricing mode. There is no per-mode duplicate anywhere in this file, and
that is the property 6.7 asks for — a pricing body that had to be written
twice would mean the seam had not actually abstracted the mode.
They live here rather than with the instrument types because pricing needs the resolved market view, and the view is this layer’s business. An instrument that fetched its own curves would invert the layering.
Macros§
- fixed_
float_ 🔒priceable - The fixed-float swap valuation, one body for the vanilla and the overnight swap: their legs, index and collateral are the same fields, and only the product name a refusal reports differs.
Structs§
- Caplet
- One caplet of a strip, passively: what a formula prices it on.
- CdsLegs 🔒
- A CDS’s leg values from one pass: the premium leg’s annuity and value, the protection leg’s value, and the settlement flows.
- CdsOption
Value - A single-name CDS option’s value, and the forward it was struck against.
- Credit
Linked 🔒Components - A credit-linked swap’s components from one pass, in the trade currency.
- Credit
Walk 🔒 - The premium schedule and protection start of a standard credit contract, walked as the contract runs: periods ending on or before the protection start are skipped (the first accrual still starts at the prior IMM date), protection is discounted at each period’s midpoint and premium at its payment date, both clamped to the valuation.
- Discretized
Bermudan 🔒 - The rollback asset for a Bermudan swaption: per exercise slice, the
affine factors of every remaining fixed payment’s discount bond seen from
that date, so the co-terminal swap’s model value at a node is
N·(P(t,S) − Σ c_i·A_i·e^{−B_i·r})withc_i = (K + s)·τ_i(sthe basis spread that strikes on the swap’s own floating leg), the unit redemption on the last, andP(t,S)the par leg at the delivered swap’s start. The factors are in the mode — they carry the curve’s and the parameters’ sensitivities — and the exercise decision compares passive values, freezing nothing: the exercised node takes the model value, which is itself active. - Discretized
Callable 🔒Bond - The rollback asset for a callable/puttable bond: face-scaled
(step, amount)cashflow injections plus(step, dirty redemption, kind)exercise entries, all on exact grid slices, step-sorted. Amounts are passive — they are contract terms — and enter the mode arithmetic as right-hand operands. - Discretized
Callable 🔒Loan DiscretizedCallableBondwith its flows and strikes in the pricing mode: a callable loan’s floating coupons read the curves.- Future
Option 🔒Parts - A futures option’s per-100 value and the parts it is built from, in the mode.
- FxOption
Inputs 🔒 - What every FX-option verb starts from: the parity forward to delivery, the two discount factors, the option’s life, and the surface.
- Index
Intrinsic - An index CDS measured against its constituents: the replicating single-name portfolio’s value, and its duration-weighted spread.
- Index
Period 🔒 - One premium period an index pays after an option’s expiry: years from expiry to its start (expiry itself, for the period running across it) and its payment, its accrual, the years it had accrued by its start, and the forward discount factors from expiry to its start and payment.
- Index
Skew - The skew adjustment of an index’s constituents: one piecewise-constant
term structure of hazard multipliers,
(pillar, factor)in pillar order, that every constituent’s curve is scaled by (ScaledSurvival). - Lattice
Moments - The callable’s clean price and its first two derivatives with respect to a parallel continuous shift of the discounting, from one lattice pass.
- Loan
OnLattice 🔒 - A callable loan’s servicing on its Hull-White lattice, from the lender’s
side: its fixed flows and exercises on their steps, and each floating
coupon still to fix as
(start step, payment step, N). - Side
Curves 🔒 - The curves one side of a cross-currency swap prices on.
Enums§
- Resolved
Recovery 🔒 - A tranche’s recovery model as the view resolves it: the contract’s, or Amraoui–Hitier on the market’s lifted floor.
Constants§
- INDEX_
OPTION_ 🔒BOUND - How far into either tail of the spread’s normal driver an index option
integrates:
|z| ≤ 8holds the density to ~1e-15. - INDEX_
OPTION_ 🔒NODES - Gauss–Legendre points on each side of an index option’s exercise boundary.
- MARGIN_
BRACKET 🔒 - The bracket a discount margin is searched over — the spread bracket, since a margin is a spread.
- OAS_
ITERATION_ 🔒CAP - The spread solves’ backstop. A 0.4-wide bracket reaches
f64resolution in about fifty halvings even if every interpolated step were refused; the tolerance exits long before, and hitting this is a reported failure. - ONE_BP 🔒
- One basis point, the unit
Leg::bpvreports in.
Functions§
- bracketed_
root 🔒 - The root of a monotone
fon[0, ∞): bracketed from[0, 1]by doubling the upper end, then refined by Illinois false position until|f| ≤ tolerance.Nonewhen no bracket is found. - callable_
oas_ with - The continuous OAS implied by a quoted clean price — a passive solve.
- caplet_
times 🔒 - The expiry a caplet is keyed on and the time its variance accrues over.
- cash_
annuity 🔒 - The par-yield cash annuity:
DF(S)·N·Σ τₖ·(1 + F/f)^(−f·tₖ)over the fixed periods entered on or after the expiry, withSthe first entered period’s accrual start,tₖthe fixed day count’s year fraction fromSto each payment andfthe fixed leg’s periods a year — the fixed leg discounted at the forward swap rate itself, as the ISDA cash-settlement par yield curve method defines it. In the mode, so its rate sensitivity flows through the forward. - cds_
option - A single-name CDS option under Black’s model on the forward spread: the
right at
expiryto enterunderlying— the CDS the option exercises into, its protection starting after expiry — a payer (the right to pay thestrikespread, buying protection) or a receiver (the right to receive it).shortis the seller’s side: the same option, its value negated. - cip_
forward 🔒 - The covered-interest-parity forward
spot·DF_base(T)/DF_quote(T), quote per one base, from the two resolved curves and the pair spot. - clean_
price_ at_ oas_ with - The clean price per 100 face of
bondat a given continuous OAS, in the caller’s mode. - conversion 🔒
- What one unit of a non-deliverable leg’s currency paid on
paysis worth today in the settlement currency, converted ashowsays: - converted_
annuity 🔒 - A non-deliverable leg’s annuity in the settlement currency: each coupon’s
notional · τtimes its conversion, principal exchanges left out — the value one unit of fixed rate adds, signed by the leg’s side. - effective_
risk_ 🔒of - The callable’s
LatticeMomentsat a given OAS: one lattice build, one rollback, in second-order forward mode. - exact_
step 🔒 - The slice
datesits on, which must be exact. - exercise_
steps 🔒 - The
(step, strike, kind)exercises ofliveentries aftercut: each on its date rolled bypays_on(Bermudan), or underamericanon every slice from its date to the slice before the next entry’s, the last on its date alone.strike(entry, on)is the redemption onon, in currency. - exercised 🔒
E[max(±X(z), 0)]over a standard normal driverz, for a payoffXrising inz: the payer’s side above the exercise boundary, the receiver’s below it, each by Gauss–Legendre. The boundary is found passively — the payoff is zero on it, so it carries no first-order term.- fair_
forward_ rate - The fair forward rate of
forward— the covered-interest-parity forward to its value date, quote per one base: the contract rate at which it is worth nothing. - fair_
margin_ with - The funding margin that zeroes a total return swap, closed-form.
- forward_
and_ 🔒annuity - The underlying’s forward swap rate and its fixed-leg annuity
Σ τ_i·N·P(t, T_i)— the two curve quantities the option formula needs, both read off the swap’s own legs. The annuity is reported positive whichever side pays fixed: the option formula supplies the sign. - forward_
yield_ 🔒error - A passively solved forward yield that cannot be found, as a pricing error.
- fra_
rate 🔒 - The FRA’s contract rate: the published fixing once the fixing date has passed, or once it has printed on the fixing date itself, else the simple forward over the accrual on the projection curve.
- fra_
settlement - The FRA’s settlement amount, paid on the accrual start: the accrual
difference discounted by the contract rate itself,
side · N · τ · (r − K) / (1 + τ·r). The factor is the contract, not an approximation — paying the undiscounted difference at the accrual end is a different instrument, and one no market quotes. - futures_
convexity - The contract’s convexity adjustment, as a rate: its futures rate less the forward rate of the same contract with no adjustment — the Hull–White model’s where the contract is priced under it, the stated spread otherwise, a term or an overnight contract alike. In the mode.
- futures_
price - The model price,
100 − 100 · futures rate, in price points. - futures_
rate 🔒 - The contract’s futures rate plus the convexity adjustment: for a contract on an overnight index, its reference period’s overnight rate — realised days from the fixings, today’s if it has printed, the rest projected, compounded or averaged as the contract settles; for a contract on a term rate, the simple forward over the accrual on the projection curve.
- fx_
option_ 🔒inputs - hull_
white_ 🔒basis - The deterministic basis spread a Hull-White swaption strikes on, entering
on
startthe fixed periodsenteredas(payment date, accrual):s = (P(S) − P(tₙ) − FL)/Aper unit notional, so that the discount par leg the one-factor model values,P(S) − P(tₙ), less(K + s)·Ais the delivered swap’s own valueFL − K·A.FLis the present value of the floating coupons whose accrual starts on or afterS, off the index’s projection curve — the payment lag, a projection curve other than the discount curve and a float schedule other than the fixed one are all in it. In the mode, so the basis carries its curve risk. - hull_
white_ 🔒parameters - The view’s Hull-White parameters, refusing a view without them — a hand-built view lacking the model is a missing input, not a zero-vol price.
- implied_
repo 🔒 - A deliverable’s implied repo and the coupons it pays inside the window:
every coupon paid after
valuationand on or beforedelivery, reinvested to delivery at the implied repo itself, soI + Σcᵢ(1 + r·τᵢ) = P(1 + r·τ)andr = (I + Σcᵢ − P) / (P·τ − Σcᵢ·τᵢ), simple onday_count. A non-positive price or denominator reads a rate of zero. - index_
intrinsic - The intrinsic value and spread of
indexfrom its constituents. - index_
skew - Solves the skew that makes an index’s constituents reprice it.
- isda_
annuity 🔒 - The risky annuity from expiry at a quoted spread
s, as the ISDA standard model converts a quote to an upfront: the flat hazard at which the periods’ protection, at losslgd, is worthstimes their premium, and the premium’s value per unit spread at that hazard. - leg_
boundaries 🔒 - A leg’s accrual boundaries: every coupon’s start, then the last end.
- leg_
value 🔒 - A leg’s value in the currency it settles in: its ordinary value off
discfor a deliverable leg; for a non-deliverable one, each payment still to come converted into the settlement currency byconversionand discounted on the settlement currency’s curve. No quanto adjustment is applied. - loan_
clean_ 🔒price_ at_ oas_ with - A callable loan’s clean price per 100 of its outstanding at a continuous
oas, asclean_price_at_oas_withreads a callable bond’s. - loan_
oas_ 🔒with - The continuous OAS at which a callable loan’s clean price is
clean_price, a passive solve ascallable_oas_with’s. - non_
deliverable_ 🔒par_ rate - The fixed rate that values a non-deliverable swap at zero, given its
floating leg’s converted value: off the fixed leg’s converted annuity for a
leg paying per coupon, and in closed form —
(1 + A/N)^(1/τ) − 1— for one accruing a compounded rate into a single payment, as BRL’s does. - note_
z_ spread_ with - The z-spread implied by a structured note’s dirty price per 100 of face —
the flat continuously-compounded spread
sover the note’s discounting for whichΣ aᵢ·DF(tᵢ)·exp(−s·τᵢ)reprices it: the note’s twin ofz_spread_with, and a passive solve as that is. - oas_
solve 🔒 - The spread at which
clean_at, monotone decreasing, repricesclean_price. - option_
kind 🔒 - A payer is a call on the forward swap rate, a receiver a put.
- overnight_
hull_ 🔒white_ rate - An overnight contract’s futures rate under Hull–White, from its strip
rate
rate(realised days read, the rest projected, no convexity). - own_
currency_ cash - The default collateral for a currency: own-currency cash.
- par_
by_ 🔒linearity - The root of a value affine in one contract number, from the product
struck at 0 and at 1:
−V(0) / (V(1) − V(0)). - par_
rate_ 🔒of - The par rate of a fixed-against-floating swap.
- require_
annuity 🔒 - Rejects a zero annuity before a par measure divides by it.
- risky_
from 🔒 risky_on_viewwith the default walk starting atdefault_from— a loan or deposit not yet drawn cannot default on principal it has not lent.- risky_
on_ 🔒view - The survival-weighted value of
flowswith the view’s credit, refusing a view without a market recovery — a hand-built view lacking one is a missing input, not a zero-recovery price. - running_
coupon 🔒 - The running coupon of a standard credit contract.
- settlement_
fixing 🔒 - The rate a cash-settled forward nets at, quote units per one base unit:
the published fixing once its date has passed or it has printed today,
else the parity forward
spot · DF_base / DF_quote, which a physical forward always reads. - spread_
solve_ 🔒error - The spread kernel’s failure, in the seam’s own taxonomy.
- step_
credit 🔒 - The view’s credit on
grid’s steps, recovering onface_at— the same refusals asrisky_on_viewfor a missing curve or recovery. - z_
spread_ with - The z-spread implied by a bond’s dirty price against a resolved view — a passive solve, as the OAS is.
Type Aliases§
- Affine
Payment 🔒 - One remaining fixed payment seen from an exercise slice: the affine
factors
(A, B)of its discount bond and its coupon(K + s)·τ(plus the unit redemption on the last),sthe slice’s basis spread.