FastMM documentation
FastMM C++ API 0.6.0
Public headers, tier 1 and tier 2
Loading...
Searching...
No Matches
decimal.hpp File Reference

Exact decimal helpers for venue payloads (6.2). More...

#include "fastmm/core/fixed_point.hpp"
#include "fastmm/core/result.hpp"
#include "fastmm/core/time.hpp"
#include <cstddef>
#include <cstdint>
#include <limits>
#include <string_view>

Go to the source code of this file.

Classes

class  fastmm::venues::DecimalText
 Stack formatting buffer: DecimalText t(px); send(t.view()); - no heap, no locale. More...
 

Namespaces

namespace  fastmm
 
namespace  fastmm::venues
 

Enumerations

enum class  fastmm::venues::DecimalError : std::uint8_t { fastmm::venues::Empty = 1 , fastmm::venues::Malformed = 2 , fastmm::venues::Overflow = 3 }
 

Functions

constexpr std::string_view fastmm::venues::to_string (DecimalError e) noexcept
 
template<class F >
Result< F, DecimalError > fastmm::venues::parse_fixed (std::string_view s) noexcept
 
Result< Price, DecimalError > fastmm::venues::parse_price (std::string_view s) noexcept
 
template<class F >
Result< F, DecimalError > fastmm::venues::parse_rounded (std::string_view s) noexcept
 A value the venue computed rather than one an order carries can have more fraction digits than 8: Binance USDⓈ-M's positionRisk and ACCOUNT_UPDATE give an entry price of "83954.61851851852", OKX a spot commission of "-0.00000192834" BTC (fillSz times the fee rate).
 
Result< Price, DecimalError > fastmm::venues::parse_avg_price (std::string_view s) noexcept
 A position's entry price, an average fill price.
 
Result< Notional, DecimalError > fastmm::venues::parse_fee (std::string_view s) noexcept
 A commission, which the venue computes from the fill.
 
Result< Qty, DecimalError > fastmm::venues::parse_qty (std::string_view s) noexcept
 
Result< Notional, DecimalError > fastmm::venues::parse_notional (std::string_view s) noexcept
 
Result< std::int64_t, DecimalError > fastmm::venues::parse_int64 (std::string_view s) noexcept
 "[-]digits" -> int64; rejects empty, signs other than a leading '-', overflow.
 
constexpr Timestamp fastmm::venues::ts_from_ms (std::int64_t ms) noexcept
 Milliseconds since the Unix epoch -> Timestamp (ns).
 
Result< Timestamp, DecimalError > fastmm::venues::parse_ts_ms (std::string_view s) noexcept
 
constexpr std::size_t fastmm::venues::format_int64 (std::int64_t v, char *out) noexcept
 Formats an int64 into a caller buffer (>= 21 chars); returns the length.
 

Detailed Description

Exact decimal helpers for venue payloads (6.2).

Every price/quantity string a venue sends is parsed with Fixed::from_decimal (integer loop, no double) and returned as a Result so the caller can count malformed messages instead of throwing. Timestamps arrive as millisecond integers (Binance E/T, Bybit ts/T) or strings (Bybit execTime).