| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
QuantLib.TermStructure.Credit
Description
Credit term structures and helpers.
Hazard shifts
shiftedHazardRateCurve retains QuantLib's parallel and relative wrappers. Their
survival calculation uses 48-point Gauss-Chebyshev quadrature, so even
a constant hazard integrates with a small numerical error. For a flat annual
hazard h, parallel survival is exp(-k*h*t), with k = pi/(96*sin(pi/96)), rather
than exp(-h*t). This numerical behavior is retained for compatibility.
Parallel queries now refuse negative or non-finite resulting hazards, including
during native survival integration, rather than returning invalid credit rates.
Shaped shifts instead retain base survival and apply the exact interpolation
primitive of their spread; see shiftedHazardRateCurve for bounds and query checks.
Conditional survival
conditionalSurvivalCurve is a hasquant curve view, not a QuantLib class binding.
It keeps the original native interpolation and hazard-wrapper quadrature. For
original-curve time s at its new fixed reference, a view-time t reads
S(s+t)/S(s), f(s+t)/S(s) and h(s+t) from the original curve.
View times are years from the new reference on the original day counter. Date
queries preserve original-date ratios when that day counter adds year fractions;
callers must check that clock convention rather than silently re-interpolate.
The new reference must lie within the original support and have positive finite
survival: normalizing zero or an invalid value cannot define a conditional curve.
Sources exposing scheduled jumps are refused: the generic curve interface does not
expose their quote handles, so transferring their jump metadata would lose updates.
The view keeps its original curve alive, observes its updates and inherits its
calendar, day counter, maximum date and extrapolation permission. Its reference
remains fixed if the original curve moves; a reference that then becomes invalid
is refused when queried. Native query values must remain finite.
Synopsis
- type GenDefaultProbabilityTermStructure d = GenTermStructure (AnyOf CDefaultProbabilityTermStructure' d)
- type DefaultProbabilityTermStructure = GenDefaultProbabilityTermStructure CDefaultProbabilityTermStructure
- type AffineHazardRateCurve = GenDefaultProbabilityTermStructure CAffineHazardRateCurve
- type PiecewiseDefaultCurve = GenDefaultProbabilityTermStructure CPiecewiseDefaultCurve
- data DefaultProbabilityHelper
- data Reference
- data TermPoint
- data TermInterval
- = DateInterval !Day !Day
- | TimeInterval !Double !Double
- data HazardRateShift q
- = ParallelHazardShift (GenQuote q)
- | RelativeHazardShift (GenQuote q)
- | KeyRateHazardShifts (NonEmpty (Day, GenQuote q))
- | BucketHazardShifts (NonEmpty (Day, GenQuote q))
- data ProbabilityTrait
- data IterativeBootstrapOpts = IterativeBootstrapOpts {}
- shiftedHazardRateCurve :: GenDefaultProbabilityTermStructure d -> HazardRateShift q -> IO DefaultProbabilityTermStructure
- flatHazardRate :: Reference -> GenQuote q -> DayCounter -> IO DefaultProbabilityTermStructure
- conditionalSurvivalCurve :: GenDefaultProbabilityTermStructure d -> Day -> IO DefaultProbabilityTermStructure
- spreadCdsHelper :: GenQuote q -> (Word, TimeUnit) -> Int -> Calendar -> Frequency -> BusinessDayConvention -> DateGenerationRule -> DayCounter -> Double -> GenYieldTermStructure y -> Bool -> Bool -> Maybe Day -> DayCounter -> Bool -> PricingModel -> Maybe Day -> IO DefaultProbabilityHelper
- upfrontCdsHelper :: GenQuote q -> Double -> (Word, TimeUnit) -> Int -> Calendar -> Frequency -> BusinessDayConvention -> DateGenerationRule -> DayCounter -> Double -> GenYieldTermStructure y -> Word -> Bool -> Bool -> Maybe Day -> DayCounter -> Bool -> PricingModel -> Maybe Day -> IO DefaultProbabilityHelper
- interpolatedDefaultDensityCurve :: NonEmpty (Day, Double) -> DayCounter -> Calendar -> [(Day, GenQuote q)] -> Interpolation -> Bool -> IO DefaultProbabilityTermStructure
- interpolatedHazardRateCurve :: NonEmpty (Day, Double) -> DayCounter -> Calendar -> [(Day, GenQuote q)] -> Interpolation -> Bool -> IO DefaultProbabilityTermStructure
- interpolatedAffineHazardRateCurve :: NonEmpty (Day, Double) -> DayCounter -> GenOneFactorAffineModel om -> Calendar -> [(Day, GenQuote q)] -> Interpolation -> Bool -> IO AffineHazardRateCurve
- interpolatedSurvivalProbabilityCurve :: NonEmpty (Day, Double) -> DayCounter -> Calendar -> [(Day, GenQuote q)] -> Interpolation -> Bool -> IO DefaultProbabilityTermStructure
- defaultIterativeBootstrapOpts :: IterativeBootstrapOpts
- piecewiseDefaultCurve :: Reference -> NonEmpty DefaultProbabilityHelper -> DayCounter -> [(Day, GenQuote q)] -> ProbabilityTrait -> Interpolation -> IterativeBootstrapOpts -> Bool -> IO PiecewiseDefaultCurve
- asDefaultProbabilityTermStructure :: GenDefaultProbabilityTermStructure d -> IO DefaultProbabilityTermStructure
- defaultProbability :: GenDefaultProbabilityTermStructure d -> TermPoint -> Bool -> IO Double
- hazardRate :: GenDefaultProbabilityTermStructure d -> TermPoint -> Bool -> IO Double
- survivalProbability :: GenDefaultProbabilityTermStructure d -> TermPoint -> Bool -> IO Double
- defaultDensity :: GenDefaultProbabilityTermStructure d -> TermPoint -> Bool -> IO Double
- defaultProbabilityBetween :: GenDefaultProbabilityTermStructure d -> TermInterval -> Bool -> IO Double
- conditionalSurvivalProbability :: AffineHazardRateCurve -> TermInterval -> Double -> Bool -> IO Double
- impliedQuote :: DefaultProbabilityHelper -> IO Double
- impliedQuoteOn :: DefaultProbabilityHelper -> GenDefaultProbabilityTermStructure d -> IO Double
- class HasNodes c where
- bootstrappedNodes :: c -> IO [(Day, Double)]
Types
Curves and helpers
type GenDefaultProbabilityTermStructure d = GenTermStructure (AnyOf CDefaultProbabilityTermStructure' d) Source #
A DefaultProbabilityTermStructure or one of its leaves; see the hierarchy under GenTermStructure.
type DefaultProbabilityTermStructure = GenDefaultProbabilityTermStructure CDefaultProbabilityTermStructure Source #
A TermStructure; see the hierarchy under GenTermStructure.
type AffineHazardRateCurve = GenDefaultProbabilityTermStructure CAffineHazardRateCurve Source #
A DefaultProbabilityTermStructure; see the hierarchy under GenTermStructure.
type PiecewiseDefaultCurve = GenDefaultProbabilityTermStructure CPiecewiseDefaultCurve Source #
A DefaultProbabilityTermStructure bootstrapped from default-probability helpers, whose nodes
can be read; see the hierarchy under GenTermStructure.
Coordinates
A term-structure reference point. ReferenceDate stays fixed for the object's lifetime;
SettlementDays follows the global evaluation date using the supplied calendar.
Constructors
| ReferenceDate !Day | |
| SettlementDays !Word !Calendar |
A date or year-fraction coordinate measured from a term structure's reference date.
data TermInterval Source #
A same-representation interval. Keeping both endpoints in one constructor prevents mixed date/time intervals that upstream does not accept.
Constructors
| DateInterval !Day !Day | |
| TimeInterval !Double !Double |
Instances
| Show TermInterval Source # | |
Defined in QuantLib.TermStructure Methods showsPrec :: Int -> TermInterval -> ShowS # show :: TermInterval -> String # showList :: [TermInterval] -> ShowS # | |
| Eq TermInterval Source # | |
Defined in QuantLib.TermStructure | |
Hazard shifts
data HazardRateShift q Source #
A live shift of a credit curve. Spreads are annual continuous hazard fractions; relative operands are dimensionless (0.01 means multiplying hazards by 1.01).
Constructors
| ParallelHazardShift | QuantLib's additive parallel hazard wrapper. |
Fields
| |
| RelativeHazardShift | QuantLib's relative hazard wrapper. |
Fields
| |
| KeyRateHazardShifts | Linear spread in curve time between dates, flat outside the grid. |
| BucketHazardShifts | Constant spread on [previous end, end), zero at and after the last end. |
Bootstrap configuration
data ProbabilityTrait Source #
Constructors
| SurvivalProbability | |
| HazardRate | |
| DefaultDensity |
Instances
data IterativeBootstrapOpts Source #
Every constructor parameter of QuantLib's curve-generic IterativeBootstrap.
The first three fields are Maybe because Nothing preserves QuantLib's
Null<Real>() sentinel, which selects a suitable value for each curve pillar.
Constructors
| IterativeBootstrapOpts | |
Fields
| |
Constructors
Flat, conditional and spreaded curves
shiftedHazardRateCurve Source #
Arguments
| :: GenDefaultProbabilityTermStructure d | Underlying credit curve. |
| -> HazardRateShift q | Live shift quotes and, for shapes, their date grid. |
| -> IO DefaultProbabilityTermStructure |
Apply a live hazard shift, retaining the underlying reference date, day counter, calendar and maximum date. The underlying and all quotes remain observed.
Parallel and relative shifts retain QuantLib's original wrappers and numerical
integration; parallel queries additionally check finite nonnegative hazards.
The shaped adapter is defined by hasquant: it adds the spread to
the underlying hazard and multiplies underlying survival by
exp(-integral spread dt). QuantLib's linear/forward-flat interpolation primitives
integrate the spread exactly, so bucket boundaries introduce no survival jumps
and the accumulated change remains after the last bucket. The base curve is
never sampled or re-interpolated. Curve times use its own day counter.
Shaped queries refuse non-finite spreads, negative or non-finite resulting hazards,
and non-finite survival probabilities or values outside [0,1]. Multiplication
roundoff at most four machine epsilons above one is clamped to one, so exactly
zero hazards are not refused because exp(-x) * exp(x) rounded upward.
Survival queries
check their endpoint and both sides of earlier spread knots; this is not a proof
of positivity at every point of an arbitrary underlying curve. Underflow and
overflow of the exponential correction remain native floating-point limits.
flatHazardRate :: Reference -> GenQuote q -> DayCounter -> IO DefaultProbabilityTermStructure Source #
Flat hazard-rate curve with either a fixed or evaluation-date-relative reference point.
conditionalSurvivalCurve Source #
Arguments
| :: GenDefaultProbabilityTermStructure d | Original credit curve, retained and observed by the view. |
| -> Day | New fixed reference date, on or after the original reference and no later than its maximum date. |
| -> IO DefaultProbabilityTermStructure |
The original native credit curve conditioned on survival at a later fixed reference. This is the delegated curve view described in Conditional survival.
Helpers and bootstrapped curves
Arguments
| :: GenQuote q | runningSpread |
| -> (Word, TimeUnit) | tenor |
| -> Int | settlementDays |
| -> Calendar | |
| -> Frequency | |
| -> BusinessDayConvention | |
| -> DateGenerationRule | |
| -> DayCounter | |
| -> Double | |
| -> GenYieldTermStructure y | discountCurve |
| -> Bool | settlesAccrual |
| -> Bool | paysAtDefaultTime |
| -> Maybe Day | startDate |
| -> DayCounter | lastPeriodDayCounter |
| -> Bool | rebatesAccrual |
| -> PricingModel | model |
| -> Maybe Day | tradeDate (1.44; QuantLib 1.43 requires |
| -> IO DefaultProbabilityHelper |
bootstrap helper for a CDS quoted by running spread
Arguments
| :: GenQuote q | upfront |
| -> Double | runningSpread |
| -> (Word, TimeUnit) | tenor |
| -> Int | settlementDays |
| -> Calendar | |
| -> Frequency | |
| -> BusinessDayConvention | |
| -> DateGenerationRule | |
| -> DayCounter | |
| -> Double | recoveryDate |
| -> GenYieldTermStructure y | discountCurve |
| -> Word | upfrontSettlementDays |
| -> Bool | |
| -> Bool | paysAtDefaultTime |
| -> Maybe Day | startDate |
| -> DayCounter | lastPeriodDayCounter |
| -> Bool | rebatesAccrual |
| -> PricingModel | model |
| -> Maybe Day | tradeDate (1.44; QuantLib 1.43 requires |
| -> IO DefaultProbabilityHelper |
the upfront must be quoted in fractional units.
interpolatedDefaultDensityCurve Source #
Arguments
| :: NonEmpty (Day, Double) | |
| -> DayCounter | |
| -> Calendar | |
| -> [(Day, GenQuote q)] | jumps |
| -> Interpolation | |
| -> Bool | |
| -> IO DefaultProbabilityTermStructure |
interpolatedHazardRateCurve Source #
Arguments
| :: NonEmpty (Day, Double) | |
| -> DayCounter | |
| -> Calendar | |
| -> [(Day, GenQuote q)] | jumps |
| -> Interpolation | |
| -> Bool | extrapolate past the curve's max date |
| -> IO DefaultProbabilityTermStructure |
interpolatedAffineHazardRateCurve Source #
Arguments
| :: NonEmpty (Day, Double) | |
| -> DayCounter | |
| -> GenOneFactorAffineModel om | |
| -> Calendar | |
| -> [(Day, GenQuote q)] | jumps |
| -> Interpolation | |
| -> Bool | extrapolate past the curve's max date |
| -> IO AffineHazardRateCurve |
Hazard-rate curve interpolated deterministically between nodes, combined with a one-factor affine short-rate model's stochastic discount mechanics -- see 'qlexperimentalcredit/interpolatedaffinehazardratecurve.hpp'.
interpolatedSurvivalProbabilityCurve Source #
Arguments
| :: NonEmpty (Day, Double) | |
| -> DayCounter | |
| -> Calendar | |
| -> [(Day, GenQuote q)] | jumps |
| -> Interpolation | |
| -> Bool | |
| -> IO DefaultProbabilityTermStructure |
piecewiseDefaultCurve Source #
Arguments
| :: Reference | |
| -> NonEmpty DefaultProbabilityHelper | instruments |
| -> DayCounter | dayCounter |
| -> [(Day, GenQuote q)] | jumps paired with their dates |
| -> ProbabilityTrait | bootstrap trait |
| -> Interpolation | interpolator |
| -> IterativeBootstrapOpts | bootstrap settings |
| -> Bool | extrapolate past the curve's max date |
| -> IO PiecewiseDefaultCurve |
Default-probability term structure bootstrapped from CDS/default helpers with either a fixed or evaluation-date-relative reference point and complete iterative-bootstrap settings.
asDefaultProbabilityTermStructure :: GenDefaultProbabilityTermStructure d -> IO DefaultProbabilityTermStructure Source #
Inspectors
defaultProbability :: GenDefaultProbabilityTermStructure d -> TermPoint -> Bool -> IO Double Source #
Default probability from the reference point to a date or year fraction.
hazardRate :: GenDefaultProbabilityTermStructure d -> TermPoint -> Bool -> IO Double Source #
Hazard rate at a date or year fraction, with annual frequency and continuous compounding.
survivalProbability :: GenDefaultProbabilityTermStructure d -> TermPoint -> Bool -> IO Double Source #
Survival probability from the reference point to a date or year fraction.
defaultDensity :: GenDefaultProbabilityTermStructure d -> TermPoint -> Bool -> IO Double Source #
Default density at a date or year fraction.
defaultProbabilityBetween :: GenDefaultProbabilityTermStructure d -> TermInterval -> Bool -> IO Double Source #
Default probability over a same-representation date or year-fraction interval.
conditionalSurvivalProbability Source #
Arguments
| :: AffineHazardRateCurve | |
| -> TermInterval | |
| -> Double | yVal |
| -> Bool | |
| -> IO Double |
Probability of survival to the interval's later point, conditional on survival to its earlier
point and on the stochastic hazard-rate component realizing yVal there -- see
'qlexperimentalcredit/onefactoraffinesurvival.hpp'.
impliedQuote :: DefaultProbabilityHelper -> IO Double Source #
The fair running-spread/upfront quote implied by the helper's current market data and pricing engine -- the value that would make the quoted instrument re-price at par. Requires the helper to have already been used to bootstrap a curve (throws otherwise, per upstream).
impliedQuoteOn :: DefaultProbabilityHelper -> GenDefaultProbabilityTermStructure d -> IO Double Source #
The quote that would make the helper reprice exactly on the given default-probability curve: a par spread or upfront read with the helper's own conventions on any credit curve.
class HasNodes c where Source #
Bootstrapped curve leaves that retain their native nodes. The class lives in this root module
for the same reason as HasHelperUnderlying: its instances span the topical curve modules.
Methods
bootstrappedNodes :: c -> IO [(Day, Double)] Source #
The curve's (date, value) nodes; reading them runs the bootstrap. The first node is the
reference date (inflation curves: the base date), the rest are helper pillars. Each value is
what the curve interpolates: the trait's quantity for yield and default curves, a
discount-factor spread for piecewiseSpreadYieldCurve, and
the rate before seasonality for inflation curves. Jump factors are applied separately and
are not part of the nodes.
An interpolated curve of the same kind on these nodes, with the original day counter, interpolation, jumps and seasonality, reproduces the bootstrapped curve. The exception is a local bootstrap, whose convex-monotone shape also depends on state the nodes do not carry.
Instances
| HasNodes PiecewiseDefaultCurve Source # | |
Defined in QuantLib.TermStructure Methods bootstrappedNodes :: PiecewiseDefaultCurve -> IO [(Day, Double)] Source # | |
| HasNodes PiecewiseYieldCurve Source # | |
Defined in QuantLib.TermStructure Methods bootstrappedNodes :: PiecewiseYieldCurve -> IO [(Day, Double)] Source # | |
| HasNodes PiecewiseYoYInflationCurve Source # | |
Defined in QuantLib.TermStructure Methods bootstrappedNodes :: PiecewiseYoYInflationCurve -> IO [(Day, Double)] Source # | |
| HasNodes PiecewiseZeroInflationCurve Source # | |
Defined in QuantLib.TermStructure Methods bootstrappedNodes :: PiecewiseZeroInflationCurve -> IO [(Day, Double)] Source # | |