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
TRngThe pricing random-number traits.
TStatsThe statistics accumulator.
TRngCalibrationThe 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
processGeneralizedBlackScholesProcessThe Black-Scholes process.
seedlongThe seed, in [1, 4294967295].
Exceptions
- ArgumentNullException
processis null.- ArgumentOutOfRangeException
seedis outside its range.
Methods
Equals(MakeMCAmericanEngine<TRng, TStats, TRngCalibration>?)
public bool Equals(MakeMCAmericanEngine<TRng, TStats, TRngCalibration>? other)
Parameters
otherMakeMCAmericanEngine<TRng, TStats, TRngCalibration>
Returns
Equals(object?)
public override bool Equals(object? obj)
Parameters
objobject
Returns
GetHashCode()
public override int GetHashCode()
Returns
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
WithAbsoluteTolerance(double)
Sets the absolute tolerance.
public MakeMCAmericanEngine<TRng, TStats, TRngCalibration> WithAbsoluteTolerance(double tolerance)
Parameters
tolerancedoubleThe 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
bboolWhether 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
bboolWhether 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
polynomialTypeLsmBasisSystemPolynomialTypeThe 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
calibrationSamplesintThe number of calibration samples.
Returns
- MakeMCAmericanEngine<TRng, TStats, TRngCalibration>
The modified builder.
Exceptions
- ArgumentOutOfRangeException
calibrationSamplesis negative.
WithControlVariate(bool)
Sets whether the European option is a control variate.
public MakeMCAmericanEngine<TRng, TStats, TRngCalibration> WithControlVariate(bool b = true)
Parameters
bboolWhether 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
samplesintThe most samples.
Returns
- MakeMCAmericanEngine<TRng, TStats, TRngCalibration>
The modified builder.
Exceptions
- ArgumentOutOfRangeException
samplesis negative.
WithPolynomialOrder(int)
Sets the regression basis' highest order.
public MakeMCAmericanEngine<TRng, TStats, TRngCalibration> WithPolynomialOrder(int polynomialOrder)
Parameters
polynomialOrderintThe 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
samplesintThe number of samples.
Returns
- MakeMCAmericanEngine<TRng, TStats, TRngCalibration>
The modified builder.
Exceptions
- ArgumentOutOfRangeException
samplesis negative.- NanoQLException
A tolerance is already set.
WithSeed(long)
Sets the seed.
public MakeMCAmericanEngine<TRng, TStats, TRngCalibration> WithSeed(long seed)
Parameters
seedlongThe seed, in [1, 4294967295].
Returns
- MakeMCAmericanEngine<TRng, TStats, TRngCalibration>
The modified builder.
Exceptions
- ArgumentOutOfRangeException
seedis outside its range.
WithSeedCalibration(long)
Sets the calibration seed.
public MakeMCAmericanEngine<TRng, TStats, TRngCalibration> WithSeedCalibration(long seed)
Parameters
seedlongThe calibration seed, in [1, 4294967295].
Returns
- MakeMCAmericanEngine<TRng, TStats, TRngCalibration>
The modified builder.
Exceptions
- ArgumentOutOfRangeException
seedis outside its range.
WithSteps(int)
Sets the number of time steps.
public MakeMCAmericanEngine<TRng, TStats, TRngCalibration> WithSteps(int steps)
Parameters
stepsintThe 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
stepsintThe 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
leftMakeMCAmericanEngine<TRng, TStats, TRngCalibration>rightMakeMCAmericanEngine<TRng, TStats, TRngCalibration>
Returns
operator !=(MakeMCAmericanEngine<TRng, TStats, TRngCalibration>?, MakeMCAmericanEngine<TRng, TStats, TRngCalibration>?)
public static bool operator !=(MakeMCAmericanEngine<TRng, TStats, TRngCalibration>? left, MakeMCAmericanEngine<TRng, TStats, TRngCalibration>? right)
Parameters
leftMakeMCAmericanEngine<TRng, TStats, TRngCalibration>rightMakeMCAmericanEngine<TRng, TStats, TRngCalibration>