ITCH 5.0 Market Data Handler 1.0.0
NASDAQ ITCH 5.0 Market Data Feed Handler
Loading...
Searching...
No Matches
Constants.h File Reference

Common constants and conversion utilities. More...

Detailed Description

Common constants and conversion utilities.

This file provides constants and utility functions for financial data processing, including:

  • Price and quantity multipliers for fixed-point representation
  • Fractional price constants for various markets
  • Conversion functions between internal and SBE (Simple Binary Encoding) formats
  • Decimal place calculations for price precision

Fixed-point representation is used to avoid floating-point precision issues in financial calculations.

#include <cstdint>

Namespaces

namespace  b2bits
namespace  b2bits::constants
namespace  b2bits::constants::detail
 Internal utility functions for financial data conversion.

Functions

std::int64_t b2bits::constants::detail::to_sbe_price_mantissa (std::int64_t val, std::int64_t mult=constants::SBE_PRICE_MULTIPLIER) noexcept
 Convert value to SBE price mantissa (fixed-point representation).
std::int64_t b2bits::constants::detail::to_sbe_qty_mantissa (std::int64_t val, std::int64_t mult=constants::SBE_QTY_MULTIPLIER) noexcept
 Convert value to SBE quantity mantissa (fixed-point representation).
constexpr std::uint16_t b2bits::constants::detail::num_price_decimals (std::uint64_t multiplier)
 Calculate number of decimal places in a multiplier.
constexpr bool b2bits::constants::detail::validate_num_price_decimals (std::uint16_t num_decimals)
 Validate that number of decimals is within supported range.
constexpr std::uint64_t b2bits::constants::detail::calculate_multiplier (std::uint16_t num_of_decimals)
 Calculate multiplier for a given number of decimal places.

Variables

static constexpr std::int64_t b2bits::constants::SBE_PRICE_MULTIPLIER = 1'000'000'000
 SBE price multiplier (1 billion) - converts prices to fixed-point with 9 decimal places.
static constexpr std::int64_t b2bits::constants::SBE_QTY_MULTIPLIER = 100
 SBE quantity multiplier (100) - converts quantities to fixed-point with 2 decimal places.
static constexpr std::int64_t b2bits::constants::INVALID_COUPON_RATE = -1
 Sentinel value indicating an invalid or missing coupon rate.
constexpr double b2bits::constants::PRICE_FRACTION_256 = 1.0 / 256LL
 Price fraction 1/256 - used for US Treasury securities pricing.
constexpr double b2bits::constants::PRICE_FRACTION_512 = 1.0 / 512LL
 Price fraction 1/512 - used for some Treasury securities (1/2 of 1/256).
constexpr double b2bits::constants::PRICE_FRACTION_100 = 1.0 / 100LL
 Price fraction 1/100 - standard percentage/decimal pricing.
constexpr double b2bits::constants::PRICE_FRACTION_50000 = 5.0 / 10000LL
 Price fraction 5/10000 (0.0005) - used for fine-grained pricing.
static constexpr int b2bits::constants::UNDERLYING_PRODUCT_GOVERNMENT = 6
 Product type identifier for government securities (bonds, notes, etc.).