3#include <slick/queue.hpp>
4#include <slick/object_pool.hpp>
10#include <unordered_map>
14#include <nlohmann/json.hpp>
59 virtual std::vector<cli::CliEndpoint *>
cliEndpoints() {
return {}; }
67 [[nodiscard]]
virtual std::vector<FeedInfo>
enabledFeeds()
const;
119 time_t event_time, uint64_t seq_num,
bool end_event);
189 std::vector<std::shared_ptr<md_feed::MDFeed>>
md_feeds_;
199 template <
typename Fn>
Where the CLI server's commands reach a thread that owns some state (the main thread,...
queue< Request > request_queue_
FeedInfo feedInfo(md_feed::FeedKind kind, std::string_view name={}) const
This exchange's feed of kind, by the feed's name or, when empty, the exchange's own.
void publishMDOrderUpdate(const symbol_name_t &symbol, const std::vector< MDOrder > &order_updates)
virtual void handleMdUnsubscription(const Request &)
std::shared_ptr< md_feed::MDFeed > md_feed_
void handleNewOrderRequest(const Request &request)
void publishTradeSubscriptionResponse(Symbol *symbol, uint8_t channel)
Frames the SUB_RESPONSE for a venue's trade channel from the symbol's recent-trade history,...
const engine::MatchingConfig & matchingConfig() const noexcept
uint64_t nextVenueTradeId() noexcept
Public trade ids, one independent sequence per venue.
void applyMarketOrder(Symbol *symbol, const MarketOrderEvent &event)
Rests, changes or removes a market order as a phantom order.
void flushMarketDataCaches(Symbol *symbol)
Publish and clear whatever market data the book produced while handling a request.
void configureMatching(const nlohmann::json &config)
Reads matching_algorithm and pro_rata from the venue's config.
SelfMatchPreventionMode smp_mode_
Self-match prevention mode applied to every symbol on this venue, from the self_match_prevention conf...
virtual void poll()
One iteration of the exchange thread's loop, called continuously between start() and stop().
void publishMDBookUpdate(symid_t sid, OrderBook &order_book, const std::array< uint8_t, 2 > &indices)
uint_fast64_t order_request_cursor_
bool publish_order_updates_
Whether flushMarketDataCaches publishes the per-order (MDUpdateType::ORDER) frames the book produces.
queue< uint8_t > md_queue_
std::vector< std::unique_ptr< order_gateway::OrderGateway > > order_gateways_
queue< Request > & request_queue() noexcept
void forEachFeed(Fn &&fn) const
Calls fn(MDFeed &) on md_feed_ and each of md_feeds_.
void replayMarketTrade(Symbol *symbol, const MarketTradeEvent &event)
Replays a market trade as an aggressor order at the trade's price and quantity, so a client order que...
queue< uint8_t > & md_queue() noexcept
std::string instance_
The config's name, one per instance of a venue that has several. Empty without one.
void markMarketChanged(Symbol *symbol)
void reconcilePhantomQty(Symbol *symbol, Side side, price_t price, qty_t target_qty, time_t event_time, uint64_t seq_num, bool end_event)
Adjusts the phantom (market-mirroring) quantity at an existing (side, price) level toward target_qty,...
std::vector< std::shared_ptr< md_feed::MDFeed > > md_feeds_
Feeds owned by the exchange and managed by base start()/stop().
void rejectModifyOrderRequest(const Request &request, OrdRejectReason reason)
Exchange(Venue venue, const nlohmann::json &config)
void restMarketOrder(Symbol *symbol, const MarketOrderEvent &event)
std::unique_ptr< md_publisher::MarketDataPublisher > md_publisher_
void publishTradeSummary(Symbol *symbol, const TradeSummaryInfo &trade_summary)
Publishes one trade onto the instrument's public tape and records it in the symbol's recent-trade his...
engine::MatchingConfig matching_
The engine assignMatching hands out. FIFO unless configureMatching says otherwise.
void publishLevelUpdate(const symbol_name_t &symbol, const std::vector< MDLevel > &level_updates)
void rejectMdSubscription(const Request &request, MDSubscriptionRejectReason reason)
std::unordered_map< utils::fixed_string< sizeof(AddOrderMessage::user_id)>, int, utils::StringViewHash, utils::StringViewEq > client_ids_
Keys use the width of AddOrderMessage::user_id.
virtual OrdRejectReason newOrderAdmission() const noexcept
virtual std::vector< FeedInfo > enabledFeeds() const
The market-data feeds the config enables: those in md_feed_ and md_feeds_.
void handleCancelOrderRequest(const Request &request)
int clientIdFor(const char *user_id)
Resolves an order's user_id to the integer identity self-match prevention compares.
void assignMatching(Symbol *symbol)
Points a new symbol at the venue's configured engine, creating the engine on first use,...
void sendOrderReplacePending(const Order *order, time_t request_time)
void flushMarketEvents()
Publishes every symbol a market event changed since the last call.
bool matching_keys_unread_
The config sets matching keys and configureMatching has not read them, so start() warns that this ven...
std::array< std::unique_ptr< engine::MatchingEngine >, engine::MatchingEngine::Type::__count__ > matching_engines_
void handleModifyOrderRequest(const Request &request)
queue< OrderResponse > & response_queue() noexcept
void sendOrderCancelPending(const Order *order, time_t request_time)
void sendOrderNewPending(const Order *order, time_t request_time)
std::vector< Symbol * > market_changed_symbols_
Symbols a market event has changed and not yet published.
virtual void handleMdSubscription(const Request &)
virtual std::vector< cli::CliEndpoint * > cliEndpoints()
Where the CLI reaches this exchange's commands (cli/cli_endpoint.hpp), each named <venue>/<instance>[...
void rejectCancelOrderRequest(const Request &request, OrdRejectReason reason)
queue< OrderResponse > response_queue_
void publishMdSubscriptionResponse(const symbol_name_t &symbol, uint8_t channel)
Publishes an accepted subscription response without a snapshot payload.
std::vector< cli::CliEndpoint * > feedCliEndpoints() const
The CLI endpoints of md_feed_ and md_feeds_ (a pcap feed's pcap/<venue>/<feed>).
void rejectNewOrderRequest(const Request &request, OrdRejectReason reason)
std::vector< PhantomReduction > phantom_reductions_
A null-terminated character buffer of fixed capacity, stored inline.
slick::sim::exch::Exchange Exchange
The CLI commands that switch a gateway's business rejects per ID: REJECT_LOGON, REJECT_NEW_ORDERS and...
Helpers for a venue whose one config entry describes several independent exchange instances,...
FeedKind
Where a feed's market data comes from.
MDSubscriptionRejectReason
utils::fixed_string< sizeof(MarketDataUpdate::symbol)> symbol_name_t
An instrument name at its wire width.
Which engine a venue's symbols match with.
Scratch for reconcilePhantomQty, reused so the reduction path allocates nothing.
One enabled market-data feed, as Exchange::enabledFeeds() reports it.
One of the venue's own orders entering, changing or leaving the book, from an order-by-order feed,...
One trade the venue reports, with the side that crossed the spread.
Transparent hash/equality for maps keyed by fixed_string.