Class TreeVanillaSwapEngine
- Namespace
- NanoQL.PricingEngines
- Assembly
- NanoQL.dll
The tree swap engine: a DiscretizedSwap rolled back to 0 on a short-rate model's lattice.
public static class TreeVanillaSwapEngine
- Inheritance
-
TreeVanillaSwapEngine
- 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 swap's mandatory times with the given number of steps,
or on a time grid, or on a lattice already built. The swap is initialized at its last mandatory time and rolled back
to 0; only its NPV is computed. A floating coupon fixed on or before the reference date is its amount
(DiscretizedSwap's public constructor).
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(VanillaSwap, EvaluationContext, ShortRateModel, Lattice, YieldTermStructure?)
Prices a swap on a lattice already built, which the caller reuses across calculations.
public static FixedVsFloatingSwapResults Calculate(VanillaSwap swap, EvaluationContext context, ShortRateModel model, Lattice lattice, YieldTermStructure? termStructure = null)
Parameters
swapVanillaSwapThe swap.
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 swap'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
- FixedVsFloatingSwapResults
The swap's results, the NPV alone: the expired results when the swap has expired.
Exceptions
- ArgumentNullException
An argument but the term structure is null.
- NanoQLException
The swap's terms are inconsistent, its nominal isn't constant, a known floating coupon's amount can't be computed, the model has no curve and none is given, the lattice's grid lacks one of the swap's times, or the swap has no time on or after the curve's reference date.
Calculate(VanillaSwap, EvaluationContext, ShortRateModel, TimeGrid, YieldTermStructure?)
Prices a swap on the model's lattice on a time grid.
public static FixedVsFloatingSwapResults Calculate(VanillaSwap swap, EvaluationContext context, ShortRateModel model, TimeGrid timeGrid, YieldTermStructure? termStructure = null)
Parameters
swapVanillaSwapThe swap.
contextEvaluationContextThe evaluation context.
modelShortRateModelThe short-rate model.
timeGridTimeGridThe time grid, which must hold the swap'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
- FixedVsFloatingSwapResults
The swap's results, the NPV alone: the expired results when the swap 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 swap's terms are inconsistent, its nominal isn't constant, a known floating coupon's amount can't be computed, the model has no curve and none is given, or the grid lacks one of the swap's times.
Calculate(VanillaSwap, EvaluationContext, ShortRateModel, int, YieldTermStructure?)
Prices a swap on the model's lattice with a number of time steps through its mandatory times.
public static FixedVsFloatingSwapResults Calculate(VanillaSwap swap, EvaluationContext context, ShortRateModel model, int timeSteps, YieldTermStructure? termStructure = null)
Parameters
swapVanillaSwapThe swap.
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
- FixedVsFloatingSwapResults
The swap's results, the NPV alone: the expired results when the swap has expired.
Exceptions
- ArgumentNullException
The swap, the context or the model is null.
- ArgumentException
timeStepsisn't positive.- NanoQLException
The swap's terms are inconsistent, its nominal isn't constant, a known floating coupon's amount can't be computed, the model has no curve and none is given, or the model can't build its lattice.