|
Slick Sim 0.10.1
Exchange simulator that shadows real venues for risk-free strategy testing
|
Namespaces | |
| namespace | cli |
| The CLI commands that switch a gateway's business rejects per ID: REJECT_LOGON, REJECT_NEW_ORDERS and LIST_REJECTS. | |
| namespace | detail |
| namespace | exch |
| Helpers for a venue whose one config entry describes several independent exchange instances, such as CME's market segments or ICE's silos. | |
| namespace | md_publisher |
| namespace | engine |
| namespace | md_feed |
| namespace | order_gateway |
| namespace | utils |
| Conversions between wire decimals with a constant exponent of -9 (CME PRICE9, ICE Decimal9) and the simulator's 1e-8 fixed point. | |
Classes | |
| struct | ControlHeader |
| Every control message starts with this. More... | |
| struct | FeedStatusMessage |
| The replay feed's state. More... | |
| struct | StartMessage |
| Starts the replay of every loaded instrument. More... | |
| struct | CliRequestMessage |
| One command to the simulator, on the CLI port. More... | |
| struct | CliReplyMessage |
| The answer to a CliRequestMessage. More... | |
| class | ControlStreams |
| Cuts each connection's control-port byte stream into whole messages, keeping the part of a message that has arrived until the rest does. More... | |
| struct | MDLevel |
| struct | MDBookUpdate |
| struct | MDLevelUpdate |
| struct | MDOrder |
| struct | MDOrderUpdate |
| Every order-book change one request (or feed event) produced, in book order. More... | |
| struct | MarketDataUpdate |
| struct | MDSubscriptionResponse |
| struct | BookSnapshot |
| struct | MDTrade |
| struct | MDTradeUpdate |
| struct | MDTradeSnapshotResponse |
| Payload of a SUB_RESPONSE for a venue's trade channel. More... | |
| struct | AddOrderMessage |
| struct | ModifyOrderMessage |
| struct | CancelOrderMessage |
| struct | MDSubscriptionMessage |
| struct | Request |
| struct | OrderResponse |
| struct | Trade |
| struct | TradeSummary |
| struct | TradeSummaryInfo |
| struct | OrderIdentity |
| The four identity fields, stored inline in the order and width used by OrderResponse. More... | |
| struct | Order |
| struct | Fill |
| struct | SymbolKey |
| An instrument is identified by both venue and name. More... | |
| struct | SymbolKeyHash |
| class | SymbolManager |
| class | OrderBook |
| struct | Empty |
| class | OrderBookImpl |
| struct | ProxiedHttpResponse |
Typedefs | |
| using | symbol_name_t = utils::fixed_string<sizeof(MarketDataUpdate::symbol)> |
| An instrument name at its wire width. | |
| using | price_t = int_fast64_t |
| using | qty_t = int_fast64_t |
| using | time_t = uint_fast64_t |
| using | symid_t = uint16_t |
| using | cum_value_t = boost::multiprecision::uint128_t |
| using | OrderBookL3 = slick::orderbook::OrderBookL3 |
| using | IOrderBookObserver = slick::orderbook::IOrderBookObserver |
| using | PriceLevelUpdate = slick::orderbook::PriceLevelUpdate |
| using | OrderUpdate = slick::orderbook::OrderUpdate |
| using | TopOfBook = slick::orderbook::TopOfBook |
| using | SymbolId = slick::orderbook::SymbolId |
| using | Timestamp = slick::orderbook::Timestamp |
Functions | |
| constexpr const char * | to_string (FeedState state) noexcept |
| constexpr const char * | to_string (CliCommandType command) noexcept |
| The command's name, as the CLI client spells it. | |
| constexpr std::string_view | to_string (MDSubscriptionRejectReason reason) |
| std::string | to_string (BusinessRejectReason reject) |
| std::string | to_string (SessionRejectReason reject) |
| std::string | to_string (OrdRejectReason reject) |
| std::string | to_string (CxlRejectReason reject) |
| void | setOrderIdentity (OrderResponse &response, const Order &order) noexcept |
| Fills a response's identity from an order: the symbol/user_id/client_order_id/ order_id header in one fixed-size copy, plus the numeric id and correlation tag. | |
| constexpr Side | opposite_side (Side side) |
| template<Side S> | |
| constexpr Side | opposite_side () |
| constexpr std::string_view | to_string (Side side) |
| constexpr std::string_view | to_string (OrderType type) |
| constexpr std::string_view | to_string (ExecType exec_type) |
| constexpr std::string_view | to_string (OrderStatus status) |
| std::string_view | to_string (TimeInForce tif) |
| constexpr std::string_view | to_string (SelfMatchPreventionMode mode) |
| constexpr SelfMatchPreventionMode | to_smp_mode (std::string_view name) |
| Parses the self_match_prevention configuration value. | |
| constexpr std::string_view | to_string (ProductType type) |
| constexpr price_t | to_price_t (double price) |
| Scales a decimal into the fixed-point representation, rounding to the nearest tick rather than truncating. | |
| constexpr double | to_price_double (price_t price) |
| constexpr qty_t | to_qty_t (double qty) |
| constexpr double | to_qty_double (qty_t qty) |
| std::string | to_fixed_string (int_fast64_t value, unsigned min_frac_digits=0) |
| Renders a fixed-point value as an exact decimal string. | |
| std::string | to_price_string (price_t price) |
| std::string | to_qty_string (qty_t qty) |
| const char * | to_string (Venue venue) |
| Venue | to_venue (std::string_view exch) |
| Matches venue names case-insensitively, including mixed-case names such as "Coinbase". | |
| orderbook::Side | to_book_side (Side side) |
| ProxiedHttpResponse | build_proxied_response (const slick::net::Http::Response &rsp) |
| void | proxy_hyperliquid_info_request (uWS::HttpResponse< false > *res, const std::string &upstream_base_url) |
Variables | |
| constexpr symid_t | INVALID_SYMBOL_ID = std::numeric_limits<symid_t>::max() |
| constexpr price_t | NULL_PRICE = std::numeric_limits<price_t>::max() |
| constexpr int32_t | DOUBLE_MULTIPLIER = static_cast<int32_t>(1e8) |
| constexpr double | EPSILON = 1e-8 |
| using slick::sim::cum_value_t = boost::multiprecision::uint128_t |
| using slick::sim::IOrderBookObserver = slick::orderbook::IOrderBookObserver |
Definition at line 30 of file order_book.hpp.
| using slick::sim::OrderBookL3 = slick::orderbook::OrderBookL3 |
Definition at line 29 of file order_book.hpp.
| using slick::sim::OrderUpdate = slick::orderbook::OrderUpdate |
Definition at line 32 of file order_book.hpp.
| using slick::sim::price_t = int_fast64_t |
| using slick::sim::PriceLevelUpdate = slick::orderbook::PriceLevelUpdate |
Definition at line 31 of file order_book.hpp.
| using slick::sim::qty_t = int_fast64_t |
| using slick::sim::symbol_name_t = utils::fixed_string<sizeof(MarketDataUpdate::symbol)> |
An instrument name at its wire width.
Symbol and OrderBook hold their name in this type, so publishing one is a fixed-size copy of the whole field rather than memcpy(update->symbol, name.c_str(), sizeof(update->symbol)), which reads past the end of any name shorter than the field - which is all of them.
Deliberately derived from the wire field rather than spelled out: widening MarketDataUpdate::symbol widens the storage with it, instead of silently reintroducing the over-read at every publish site.
Definition at line 122 of file market_data.hpp.
| using slick::sim::SymbolId = slick::orderbook::SymbolId |
Definition at line 34 of file order_book.hpp.
| using slick::sim::symid_t = uint16_t |
| using slick::sim::time_t = uint_fast64_t |
| using slick::sim::Timestamp = slick::orderbook::Timestamp |
Definition at line 35 of file order_book.hpp.
| using slick::sim::TopOfBook = slick::orderbook::TopOfBook |
Definition at line 33 of file order_book.hpp.
|
strong |
| Enumerator | |
|---|---|
| UNKNOWN | |
| UNKNOWN_SECURITY_ID | |
| DUPLICATE_REQUEST_ID | |
Definition at line 34 of file messages.hpp.
|
strong |
What a CLI request asks for. The values are on the wire: append, never renumber.
| Enumerator | |
|---|---|
| LIST_TARGETS | Any target. The CLI server answers with every target it routes to. |
| SET_LOG_LEVEL | sim. arg is the level; empty reports the current one. |
| SHUTDOWN | sim. Stops the simulator. |
| REJECT_LOGON | A venue. flag 1 refuses the logons of ID arg from now on, 0 stops. |
| REJECT_NEW_ORDERS | A venue. flag 1 rejects every new order of ID arg, 0 stops. |
| LIST_REJECTS | A venue. The IDs both of the above apply to. |
| START_REPLAY | pcap. Starts each feed's replay, as a control-channel START does. |
| PCAP_STATUS | pcap. Each feed's state, progress and window. |
| LIST_FEEDS | Any target. The CLI server answers with every enabled market-data feed. |
| GET_VERSION | Any target. The CLI server answers with slick-sim's version. |
Definition at line 45 of file control_messages.hpp.
|
strong |
| Enumerator | |
|---|---|
| OK | |
| FAILED | |
Definition at line 75 of file control_messages.hpp.
|
strong |
| Enumerator | |
|---|---|
| FEED_STATUS | Sim to client. |
| START | Client to sim: start the replay. |
| CLI_REQUEST | Client to sim, on the CLI port: CliRequestMessage. |
| CLI_REPLY | Sim to client, on the CLI port: CliReplyMessage. |
Definition at line 37 of file control_messages.hpp.
|
strong |
Definition at line 155 of file messages.hpp.
|
strong |
|
strong |
Definition at line 12 of file messages.hpp.
|
strong |
Where a pcap replay feed is. The values are on the wire: append, never renumber.
Definition at line 14 of file control_messages.hpp.
| enum slick::sim::MDSubscriptionRejectReason : uint8_t |
| Enumerator | |
|---|---|
| NONE | |
| UNKNOWN_CONTRACT | |
| MARKET_CLOSED | |
Definition at line 127 of file market_data.hpp.
| enum slick::sim::MDUpdateAction : uint8_t |
| Enumerator | |
|---|---|
| ACTION_NEW | |
| ACTION_CHANGE | |
| ACTION_DELETE | |
Definition at line 47 of file market_data.hpp.
| enum slick::sim::MDUpdateType : uint8_t |
Definition at line 20 of file market_data.hpp.
|
strong |
| Enumerator | |
|---|---|
| UNKNOWN | |
| NEW_ORDER_SINGLE | |
| ORDER_CANCEL_REQUEST | |
| ORDER_REPLACE_REQUEST | |
| EXECUTION_REPORT | |
| ORDER_CANCEL_REJECT | |
| HEARTBEAT | |
| TEST_REQUEST | |
| RE_SEND_REQUEST | |
| REJECT | |
| MD_SUBSCRIPTION | |
| MD_UNSUBSCRIPTION | |
Definition at line 224 of file messages.hpp.
|
strong |
| Enumerator | |
|---|---|
| L2 | |
| L3 | |
Definition at line 270 of file order_book.hpp.
|
strong |
|
strong |
|
strong |
Definition at line 76 of file messages.hpp.
|
strong |
|
strong |
|
strong |
| Enumerator | |
|---|---|
| NONE | |
| ALREADY_LOGGED_IN | |
| NOT_LOGGED_IN | |
| INVALID_SESSION_ID | |
| UNKNOWN | |
Definition at line 52 of file messages.hpp.
| enum slick::sim::Side : uint8_t |
|
strong |
| enum slick::sim::UpdateFlags : uint8_t |
| Enumerator | |
|---|---|
| F_NONE | |
| F_IS_SNAPSHOT | |
| F_END_EVENT | |
| F_NOT_IN_BOOK | On an MDTrade: this print was never applied to the order book. Set only for prints seeded from a venue's own trade snapshot, which happened before the simulator was listening. Every trade the matching engine produced is in the book by construction, whatever its timestamp. |
Definition at line 36 of file market_data.hpp.
| enum slick::sim::Venue : uint8_t |
|
inline |
Definition at line 28 of file hyperliquid_info_proxy.hpp.
Referenced by proxy_hyperliquid_info_request().
Definition at line 39 of file order.hpp.
References BUY, SELL, and UNKNOWN_SIDE.
Referenced by slick::sim::engine::detail::recordTrade().
Definition at line 26 of file order.hpp.
References BUY, SELL, and UNKNOWN_SIDE.
|
inline |
Definition at line 50 of file hyperliquid_info_proxy.hpp.
References build_proxied_response().
|
inlinenoexcept |
Fills a response's identity from an order: the symbol/user_id/client_order_id/ order_id header in one fixed-size copy, plus the numeric id and correlation tag.
Every response built from an order goes through here, so neither of those two can be left holding a recycled slot's previous value.
Definition at line 368 of file messages.hpp.
Referenced by slick::sim::engine::MatchingEngine::publishOrderAck(), slick::sim::engine::MatchingEngine::publishOrderCancel(), slick::sim::engine::MatchingEngine::publishOrderExecution(), slick::sim::engine::MatchingEngine::publishOrderModify(), slick::sim::exch::Exchange::sendOrderCancelPending(), slick::sim::exch::Exchange::sendOrderNewPending(), and slick::sim::exch::Exchange::sendOrderReplacePending().
|
inline |
|
inline |
Renders a fixed-point value as an exact decimal string.
Formats straight from the integer, never through double. std::to_string(double) formats with f, which emits exactly six fractional digits, but the scale here carries eight: a size of 0.00011628 went onto the wire as "0.000116", and one tick, 0.00000001, as "0.000000" - a value the receiver reads as zero.
Trailing fractional zeros are trimmed, and the point is omitted entirely for a whole number, so 8.2 renders as "8.2" rather than "8.20000000".
min_frac_digits sets a floor on how far that trimming goes, for a venue whose own serialiser always leaves a fractional digit behind: at 1, a whole 77052 renders as "77052.0" instead of "77052". It never pads past the scale's eight digits, and 0 - the default - is the trim-everything behaviour above.
Definition at line 72 of file types.hpp.
References DOUBLE_MULTIPLIER.
Referenced by slick::sim::md_publisher::to_hyperliquid_number(), to_price_string(), and to_qty_string().
|
inlineconstexpr |
Definition at line 46 of file types.hpp.
References DOUBLE_MULTIPLIER.
Referenced by slick::sim::exch::Symbol::addOrder(), slick::sim::order_gateway::OrderStore::apply(), slick::sim::Order::avg_fill_price_double(), slick::sim::engine::detail::fillRestingFromFeed(), slick::sim::Order::last_fill_price_double(), slick::sim::Order::price_double(), and slick::sim::OrderBookImpl< BookType >::to_string().
|
inline |
Definition at line 107 of file types.hpp.
References to_fixed_string().
Referenced by slick::sim::order_gateway::coinbase::to_json().
|
inlineconstexpr |
Scales a decimal into the fixed-point representation, rounding to the nearest tick rather than truncating.
price * 1e8 is a binary floating-point multiply, and most decimal fractions have no exact binary form, so the product lands just under the intended integer: 8.2 * 1e8 is 819999999.99999988, and a plain cast to an integer throws the fraction away, yielding 819999999 - a price of 8.19999999. The same happens to 0.29 and 4.35, and to quantities. Adding half a tick before truncating rounds to nearest instead, which lands on the intended value for every decimal that fits in the scale.
Definition at line 42 of file types.hpp.
References DOUBLE_MULTIPLIER.
Referenced by slick::sim::exch::CoinbaseExchange::onLevel2Snapshot(), slick::sim::exch::CoinbaseExchange::onLevel2Updates(), slick::sim::exch::CoinbaseExchange::onMarketTrades(), and slick::sim::exch::CoinbaseExchange::onMarketTradesSnapshot().
|
inlineconstexpr |
Definition at line 54 of file types.hpp.
References DOUBLE_MULTIPLIER.
Referenced by slick::sim::exch::Symbol::addOrder(), slick::sim::order_gateway::OrderStore::apply(), slick::sim::Order::cum_qty_double(), slick::sim::engine::detail::fillRestingFromFeed(), slick::sim::Order::last_fill_qty_double(), slick::sim::Order::leaves_qty_double(), slick::sim::Order::qty_double(), slick::sim::OrderBookImpl< BookType >::to_string(), and slick::sim::engine::ProRataConfig::validate().
|
inline |
Definition at line 108 of file types.hpp.
References to_fixed_string().
Referenced by slick::sim::order_gateway::coinbase::to_json().
|
inlineconstexpr |
Definition at line 50 of file types.hpp.
References DOUBLE_MULTIPLIER.
Referenced by slick::sim::exch::CoinbaseExchange::onLevel2Snapshot(), slick::sim::exch::CoinbaseExchange::onLevel2Updates(), slick::sim::exch::CoinbaseExchange::onMarketTrades(), and slick::sim::exch::CoinbaseExchange::onMarketTradesSnapshot().
|
inlineconstexpr |
Parses the self_match_prevention configuration value.
Returns NONE for an unrecognised name, so a typo disables SMP rather than aborting startup.
Definition at line 253 of file order.hpp.
References CANCEL_NEWEST, CANCEL_RESTING, and NONE.
|
inline |
Definition at line 40 of file messages.hpp.
References DUPLICATE_REQUEST_ID, UNKNOWN, and UNKNOWN_SECURITY_ID.
|
nodiscardconstexprnoexcept |
The command's name, as the CLI client spells it.
Definition at line 59 of file control_messages.hpp.
References GET_VERSION, LIST_FEEDS, LIST_REJECTS, LIST_TARGETS, PCAP_STATUS, REJECT_LOGON, REJECT_NEW_ORDERS, SET_LOG_LEVEL, SHUTDOWN, and START_REPLAY.
|
inline |
Definition at line 177 of file messages.hpp.
References ICEBERG_REQUEST_ON_NON_ICEBERG, INTERCEPTED, INVALID_DISPLAY_QTY, INVALID_MIN_QTY, INVALID_QTY, INVALID_TICK_SIZE, MARKET_CLOSED, MARKET_HALTED, NON_ICEBERG_REQUEST_ON_ICEBERG, NONE, ORDER_NOT_FOUND, ORDER_TYPE_MISMATCH, PREOPEN, PRICE_CANT_BE_ABOVE_STOP_PRICE, PRICE_CANT_BE_BELOW_STOP_PRICE, STOP_PRICE_MUST_BE_ABOVE_LAST_TRADE_PRICE, STOP_PRICE_MUST_BE_BELOW_LAST_TRADE_PRICE, TIME_IN_FORCE_MISMATCH, and UNKNOWN.
|
inlineconstexpr |
Definition at line 119 of file order.hpp.
References CANCELED, EXPIRED, NEW, ORDER_STATUS, PENDING_CANCEL, PENDING_REPLACE, REJECTED, REPLACED, RESTATED, TRADE, TRADE_CANCEL, and TRADE_CORRECT.
|
nodiscardconstexprnoexcept |
Definition at line 24 of file control_messages.hpp.
References ERROR, FINISHED, IDLE, LOADING, READY, REPLAYING, and SYNCING.
Referenced by slick::sim::md_feed::PcapFeedBase::PcapFeedBase(), slick::sim::order_gateway::TcpOrderGateway::TcpOrderGateway(), slick::sim::exch::Symbol::addOrder(), slick::sim::exch::Exchange::configureMatching(), slick::sim::exch::Exchange::feedInfo(), slick::sim::order_gateway::TcpOrderGateway::onClientConnected(), slick::sim::order_gateway::TcpOrderGateway::onClientDisconnected(), slick::sim::cli::refuse_unserved(), slick::sim::cli::serve_rejects(), slick::sim::exch::Exchange::start(), slick::sim::md_publisher::WebsocketMarketDataPublisher::start(), slick::sim::order_gateway::RestWsOrderGateway::start(), slick::sim::order_gateway::TcpOrderGateway::start(), slick::sim::order_gateway::coinbase::to_json(), and slick::sim::cli::toggle_id().
|
inlineconstexpr |
Definition at line 133 of file market_data.hpp.
References MARKET_CLOSED, NONE, and UNKNOWN_CONTRACT.
|
inlineconstexpr |
Definition at line 167 of file order.hpp.
References ACCEPTED_FOR_BIDDING, CALCULATED, CANCELED, DONE_FOR_DAY, EXPIRED, FILLED, NEW, PARTIALLY_FILLED, PENDING_CANCEL, PENDING_NEW, PENDING_REPLACE, REJECTED, REPLACED, STOPPED, and SUSPENDED.
|
inlineconstexpr |
Definition at line 76 of file order.hpp.
References BRACKET, LIMIT, LIQUIDATION, MARKET, ROLL_CLOSE, ROLL_OPEN, SCALED, STOP, STOP_LIMIT, TWAP, and UNKNOWN.
|
inline |
Definition at line 102 of file messages.hpp.
References CLIENT_ORDER_ID_ALREADY_EXISTS, FAK_MUST_BE_LIMIT, FOK_CANNOT_FILL, ICEBERG_MUST_BE_DAY_OR_GTC, ICEBERG_MUST_BE_LIMIT, INVALID_DISPLAY_QTY, INVALID_MIN_QTY, INVALID_QTY, INVALID_TICK_SIZE, LICENSE_REQUIRED, MARKET_CLOSED, MARKET_HALTED, NONE, ORDER_TYPE_NOT_ALLOWED_IN_CURRENT_MARKET_STATE, PRICE_CANT_BE_ABOVE_STOP_PRICE, PRICE_CANT_BE_BELOW_STOP_PRICE, SMP, STOP_PRICE_MUST_BE_ABOVE_LAST_TRADE_PRICE, STOP_PRICE_MUST_BE_BELOW_LAST_TRADE_PRICE, TIME_IN_FORCE_NOT_ALLOWED_IN_CURRENT_MARKET_STATE, UNKNOWN, UNKNOWN_CONTRACT, and UNKNOWN_ORDER.
|
inlineconstexpr |
|
inlineconstexpr |
Definition at line 239 of file order.hpp.
References CANCEL_NEWEST, CANCEL_RESTING, and NONE.
|
inline |
Definition at line 60 of file messages.hpp.
References ALREADY_LOGGED_IN, INVALID_SESSION_ID, NONE, NOT_LOGGED_IN, and UNKNOWN.
|
inlineconstexpr |
Definition at line 49 of file order.hpp.
References BUY, SELL, and UNKNOWN_SIDE.
|
inline |
Definition at line 213 of file order.hpp.
References AT_THE_OPENING, DAY, FILL_OR_KILL, GOOD_TILL_CANCEL, GOOD_TILL_CROSSING, GOOD_TILL_DATE, and IMMEDIATE_OR_CANCEL.
|
inline |
Definition at line 163 of file types.hpp.
References __COUNT__, SLICK_SIM_VENUE_CASE, SLICK_SIM_VENUE_LIST, and UNKNOWN_VENUE.
|
inline |
Matches venue names case-insensitively, including mixed-case names such as "Coinbase".
ExchangeRegistry uses the same iequals comparison for config keys.
Definition at line 177 of file types.hpp.
References SLICK_SIM_VENUE_LIST, SLICK_SIM_VENUE_MATCH, and UNKNOWN_VENUE.
|
constexpr |
Definition at line 29 of file types.hpp.
Referenced by to_fixed_string(), to_price_double(), to_price_t(), to_qty_double(), and to_qty_t().
Definition at line 28 of file types.hpp.
Referenced by slick::sim::exch::Symbol::addOrder(), slick::sim::engine::detail::canFillCompletely(), slick::sim::exch::Exchange::rejectCancelOrderRequest(), slick::sim::exch::Exchange::restMarketOrder(), slick::sim::Order::restsRemainder(), and slick::sim::engine::detail::wouldSelfMatch().