34 [[nodiscard]]
static constexpr std::int32_t
to_cbps(
double bps)
noexcept {
35 return static_cast<std::int32_t
>(bps * 100.0 + (bps < 0 ? -0.5 : 0.5));
44 static_cast<std::int64_t
>(
static_cast<Int128
>(notional.raw) *
cbps(l) / 1'000'000));
47 return fee(
mul(px, qty), l);
57 [[nodiscard]] static
FeeTable from_bps(
double maker_bps,
double taker_bps) noexcept {
71 has_[
id.value / 64] |= std::uint64_t{1} << (
id.value % 64);
75 (has_[
id.value / 64] & (std::uint64_t{1} << (
id.value % 64))) != 0;
77 [[nodiscard]]
constexpr const FeeRates&
default_schedule() const noexcept {
return default_; }
82 [[nodiscard]]
constexpr bool is_uniform() const noexcept {
101 return default_.
fee(px, qty, l);
104 return default_.
fee(n, l);
109 std::array<FeeRates, kMaxInstruments> per_{};
113static_assert(std::is_trivially_copyable_v<FeeTable>);
constexpr FeeTable() noexcept=default
constexpr std::int64_t maker_cbps() const noexcept
Definition fees.hpp:92
static FeeTable uniform(FeeRates s) noexcept
Definition fees.hpp:62
void set_default(FeeRates s) noexcept
Rates of every instrument without an override.
Definition fees.hpp:69
constexpr const FeeRates & default_schedule() const noexcept
Definition fees.hpp:79
void set_instrument(InstrumentId id, FeeRates s) noexcept
Definition fees.hpp:70
constexpr Notional fee(InstrumentId id, Price px, Qty qty, Liquidity l) const noexcept
Definition fees.hpp:95
constexpr bool is_uniform() const noexcept
True when every override equals the default, so one line describes the whole run.
Definition fees.hpp:84
constexpr const FeeRates & schedule(InstrumentId id) const noexcept
Definition fees.hpp:80
static FeeTable from_bps(double maker_bps, double taker_bps) noexcept
Every instrument pays the same rates.
Definition fees.hpp:59
constexpr bool has_override(InstrumentId id) const noexcept
Definition fees.hpp:75
constexpr std::int64_t taker_cbps() const noexcept
Definition fees.hpp:93
Fixed<Tag>: int64 fixed point with a global 1e-8 scale (ADR-0001).
Instrument: the single definition of a tradable contract (5.3 / 5.15).
Definition strategy.hpp:16
StrongId< struct InstrumentTag, std::uint32_t > InstrumentId
Dense index into the engine's instrument table.
Definition strong_id.hpp:38
constexpr std::size_t kMaxInstruments
Definition instrument.hpp:26
constexpr Notional mul(Price p, Qty q) noexcept
price * qty with a 128-bit intermediate, truncated toward zero to 1e-8.
Definition fixed_point.hpp:362
Liquidity
Definition enums.hpp:434
One maker/taker pair. 1 cbps == 0.01 bps == 1e-6 of the notional.
Definition fees.hpp:26
constexpr Notional fee(Notional notional, Liquidity l) const noexcept
Definition fees.hpp:44
constexpr double maker_bps() const noexcept
Definition fees.hpp:39
static FeeRates from_bps(double maker_bps, double taker_bps) noexcept
Definition fees.hpp:30
std::int32_t maker_cbps
> 0 fee, < 0 rebate
Definition fees.hpp:27
std::int32_t taker_cbps
Definition fees.hpp:28
constexpr bool operator==(const FeeRates &) const noexcept=default
static constexpr std::int32_t to_cbps(double bps) noexcept
Definition fees.hpp:36
constexpr double taker_bps() const noexcept
Definition fees.hpp:40
constexpr std::int64_t cbps(Liquidity l) const noexcept
Definition fees.hpp:41
static constexpr Fixed from_raw(std::int64_t r) noexcept
Definition fixed_point.hpp:155