Class MakeMCBarrierEngine<TRng, TStats>
- Namespace
- NanoQL.PricingEngines
- Assembly
- NanoQL.dll
A builder of the Monte Carlo barrier engine, with QuantLib's defaults but the seed.
public sealed record MakeMCBarrierEngine<TRng, TStats> : IEquatable<MakeMCBarrierEngine<TRng, TStats>> where TRng : IRngTraits where TStats : IStatistics, new()
Type Parameters
TRngThe random-number traits.
TStatsThe statistics accumulator.
- Inheritance
-
MakeMCBarrierEngine<TRng, TStats>
- Implements
-
IEquatable<MakeMCBarrierEngine<TRng, TStats>>
- Inherited Members
Remarks
An immutable builder: each method returns a modified copy. ToEngine() returns the engine as a function of the option and the context, its settings bound, in place of QuantLib's conversion to a pricing engine, with QuantLib's checks on the steps. A builder has no value equality.
The seed is a constructor argument (as in MakeMCHullWhiteCapFloorEngine<TRng, TStats>): QuantLib's default, 0, a seed from the clock, is refused.
Constructors
MakeMCBarrierEngine(GeneralizedBlackScholesProcess, long)
Initializes a new instance of the MakeMCBarrierEngine<TRng, TStats> record.
public MakeMCBarrierEngine(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(MakeMCBarrierEngine<TRng, TStats>?)
public bool Equals(MakeMCBarrierEngine<TRng, TStats>? other)
Parameters
otherMakeMCBarrierEngine<TRng, TStats>
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<BarrierOption, EvaluationContext, OneAssetOptionResults> ToEngine()
Returns
- Func<BarrierOption, 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 MakeMCBarrierEngine<TRng, TStats> WithAbsoluteTolerance(double tolerance)
Parameters
tolerancedoubleThe tolerance.
Returns
- MakeMCBarrierEngine<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 MakeMCBarrierEngine<TRng, TStats> WithAntitheticVariate(bool b = true)
Parameters
bboolWhether to use antithetic variates.
Returns
- MakeMCBarrierEngine<TRng, TStats>
The modified builder.
WithBias(bool)
Sets whether the barrier is checked at the path's points only, the biased pricer.
public MakeMCBarrierEngine<TRng, TStats> WithBias(bool b = true)
Parameters
bboolWhether to use the biased pricer.
Returns
- MakeMCBarrierEngine<TRng, TStats>
The modified builder.
WithBrownianBridge(bool)
Sets whether the draws are ordered by a Brownian bridge.
public MakeMCBarrierEngine<TRng, TStats> WithBrownianBridge(bool b = true)
Parameters
bboolWhether to use a Brownian bridge.
Returns
- MakeMCBarrierEngine<TRng, TStats>
The modified builder.
WithMaxSamples(int)
Sets the most samples for a tolerance.
public MakeMCBarrierEngine<TRng, TStats> WithMaxSamples(int samples)
Parameters
samplesintThe most samples.
Returns
- MakeMCBarrierEngine<TRng, TStats>
The modified builder.
Exceptions
- ArgumentOutOfRangeException
samplesis negative.
WithSamples(int)
Sets the number of samples.
public MakeMCBarrierEngine<TRng, TStats> WithSamples(int samples)
Parameters
samplesintThe number of samples.
Returns
- MakeMCBarrierEngine<TRng, TStats>
The modified builder.
Exceptions
- ArgumentOutOfRangeException
samplesis negative.- NanoQLException
A tolerance is already set.
WithSeed(long)
Sets the seed.
public MakeMCBarrierEngine<TRng, TStats> WithSeed(long seed)
Parameters
seedlongThe seed, in [1, 4294967295].
Returns
- MakeMCBarrierEngine<TRng, TStats>
The modified builder.
Exceptions
- ArgumentOutOfRangeException
seedis outside its range.
WithSteps(int)
Sets the number of time steps.
public MakeMCBarrierEngine<TRng, TStats> WithSteps(int steps)
Parameters
stepsintThe number of steps.
Returns
- MakeMCBarrierEngine<TRng, TStats>
The modified builder.
WithStepsPerYear(int)
Sets the number of time steps per year.
public MakeMCBarrierEngine<TRng, TStats> WithStepsPerYear(int steps)
Parameters
stepsintThe number of steps per year.
Returns
- MakeMCBarrierEngine<TRng, TStats>
The modified builder.
Operators
operator ==(MakeMCBarrierEngine<TRng, TStats>?, MakeMCBarrierEngine<TRng, TStats>?)
public static bool operator ==(MakeMCBarrierEngine<TRng, TStats>? left, MakeMCBarrierEngine<TRng, TStats>? right)
Parameters
leftMakeMCBarrierEngine<TRng, TStats>rightMakeMCBarrierEngine<TRng, TStats>
Returns
operator !=(MakeMCBarrierEngine<TRng, TStats>?, MakeMCBarrierEngine<TRng, TStats>?)
public static bool operator !=(MakeMCBarrierEngine<TRng, TStats>? left, MakeMCBarrierEngine<TRng, TStats>? right)
Parameters
leftMakeMCBarrierEngine<TRng, TStats>rightMakeMCBarrierEngine<TRng, TStats>