Struct HazardRate
- Namespace
- NanoQL.TermStructures
- Assembly
- NanoQL.dll
The hazard-rate curve traits: the bootstrap of hazard rates, and the formulas of InterpolatedHazardRateCurve<TInterpolator>.
public readonly struct HazardRate : IDefaultProbabilityTraits, IBootstrapTraits<DefaultProbabilityTermStructure>
- Implements
- Inherited Members
Remarks
A stateless configuration struct, as every bootstrap traits struct is.
Explicit Interface Implementations
DefaultDensityImpl(ReadOnlySpan<double>, ReadOnlySpan<double>, Interpolation, double)
The default density: the hazard rate times the survival probability, as for every HazardRateStructure.
static double DefaultDensityImpl(ReadOnlySpan<double> times, ReadOnlySpan<double> data, Interpolation interpolation, double t)
Parameters
timesReadOnlySpan<double>The nodes' times.
dataReadOnlySpan<double>The nodes' hazard rates.
interpolationInterpolationThe interpolation of the rates.
tdoubleThe time.
Returns
- double
The density.
Exceptions
- ArgumentException
timesis empty, ortis past the last time anddatais empty, where QuantLib reads past their end.
Guess(int, BootstrapState<DefaultProbabilityTermStructure>, bool, int)
The guess for a node's value.
static double Guess(int i, BootstrapState<DefaultProbabilityTermStructure> c, bool validData, int firstAliveHelper)
Parameters
iintThe node.
cBootstrapState<DefaultProbabilityTermStructure>The working state of the curve under construction.
validDataboolWhether the curve's data hold a previous pass's values.
firstAliveHelperintThe index of the first helper alive at the curve's first date.
Returns
- double
The guess.
HazardRateImpl(ReadOnlySpan<double>, ReadOnlySpan<double>, Interpolation, double, DefaultProbabilityTermStructure)
The hazard rate: the interpolation's, flat past the last node.
static double HazardRateImpl(ReadOnlySpan<double> times, ReadOnlySpan<double> data, Interpolation interpolation, double t, DefaultProbabilityTermStructure curve)
Parameters
timesReadOnlySpan<double>The nodes' times.
dataReadOnlySpan<double>The nodes' hazard rates.
interpolationInterpolationThe interpolation of the rates.
tdoubleThe time.
curveDefaultProbabilityTermStructureThe curve, which this kind doesn't read.
Returns
- double
The rate.
Exceptions
- ArgumentException
timesis empty, ortis past the last time anddatais empty, where QuantLib reads past their end.
InitialDate(BootstrapState<DefaultProbabilityTermStructure>)
The start of the curve's data: the reference date.
static Date InitialDate(BootstrapState<DefaultProbabilityTermStructure> c)
Parameters
cBootstrapState<DefaultProbabilityTermStructure>The working state of the curve under construction.
Returns
- Date
The date.
InitialValue(BootstrapState<DefaultProbabilityTermStructure>)
A dummy value at the reference date, which the first pillar's value overwrites.
static double InitialValue(BootstrapState<DefaultProbabilityTermStructure> c)
Parameters
cBootstrapState<DefaultProbabilityTermStructure>The working state of the curve under construction.
Returns
- double
The value.
MaxDate(ReadOnlySpan<Date>)
The maximum date: the last node's.
static Date MaxDate(ReadOnlySpan<Date> dates)
Parameters
datesReadOnlySpan<Date>The nodes' dates.
Returns
- Date
The date.
Exceptions
- ArgumentException
datesis empty, where QuantLib reads past its end.
MaxIterations
Gets the upper bound of the bootstrap's convergence loop: 30.
static int MaxIterations { get; }
Returns
MaxValueAfter(int, BootstrapState<DefaultProbabilityTermStructure>, bool, int)
The upper bound of a node's value, from the previous values.
static double MaxValueAfter(int i, BootstrapState<DefaultProbabilityTermStructure> c, bool validData, int firstAliveHelper)
Parameters
iintThe node.
cBootstrapState<DefaultProbabilityTermStructure>The working state of the curve under construction.
validDataboolWhether the curve's data hold a previous pass's values.
firstAliveHelperintThe index of the first helper alive at the curve's first date.
Returns
- double
The bound.
MinValueAfter(int, BootstrapState<DefaultProbabilityTermStructure>, bool, int)
The lower bound of a node's value, from the previous values.
static double MinValueAfter(int i, BootstrapState<DefaultProbabilityTermStructure> c, bool validData, int firstAliveHelper)
Parameters
iintThe node.
cBootstrapState<DefaultProbabilityTermStructure>The working state of the curve under construction.
validDataboolWhether the curve's data hold a previous pass's values.
firstAliveHelperintThe index of the first helper alive at the curve's first date.
Returns
- double
The bound.
SurvivalProbabilityImpl(ReadOnlySpan<double>, ReadOnlySpan<double>, Interpolation, double)
The survival probability: the exponential of minus the hazard rate's integral, flat past the last node.
static double SurvivalProbabilityImpl(ReadOnlySpan<double> times, ReadOnlySpan<double> data, Interpolation interpolation, double t)
Parameters
timesReadOnlySpan<double>The nodes' times.
dataReadOnlySpan<double>The nodes' hazard rates.
interpolationInterpolationThe interpolation of the rates.
tdoubleThe time.
Returns
- double
The probability.
Exceptions
- ArgumentException
tisn't 0 andtimesis empty, ortis past the last time anddatais empty, where QuantLib reads past their end.
UpdateGuess(double[], double, int)
Writes a root finder's trial value into the curve's data: QuantLib's updateGuess.
static void UpdateGuess(double[] data, double rate, int i)
Parameters
Exceptions
- ArgumentOutOfRangeException
iisn't a point ofdata, where QuantLib writes past its end.