Table of Contents

Class DataFormattersFunctions

Namespace
NanoQL.Utilities
Assembly
NanoQL.dll

QuantLib's output manipulators (dataformatters.hpp), returning the text they would write.

public static class DataFormattersFunctions
Inheritance
DataFormattersFunctions
Inherited Members

Remarks

Where QuantLib streams a number with the stream's defaults, the text follows a C++ stream: six significant digits, trailing zeros removed, an exponent of at least two digits (1e-07), and exact ties rounded half to even. A bool is written True or False, where a C++ stream writes 1 or 0; QuantLib streams no boolean through these functions.

Methods

CheckNull<T>(T?)

A value, or "null" for a missing one.

public static string CheckNull<T>(T? value) where T : struct

Parameters

value T?

The value, or null.

Returns

string

The text.

Type Parameters

T

The value's type.

Ordinal(int)

A natural number as an ordinal: 1st, 2nd, 3rd, 4th, 11th, 12th, 13th, 21st, ...

public static string Ordinal(int n)

Parameters

n int

The number.

Returns

string

The text.

Remarks

As in QuantLib, only 11, 12 and 13 are special-cased, so 111 gives "111st".

Percent(double?)

A real as a percentage with six decimals, e.g. "3.250000 %".

public static string Percent(double? value)

Parameters

value double?

The value, or null.

Returns

string

The text, or "null".

Remarks

As in QuantLib, the percentage is the product value * 100.0, so a value whose product overflows is written as infinite; a NaN or infinite percentage is written as a C++ stream writes it, "nan", "inf" or "-inf".

PowerOfTwo<T>(T?)

An integer as an odd number times a power of two, e.g. "3*2^2" for 12.

public static string PowerOfTwo<T>(T? n) where T : struct, IBinaryInteger<T>

Parameters

n T?

The number, or null.

Returns

string

The text, or "null".

Type Parameters

T

The integer type.

Rate(double?)

A rate or spread as a percentage.

public static string Rate(double? r)

Parameters

r double?

The rate, or null.

Returns

string

The text, or "null".

Sequence<T>(IEnumerable<T>)

A sequence as space-separated values in parentheses, e.g. "( 1 2.5 3 )".

public static string Sequence<T>(IEnumerable<T> c)

Parameters

c IEnumerable<T>

The sequence.

Returns

string

The text.

Type Parameters

T

The element type.

Volatility(double?)

A volatility as a percentage.

public static string Volatility(double? v)

Parameters

v double?

The volatility, or null.

Returns

string

The text, or "null".