Class MCLongstaffSchwartzPathEngine<TRng, TStats>
- Namespace
- NanoQL.Experimental
- Assembly
- NanoQL.dll
The Longstaff-Schwartz Monte Carlo engine for path options (Longstaff and Schwartz, 2001): calibration paths fit the exercise decisions, then the pricing paths are valued on them.
[Experimental("NQL0001")]
public abstract class MCLongstaffSchwartzPathEngine<TRng, TStats> : McSimulation<MultiPath, TStats> where TRng : IRngTraits where TStats : IStatistics, new()
Type Parameters
TRngThe random-number traits.
TStatsThe statistics.
- Inheritance
-
McSimulation<MultiPath, TStats>MCLongstaffSchwartzPathEngine<TRng, TStats>
- Derived
- Inherited Members
Remarks
An extension point and an immutable object: a concrete engine's static Calculate builds one per call and
implements LsmPathPricer(). Run() builds the pricer, adds the calibration samples,
calibrates and prices on the same pricer, QuantLib's mutable pricer the call's working state.
One seed draws the calibration and the pricing paths, so the pricing run's first paths are the calibration's (Longstaff and Schwartz's in-sample estimator, QuantLib's code); there is no calibration seed, as QuantLib's path engine has none. The calibration samples default to 2,048; none is refused, where QuantLib's calibration reads the first of no path.
Constructors
MCLongstaffSchwartzPathEngine(PathMultiAssetOption, EvaluationContext, StochasticProcess, int?, int?, bool, bool, bool, int?, double?, int?, long, int?)
Initializes a new instance of the MCLongstaffSchwartzPathEngine<TRng, TStats> class.
protected MCLongstaffSchwartzPathEngine(PathMultiAssetOption option, EvaluationContext context, StochasticProcess process, int? timeSteps, int? timeStepsPerYear, bool brownianBridge, bool antitheticVariate, bool controlVariate, int? requiredSamples, double? requiredTolerance, int? maxSamples, long seed, int? nCalibrationSamples = null)
Parameters
optionPathMultiAssetOptionThe path option.
contextEvaluationContextThe evaluation context.
processStochasticProcessThe process the paths follow.
timeStepsint?The number of time steps, or null.
timeStepsPerYearint?The number of time steps per year, or null.
brownianBridgeboolWhether to build the paths by a Brownian bridge.
antitheticVariateboolWhether to use antithetic paths.
controlVariateboolWhether to use a control variate, which this engine doesn't provide.
requiredSamplesint?The number of samples, or null.
requiredTolerancedouble?The tolerance, or null.
maxSamplesint?The largest number of samples, or null.
seedlongThe seed, in [1, 4294967295].
nCalibrationSamplesint?The calibration samples, positive, or null for 2,048.
Exceptions
- ArgumentNullException
An argument is null.
- ArgumentException
The time steps are neither or both given, or not positive.
- ArgumentOutOfRangeException
The seed or a sample count is out of range, or
nCalibrationSamplesisn't positive.
Properties
BrownianBridge
Gets whether the paths are built by a Brownian bridge.
protected bool BrownianBridge { get; }
Property Value
Context
Gets the evaluation context.
protected EvaluationContext Context { get; }
Property Value
MaxSamples
Gets the largest number of samples, or null.
protected int? MaxSamples { get; }
Property Value
- int?
NCalibrationSamples
Gets the number of calibration samples.
protected int NCalibrationSamples { get; }
Property Value
Option
Gets the path option.
protected PathMultiAssetOption Option { get; }
Property Value
Process
Gets the process the paths follow.
protected StochasticProcess Process { get; }
Property Value
RequiredSamples
Gets the number of samples, or null.
protected int? RequiredSamples { get; }
Property Value
- int?
RequiredTolerance
Gets the tolerance, or null.
protected double? RequiredTolerance { get; }
Property Value
Seed
Gets the seed.
protected long Seed { get; }
Property Value
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
LsmPathPricer()
The engine's path pricer, in its calibration phase.
protected abstract LongstaffSchwartzMultiPathPricer LsmPathPricer()
Returns
- LongstaffSchwartzMultiPathPricer
The pricer.
PathGenerator()
The path generator.
protected override IPathGenerator<MultiPath> PathGenerator()
Returns
- IPathGenerator<MultiPath>
A new path generator.
PathPricer()
The path pricer.
protected override PathPricer<MultiPath> PathPricer()
Returns
- PathPricer<MultiPath>
A new path pricer.
Exceptions
- NanoQLException
Always ("path pricer unknown"): Run() passes its pricer.
Run()
QuantLib's calculate(): the pricer, the calibration samples on the pricing generator, the calibration,
and the pricing on the same pricer.
protected MonteCarloModel<MultiPath, TStats> Run()
Returns
- MonteCarloModel<MultiPath, TStats>
The pricing model.
TimeGrid()
The time grid of the paths.
protected override TimeGrid TimeGrid()
Returns
- TimeGrid
The time grid.