Table of Contents

Class MakeMCVarianceSwapEngine<TRng, TStats>

Namespace
NanoQL.PricingEngines
Assembly
NanoQL.dll

A builder of the Monte Carlo variance-swap engine, with QuantLib's defaults but the seed.

public sealed record MakeMCVarianceSwapEngine<TRng, TStats> : IEquatable<MakeMCVarianceSwapEngine<TRng, TStats>> where TRng : IRngTraits where TStats : IStatistics, new()

Type Parameters

TRng

The random-number traits.

TStats

The statistics accumulator.

Inheritance
MakeMCVarianceSwapEngine<TRng, TStats>
Implements
Inherited Members

Remarks

An immutable builder: each method returns a modified copy. ToEngine() returns the engine as a function of the swap and the context, its settings bound, in place of QuantLib's conversion to a pricing engine. The seed is a constructor argument: QuantLib's default, 0, a seed from the clock, is refused. A builder has no value equality.

Constructors

MakeMCVarianceSwapEngine(GeneralizedBlackScholesProcess, long)

Initializes a new instance of the MakeMCVarianceSwapEngine<TRng, TStats> record.

public MakeMCVarianceSwapEngine(GeneralizedBlackScholesProcess process, long seed)

Parameters

process GeneralizedBlackScholesProcess

The Black-Scholes process.

seed long

The seed, in [1, 4294967295].

Exceptions

ArgumentNullException

process is null.

ArgumentOutOfRangeException

seed is outside its range.

Methods

Equals(MakeMCVarianceSwapEngine<TRng, TStats>?)

public bool Equals(MakeMCVarianceSwapEngine<TRng, TStats>? other)

Parameters

other MakeMCVarianceSwapEngine<TRng, TStats>

Returns

bool

Equals(object?)

public override bool Equals(object? obj)

Parameters

obj object

Returns

bool

GetHashCode()

public override int GetHashCode()

Returns

int

ToEngine()

The engine with the builder's settings: QuantLib's conversion to a pricing engine.

public Func<VarianceSwap, EvaluationContext, VarianceSwapResults> ToEngine()

Returns

Func<VarianceSwap, EvaluationContext, VarianceSwapResults>

The engine, a function of the swap and the context.

Exceptions

NanoQLException

The steps are given neither way, or both ways.

ToString()

public override string ToString()

Returns

string

WithAbsoluteTolerance(double)

Sets the absolute tolerance.

public MakeMCVarianceSwapEngine<TRng, TStats> WithAbsoluteTolerance(double tolerance)

Parameters

tolerance double

The tolerance.

Returns

MakeMCVarianceSwapEngine<TRng, TStats>

The modified builder.

Exceptions

NanoQLException

A number of samples is already set, or the random-number traits allow no error estimate.

WithAntitheticVariate(bool)

Sets whether antithetic variates are used.

public MakeMCVarianceSwapEngine<TRng, TStats> WithAntitheticVariate(bool b = true)

Parameters

b bool

Whether to use antithetic variates.

Returns

MakeMCVarianceSwapEngine<TRng, TStats>

The modified builder.

WithBrownianBridge(bool)

Sets whether the draws are ordered by a Brownian bridge.

public MakeMCVarianceSwapEngine<TRng, TStats> WithBrownianBridge(bool b = true)

Parameters

b bool

Whether to use a Brownian bridge.

Returns

MakeMCVarianceSwapEngine<TRng, TStats>

The modified builder.

WithMaxSamples(int)

Sets the most samples for a tolerance.

public MakeMCVarianceSwapEngine<TRng, TStats> WithMaxSamples(int samples)

Parameters

samples int

The most samples.

Returns

MakeMCVarianceSwapEngine<TRng, TStats>

The modified builder.

Exceptions

ArgumentOutOfRangeException

samples is negative.

WithSamples(int)

Sets the number of samples.

public MakeMCVarianceSwapEngine<TRng, TStats> WithSamples(int samples)

Parameters

samples int

The number of samples.

Returns

MakeMCVarianceSwapEngine<TRng, TStats>

The modified builder.

Exceptions

ArgumentOutOfRangeException

samples is negative.

NanoQLException

A tolerance is already set.

WithSeed(long)

Sets the seed.

public MakeMCVarianceSwapEngine<TRng, TStats> WithSeed(long seed)

Parameters

seed long

The seed, in [1, 4294967295].

Returns

MakeMCVarianceSwapEngine<TRng, TStats>

The modified builder.

Exceptions

ArgumentOutOfRangeException

seed is outside its range.

WithSteps(int)

Sets the number of time steps.

public MakeMCVarianceSwapEngine<TRng, TStats> WithSteps(int steps)

Parameters

steps int

The number of steps.

Returns

MakeMCVarianceSwapEngine<TRng, TStats>

The modified builder.

WithStepsPerYear(int)

Sets the number of time steps per year.

public MakeMCVarianceSwapEngine<TRng, TStats> WithStepsPerYear(int steps)

Parameters

steps int

The number of steps per year.

Returns

MakeMCVarianceSwapEngine<TRng, TStats>

The modified builder.

Operators

operator ==(MakeMCVarianceSwapEngine<TRng, TStats>?, MakeMCVarianceSwapEngine<TRng, TStats>?)

public static bool operator ==(MakeMCVarianceSwapEngine<TRng, TStats>? left, MakeMCVarianceSwapEngine<TRng, TStats>? right)

Parameters

left MakeMCVarianceSwapEngine<TRng, TStats>
right MakeMCVarianceSwapEngine<TRng, TStats>

Returns

bool

operator !=(MakeMCVarianceSwapEngine<TRng, TStats>?, MakeMCVarianceSwapEngine<TRng, TStats>?)

public static bool operator !=(MakeMCVarianceSwapEngine<TRng, TStats>? left, MakeMCVarianceSwapEngine<TRng, TStats>? right)

Parameters

left MakeMCVarianceSwapEngine<TRng, TStats>
right MakeMCVarianceSwapEngine<TRng, TStats>

Returns

bool