7#include <boost/multiprecision/cpp_int.hpp>
12#define SLICK_SIM_ZERO_SIZE_ARRAY_BEGIN _Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wpedantic\"")
13#define SLICK_SIM_ZERO_SIZE_ARRAY_END _Pragma("GCC diagnostic pop")
15#define SLICK_SIM_ZERO_SIZE_ARRAY_BEGIN
16#define SLICK_SIM_ZERO_SIZE_ARRAY_END
72inline std::string
to_fixed_string(int_fast64_t value,
unsigned min_frac_digits = 0) {
73 const bool negative = value < 0;
75 const uint64_t magnitude = negative
76 ? (0ULL -
static_cast<uint64_t
>(value))
77 :
static_cast<uint64_t
>(value);
80 uint64_t fraction = magnitude % scale;
86 out += std::to_string(magnitude / scale);
88 if (fraction == 0 && min_frac_digits == 0) {
93 for (
int i = 7; i >= 0; --i) {
94 digits[i] =
static_cast<char>(
'0' + fraction % 10);
97 std::string_view significant(digits, 8);
98 while (significant.size() > min_frac_digits && significant.back() ==
'0') {
99 significant.remove_suffix(1);
103 out.append(significant);
117inline bool iequals(std::string_view a, std::string_view b)
noexcept {
118 if (a.size() != b.size()) {
121 for (
size_t i = 0; i < a.size(); ++i) {
124 if (ca >=
'a' && ca <=
'z') { ca =
static_cast<char>(ca - (
'a' -
'A')); }
125 if (cb >=
'a' && cb <=
'z') { cb =
static_cast<char>(cb - (
'a' -
'A')); }
148#define SLICK_SIM_VENUE_LIST(X) \
151 X(COINBASE, "COINBASE") \
152 X(HYPERLIQUID, "HYPERLIQUID") \
157#define SLICK_SIM_VENUE_ENUMERATOR(name, text) name,
159#undef SLICK_SIM_VENUE_ENUMERATOR
165#define SLICK_SIM_VENUE_CASE(name, text) case Venue::name: return text;
167#undef SLICK_SIM_VENUE_CASE
178#define SLICK_SIM_VENUE_MATCH(name, text) \
179 if (detail::iequals(exch, text)) { return Venue::name; }
181#undef SLICK_SIM_VENUE_MATCH
bool iequals(std::string_view a, std::string_view b) noexcept
ASCII case-insensitive compare, used for every venue-name lookup.
Helpers for a venue whose one config entry describes several independent exchange instances,...
std::string to_fixed_string(int_fast64_t value, unsigned min_frac_digits=0)
Renders a fixed-point value as an exact decimal string.
constexpr price_t NULL_PRICE
constexpr int32_t DOUBLE_MULTIPLIER
constexpr symid_t INVALID_SYMBOL_ID
constexpr double to_price_double(price_t price)
Venue to_venue(std::string_view exch)
Matches venue names case-insensitively, including mixed-case names such as "Coinbase".
constexpr price_t to_price_t(double price)
Scales a decimal into the fixed-point representation, rounding to the nearest tick rather than trunca...
boost::multiprecision::uint128_t cum_value_t
constexpr const char * to_string(FeedState state) noexcept
std::string to_price_string(price_t price)
std::string to_qty_string(qty_t qty)
constexpr qty_t to_qty_t(double qty)
constexpr double to_qty_double(qty_t qty)
#define SLICK_SIM_VENUE_ENUMERATOR(name, text)
#define SLICK_SIM_VENUE_MATCH(name, text)
#define SLICK_SIM_VENUE_CASE(name, text)
#define SLICK_SIM_VENUE_LIST(X)
One line per venue: the enumerator, then the canonical name to_string returns and to_venue accepts.