|
ITCHCPP 1.6.0
High-Performance NASDAQ TotalView-ITCH 5.0 Parser & Market-Data Platform
|
A strongly typed fixed-point price carrying its own decimal scale. More...
#include <price.hpp>
Public Types | |
| using | raw_type = RawType |
Public Member Functions | |
| constexpr | BasicPrice () noexcept=default |
| Constructs a zero-valued price at this scale. | |
| constexpr | BasicPrice (raw_type raw_value) noexcept |
| Wraps a raw on-wire price value at this scale. | |
| constexpr auto | raw () const noexcept -> raw_type |
| The underlying raw integer value, exactly as it appears on the wire. | |
| constexpr auto | to_double () const noexcept -> double |
| The price as a floating-point value (raw / 10^Decimals). | |
| auto | to_string () const -> std::string |
| The price as a fixed-precision decimal string. | |
Static Public Member Functions | |
| static constexpr auto | divisor () noexcept -> raw_type |
| The scale's divisor, i.e. | |
Static Public Attributes | |
| static constexpr unsigned int | decimals = Decimals |
| The number of implied decimal places for this price scale. | |
Friends | |
| constexpr auto | operator== (BasicPrice, BasicPrice) noexcept -> bool=default |
| Compares two prices of the same scale for equality by raw value. | |
| constexpr auto | operator<=> (BasicPrice, BasicPrice) noexcept=default |
| Orders two prices of the same scale by raw value. | |
A strongly typed fixed-point price carrying its own decimal scale.
ITCH prices are wire integers with an implied number of decimal places. Standard price fields imply 4 decimals (divisor 10,000); MWCB decline-level prices imply 8 decimals (divisor 100,000,000). Exposing both as a bare uint32_t/uint64_t makes it trivially easy to divide by the wrong scale and silently produce a wrong price.
BasicPrice encodes the scale in the type. The two scales are therefore distinct types (StandardPrice vs MwcbPrice) that cannot be mixed, compared, or assigned to one another by accident: the 4-vs-8 decimal mistake becomes a compile error rather than a runtime bug.
| RawType | The unsigned integer type of the on-wire value. |
| Decimals | The number of implied decimal places. |
| using itch::BasicPrice< RawType, Decimals >::raw_type = RawType |
|
constexprdefaultnoexcept |
Constructs a zero-valued price at this scale.
|
inlineexplicitconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlinestaticconstexprnoexcept |
The scale's divisor, i.e.
10^Decimals.
Definition at line 61 of file price.hpp.
Referenced by itch::BasicPrice< RawType, Decimals >::to_double().
|
inlineconstexprnoexcept |
The price as a floating-point value (raw / 10^Decimals).
double. Definition at line 72 of file price.hpp.
References itch::BasicPrice< RawType, Decimals >::divisor().
Referenced by itch::BasicPrice< RawType, Decimals >::to_string().
|
inline |
The price as a fixed-precision decimal string.
Decimals fractional digits. Definition at line 79 of file price.hpp.
References itch::BasicPrice< RawType, Decimals >::to_double().
|
friend |
Compares two prices of the same scale for equality by raw value.
| lhs | The left-hand price. |
| rhs | The right-hand price. |
true if both prices have the same raw value.
|
friend |
Orders two prices of the same scale by raw value.
| lhs | The left-hand price. |
| rhs | The right-hand price. |
lhs and rhs.
|
staticconstexpr |