Table of Contents

Class CommodityType

Namespace
NanoQL.Experimental
Assembly
NanoQL.dll

A commodity type: its name and code, such as "Heating Oil" and "HO".

[Experimental("NQL0001")]
public class CommodityType : IEquatable<CommodityType>
Inheritance
CommodityType
Implements
Derived
Inherited Members

Remarks

Immutable, and an extension point: NullCommodityType derives from it, and a user may build one. QuantLib's empty CommodityType(), a placeholder whose members throw, is a CommodityType? null.

QuantLib keeps a process-wide registry keyed by code, so a second construction with a known code returns the first construction's name whatever it was given (commoditytype.cpp:28-38). There is no registry here, so every type holds the data it is given, a documented divergence (Divergences/CommodityRegistryTests.cs).

Two types are equal when their codes are, compared ordinally, as QuantLib's operator== compares them (commoditytype.hpp:107-109); the hash is the code's. The equality is sealed.

Constructors

CommodityType(string, string)

Initializes a new instance of the CommodityType class.

public CommodityType(string name, string code)

Parameters

name string

The type's name, such as "Heating Oil".

code string

The type's code, such as "HO".

Exceptions

ArgumentNullException

A string is null.

Properties

Code

Gets the type's code, such as "HO".

public string Code { get; }

Property Value

string

Name

Gets the type's name, such as "Heating Oil".

public string Name { get; }

Property Value

string

Methods

Equals(CommodityType?)

public bool Equals(CommodityType? other)

Parameters

other CommodityType

Returns

bool

Equals(object?)

public override sealed bool Equals(object? obj)

Parameters

obj object

Returns

bool

GetHashCode()

public override sealed int GetHashCode()

Returns

int

ToString()

The type's code, as QuantLib's operator<< writes it.

public override string ToString()

Returns

string

The code.

Operators

operator ==(CommodityType?, CommodityType?)

Whether two types are equal: their codes are.

public static bool operator ==(CommodityType? left, CommodityType? right)

Parameters

left CommodityType

A type, or null.

right CommodityType

Another type, or null.

Returns

bool

true when both are null or their codes are equal.

operator !=(CommodityType?, CommodityType?)

Whether two types differ.

public static bool operator !=(CommodityType? left, CommodityType? right)

Parameters

left CommodityType

A type, or null.

right CommodityType

Another type, or null.

Returns

bool

The negation of ==.