Table of Contents

Class DiscretizedBarrierOption

Namespace
NanoQL.PricingEngines
Assembly
NanoQL.dll

A barrier option on a lattice: knocked out to its rebate, or knocked in to its vanilla, at the nodes beyond the barrier.

[WorkingType]
public sealed class DiscretizedBarrierOption : DiscretizedAsset, IDiscretizedBarrierAsset<DiscretizedBarrierOption>
Inheritance
DiscretizedBarrierOption
Implements
Inherited Members

Remarks

A working type, as every discretized asset is: its values are views of its buffers, its exercise reads the lattice's grid into a buffer it reserves at its widest step, and the vanilla sub-asset a knock-in rolls back beside it is kept and initialized again at each reset, so a rollback allocates nothing.

The American window is bounded by its two times compared with IsOnTime as well, upstream's fix after v1.44 (#2878): the grid's last time can be an ulp off the maturity the engine starts the asset at, where QuantLib 1.44's plain comparison skips the exercise at expiry (Divergences/BarrierUpstreamFixesTests.cs).

Constructors

DiscretizedBarrierOption(BarrierOption, StochasticProcess, TimeGrid?)

Initializes a new instance of the DiscretizedBarrierOption class.

public DiscretizedBarrierOption(BarrierOption option, StochasticProcess process, TimeGrid? grid = null)

Parameters

option BarrierOption

The barrier option.

process StochasticProcess

The process, which converts the exercise dates to times.

grid TimeGrid

The time grid the exercise times are moved to the closest of, or null for none, QuantLib's empty grid.

Exceptions

ArgumentNullException

option or process is null.

NanoQLException

The option has no payoff.

Properties

Barrier

Gets the option's barrier.

public double Barrier { get; }

Property Value

double

BarrierType

Gets the option's barrier type.

public BarrierType BarrierType { get; }

Property Value

BarrierType

Rebate

Gets the option's rebate.

public double Rebate { get; }

Property Value

double

Vanilla

Gets the vanilla sub-asset's values at its time: a view, valid until its next step or reset.

public ReadOnlySpan<double> Vanilla { get; }

Property Value

ReadOnlySpan<double>

Methods

CheckBarrier(Span<double>, ReadOnlySpan<double>)

Applies the barrier at the asset's time to values on a grid: a knock-out's nodes beyond the barrier take the rebate, a knock-in's the vanilla (exercised where the time is an exercise time), and the others the exercise, or a knock-in's rebate at the end.

public void CheckBarrier(Span<double> values, ReadOnlySpan<double> grid)

Parameters

values Span<double>

The values, written in place.

grid ReadOnlySpan<double>

The underlying's values at the nodes.

Exceptions

NanoQLException

The asset isn't on a lattice, or its exercise or barrier type is invalid.

MandatoryTimes()

The option's mandatory times: its exercise times.

public override ImmutableArray<double> MandatoryTimes()

Returns

ImmutableArray<double>

The times.

PostAdjustValuesImpl()

Rolls a knock-in's vanilla sub-asset back to the asset's time, then applies the barrier on the lattice's grid there.

protected override void PostAdjustValuesImpl()

Reset(int)

Sets the values to zero at the given size, initializes the vanilla sub-asset beside them, then applies the barrier.

public override void Reset(int size)

Parameters

size int

The number of values.

Exceptions

ArgumentOutOfRangeException

size is negative.

NanoQLException

The asset isn't on a lattice.

Explicit Interface Implementations

Create(BarrierOption, StochasticProcess, TimeGrid?)

Builds the asset of a barrier option.

static DiscretizedBarrierOption Create(BarrierOption option, StochasticProcess process, TimeGrid? grid)

Parameters

option BarrierOption

The barrier option.

process StochasticProcess

The process, which converts the exercise dates to times.

grid TimeGrid

The time grid the exercise times are moved to the closest of, or null for none, QuantLib's empty grid.

Returns

DiscretizedBarrierOption

The asset.