Documentation
Portfolio and risk
Grouping trades into a portfolio, its present value by currency, and bucketed curve risk with NxPortfolio::CalcShapeRisk - DV01 per input quote, equivalent hedge notionals, and what the results do not cover.
A portfolio groups trades, values them together, and measures how its value
moves when the quotes a curve was built from move. The classes are in
NX_Portfolio.h, NX_Trade.h and NX_Counterparty.h.
Trades and portfolios
| Class | Role |
|---|---|
NxCounterparty | A named counterparty (NxCounterparty(name)). |
NxTrade | One instrument held against a counterparty: Init(counterparty, instrument). Any instrument of this release can be held, a swap in particular. |
NxPortfolio | A list of trades and a name: NxPortfolio(trades, name). |
auto cpty = std::make_shared<NxCounterparty>("Desk");
auto trade = std::make_shared<NxTrade>();
trade->Init(cpty, swap); // swap: std::shared_ptr<NxSwap>
NxPortfolio book({ trade }, "SOFR book");
NxWallet pv = book.Pv(*market, today); // market: the IndexGlob
double usd = pv.Amount("USD");
NxPortfolio::Pv(indexGlob, pvDt) adds the trades’ Pv wallets: an amount per
currency, never converted (see Swaps for NxWallet and the pricing
date).
Bucketed curve risk: CalcShapeRisk
NxRiskResult CalcShapeRisk(std::shared_ptr<IndexGlob> revaIndexGlob,
std::shared_ptr<NxShape> revaShape,
const std::vector<std::string> & fraRiskTenors, // e.g. "0x3", "3x6"
const std::vector<std::string> & swapRiskTenors, // e.g. "1Y", "2Y", "5Y"
char riskInterp, // as for the shape
std::string indexName = "") const;
It measures the portfolio’s sensitivity to one shape (one index’s single-curve bootstrap, e.g. the SOFR shape) in buckets you choose, independently of the quotes the curve was actually built from:
- Risk instruments. One FRA per
fraRiskTenorsentry and one swap perswapRiskTenorsentry, on the shape’s own conventions, each with a notional of 1,000,000. Their par rates on the revaluation curves are the risk quotes. - Rebuild. The shape is rebuilt from the risk quotes, and the indexes of its currency are recalibrated on it, on copies: the revaluation curves you pass are not changed.
- Bump and reprice. Each risk quote in turn is moved down then up by half
of 0.01 bp (a central difference), the shape is rebuilt, and the portfolio is
repriced. The DV01 of that bucket is the PV change per 1 bp:
(PV_up - PV_down) / 0.01. - Hedge. The same bumps reprice every risk instrument, which gives the
matrix
M(i, j): the DV01 of risk instrumentjto bucketi. The hedge isM⁻¹ · dv01: the notional of each risk instrument, in millions, receive-fixed positive, whose DV01s add up to the portfolio’s in every bucket.
NxRiskResult holds:
| Member | Content |
|---|---|
tenors, tenorMat | The bucket codes, and the maturity of each risk instrument. |
dv01 | PV change per 1 bp of each risk quote, in the shape’s currency. |
hedge | Equivalent receive-fixed notional per bucket, in millions (zeros if hedgeOk is false). |
dv01Matrix, hedgeOk | The matrix M after inversion, and whether it could be inverted. |
Sort() | Orders every result, the matrix included, by increasing tenor maturity. |
A 20 million receiver of a 10Y swap measured with a 10Y bucket shows a hedge
of +20.000 in that bucket.
What the results do not cover
- One currency. Risk counts only the PV in the shape’s currency
(
Amount(ccy)of the portfolio’s wallet). Legs in other currencies, such as the foreign leg of a cross-currency swap, do not contribute, and no FX risk is computed. Measure each currency against its own shape. - No gamma.
NxRiskResult::gammais filled from the same 0.01 bp bumps, which is below the curve solver’s noise; it is not a usable second-order measure and should not be relied on. Bump the quotes yourself by a larger amount (for example ±1 bp) if you need convexity. - Curve risk only. Special-day (turn) risk and inflation risk are not
produced by
CalcShapeRisk; obtain them by bumping the corresponding inputs and repricing, as the example workbook does. - Credit. The portfolio’s CDS and bond risk methods are not part of this release.
From the library at v1.0.0 (ccaff0b). Edit this page on GitHub