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

Per-unit instrument price; may be negative in derivative markets. More...

Inheritance diagram for openpit::param::Price:
Collaboration diagram for openpit::param::Price:

Public Member Functions

Notional CalculateNotional (const Quantity &quantity) const
 Calculates notional exposure for a quantity. More...
 
PositionSize CalculatePositionSize (const Quantity &quantity) const
 Calculates signed position size for a quantity. More...
 
Volume CalculateVolume (const Quantity &quantity) const
 Calculates settlement volume for a quantity. More...
 
Price CheckedNeg () const
 Negates the price and throws openpit::Error on overflow. More...
 
- Public Member Functions inherited from openpit::param::detail::ExactValue< Price, detail::PriceTraits >
Price CheckedAdd (const Price &other) const
 Adds another value and throws openpit::Error on overflow. More...
 
Price CheckedDivFloat (double divisor) const
 Divides by an imprecise boundary double. More...
 
Price CheckedDivInt (std::int64_t divisor) const
 Divides by a signed integer and throws openpit::Error on failure. More...
 
Price CheckedDivUint (std::uint64_t divisor) const
 Divides by an unsigned integer and throws openpit::Error on failure. More...
 
Price CheckedMulFloat (double scalar) const
 Multiplies by an imprecise boundary double. More...
 
Price CheckedMulInt (std::int64_t scalar) const
 Multiplies by a signed integer and throws openpit::Error on failure. More...
 
Price CheckedMulUint (std::uint64_t scalar) const
 Multiplies by an unsigned integer and throws openpit::Error on failure. More...
 
Price CheckedRemFloat (double divisor) const
 Computes the remainder for an imprecise boundary double divisor. More...
 
Price CheckedRemInt (std::int64_t divisor) const
 Computes the remainder for a signed integer divisor. More...
 
Price CheckedRemUint (std::uint64_t divisor) const
 Computes the remainder for an unsigned integer divisor. More...
 
Price CheckedSubtract (const Price &other) const
 Subtracts another value and throws openpit::Error on failure. More...
 
int Compare (const Price &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 Price &other) const
 
bool operator< (const Price &other) const
 
bool operator<= (const Price &other) const
 
bool operator== (const Price &other) const
 
bool operator> (const Price &other) const
 
bool operator>= (const Price &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< Price, detail::PriceTraits >
static Price FromDecimal (Decimal value)
 Validates an exact decimal representation. More...
 
static Price FromDecimalRounded (Decimal value, std::uint32_t scale, RoundingStrategy rounding)
 Rounds an exact decimal representation to scale digits. More...
 
static Price FromDouble (double value)
 Creates a value from an imprecise boundary double. More...
 
static Price FromDoubleRounded (double value, std::uint32_t scale, RoundingStrategy rounding)
 Converts and rounds an imprecise boundary double. More...
 
static Price FromInt64 (std::int64_t value)
 Creates a value from a signed integer. More...
 
static Price FromString (std::string_view value)
 Parses an exact decimal string. More...
 
static Price FromStringRounded (std::string_view value, std::uint32_t scale, RoundingStrategy rounding)
 Parses and rounds an exact decimal string to scale digits. More...
 
static Price FromUint64 (std::uint64_t value)
 Creates a value from an unsigned integer. More...
 

Detailed Description

Per-unit instrument price; may be negative in derivative markets.

Member Function Documentation

◆ CalculateNotional()

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

Calculates notional exposure for a quantity.

◆ CalculatePositionSize()

PositionSize openpit::param::Price::CalculatePositionSize ( const Quantity quantity) const
inline

Calculates signed position size for a quantity.

◆ CalculateVolume()

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

Calculates settlement volume for a quantity.

◆ CheckedNeg()

Price openpit::param::Price::CheckedNeg ( ) const
inline

Negates the price and throws openpit::Error on overflow.