Table of Contents

Class EnergyFuture

Namespace
NanoQL.Experimental
Assembly
NanoQL.dll

An energy future: a quantity bought or sold at a trade price, valued at its index's quote.

[Experimental("NQL0001")]
public sealed class EnergyFuture : EnergyCommodity
Inheritance
EnergyFuture
Inherited Members

Remarks

The value is (quote − trade price) × quantity × lots × buy-sell, in the base currency and unit, less the secondary costs. The quote is the index's stored fixing when its last quote date is the evaluation date or the day before, its forward price at the evaluation date otherwise (with QuantLib's warning). The future never expires, as QuantLib's.

Three of QuantLib's lines are fixed (Divergences/EnergyFutureTests.cs):

  • The lot multiplies the quantity once: QuantLib's conversion factor already carries it and the value multiplies by it again, so lot 1,000 prices 5,000,000 there for 5,000 here;
  • The secondary costs are charged on the quantity the value uses, in the base unit with its lots, where QuantLib's reads the raw amount (a fee of 0.1 a unit on 10 gallons reads 42 there, 1 here);
  • Within QuantLib's window the quote is the stored history's entry for the evaluation date where there is one (QuantLib's), else the day before's, read from the history itself: QuantLib reads the evaluation date's fixing alone, so with the last fixing yesterday it refuses ("missing quote"), and through the index's fixing, which refuses a Saturday evaluation on a weekday index. Neither entry: QuantLib's "missing quote".

Constructors

EnergyFuture(int, Quantity, CommodityUnitCost, CommodityIndex, CommodityType, IReadOnlyDictionary<string, object>?)

Initializes a new instance of the EnergyFuture class.

public EnergyFuture(int buySell, Quantity quantity, CommodityUnitCost tradePrice, CommodityIndex index, CommodityType commodityType, IReadOnlyDictionary<string, object>? secondaryCosts)

Parameters

buySell int

1 for a bought future, −1 for a sold one (QuantLib's integer, any value taken).

quantity Quantity

The quantity per lot, in its unit.

tradePrice CommodityUnitCost

The trade price, per its unit.

index CommodityIndex

The index.

commodityType CommodityType

The commodity type.

secondaryCosts IReadOnlyDictionary<string, object>

The secondary costs by name; null for none.

Exceptions

ArgumentNullException

An argument but the costs is null.

Properties

BuySell

Gets 1 for a bought future, −1 for a sold one.

public int BuySell { get; }

Property Value

int

Index

Gets the index.

public CommodityIndex Index { get; }

Property Value

CommodityIndex

Quantity

Gets the quantity the instrument delivers.

public override Quantity Quantity { get; }

Property Value

Quantity

TradePrice

Gets the trade price, per its unit.

public CommodityUnitCost TradePrice { get; }

Property Value

CommodityUnitCost

Methods

Calculate(EvaluationContext)

Prices the future: QuantLib's performCalculations, in the context's base currency and unit.

public EnergyCommodityResults Calculate(EvaluationContext context)

Parameters

context EvaluationContext

The evaluation context.

Returns

EnergyCommodityResults

The NPV, the secondary cost amounts and the pricing errors.

Exceptions

ArgumentNullException

context is null.

NanoQLException

The quote is missing ("missing quote for …"), or a price, quantity or cost can't be converted.

IsExpired(EvaluationContext)

Whether the instrument might still have a value greater than zero.

public override bool IsExpired(EvaluationContext context)

Parameters

context EvaluationContext

The evaluation context.

Returns

bool

true when the instrument has expired.

Remarks

Never, as QuantLib's.