|
FastMM C++ API 0.6.0
Public headers, tier 1 and tier 2
|
Fixed<Tag>: int64 fixed point with a global 1e-8 scale (ADR-0001). More...
#include "fastmm/core/config_macros.hpp"#include "fastmm/core/enums.hpp"#include <compare>#include <cstddef>#include <cstdint>#include <limits>#include <optional>#include <string_view>#include <type_traits>Go to the source code of this file.
Classes | |
| struct | fastmm::Fixed< Tag > |
Namespaces | |
| namespace | fastmm |
| namespace | fastmm::literals |
Exact literals, parsed at compile time: 100.25_px, 0.01_qty (up to 8 decimals), 5_bps, 0.25_bps (up to 4 decimals). More decimals, or a value out of range, is a compile error. An inline namespace, so using namespace fastmm; brings them in too (like std::literals). | |
Typedefs | |
| using | fastmm::Price = Fixed< struct PriceTag > |
| using | fastmm::Qty = Fixed< struct QtyTag > |
| using | fastmm::Notional = Fixed< struct NotionalTag > |
| using | fastmm::Ratio = Fixed< RatioTag > |
| A dimensionless factor: 1.0 == 1e8 raw, 1 bp == 10'000 raw, so 0.0001 bp is the smallest step. | |
Functions | |
| template<class T > | |
| constexpr Fixed< T > | fastmm::operator* (Fixed< T > v, Ratio r) noexcept |
| value * ratio in the value's domain, through Int128 with one truncation toward zero: mid * 5_bps, qty * ratio(filled, total). | |
| template<class T > | |
| constexpr Fixed< T > | fastmm::operator* (Ratio r, Fixed< T > v) noexcept |
| constexpr Ratio | fastmm::operator* (Ratio a, Ratio b) noexcept |
| template<class T > | |
| constexpr Ratio | fastmm::ratio (Fixed< T > num, Fixed< T > den) noexcept |
| num / den as a Ratio, truncated toward zero; zero when den is zero. | |
| constexpr Notional | fastmm::mul (Price p, Qty q) noexcept |
| price * qty with a 128-bit intermediate, truncated toward zero to 1e-8. | |
| template<class A , class B > | |
| constexpr std::int64_t | fastmm::mul_raw (Fixed< A > a, Fixed< B > b) noexcept |
| Generic scaled multiply for fixed*fixed in one domain (e.g. qty * multiplier). | |
| constexpr Price | fastmm::div (Notional n, Qty q) noexcept |
| notional / qty -> price (used for average cost). Truncates toward zero. | |
| template<class T > | |
| constexpr Fixed< T > | fastmm::apply_bps (Fixed< T > v, std::int64_t bps) noexcept |
| value * bps / 10000 in one domain. | |
| constexpr std::int64_t | fastmm::floor_div (std::int64_t a, std::int64_t b) noexcept |
| Floor division for possibly-negative numerators (prices are >= 0, but be safe). | |
| constexpr Price | fastmm::round_to_tick (Price p, Price tick, Side side) noexcept |
| Round to the tick grid in the passive direction: bids down, asks up. tick > 0. | |
| constexpr Price | fastmm::round_to_tick_nearest (Price p, Price tick) noexcept |
| constexpr bool | fastmm::on_tick (Price p, Price tick) noexcept |
| constexpr Qty | fastmm::round_to_lot (Qty q, Qty lot) noexcept |
| Quantities always round down (never send more than intended). | |
| constexpr bool | fastmm::on_lot (Qty q, Qty lot) noexcept |
| template<class T > | |
| constexpr Fixed< T > | fastmm::min (Fixed< T > a, Fixed< T > b) noexcept |
| template<class T > | |
| constexpr Fixed< T > | fastmm::max (Fixed< T > a, Fixed< T > b) noexcept |
| template<class T > | |
| constexpr std::optional< Fixed< T > > | fastmm::checked_add (Fixed< T > a, Fixed< T > b) noexcept |
| Checked arithmetic: nullopt instead of a wrapped int64. The operators stay unchecked; these are for the places that combine a value from outside the engine with a configured one. | |
| template<class T > | |
| constexpr std::optional< Fixed< T > > | fastmm::checked_sub (Fixed< T > a, Fixed< T > b) noexcept |
| template<class T > | |
| constexpr std::optional< Fixed< T > > | fastmm::checked_mul (Fixed< T > a, std::int64_t k) noexcept |
| constexpr Price | fastmm::literals::operator""_px (unsigned long long v) noexcept |
| 100_px == Price::from_int(100). | |
| constexpr Qty | fastmm::literals::operator""_qty (unsigned long long v) noexcept |
| template<char... Cs> | |
| constexpr Price | fastmm::literals::operator""_px () noexcept |
| template<char... Cs> | |
| constexpr Qty | fastmm::literals::operator""_qty () noexcept |
| template<char... Cs> | |
| constexpr Ratio | fastmm::literals::operator""_bps () noexcept |
Variables | |
| constexpr std::int64_t | fastmm::kFixedScale = 100'000'000 |
| 1e-8 | |
| constexpr int | fastmm::kFixedDecimals = 8 |
| constexpr std::size_t | fastmm::kMaxDecimalChars = 24 |
| sign + 11 integer digits + '.' + 8 fraction digits + NUL | |
| constexpr std::int64_t | fastmm::kRatioPerBp = 10'000 |
| Ratio (below): 1.0 == kFixedScale raw, one basis point == kRatioPerBp raw. | |
| constexpr int | fastmm::kBpsDecimals = 4 |
Fixed<Tag>: int64 fixed point with a global 1e-8 scale (ADR-0001).
Price, Qty and Notional are distinct types: p * q does not compile, use mul(p, q) which widens to Int128. Exact decimal parsing/formatting (no double) is used for every venue string; from_double/to_double exist only for config and diagnostics. Range: +-92,233,720,368.54775807. Instruments outside this are rejected at load time.