|
Slick Sim 0.10.1
Exchange simulator that shadows real venues for risk-free strategy testing
|
Conversions between wire decimals with a constant exponent of -9 (CME PRICE9, ICE Decimal9) and the simulator's 1e-8 fixed point. More...
Classes | |
| class | fixed_string |
| A null-terminated character buffer of fixed capacity, stored inline. More... | |
| struct | StringViewHash |
| Transparent hash/equality for maps keyed by fixed_string. More... | |
| struct | StringViewEq |
| class | RingBuffer |
Functions | |
| constexpr bool | from_decimal9 (int64_t mantissa, int64_t &out) noexcept |
| Returns false when the value has a digit at 1e-9. | |
| constexpr int64_t | to_decimal9 (int64_t fixed) noexcept |
| The inverse. | |
| template<size_t N> | |
| bool | copy_wire_field (char(&dst)[N], std::string_view src) noexcept |
| Copies a name into a fixed-width wire field. | |
| uint64_t | mul_div_floor (uint64_t a, uint64_t b, uint64_t c) noexcept |
| floor(a * b / c), with the product held at 128 bits. | |
| uint64_t | nextOrderId () noexcept |
| void | executeOrder (Order *order, price_t price, qty_t executed_quantity, time_t timestamp) |
| template<Side s> | |
| bool | isPriceBetter (price_t a, price_t b) |
| template<Side s> | |
| bool | isPriceBetterOrEqual (price_t a, price_t b) |
| bool | isPriceBetter (Side side, price_t a, price_t b) |
| bool | isPriceBetterOrEqual (Side side, price_t a, price_t b) |
| std::string | format_timestamp_iso8601 (const std::chrono::system_clock::time_point &tp, int num_sebsecond_digits=3) |
| std::string | format_timestamp_iso8601 (uint64_t timestamp, int num_subsecond_digits=3) |
| std::string | format_timestamp_iso8601 (int num_sebsecond_digits=3) |
| std::string | format_heatbeat_timestamp () |
| uint64_t | get_current_time_ns () |
Variables | |
| constexpr int64_t | DECIMAL9_PER_FIXED = 1'000'000'000 / DOUBLE_MULTIPLIER |
| A 1e-9 mantissa is one decimal place finer than the simulator's scale. | |
| constexpr uint64_t | ONE_SECOND_NS = 1'000'000'000 |
| constexpr uint64_t | ONE_MILLISECOND_NS = 1'000'000 |
| constexpr uint64_t | ONE_MICROSECOND_NS = 1'000 |
Conversions between wire decimals with a constant exponent of -9 (CME PRICE9, ICE Decimal9) and the simulator's 1e-8 fixed point.
Null values are each protocol's own, so its codec maps them before calling these.
|
inlinenoexcept |
Copies a name into a fixed-width wire field.
Truncates to N-1 characters and zero-fills the remainder. The result is always NUL-terminated, with no bytes copied from beyond the source string.
Copying sizeof(dst) bytes from a shorter string would over-read it and could change the value the receiver sees. Zeroing dst before copying up to N bytes also fails for an N-character value, which overwrites the terminator.
Returns true when the value did not fit, so callers can warn about truncation.
Definition at line 24 of file fixed_string.hpp.
Referenced by slick::sim::utils::fixed_string< sizeof(MarketDataUpdate::symbol)>::assign().
|
inline |
Definition at line 15 of file order.hpp.
References slick::sim::Order::avg_fill_price, slick::sim::Order::cum_quantity, slick::sim::Order::cum_value, slick::sim::Order::last_fill_price, slick::sim::Order::last_fill_qty, slick::sim::Order::last_fill_time, slick::sim::Order::last_update_time, slick::sim::Order::leaves_quantity, and slick::sim::Order::num_fills.
Referenced by slick::sim::OrderBook::executeOrder(), and slick::sim::engine::detail::fillResting().
|
inline |
Definition at line 62 of file timestamp.hpp.
|
inline |
Definition at line 9 of file timestamp.hpp.
Referenced by format_timestamp_iso8601(), format_timestamp_iso8601(), and slick::sim::order_gateway::coinbase::to_json().
|
inline |
Definition at line 57 of file timestamp.hpp.
References format_timestamp_iso8601().
|
inline |
Definition at line 30 of file timestamp.hpp.
References format_timestamp_iso8601().
|
inlinenodiscardconstexprnoexcept |
Returns false when the value has a digit at 1e-9.
No listed tick or lot is that fine, so such a value is off-tick, and rounding it would trade at a price or size the client never sent.
Definition at line 18 of file decimal.hpp.
References DECIMAL9_PER_FIXED.
|
inline |
Definition at line 93 of file timestamp.hpp.
Referenced by slick::sim::OrderBook::allocateOrder(), slick::sim::exch::Symbol::cancelOrder(), slick::sim::exch::Exchange::handleModifyOrderRequest(), slick::sim::exch::Symbol::modifyOrder(), slick::sim::exch::CoinbaseExchange::onLevel2Updates(), slick::sim::exch::CoinbaseExchange::onMarketTrades(), slick::sim::exch::CoinbaseExchange::processSequencedEvents(), slick::sim::exch::Exchange::rejectCancelOrderRequest(), slick::sim::exch::Exchange::rejectModifyOrderRequest(), and slick::sim::exch::Exchange::rejectNewOrderRequest().
Definition at line 8 of file price.hpp.
References slick::sim::BUY.
Definition at line 25 of file price.hpp.
References slick::sim::BUY.
Definition at line 17 of file price.hpp.
References slick::sim::BUY.
Referenced by slick::sim::engine::detail::canFillCompletely(), and slick::sim::engine::detail::wouldSelfMatch().
Definition at line 33 of file price.hpp.
References slick::sim::BUY.
|
inlinenoexcept |
floor(a * b / c), with the product held at 128 bits.
Fixed-point quantities carry a 1e8 scale, so the product of two of them overflows 64 bits. Requires b <= c: the result is then at most a and always fits, which is also _udiv128's precondition (it faults on a quotient over 64 bits). MSVC x64 and GCC/Clang take the first two branches; the boost fallback (32-bit MSVC, compilers without __int128) is not built by any CI job.
|
inlinenoexcept |
Definition at line 10 of file order.hpp.
Referenced by slick::sim::OrderBook::allocateOrder(), slick::sim::exch::CoinbaseExchange::onLevel2Snapshot(), slick::sim::exch::Exchange::reconcilePhantomQty(), and slick::sim::exch::Exchange::replayMarketTrade().
|
inlinenodiscardconstexprnoexcept |
The inverse.
A fixed-point value above 9.2e17 would overflow the multiply, but that is 9.2e9 in price or size units - far past any tick, lot or level a wire decimal of this exponent can carry.
Definition at line 29 of file decimal.hpp.
References DECIMAL9_PER_FIXED.
|
inlineconstexpr |
A 1e-9 mantissa is one decimal place finer than the simulator's scale.
Definition at line 12 of file decimal.hpp.
Referenced by from_decimal9(), and to_decimal9().
|
constexpr |
Definition at line 101 of file timestamp.hpp.
|
constexpr |
Definition at line 100 of file timestamp.hpp.
|
constexpr |
Definition at line 99 of file timestamp.hpp.
Referenced by slick::sim::exch::CoinbaseExchange::processSequencedEvents().