Repository navigation
Releases
qeLib 0.4.0
Summary
- Breaking changes. A credit index's version after a credit event is
now described on its own outstanding notional, as the market quotes it.
Index and tranche objects saved by 0.3.0 after version 1 no longer load.
Data.FxRatetakes the date it is observed on. Government z-spreads take
an optional settlement curve. The flat-spread conversions,
Data.BespokeCds,Curves.termRateHedgesand index option quote sheets
change their inputs. Interface changes, below, says what to change. - Implied quotes. CDS and index CDS quotes, swaption, cap, FX and
index CDS option volatilities, and base correlations, each implied by
the curves, model or surface that prices them. - Credit. Robust CDS strips correct the quotes they cannot match. New
quote types hold CDS and index quotes in flat spreads. Index CDS options
can now use the SABR model. The index and tranche greeks give each
name's jump to default. Credit events can settle as of the end of the
valuation date. - FX. FX options are valued at a time of day, to their expiry cut. A
spot rate can be moved to another date, as a theta needs. - Rates. A rates model's density can be shocked. The SABR calibrations
and the caplet strip have a Jacobian to the curves. - Numerics. Black and Bachelier implied volatilities and the normal
distribution use Jäckel's methods. - Tools. The SPI log tools ship with qeLib. Each reported cashflow has
a type.
Interface changes
These may need changes to workbooks and scripts written for 0.3.0.
-
A government z-spread is matched by the value today, the settlement
amount on its own curve.Bonds.governmentBondZSpreadPriceand
governmentBondZSpread, and the bills'governmentBillZSpreadPriceand
governmentBillZSpread, take an optionalsettlementDiscountCurve,
typically OIS, as the government curve fits do. The price at a z-spread
is now the one at which a trade is worth nothing today: its cashflows
valued aspvGovernmentBondZSpread(pvGovernmentBillZSpread) values
them - on the curve shifted by the spread from its base date, the
valuation date - equal to its settlement amount discounted on the
settlement curve, or on the curve itself if that is omitted. Before, the
cashflows were taken to the settlement date on the curve alone and
shifted from there, so a holding valued at its z-spread was not worth its
price, and a security a fit with an OIS settlement curve reprices had a
small z-spread over it. Now it has none. The spread shifts from the
valuation date, not settlement, so z-spreads differ slightly even with no
settlement curve. -
The flat-spread conversions take and give the spread quote types.
IsdaCds.cdsCurveFromSpreadsandcdsCurveFromSpreadsJacobiantake a
Data.CdsSpreadCurve,indexCdsQuotesFromSpreadsand its Jacobian a
Data.IndexCdsSpreadQuotes, andindexCdoQuotesFromReferenceSpreads
and its Jacobian aData.IndexCdoSpreadReferenceQuotes, each with the
recovery rate, the ISDA discount curve and the holiday calendars, in
place of the type's fields as arguments. The quotes must be observed on
the discount curve's base date, the trade date, which the conversions
used to set.IsdaCds.cdsCurveToSpreadsgives aData.CdsSpreadCurve,
not an array, and refuses a curve whose quotes have different coupons
or that has no quotes. What they give is unchanged. -
An index version after a credit event is in the market's convention.
A version is now described on its own outstanding notional, as the index
administrator publishes it. What describes a version carries its index
factor,indexFactor(1 by default, and at version 1):Data.IndexCds,
Data.IndexCdo,Data.IndexCdsQuotes,Data.IndexCdoQuotes,
Data.IndexCdsSpreadQuotesandData.IndexCdoSpreadReferenceQuotes,
andIndexCds.makeStandardandIndexCdo.makeStandardtake it.
Data.IndexCdsKeyonly identifies the version. The constituents' weights of an
IndexCdsorIndexCdoadd up to 1: each name is 1/124, not 0.008,
once 1 of 125 has defaulted. Tranche points andData.BaseCorrelation
detachments are fractions of the version's outstanding notional:
(X - L) / (1 - w) for a point X of the previous version, w the
defaulted weight and L its loss, the senior tranche detaching at 100%.
At 30% recovery on 1 of 125 names, 0-3% becomes 0-2.4597% and 3-7%
becomes 2.4597-6.4919%.IndexCds.applyCreditEvent,
IndexCdo.applyCreditEvent,BaseCorrelation.applyCreditEventand the
threeapplyCreditEventTo...Quotesfunctions give the next version in
these units, and everything that takes a version reads them: the index
strip, the index and tranche pricers, base correlation calibration and
mapping,impliedBaseCorrelationand the option pricers.
indexFactor()on an index or tranche is now itsindexFactor
attribute, andoutstandingFactor()the factor times the weights' sum
(which differs for a part of a version-1 index). The market still names
a tranche by its points at version 1, its quoted points:
Data.IndexCdocarriesquotedAttachmentandquotedDetachment, and
Data.IndexCdoQuotes(and the spread reference quotes)
quotedAttachmentsandquotedDetachments, required arguments right
after the points (and after them inIndexCdo.makeStandard), the
points themselves while the index factor is 1.makeV1on each of the
three makes one on version 1 with the quoted points and factor filled
in. The tranche factor,trancheFactor()(trancheFactors()on
the quotes), is the outstanding notional per unit of quoted notional:
the width times the index factor over the quoted width - in Markit's
CDX.NA.HY 33 example, 0.9395 for the 0-15% equity and 0.99858 for the
35-100% super senior. The credit events keep the quoted points and set
the factor. A trade's notional is its current notional, which its legs
are on:IndexCds.makeStandardis given the original notional and
applies the index factor, andIndexCdo.makeStandard(and
generateIndexCdo) the quoted notional and applies the tranche factor -
10m quoted at a tranche factor of 0.8133 is a trade of 8.133m. Before,
IndexCdo.makeStandardtook the current notional; calls after version
1 must give the quoted one. Upfronts and deltas stay
per unit of each tranche's and index's own outstanding notional, and an
index option'ssettledLoss, prices and exercise price stay per unit of
original notional. Values and risks are unchanged: tests price each
next version both ways, in the market's convention and in the original
notional's units, and get the same value. Bespoke tranches keep their
pool's original notional.This breaks objects made after version 1 in the previous convention. An
IndexCdsorIndexCdoafter version 1 whose weights do not add up to
1 is refused, so one saved by 0.3.0 fails to load rather than pricing
wrongly. Make it again with its index factor, its weights over the
factor, its points over the factor and its quoted points. Code making a
tranche or tranche quotes passes the quoted points after the points, or
usesmakeV1at version 1. The notes on the
quote conversions now say when the next version trades: once the
Determinations Committee has announced the event, around its event
determination date, for the events covered (not restructuring). -
An index option quote sheet keeps the version its options were traded
on. Options keep referencing their version for their whole life, and
dealers keep quoting them on it after a name defaults.
CreditOption.applyCreditEventToIndexCdsOptionQuotesnow takes only the
sheet, the index as its options stand and the event. It keeps the
sheet's key, strikes, prices, forward and reference as quoted, adds the
names' loss to itssettledLossas for a traded option, and gives the
index's next version. It no longer converts the reference, and accepts
a sheet observed on any date.settledLossis now the loss since the
key's version.impliedIndexCdsVolatilitiesand the functions that
take a sheet accept an index of the sheet's version or a later one: the
current version, as the same events leave it, on the names left's
curves.impliedIndexCdsOptionQuotestakesquotesKey, the version the
options were traded on, aftersettledLoss. A sheet saved after an
event on the next version's key no longer fits its options: apply the
events to the sheet as quoted. Values are unchanged. -
Data.BespokeCdstakes a fixed recovery for each contingent leg.
fixedRecoveryis empty, or has one recovery for each contingent leg, in
the order ofcontingentLegs. Each leg pays one minus its own recovery,
inCreditCorrelation.pvBespokeCds, its greeks and
Data.BespokeCds.applyCreditEvent. Before,fixedRecoveryhad at most
one entry, which applied to every leg. A swap with one contingent leg is
unchanged. A swap saved by 0.3.0 with one fixed recovery and several
contingent legs no longer loads: give the recovery once for each leg. -
Curves.termRateHedgestakes the overnight index.overnightIndex,
the third input, is the currency's overnight index, the one the OIS strip
given toCurves.termRateStripwas built on. The overnight leg of each
basis swap hedge names it, so a book that holds the hedges knows which
index's curve and fixings that leg takes. Before, the leg named no index.
Calls must add it afterindex. -
Data.FxRatehas an observation date.observationDate, its first
input, is the date the rate is observed on, and its spot date is
spotDaysbusiness days after it. Before, the spot date was taken from
the discount curves' base date. Each FX pricer, strip, hedge and
cashflow function now refuses a rate observed on another date than its
curves' or quotes' base date. A fixing applied to a trade must be
observed on t...
qeLib 0.3.0
Interface changes
Data.Cds,Data.NthToDefault,Data.IndexCdo,Data.BespokeCdoand
Data.BespokeCdsno longer keep holiday calendar names. Nothing used
them: these instruments' dates are already adjusted. Their constructors
lose their last input,holidays, and the types the field. The
makeStandardfunctions still take the names and the calendars, to
adjust the dates. Objects saved by 0.2.0 still load, without the names.
Data.IndexCdskeeps its names, which options on it use for their
settlement and strike conversion.
SPI's runtime libraries in these binaries are PeterTaylor2/spi at 2120211, unmodified, built without curl (G_SPI_NO_CURL=1). Their source is spi-source-2120211.zip, below.
qeLib 0.2.0
Interface changes
These may need changes to workbooks and scripts written for 0.1.0.
- Six Data types are built only by their make functions. Their
constructors took optional fields that had to be set in combination, or a
swap of a kind they then refused. Each make function takes only arguments
that are required, or optional on their own. The types' fields can still be
read, and objects saved by 0.1.0 still load.Data.InterestRateSwap:makeFixedAgainstTermRate,
makeFixedAgainstOvernightandmakeTermRateAgainstOvernight, as well
asmakeStandardandmakeBasisSwap. A swap with all three kinds of leg
can no longer be made.Data.CmsSwap:makeFixed,makeTermRateandmakeOvernight, one for
each kind of funding leg, as well asmakeStandard.Data.CrossCurrencySwap:makeConstantNotionalandmakeResetting, as
well asmakeStandard.Data.TermRateStub:makeSingleandmakeInterpolated.Data.SwaptionTermRateandData.BermudanSwaptionTermRate:make, as
well asmakeStandard.maketakes the strike, the notional, the fixed
leg's day count and dates, and the term rate leg, in place of a swap.
RatesOption.pvInterestRateLegsInstrumentand
RatesOption.greeksInterestRateLegsInstrumentstake two more optional
inputs,capletModelsandrangeAccrualModel, aftercmsModels, for
range accrual legs. In Excel, and in Python calls that pass inputs by
position,overnightProjection,calendarsandvaluationContextmove
two places along.
New
- A Python wheel for macOS 11 and later, with Python 3.14: one universal2
wheel, for Apple Silicon and Intel Macs. - Range accrual legs,
Data.RangeAccrualLeg, which pay each coupon on
the share of its days on which a rate is in a range. They are built from
three parts: the coupons (Data.RangeAccrualCoupons, fixed or floating),
the range (Data.RangeAccrualRange, between, above or below barriers) and
what is observed (Data.RangeAccrualObservation, a term rate, an overnight
rate or a swap rate). They sit inData.InterestRateLegsInstrument, so a
note is the leg and its notional, and a swap the leg and a funding leg.
Each day is priced from the smile, on caplet models
(RatesOption.CapletModels) or CMS models. A floating coupon not yet fixed
also takes a one-factor Markov model, such asRatesOption.LgmModel. - Callable interest rate legs,
Data.CallableInterestRateLegs: legs of
any kind that one side may call, at par or at call prices, such as
callable notes and cancellable swaps.
RatesOption.pvCallableInterestRateLegsQuadratureand
pvCallableInterestRateLegsFiniteDifferenceprice them on a one-factor
Markov model, with greeks to match.
RatesOption.applyCallableInterestRateLegsCallapplies a call. - Cashflows of Bermudan swaptions and callable legs, at zero volatility:
RatesOption.bermudanSwaptionTermRateCashflows,
bermudanSwaptionOisCashflowsandcallableInterestRateLegsCashflows. - A speed optimisation for calibrating base correlations again after
quotes change,CreditCorrelation.BaseCorrelationPool. It keeps the rows before the first
changed quote and the loss distributions, and matches
calibrateBaseCorrelation's results to the last bit. - Calls from several threads at once. qeLib keeps no state shared between
calls without a lock. The ISDA CDS Standard Model's code has been changed
for this alone; its results are unchanged, andlicenses/NOTICES.txtlists
the changes.
Changed
- Base correlation calibration solves each row by secant steps inside its
bracket, in fewer evaluations. Base correlations change within the
calibration's tolerance. - The greeks of tranches, and the Jacobian of base correlations, take about a
quarter less time. - Beyond the quoted strikes, the smiles of stripped caplet volatilities and of
the swaption cube are smooth in the volatilities, so that greeks hedge to
second order.
Known issues
- Range accruals priced on stripped caplet volatilities
(RatesOption.CapletVolatilityCalculatorStripped) are strongly curved in
the volatilities quoted at the first and last strikes. Beyond those
strikes, the smile's tail widens with its slope at the end, so a hedge
sized by the greeks leaves more of a day's move than on SABR caplet models
(RatesOption.CapletSabrPiecewise), whose smiles have no such tail.
SPI's runtime libraries in these binaries are PeterTaylor2/spi at 2120211, unmodified, built without curl (G_SPI_NO_CURL=1). Their source is spi-source-2120211.zip, below.
qeLib 0.1.0
The first release of qeLib, a library of quantitative finance analytics for
Excel and Python.
What a release contains
- The Excel add-in for 64-bit Excel on Windows, with the User Guide, example
workbooks and the log tool, which turns a log of qeLib calls into a
workbook. - Python wheels for Python 3.13 on 64-bit Windows and Python 3.14 on x86-64
Linux:pip install qelib, thenimport qeLib. - An evaluation license, valid for 90 days. Named developer licenses are
available on request.
Every function is available as qeLib.<Service>.<Name>, in both Excel and
Python.
Services
- Data: dates, tenors, holiday calendars and business-day conventions;
market data; trades and their legs. - Core: numerics and date arithmetic.
- IsdaCds: the ISDA CDS Standard Model, with CDS from a flat spread or
points upfront. - Curves: discount, projection, survival and recovery curves. CDS, OIS,
multi-curve and cross-currency stripping, with turns. Swap and CDS
pricing. - CreditCorrelation: one-factor copulas, recovery models and loss
distributions for index and bespoke tranches and nth-to-default baskets,
with base correlations calibrated to tranche quotes or expected losses. - RatesOption: caps, floors, swaptions and CMS, on Black-Scholes
volatilities or SABR, with SABR calibrated to cap volatilities and
swaption cubes. Bermudan swaptions, by finite differences or by
quadrature. - CreditOption: options on CDS indices, with the default-adjusted
forward, volatility surfaces and implied spread densities. - SRT: significant risk transfer securitisations under the EU CRR: the
capital before and after a transfer, the risk transfer tests, pool
selection, tranche thickness and the output floor. - FxOption: foreign exchange options on SABR, Vanna-Volga or SVI smiles
calibrated to market quotes. - Bonds: government bonds and bills: yields and prices in each market's
convention, curve pricing, z-spreads, and government curves fitted to
prices, including Nelson-Siegel-Svensson. Classic term repos and general
collateral repos on them.
Across the services
- Greeks by adjoint algorithmic differentiation, projected onto the quotes
the curves were built from. - Hedge notionals: the amounts of chosen hedge trades that offset a book's
greeks. - Expected cashflows for every instrument.
SPI's runtime libraries in these binaries are PeterTaylor2/spi at 40aad96, unmodified, built without curl (G_SPI_NO_CURL=1). Their source is spi-source-40aad96.zip, below.