Class MCVarianceSwapEngine
- Namespace
- NanoQL.PricingEngines
- Assembly
- NanoQL.dll
The Monte Carlo variance-swap engine: the variance the swap pays as the mean of the paths' realized variances, as described in Demeterfi, Derman, Kamal and Zou, "A Guide to Volatility and Variance Swaps" (1999).
public static class MCVarianceSwapEngine
- Inheritance
-
MCVarianceSwapEngine
- Inherited Members
Remarks
Stateless: each call runs its own simulation. It prices the variance from the evaluation date, whatever the swap's start date, as QuantLib documents ("does not manage seasoned variance swaps").
The path grid runs on the process's clock (Clock(GeneralizedBlackScholesProcess, FdmQuantoHelper?)), the earliest reference date of
its structures, each read there accruing nothing before its own date, and the payment discounted by date
(Divergences/McVarianceSwapMismatchedTimesTests.cs), where QuantLib's grid runs on the risk-free curve's
time; on structures dated alike, QuantLib's.
Methods
Calculate<TRng, TStats>(VarianceSwap, EvaluationContext, GeneralizedBlackScholesProcess, int?, int?, bool, bool, int?, double?, int?, long)
Prices a variance swap by Monte Carlo.
public static VarianceSwapResults Calculate<TRng, TStats>(VarianceSwap swap, EvaluationContext context, GeneralizedBlackScholesProcess process, int? timeSteps, int? timeStepsPerYear, bool brownianBridge, bool antitheticVariate, int? requiredSamples, double? requiredTolerance, int? maxSamples, long seed) where TRng : IRngTraits where TStats : IStatistics, new()
Parameters
swapVarianceSwapThe variance swap.
contextEvaluationContextThe evaluation context.
processGeneralizedBlackScholesProcessThe Black-Scholes process.
timeStepsint?The number of time steps, or null.
timeStepsPerYearint?The number of time steps per year, or null.
brownianBridgeboolWhether the draws are ordered by a Brownian bridge.
antitheticVariateboolWhether antithetic variates are used.
requiredSamplesint?The number of samples, or null.
requiredTolerancedouble?The absolute tolerance, or null; it takes precedence.
maxSamplesint?The most samples for a tolerance, or null for no limit.
seedlongThe seed, in [1, 4294967295].
Returns
- VarianceSwapResults
The swap's results: the NPV, the variance and, where the numbers give one, the error estimate.
Type Parameters
TRngThe random-number traits.
TStatsThe statistics accumulator.
Exceptions
- ArgumentNullException
The swap, the context or the process is null.
- ArgumentException
The time steps are both given, neither, or not positive.
- ArgumentOutOfRangeException
A number of samples is negative, or the seed is outside its range.
- NanoQLException
Neither a tolerance nor a number of samples is given, or the samples can't reach the tolerance.