OpenPit C++ SDK
C++17 SDK for the OpenPit pre-trade risk engine
openpit::param::Quantity Class Referencefinal

Non-negative instrument quantity. More...

Inheritance diagram for openpit::param::Quantity:
Collaboration diagram for openpit::param::Quantity:

Public Member Functions

Notional CalculateNotional (const Price &price) const
 Calculates notional exposure at a price. More...
 
Volume CalculateVolume (const Price &price) const
 Calculates settlement volume at a price. More...
 
PositionSize ToPositionSize () const
 Converts the quantity to a positive position size. More...
 
PositionSize ToPositionSize (Side side) const
 Converts the quantity to a position size directed by side. More...
 
- Public Member Functions inherited from openpit::param::detail::ExactValue< Quantity, detail::QuantityTraits >
Quantity CheckedAdd (const Quantity &other) const
 Adds another value and throws openpit::Error on overflow. More...
 
Quantity CheckedDivFloat (double divisor) const
 Divides by an imprecise boundary double. More...
 
Quantity CheckedDivInt (std::int64_t divisor) const
 Divides by a signed integer and throws openpit::Error on failure. More...
 
Quantity CheckedDivUint (std::uint64_t divisor) const
 Divides by an unsigned integer and throws openpit::Error on failure. More...
 
Quantity CheckedMulFloat (double scalar) const
 Multiplies by an imprecise boundary double. More...
 
Quantity CheckedMulInt (std::int64_t scalar) const
 Multiplies by a signed integer and throws openpit::Error on failure. More...
 
Quantity CheckedMulUint (std::uint64_t scalar) const
 Multiplies by an unsigned integer and throws openpit::Error on failure. More...
 
Quantity CheckedRemFloat (double divisor) const
 Computes the remainder for an imprecise boundary double divisor. More...
 
Quantity CheckedRemInt (std::int64_t divisor) const
 Computes the remainder for a signed integer divisor. More...
 
Quantity CheckedRemUint (std::uint64_t divisor) const
 Computes the remainder for an unsigned integer divisor. More...
 
Quantity CheckedSubtract (const Quantity &other) const
 Subtracts another value and throws openpit::Error on failure. More...
 
int Compare (const Quantity &other) const
 Compares this value with another value of the same domain type. More...
 
::openpit::param::Decimal Decimal () const noexcept
 Returns the lossless decimal representation. More...
 
bool IsZero () const
 Returns whether the value is exactly zero. More...
 
bool operator!= (const Quantity &other) const
 
bool operator< (const Quantity &other) const
 
bool operator<= (const Quantity &other) const
 
bool operator== (const Quantity &other) const
 
bool operator> (const Quantity &other) const
 
bool operator>= (const Quantity &other) const
 
double ToDouble () const
 Converts to an imprecise boundary double. More...
 
std::string ToString () const
 Formats the exact value as a decimal string. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from openpit::param::detail::ExactValue< Quantity, detail::QuantityTraits >
static Quantity FromDecimal (Decimal value)
 Validates an exact decimal representation. More...
 
static Quantity FromDecimalRounded (Decimal value, std::uint32_t scale, RoundingStrategy rounding)
 Rounds an exact decimal representation to scale digits. More...
 
static Quantity FromDouble (double value)
 Creates a value from an imprecise boundary double. More...
 
static Quantity FromDoubleRounded (double value, std::uint32_t scale, RoundingStrategy rounding)
 Converts and rounds an imprecise boundary double. More...
 
static Quantity FromInt64 (std::int64_t value)
 Creates a value from a signed integer. More...
 
static Quantity FromString (std::string_view value)
 Parses an exact decimal string. More...
 
static Quantity FromStringRounded (std::string_view value, std::uint32_t scale, RoundingStrategy rounding)
 Parses and rounds an exact decimal string to scale digits. More...
 
static Quantity FromUint64 (std::uint64_t value)
 Creates a value from an unsigned integer. More...
 

Detailed Description

Non-negative instrument quantity.

Member Function Documentation

◆ CalculateNotional()

Notional openpit::param::Quantity::CalculateNotional ( const Price price) const
inline

Calculates notional exposure at a price.

◆ CalculateVolume()

Volume openpit::param::Quantity::CalculateVolume ( const Price price) const
inline

Calculates settlement volume at a price.

◆ ToPositionSize() [1/2]

PositionSize openpit::param::Quantity::ToPositionSize ( ) const
inline

Converts the quantity to a positive position size.

◆ ToPositionSize() [2/2]

PositionSize openpit::param::Quantity::ToPositionSize ( Side  side) const
inline

Converts the quantity to a position size directed by side.