Table of Contents

Class MCVanillaEngine<TMc, TPath, TStats>

Namespace
NanoQL.PricingEngines
Assembly
NanoQL.dll

The base of the Monte Carlo engines for vanilla options: a time grid to the last exercise, paths of the process on it, and a control variate's value from a control engine.

public abstract class MCVanillaEngine<TMc, TPath, TStats> : McSimulation<TPath, TStats> where TMc : IMcTraits<TPath> where TStats : IStatistics, new()

Type Parameters

TMc

The Monte Carlo traits, QuantLib's MC<RNG>: the path type and its generator.

TPath

The path type.

TStats

The statistics accumulator.

Inheritance
McSimulation<TPath, TStats>
MCVanillaEngine<TMc, TPath, TStats>
Inherited Members

Remarks

An extension point and an immutable object (over McSimulation<TPath, TStats>): a concrete engine's static Calculate builds one per call from the option, the context, the process and QuantLib's settings, with QuantLib's constructor checks, implements the path pricer, and reads Run()'s model and results. The vanilla option is its only instrument, as in every QuantLib instantiation. The control variate's value comes from ControlPricingEngine(), an engine delegate of the engines' form, on the option.

The process is the engine's: the Black-Scholes engines pass the process on their clock, whose times run from the earliest structure's reference date, so TimeGrid()'s times are that clock's.

Constructors

MCVanillaEngine(VanillaOption, EvaluationContext, StochasticProcess, int?, int?, bool, bool, bool, int?, double?, int?, long)

Initializes a new instance of the MCVanillaEngine<TMc, TPath, TStats> class.

protected MCVanillaEngine(VanillaOption option, EvaluationContext context, StochasticProcess process, int? timeSteps, int? timeStepsPerYear, bool brownianBridge, bool antitheticVariate, bool controlVariate, int? requiredSamples, double? requiredTolerance, int? maxSamples, long seed)

Parameters

option VanillaOption

The option.

context EvaluationContext

The evaluation context.

process StochasticProcess

The process the paths follow.

timeSteps int?

The number of time steps, or null for steps per year.

timeStepsPerYear int?

The number of time steps per year, or null for a number of steps.

brownianBridge bool

Whether the draws are ordered by a Brownian bridge.

antitheticVariate bool

Whether antithetic variates are used.

controlVariate bool

Whether a control variate is used.

requiredSamples int?

The number of samples, or null.

requiredTolerance double?

The absolute tolerance, or null; it takes precedence.

maxSamples int?

The most samples for a tolerance, or null for no limit.

seed long

The seed, in [1, 4294967295].

Exceptions

ArgumentNullException

The option, the context or the process is null.

ArgumentException

Neither or both of the time steps and the time steps per year are given, or the one given isn't positive.

ArgumentOutOfRangeException

requiredSamples or maxSamples is negative, or seed is outside its range.

Properties

BrownianBridge

Gets a value indicating whether the draws are ordered by a Brownian bridge.

protected bool BrownianBridge { get; }

Property Value

bool

Context

Gets the evaluation context.

protected EvaluationContext Context { get; }

Property Value

EvaluationContext

MaxSamples

Gets the most samples for a tolerance, or null for no limit.

protected int? MaxSamples { get; }

Property Value

int?

Option

Gets the option, QuantLib's engine arguments.

protected VanillaOption Option { get; }

Property Value

VanillaOption

Process

Gets the process the paths follow.

protected StochasticProcess Process { get; }

Property Value

StochasticProcess

RequiredSamples

Gets the number of samples, or null.

protected int? RequiredSamples { get; }

Property Value

int?

RequiredTolerance

Gets the absolute tolerance, or null.

protected double? RequiredTolerance { get; }

Property Value

double?

Seed

Gets the seed.

protected long Seed { get; }

Property Value

long

TimeSteps

Gets the number of time steps, or null.

protected int? TimeSteps { get; }

Property Value

int?

TimeStepsPerYear

Gets the number of time steps per year, or null.

protected int? TimeStepsPerYear { get; }

Property Value

int?

Methods

ControlPricingEngine()

The control variate's engine, QuantLib's controlPricingEngine(); by default none.

protected virtual Func<VanillaOption, EvaluationContext, OneAssetOptionResults>? ControlPricingEngine()

Returns

Func<VanillaOption, EvaluationContext, OneAssetOptionResults>

The engine, or null.

ControlVariateValue()

The control variate's value: the control engine's NPV on the option.

protected override double? ControlVariateValue()

Returns

double?

The value.

Exceptions

NanoQLException

The engine gives no control engine, or its NPV.

PathGenerator()

The path generator: the traits' sequence generator, of the process's factors per step, and paths on the grid.

protected override IPathGenerator<TPath> PathGenerator()

Returns

IPathGenerator<TPath>

A new path generator.

Run()

QuantLib's calculate: runs the simulation and returns its model and QuantLib's results, the mean as the value and, where the traits allow one, the error estimate.

protected (MonteCarloModel<TPath, TStats> Model, OneAssetOptionResults Results) Run()

Returns

(MonteCarloModel<TPath, TStats> Model, OneAssetOptionResults Results)

The call's model and results.

Exceptions

NanoQLException

The simulation refuses, or the samples can't reach the tolerance.

TimeGrid()

The time grid: to the last exercise, in the steps given or the steps per year, at least one.

protected override TimeGrid TimeGrid()

Returns

TimeGrid

The grid.

Exceptions

NanoQLException

No steps are given.