Table of Contents

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

TRng

The random-number traits.

TStats

The statistics.

Inheritance
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

option PathMultiAssetOption

The path option.

context EvaluationContext

The evaluation context.

process StochasticProcess

The process the paths follow.

timeSteps int?

The number of time steps, or null.

timeStepsPerYear int?

The number of time steps per year, or null.

brownianBridge bool

Whether to build the paths by a Brownian bridge.

antitheticVariate bool

Whether to use antithetic paths.

controlVariate bool

Whether to use a control variate, which this engine doesn't provide.

requiredSamples int?

The number of samples, or null.

requiredTolerance double?

The tolerance, or null.

maxSamples int?

The largest number of samples, or null.

seed long

The seed, in [1, 4294967295].

nCalibrationSamples int?

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 nCalibrationSamples isn't positive.

Properties

BrownianBridge

Gets whether the paths are built by a Brownian bridge.

protected bool BrownianBridge { get; }

Property Value

bool

Context

Gets the evaluation context.

protected EvaluationContext Context { get; }

Property Value

EvaluationContext

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

int

Option

Gets the path option.

protected PathMultiAssetOption Option { get; }

Property Value

PathMultiAssetOption

Process

Gets the process the paths follow.

protected StochasticProcess Process { get; }

Property Value

StochasticProcess

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

double?

Seed

Gets the seed.

protected long Seed { get; }

Property Value

long

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.