Table of Contents

Class MakeMCAmericanEngine<TRng, TStats, TRngCalibration>

Namespace
NanoQL.PricingEngines
Assembly
NanoQL.dll

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

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

Type Parameters

TRng

The pricing random-number traits.

TStats

The statistics accumulator.

TRngCalibration

The calibration random-number traits.

Inheritance
MakeMCAmericanEngine<TRng, TStats, TRngCalibration>
Implements
IEquatable<MakeMCAmericanEngine<TRng, TStats, TRngCalibration>>
Inherited Members

Remarks

An immutable builder: each method returns a modified copy, and ToEngine() the engine as a function of the option and the context, with QuantLib's checks on the steps. QuantLib's defaults: 2,048 calibration samples, a polynomial order of 2, the monomial basis, no antithetic variates and no control variate.

The seed is a constructor argument; the calibration seed is optional, its default QuantLib's documented one, the seed plus 1,768,237,423 modulo 2³², where QuantLib's builder passes its narrowed null.

Constructors

MakeMCAmericanEngine(GeneralizedBlackScholesProcess, long)

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

public MakeMCAmericanEngine(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(MakeMCAmericanEngine<TRng, TStats, TRngCalibration>?)

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

Parameters

other MakeMCAmericanEngine<TRng, TStats, TRngCalibration>

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<VanillaOption, EvaluationContext, OneAssetOptionResults> ToEngine()

Returns

Func<VanillaOption, EvaluationContext, OneAssetOptionResults>

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

Exceptions

NanoQLException

The number of steps is given neither or both ways.

ToString()

public override string ToString()

Returns

string

WithAbsoluteTolerance(double)

Sets the absolute tolerance.

public MakeMCAmericanEngine<TRng, TStats, TRngCalibration> WithAbsoluteTolerance(double tolerance)

Parameters

tolerance double

The tolerance.

Returns

MakeMCAmericanEngine<TRng, TStats, TRngCalibration>

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 the pricing uses antithetic variates.

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

Parameters

b bool

Whether to use antithetic variates.

Returns

MakeMCAmericanEngine<TRng, TStats, TRngCalibration>

The modified builder.

WithAntitheticVariateCalibration(bool)

Sets whether the calibration uses antithetic variates.

public MakeMCAmericanEngine<TRng, TStats, TRngCalibration> WithAntitheticVariateCalibration(bool b = true)

Parameters

b bool

Whether to use antithetic variates in the calibration.

Returns

MakeMCAmericanEngine<TRng, TStats, TRngCalibration>

The modified builder.

WithBasisSystem(LsmBasisSystemPolynomialType)

Sets the regression basis' family.

public MakeMCAmericanEngine<TRng, TStats, TRngCalibration> WithBasisSystem(LsmBasisSystemPolynomialType polynomialType)

Parameters

polynomialType LsmBasisSystemPolynomialType

The family.

Returns

MakeMCAmericanEngine<TRng, TStats, TRngCalibration>

The modified builder.

WithCalibrationSamples(int)

Sets the number of calibration samples.

public MakeMCAmericanEngine<TRng, TStats, TRngCalibration> WithCalibrationSamples(int calibrationSamples)

Parameters

calibrationSamples int

The number of calibration samples.

Returns

MakeMCAmericanEngine<TRng, TStats, TRngCalibration>

The modified builder.

Exceptions

ArgumentOutOfRangeException

calibrationSamples is negative.

WithControlVariate(bool)

Sets whether the European option is a control variate.

public MakeMCAmericanEngine<TRng, TStats, TRngCalibration> WithControlVariate(bool b = true)

Parameters

b bool

Whether to use the control variate.

Returns

MakeMCAmericanEngine<TRng, TStats, TRngCalibration>

The modified builder.

WithMaxSamples(int)

Sets the most samples for a tolerance.

public MakeMCAmericanEngine<TRng, TStats, TRngCalibration> WithMaxSamples(int samples)

Parameters

samples int

The most samples.

Returns

MakeMCAmericanEngine<TRng, TStats, TRngCalibration>

The modified builder.

Exceptions

ArgumentOutOfRangeException

samples is negative.

WithPolynomialOrder(int)

Sets the regression basis' highest order.

public MakeMCAmericanEngine<TRng, TStats, TRngCalibration> WithPolynomialOrder(int polynomialOrder)

Parameters

polynomialOrder int

The order.

Returns

MakeMCAmericanEngine<TRng, TStats, TRngCalibration>

The modified builder.

WithSamples(int)

Sets the number of samples.

public MakeMCAmericanEngine<TRng, TStats, TRngCalibration> WithSamples(int samples)

Parameters

samples int

The number of samples.

Returns

MakeMCAmericanEngine<TRng, TStats, TRngCalibration>

The modified builder.

Exceptions

ArgumentOutOfRangeException

samples is negative.

NanoQLException

A tolerance is already set.

WithSeed(long)

Sets the seed.

public MakeMCAmericanEngine<TRng, TStats, TRngCalibration> WithSeed(long seed)

Parameters

seed long

The seed, in [1, 4294967295].

Returns

MakeMCAmericanEngine<TRng, TStats, TRngCalibration>

The modified builder.

Exceptions

ArgumentOutOfRangeException

seed is outside its range.

WithSeedCalibration(long)

Sets the calibration seed.

public MakeMCAmericanEngine<TRng, TStats, TRngCalibration> WithSeedCalibration(long seed)

Parameters

seed long

The calibration seed, in [1, 4294967295].

Returns

MakeMCAmericanEngine<TRng, TStats, TRngCalibration>

The modified builder.

Exceptions

ArgumentOutOfRangeException

seed is outside its range.

WithSteps(int)

Sets the number of time steps.

public MakeMCAmericanEngine<TRng, TStats, TRngCalibration> WithSteps(int steps)

Parameters

steps int

The number of steps.

Returns

MakeMCAmericanEngine<TRng, TStats, TRngCalibration>

The modified builder.

WithStepsPerYear(int)

Sets the number of time steps per year.

public MakeMCAmericanEngine<TRng, TStats, TRngCalibration> WithStepsPerYear(int steps)

Parameters

steps int

The number of steps per year.

Returns

MakeMCAmericanEngine<TRng, TStats, TRngCalibration>

The modified builder.

Operators

operator ==(MakeMCAmericanEngine<TRng, TStats, TRngCalibration>?, MakeMCAmericanEngine<TRng, TStats, TRngCalibration>?)

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

Parameters

left MakeMCAmericanEngine<TRng, TStats, TRngCalibration>
right MakeMCAmericanEngine<TRng, TStats, TRngCalibration>

Returns

bool

operator !=(MakeMCAmericanEngine<TRng, TStats, TRngCalibration>?, MakeMCAmericanEngine<TRng, TStats, TRngCalibration>?)

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

Parameters

left MakeMCAmericanEngine<TRng, TStats, TRngCalibration>
right MakeMCAmericanEngine<TRng, TStats, TRngCalibration>

Returns

bool