Class TreeCapFloorEngine
- Namespace
- NanoQL.PricingEngines
- Assembly
- NanoQL.dll
The tree cap/floor engine: a DiscretizedCapFloor rolled back on a short-rate model's lattice.
public static class TreeCapFloorEngine
- Inheritance
-
TreeCapFloorEngine
- Inherited Members
Remarks
A static class: Calculate runs QuantLib's four steps (playbook §2.1) on the model, an argument where
QuantLib's engine holds it, on a lattice built through the asset's mandatory times with the given number of steps,
or on a time grid, or on a lattice already built. The asset is initialized at its last payment and rolled back to
its first start, or to the reference date where that start is before it (a seasoned cap), where QuantLib's grid
refuses the negative time, or to the first caplet's fixing where the asset values that caplet there, before its
start (Divergences/CapletFixingExpiryTests.cs). A caplet paid on the reference date counts only when the
context includes today's cash flows, as the discretized swap's known coupon does.
The term structure is needed only when the model can't provide one: a model that is an ITermStructureConsistentModel reads its own curve's reference date and day counter.
Methods
Calculate(CapFloor, EvaluationContext, ShortRateModel, Lattice, YieldTermStructure?)
Prices a cap, floor or collar on a lattice already built, which the caller reuses across calculations.
public static InstrumentResults Calculate(CapFloor capFloor, EvaluationContext context, ShortRateModel model, Lattice lattice, YieldTermStructure? termStructure = null)
Parameters
capFloorCapFloorThe cap, floor or collar.
contextEvaluationContextThe evaluation context.
modelShortRateModelThe short-rate model, whose curve gives the reference date and day counter of the times.
latticeLatticeThe lattice, which must hold the cap's mandatory times.
termStructureYieldTermStructureThe curve that gives the reference date and day counter of the times, for a model that has no curve of its own; null, QuantLib's empty handle, by default.
Returns
- InstrumentResults
The instrument's results: the expired results when it has expired.
Exceptions
- ArgumentNullException
An argument but the term structure is null.
- NanoQLException
The cap's terms are inconsistent, a forward can't be computed, the model has no curve and none is given, or the lattice's grid lacks one of the cap's times.
Calculate(CapFloor, EvaluationContext, ShortRateModel, TimeGrid, YieldTermStructure?)
Prices a cap, floor or collar on the model's lattice on a time grid.
public static InstrumentResults Calculate(CapFloor capFloor, EvaluationContext context, ShortRateModel model, TimeGrid timeGrid, YieldTermStructure? termStructure = null)
Parameters
capFloorCapFloorThe cap, floor or collar.
contextEvaluationContextThe evaluation context.
modelShortRateModelThe short-rate model.
timeGridTimeGridThe time grid, which must hold the cap's mandatory times.
termStructureYieldTermStructureThe curve that gives the reference date and day counter of the times, for a model that has no curve of its own; null, QuantLib's empty handle, by default.
Returns
- InstrumentResults
The instrument's results: the expired results when it has expired.
Remarks
The lattice is built first, as QuantLib's engine builds it at construction.
Exceptions
- ArgumentNullException
An argument but the term structure is null.
- NanoQLException
The model can't build its lattice on the grid, the cap's terms are inconsistent, a forward can't be computed, the model has no curve and none is given, or the grid lacks one of the cap's times.
Calculate(CapFloor, EvaluationContext, ShortRateModel, int, YieldTermStructure?)
Prices a cap, floor or collar on the model's lattice with a number of time steps through its mandatory times.
public static InstrumentResults Calculate(CapFloor capFloor, EvaluationContext context, ShortRateModel model, int timeSteps, YieldTermStructure? termStructure = null)
Parameters
capFloorCapFloorThe cap, floor or collar.
contextEvaluationContextThe evaluation context.
modelShortRateModelThe short-rate model.
timeStepsintThe number of time steps, positive.
termStructureYieldTermStructureThe curve that gives the reference date and day counter of the times, for a model that has no curve of its own; null, QuantLib's empty handle, by default.
Returns
- InstrumentResults
The instrument's results: the expired results when it has expired.
Exceptions
- ArgumentNullException
The cap, the context or the model is null.
- ArgumentException
timeStepsisn't positive.- NanoQLException
The cap's terms are inconsistent, a cash flow isn't a floating-rate coupon, a forward can't be computed, the model has no curve and none is given, or the model can't build its lattice.