Represents rules for valid price quantization for a given instrument on a certain exchange.
More...
|
| std::string | getText () const |
| | Returns textual representation of price increments in the format:
|
| |
| std::vector< double > | getPriceIncrements () const |
| | Returns internal representation of price increments as a single array of double values.
|
| |
| double | getPriceIncrement () const |
| | Returns the first price increment (for price range adjacent to 0), usually the smallest one.
|
| |
| double | getPriceIncrement (double price) const |
| | Returns price increment which shall be applied to the specified price.
|
| |
| double | getPriceIncrement (double price, std::int32_t direction) const |
| | Returns price increment which shall be applied to the specified price in the specified direction.
|
| |
| std::int32_t | getPricePrecision () const |
| | Returns first price precision (for price range adjacent to 0), usually the largest one.
|
| |
| std::int32_t | getPricePrecision (double price) const |
| | Returns price precision for the price range which contains a specified price.
|
| |
| double | roundPrice (double price) const |
| | Returns specified price rounded to nearest valid value.
|
| |
| double | roundPrice (double price, std::int32_t direction) const |
| | Returns specified price rounded in the specified direction to the nearest value that is valid, according to price increment rules.
|
| |
| double | roundPrice (double price, RoundingMode roundingMode) const |
| | Returns specified price rounded according to specified rounding mode to nearest value that is valid, according to price increment rules.
|
| |
| double | incrementPrice (double price, std::int32_t direction) const |
| | Returns specified price incremented in the specified direction by appropriate increment and then rounded to the nearest valid value.
|
| |
| double | incrementPrice (double price, std::int32_t direction, double step) const |
| | Returns specified price incremented in the specified direction by the maximum of a specified step and appropriate increment, and then rounded to the nearest valid value.
|
| |
| bool | operator== (const PriceIncrements &other) const |
| | Returns true if this object is equal to other object.
|
| |
| bool | operator== (const PriceIncrements::Ptr &other) const |
| | Returns true if this object is equal to other object.
|
| |
| std::size_t | hashCode () const noexcept |
| |
| std::string | toString () const override |
| | Returns a string representation of the current object.
|
| |
| template<typename T> |
| bool | is () const noexcept |
| | Checks that the pointer to the current type could be converted to type T* In other words: whether type T belongs to the type hierarchy in which the current type resides.
|
| |
| template<typename T> |
| std::shared_ptr< T > | sharedAs () noexcept |
| | Returns a pointer to the current object wrapped in a smart pointer to type T.
|
| |
| template<typename T> |
| std::shared_ptr< T > | sharedAs () const noexcept |
| | Returns a pointer to the current object wrapped in a smart pointer to type T.
|
| |
|
virtual | ~Entity () noexcept=default |
| | The default virtual d-tor.
|
| |
|
| static Ptr | valueOf (const StringLike &text) |
| | Returns an instance of price increments for specified textual representation.
|
| |
| static Ptr | valueOf (double increment) |
| | Returns an instance of price increments for a specified single increment.
|
| |
| static Ptr | valueOf (const std::vector< double > &increments) |
| | Returns an instance of price increments for specified internal representation.
|
| |
| static Ptr | valueOf (std::initializer_list< double > increments) |
| | Returns an instance of price increments for specified internal representation.
|
| |
| static auto | createShared (Args &&...args) |
| | Creates a smart pointer to an object.
|
| |
Represents rules for valid price quantization for a given instrument on a certain exchange.
These rules are defined as a set of price ranges with associated price increments. Each price increment defines what price values are valid for the corresponding price range-valid prices shall be divisible by corresponding price increment.
All price ranges shall be mutually exclusive, and they shall cover the entire space from 0 to infinity. Therefore, all ranges can be represented as a sequence of numbers where increments are interleaved with range limits, with extreme limits (0 and infinity) omitted for short. Negative space (from negative infinity to 0) uses symmetrical price ranges.
There is a special value PriceIncrements::EMPTY that is used to represent unknown or undefined rules. This value has empty textual representation and is considered to have a sole increment with value 0.
See PriceIncrements::getText() and PriceIncrements::getPriceIncrements() for details about used formats and representations.
NOTE:This class produces precise results for decimal numbers with at most 14 significant digits and at most 14 digits after the decimal point.
| std::int32_t PriceIncrements::getPricePrecision |
( |
double | price | ) |
const |
Returns price precision for the price range which contains a specified price.
Price precision is a number of decimal digits after decimal point that are needed to represent all valid prices in the given price range. This method returns price precision in the interval [0, 18] inclusive. If the price is Not-a-Number (NaN), then the first price precision is returned. If the price is a breakpoint between two ranges, then precision of the lower range is returned.
- Parameters
-
- Returns
- The price precision.
| std::string PriceIncrements::getText |
( |
| ) |
const |
Returns textual representation of price increments in the format:
TEXT ::= "" | LIST
LIST ::= INCREMENT | RANGE "; " LIST
RANGE ::= INCREMENT " " UPPER_LIMIT
Where INCREMENT is a price increment in the given price range and UPPER_LIMIT is the upper bound of that range. All ranges are listed in the ascending order of upper limits, and the last range is considered to extend toward infinity and is therefore specified without upper limit. All increments and limits are finite positive numbers. The case with empty text is a special stub used for PriceIncrements::EMPTY value, it uses a sole increment with value 0.
- Returns
- The textual representation.
| double PriceIncrements::roundPrice |
( |
double | price, |
|
|
std::int32_t | direction ) const |
Returns specified price rounded in the specified direction to the nearest value that is valid, according to price increment rules.
If the price is Not-a-Number (NaN), then NaN is returned. If the appropriate price increment is 0, then the specified price is returned as is. If a direction is 0, then the price is rounded to the nearest valid value.
- Parameters
-
| price | The price to round. |
| direction | The direction. |
- Returns
- The rounded price.