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

Signed profit-and-loss contribution. More...

Inheritance diagram for openpit::param::Pnl:
Collaboration diagram for openpit::param::Pnl:

Public Member Functions

Pnl CheckedNeg () const
 Negates the PnL and throws openpit::Error on overflow. More...
 
CashFlow ToCashFlow () const
 Converts the PnL to an equivalent cash-flow contribution. More...
 
PositionSize ToPositionSize () const
 Converts the PnL to an equivalent signed position size. More...
 
- Public Member Functions inherited from openpit::param::detail::ExactValue< Pnl, detail::PnlTraits >
Pnl CheckedAdd (const Pnl &other) const
 Adds another value and throws openpit::Error on overflow. More...
 
Pnl CheckedDivFloat (double divisor) const
 Divides by an imprecise boundary double. More...
 
Pnl CheckedDivInt (std::int64_t divisor) const
 Divides by a signed integer and throws openpit::Error on failure. More...
 
Pnl CheckedDivUint (std::uint64_t divisor) const
 Divides by an unsigned integer and throws openpit::Error on failure. More...
 
Pnl CheckedMulFloat (double scalar) const
 Multiplies by an imprecise boundary double. More...
 
Pnl CheckedMulInt (std::int64_t scalar) const
 Multiplies by a signed integer and throws openpit::Error on failure. More...
 
Pnl CheckedMulUint (std::uint64_t scalar) const
 Multiplies by an unsigned integer and throws openpit::Error on failure. More...
 
Pnl CheckedRemFloat (double divisor) const
 Computes the remainder for an imprecise boundary double divisor. More...
 
Pnl CheckedRemInt (std::int64_t divisor) const
 Computes the remainder for a signed integer divisor. More...
 
Pnl CheckedRemUint (std::uint64_t divisor) const
 Computes the remainder for an unsigned integer divisor. More...
 
Pnl CheckedSubtract (const Pnl &other) const
 Subtracts another value and throws openpit::Error on failure. More...
 
int Compare (const Pnl &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 Pnl &other) const
 
bool operator< (const Pnl &other) const
 
bool operator<= (const Pnl &other) const
 
bool operator== (const Pnl &other) const
 
bool operator> (const Pnl &other) const
 
bool operator>= (const Pnl &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...
 

Static Public Member Functions

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

Detailed Description

Signed profit-and-loss contribution.

Member Function Documentation

◆ CheckedNeg()

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

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

◆ FromFee()

Pnl openpit::param::Pnl::FromFee ( const Fee fee)
inlinestatic

Converts a fee contribution to its PnL effect.

◆ ToCashFlow()

CashFlow openpit::param::Pnl::ToCashFlow ( ) const
inline

Converts the PnL to an equivalent cash-flow contribution.

◆ ToPositionSize()

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

Converts the PnL to an equivalent signed position size.