Class ForwardVanillaEngine
- Namespace
- NanoQL.PricingEngines
- Assembly
- NanoQL.dll
The forward-start engine for vanilla options: a vanilla engine run on the forward process from the reset date, at the moneyness times the spot, its results discounted on the dividend curve to the reset date.
public class ForwardVanillaEngine
- Inheritance
-
ForwardVanillaEngine
- Derived
- Inherited Members
Remarks
An extension point, as QuantLib's template: ForwardPerformanceVanillaEngine derives it and overrides OriginalResults(ForwardVanillaOption, OneAssetOptionResults). Immutable; it holds the process and the inner engine, a delegate in the engines' form taking the forward process; the forward process is built per call.
The payoff must be a plain vanilla one: QuantLib builds the inner option's plain vanilla payoff from the payoff's
type alone, so a cash-or-nothing forward start prices as the vanilla
(Divergences/ForwardNonPlainPayoffTests.cs); it is refused with the text of QuantLib's Monte Carlo forward
engines. The vega is the derivative under a parallel shift of the input volatilities, the inner vega in the period's
forward volatility times dσ_f/dε, where QuantLib's is the inner vega alone
(Divergences/ForwardVegaTermStructureTests.cs): exactly QuantLib's where the volatilities at the reset and at
expiry are equal. The dividend rate read for the theta is on the process's clock (Clock(GeneralizedBlackScholesProcess, FdmQuantoHelper?)), each curve read by date, and the dividend rho's reset term on the dividend
curve's own time, the derivative of its zero rates (Divergences/ExoticMismatchedTimesTests.cs); on structures
dated alike, QuantLib's reads.
Constructors
ForwardVanillaEngine(GeneralizedBlackScholesProcess, Func<VanillaOption, EvaluationContext, GeneralizedBlackScholesProcess, OneAssetOptionResults>)
Initializes a new instance of the ForwardVanillaEngine class.
public ForwardVanillaEngine(GeneralizedBlackScholesProcess process, Func<VanillaOption, EvaluationContext, GeneralizedBlackScholesProcess, OneAssetOptionResults> engine)
Parameters
processGeneralizedBlackScholesProcessThe underlying's process.
engineFunc<VanillaOption, EvaluationContext, GeneralizedBlackScholesProcess, OneAssetOptionResults>The vanilla engine run on the forward process.
Exceptions
- ArgumentNullException
An argument is null.
Properties
Engine
Gets the vanilla engine run on the forward process.
protected Func<VanillaOption, EvaluationContext, GeneralizedBlackScholesProcess, OneAssetOptionResults> Engine { get; }
Property Value
Process
Gets the underlying's process.
protected GeneralizedBlackScholesProcess Process { get; }
Property Value
Methods
Calculate(ForwardVanillaOption, EvaluationContext)
Prices a forward-start option: QuantLib's calculate.
public OneAssetOptionResults Calculate(ForwardVanillaOption option, EvaluationContext context)
Parameters
optionForwardVanillaOptionThe option.
contextEvaluationContextThe evaluation context.
Returns
- OneAssetOptionResults
The option's results; the expired results when it has expired.
Exceptions
- ArgumentNullException
An argument is null.
- NanoQLException
The option's terms are invalid, its payoff isn't plain vanilla, the spot isn't positive, or the inner engine refuses.
Calculate(ForwardVanillaOption, EvaluationContext, GeneralizedBlackScholesProcess, Func<VanillaOption, EvaluationContext, GeneralizedBlackScholesProcess, OneAssetOptionResults>)
Prices a forward-start option: QuantLib's ForwardVanillaEngine<Engine>.
public static OneAssetOptionResults Calculate(ForwardVanillaOption option, EvaluationContext context, GeneralizedBlackScholesProcess process, Func<VanillaOption, EvaluationContext, GeneralizedBlackScholesProcess, OneAssetOptionResults> engine)
Parameters
optionForwardVanillaOptionThe option.
contextEvaluationContextThe evaluation context.
processGeneralizedBlackScholesProcessThe underlying's process.
engineFunc<VanillaOption, EvaluationContext, GeneralizedBlackScholesProcess, OneAssetOptionResults>The vanilla engine run on the forward process.
Returns
- OneAssetOptionResults
The option's results: the value and the inner engine's Greeks, carried to today.
Exceptions
- ArgumentNullException
An argument is null.
- NanoQLException
The option's terms are invalid, its payoff isn't plain vanilla, the spot isn't positive, or the inner engine refuses.
ForwardProcess(ForwardVanillaOption)
The forward process: QuantLib's setup, the curves and the volatility implied from the reset date.
public GeneralizedBlackScholesProcess ForwardProcess(ForwardVanillaOption option)
Parameters
optionForwardVanillaOptionThe forward-start option.
Returns
- GeneralizedBlackScholesProcess
The process the inner engine reads.
Exceptions
- ArgumentNullException
optionis null.- NanoQLException
The spot isn't positive.
OriginalResults(ForwardVanillaOption, OneAssetOptionResults)
The forward-start option's results from the inner engine's: QuantLib's getOriginalResults, with the vega
under a parallel shift and the reset term on the dividend curve's own time.
protected virtual OneAssetOptionResults OriginalResults(ForwardVanillaOption option, OneAssetOptionResults originalResults)
Parameters
optionForwardVanillaOptionThe forward-start option.
originalResultsOneAssetOptionResultsThe inner engine's results.
Returns
- OneAssetOptionResults
The forward-start option's results.
Exceptions
- ArgumentNullException
An argument is null.
ResetRate(YieldTermStructure, ForwardVanillaOption, TermStructure)
A curve's continuous zero rate to the reset: QuantLib's zeroRate(resetDate, dayCounter, Continuous) where
the curve shares the clock's times; otherwise the rate of the discount it accrues over the clock's reset time.
protected static double ResetRate(YieldTermStructure curve, ForwardVanillaOption option, TermStructure clock)
Parameters
curveYieldTermStructureThe curve.
optionForwardVanillaOptionThe forward-start option.
clockTermStructureThe process's clock.
Returns
- double
The rate.
ResetTime(ForwardVanillaOption, TermStructure)
The time to the reset on a curve's own clock, none before its date: the time over which a parallel shift of the curve's zero rates discounts the value to the reset, where QuantLib reads the risk-free curve's year fraction for every curve.
protected static double ResetTime(ForwardVanillaOption option, TermStructure curve)
Parameters
optionForwardVanillaOptionThe forward-start option.
curveTermStructureThe curve.
Returns
- double
The reset time.
ShiftedVega(ForwardVanillaOption, double)
The vega under a parallel shift of the input volatilities (NanoQL.PricingEngines.ForwardVanillaEngine.ShiftedVega(NanoQL.TermStructures.BlackVolTermStructure,NanoQL.Time.Date,NanoQL.Time.Date,System.Double,System.Boolean,System.Double)) over the option's period, from the reset to expiry, at the inner strike, the period at its forward where the spot's forward over it is close to that strike.
protected double ShiftedVega(ForwardVanillaOption option, double innerVega)
Parameters
optionForwardVanillaOptionThe forward-start option.
innerVegadoubleThe inner engine's vega.
Returns
- double
The shifted vega.
Underlying(ForwardVanillaOption)
The inner vanilla option: QuantLib's setup, the plain vanilla payoff at the moneyness times the spot.
public VanillaOption Underlying(ForwardVanillaOption option)
Parameters
optionForwardVanillaOptionThe forward-start option.
Returns
- VanillaOption
The vanilla option the inner engine prices.
Exceptions
- ArgumentNullException
optionis null.- NanoQLException
The payoff isn't plain vanilla.