Skip to content

Releases

qeLib 0.4.0

Choose a tag to compare

@mortenbaiandersen-cpu mortenbaiandersen-cpu released this 26 Nov 10:41

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.FxRate takes the date it is observed on. Government z-spreads take
    an optional settlement curve. The flat-spread conversions,
    Data.BespokeCds, Curves.termRateHedges and 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.governmentBondZSpreadPrice and
    governmentBondZSpread, and the bills' governmentBillZSpreadPrice and
    governmentBillZSpread, take an optional settlementDiscountCurve,
    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 as pvGovernmentBondZSpread (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.cdsCurveFromSpreads and cdsCurveFromSpreadsJacobian take a
    Data.CdsSpreadCurve, indexCdsQuotesFromSpreads and its Jacobian a
    Data.IndexCdsSpreadQuotes, and indexCdoQuotesFromReferenceSpreads
    and its Jacobian a Data.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.cdsCurveToSpreads gives a Data.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.IndexCdsSpreadQuotes and Data.IndexCdoSpreadReferenceQuotes,
    and IndexCds.makeStandard and IndexCdo.makeStandard take it.
    Data.IndexCdsKey only identifies the version. The constituents' weights of an
    IndexCds or IndexCdo add up to 1: each name is 1/124, not 0.008,
    once 1 of 125 has defaulted. Tranche points and Data.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.applyCreditEvent and the
    three applyCreditEventTo...Quotes functions 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, impliedBaseCorrelation and the option pricers.
    indexFactor() on an index or tranche is now its indexFactor
    attribute, and outstandingFactor() 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.IndexCdo carries quotedAttachment and quotedDetachment, and
    Data.IndexCdoQuotes (and the spread reference quotes)
    quotedAttachments and quotedDetachments, required arguments right
    after the points (and after them in IndexCdo.makeStandard), the
    points themselves while the index factor is 1. makeV1 on 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.makeStandard is given the original notional and
    applies the index factor, and IndexCdo.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.makeStandard took 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's settledLoss, 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
    IndexCds or IndexCdo after 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
    uses makeV1 at 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.applyCreditEventToIndexCdsOptionQuotes now 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 its settledLoss as 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. settledLoss is now the loss since the
    key's version. impliedIndexCdsVolatilities and 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. impliedIndexCdsOptionQuotes takes quotesKey, the version the
    options were traded on, after settledLoss. 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.BespokeCds takes a fixed recovery for each contingent leg.
    fixedRecovery is empty, or has one recovery for each contingent leg, in
    the order of contingentLegs. Each leg pays one minus its own recovery,
    in CreditCorrelation.pvBespokeCds, its greeks and
    Data.BespokeCds.applyCreditEvent. Before, fixedRecovery had 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.termRateHedges takes the overnight index. overnightIndex,
    the third input, is the currency's overnight index, the one the OIS strip
    given to Curves.termRateStrip was 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 after index.

  • Data.FxRate has an observation date. observationDate, its first
    input, is the date the rate is observed on, and its spot date is
    spotDays business 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...

Read more

qeLib 0.3.0

Choose a tag to compare

@mortenbaiandersen-cpu mortenbaiandersen-cpu released this 13 Nov 19:50

Interface changes

  • Data.Cds, Data.NthToDefault, Data.IndexCdo, Data.BespokeCdo and
    Data.BespokeCds no 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
    makeStandard functions still take the names and the calendars, to
    adjust the dates. Objects saved by 0.2.0 still load, without the names.
    Data.IndexCds keeps 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

Choose a tag to compare

@mortenbaiandersen-cpu mortenbaiandersen-cpu released this 12 Nov 09:22

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,
      makeFixedAgainstOvernight and makeTermRateAgainstOvernight, as well
      as makeStandard and makeBasisSwap. A swap with all three kinds of leg
      can no longer be made.
    • Data.CmsSwap: makeFixed, makeTermRate and makeOvernight, one for
      each kind of funding leg, as well as makeStandard.
    • Data.CrossCurrencySwap: makeConstantNotional and makeResetting, as
      well as makeStandard.
    • Data.TermRateStub: makeSingle and makeInterpolated.
    • Data.SwaptionTermRate and Data.BermudanSwaptionTermRate: make, as
      well as makeStandard. make takes the strike, the notional, the fixed
      leg's day count and dates, and the term rate leg, in place of a swap.
  • RatesOption.pvInterestRateLegsInstrument and
    RatesOption.greeksInterestRateLegsInstruments take two more optional
    inputs
    , capletModels and rangeAccrualModel, after cmsModels, for
    range accrual legs. In Excel, and in Python calls that pass inputs by
    position, overnightProjection, calendars and valuationContext move
    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 in Data.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 as RatesOption.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.pvCallableInterestRateLegsQuadrature and
    pvCallableInterestRateLegsFiniteDifference price them on a one-factor
    Markov model, with greeks to match.
    RatesOption.applyCallableInterestRateLegsCall applies a call.
  • Cashflows of Bermudan swaptions and callable legs, at zero volatility:
    RatesOption.bermudanSwaptionTermRateCashflows,
    bermudanSwaptionOisCashflows and callableInterestRateLegsCashflows.
  • 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, and licenses/NOTICES.txt lists
    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

Choose a tag to compare

@mortenbaiandersen-cpu mortenbaiandersen-cpu released this 10 Nov 06:37

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, then import 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.