FastMM documentation
FastMM C++ API 0.6.0
Public headers, tier 1 and tier 2
Loading...
Searching...
No Matches
venue.hpp
Go to the documentation of this file.
1#pragma once
2// Venue: the control-path interface every exchange connector implements (6.2). Nothing here
3// is on the hot path; the hot path lives in the connector's feed/gateway objects that the
4// concrete Venue owns and drives from its reactor thread.
5//
6// Threading contract (see include/fastmm/live/session.hpp):
7// * load_reference_data() and attach() run once on the main thread before any reactor
8// thread starts (blocking REST allowed).
9// * connect/disconnect/subscribe/on_timer/on_wake/request_open_orders run on the venue's
10// reactor thread (the backend posts them there).
11// * cancel_all() must be callable from ANY thread, including when the reactor thread is
12// wedged: implementations use an independent blocking REST connection (6.7 kill switch).
13#include "fastmm/core/fees.hpp"
14#include "fastmm/core/fill_audit.hpp"
16#include "fastmm/core/msg_ring.hpp"
17#include "fastmm/core/order_budget.hpp"
19#include "fastmm/core/seqlock.hpp"
21#include "fastmm/core/time.hpp"
27
28#include <cstdint>
29#include <functional>
30#include <span>
31#include <string>
32#include <string_view>
33#include <utility>
34#include <vector>
35
36namespace fastmm::venues {
37
38struct VenueCaps {
39 bool supports_replace = false; // Binance cancelReplace / Bybit amend
40 bool supports_post_only = true; // LIMIT_MAKER / PostOnly
41 bool ws_order_entry = true; // orders over WebSocket (REST fallback otherwise)
42 bool user_stream = true; // private order/fill stream available (false in dry-run)
43 // Moves an asset between accounts of the same exchange (Venue::transfer): the connector has the
44 // credentials for it (Binance: a master-account key, transfer_api_key_env).
45 bool internal_transfer = false;
46};
48enum class ChannelState : std::uint8_t { Down = 0, Connecting = 1, Live = 2, Stale = 3 };
49[[nodiscard]] constexpr std::string_view to_string(ChannelState s) noexcept {
50 switch (s) {
52 return "Down";
54 return "Connecting";
56 return "Live";
58 return "Stale";
59 }
60 return "?";
61}
62
63// Multicast feed (nasdaq_itch, ADR-0015 section 5); zero for the WebSocket venues.
64enum class FeedState : std::uint8_t {
65 None = 0, // not a multicast venue
66 Down = 1, // not joined yet
67 Snapshot = 2, // joined and buffering; waiting for GLIMPSE (or sequence 1)
68 Live = 3, // books built, messages applied as they arrive
69 Lost = 4, // cannot rebuild the books: the venue's kill switch is tripped (FeedLost)
70};
71[[nodiscard]] constexpr std::string_view to_string(FeedState s) noexcept {
72 switch (s) {
74 return "none";
75 case FeedState::Down:
76 return "down";
78 return "snapshot";
79 case FeedState::Live:
80 return "live";
81 case FeedState::Lost:
82 return "lost";
83 }
84 return "?";
85}
86
87struct VenueFeedStatus {
89 std::uint8_t backend = 0; // 0 kernel, 1 af_xdp, 2 dpdk
90 std::uint8_t xdp_mode = 0; // net::XdpMode the first interface settled on (af_xdp)
91 std::uint64_t packets = 0; // MoldUDP64 packets accepted (all lines, retransmissions included)
92 std::uint64_t bytes = 0; // datagram payload bytes received
93 std::uint64_t line_packets[2] = {0, 0}; // lines A, B
94 std::uint64_t line_duplicates[2] = {0, 0}; // copies that arrived after the first
95 std::int64_t line_skew_mean_ns[2] = {0, 0}; // arrival of a duplicate after the first copy
96 std::int64_t line_skew_max_ns[2] = {0, 0};
97 std::uint64_t gaps = 0; // gaps declared
98 std::uint64_t recovered = 0; // messages delivered from retransmissions
99 std::uint64_t unrecovered = 0; // sequences given up
100 std::uint64_t snapshot_recoveries = 0; // GLIMPSE snapshots applied after the first
101 std::uint64_t recovery_overflows = 0; // recovery buffer full during a snapshot
102 std::uint64_t reorder_high_water = 0;
103 std::uint64_t requests = 0; // MoldUDP64 request packets sent
104 std::uint64_t malformed = 0; // datagrams that are not MoldUDP64 packets, bad frames (af_xdp)
105 std::uint64_t book_errors = 0; // L3 inconsistencies (each starts a resync)
106 WireLatencyStats kernel_to_t0; // t0_wall_ns - sw_ts_ns (kernel backend only)
107 // af_xdp: XDP_STATISTICS summed over the sockets, and packets passed to the kernel because
108 // their RX queue had no socket.
109 std::uint64_t xdp_rx_dropped = 0;
110 std::uint64_t xdp_rx_invalid_descs = 0;
111 std::uint64_t xdp_rx_ring_full = 0;
112 std::uint64_t xdp_fill_ring_empty = 0;
113 std::uint64_t xdp_fallback = 0;
116// Snapshot for the stats line; every field is a plain counter so it can be copied out from
117// the control thread (the venue publishes it through a Seqlocked).
118struct VenueStatus {
122 std::uint32_t books_synced = 0;
123 std::uint32_t books_total = 0;
124 std::uint64_t md_messages = 0;
125 std::uint64_t md_malformed = 0;
126 std::uint64_t md_dropped = 0; // ring overflow
127 std::uint64_t resyncs = 0;
128 std::uint64_t orders_sent = 0;
129 std::uint64_t cancels_sent = 0;
130 std::uint64_t replaces_sent = 0;
131 std::uint64_t order_events = 0;
132 std::uint64_t order_send_failures = 0;
133 std::uint64_t shadows = 0; // order shadows held: orders working, in flight, or not yet swept
134 std::uint64_t shadows_swept =
135 0; // order shadows a reconciliation proved dead (lost terminal events)
136 std::uint64_t shadows_refused = 0; // orders not sent: no room for a shadow (OrderTableFull)
137 std::uint64_t rest_requests = 0;
138 std::uint64_t rest_errors = 0;
139 std::uint64_t rate_limit_cooldowns = 0;
140 // Orders and replaces the connector's rate limiter refused (VenueRateLimit, never sent), by
141 // the limit that refused them (RateLimiter::check): the IP's request weight, the order-count
142 // windows of up to 10 s, up to a minute and longer (the day), and a pause (429, 418).
143 std::uint64_t refused_weight = 0;
144 std::uint64_t refused_orders_10s = 0;
145 std::uint64_t refused_orders_1m = 0;
146 std::uint64_t refused_orders_1d = 0;
147 std::uint64_t refused_paused = 0;
148 std::int64_t clock_offset_ms = 0; // venue - local
149 std::uint64_t reconnects = 0;
150 std::uint64_t executions_fetched = 0; // trade-history rows replayed into the order sink
151 std::uint64_t execution_queries = 0;
152 std::uint64_t execution_query_errors = 0; // a reconciliation that could not be made exact
153 std::uint64_t funding_fetched = 0; // funding payments replayed from the venue
154 std::int64_t last_md_rx_ns = 0; // reactor clock
155 // Network-thread order latency (wire_latency.hpp), cumulative for the session. The ns
156 // percentiles need a calibration source (Venue::set_tsc_calibration_source); counts do not.
157 WireLatencyStats wire_tick_to_trade; // inbound receive (t0_cycles) -> send call returned
158 WireLatencyStats order_encode; // JSON encoding + signing
159 WireLatencyStats order_send; // WebSocket write / REST request call
160 WireLatencyWindow wire_1m; // the same three over the last minute (60-70 s)
161 WireLatencyWindow wire_1h; // and over the last hour (60-70 min)
162 VenueFeedStatus feed; // multicast venues only
165// The account's own fee rates on one instrument (Venue::account_fees).
166struct VenueFee {
171// An order counted as sent whose batch was then never written (the connection failed at
172// uncork()): the connector rejects it, so it is taken back out of the sent counters.
173inline void unsend(VenueStatus& s, OrderCommandKind k) noexcept {
174 switch (k) {
176 --s.orders_sent;
177 break;
179 --s.cancels_sent;
180 break;
182 --s.replaces_sent;
183 break;
184 }
185}
186
187class Venue {
188 public:
189 virtual ~Venue() = default;
190
191 [[nodiscard]] virtual VenueId id() const noexcept = 0;
192 [[nodiscard]] virtual std::string_view name() const noexcept = 0;
193 [[nodiscard]] virtual VenueCaps caps() const noexcept = 0;
195 // Fetches exchangeInfo / instruments-info for every instrument of this venue and
196 // overwrites tick/lot/min_qty/max_qty/min_notional with the venue's values (config values
197 // are a fallback when the venue is unreachable and `allow_offline` is set). Fatal on
198 // mismatch of a required symbol.
199 virtual Result<void, std::string> load_reference_data(InstrumentTable& instruments) = 0;
200 // The account's fee rates on this venue's instruments in `instruments`, fetched from the venue
201 // (Binance Spot with fetch_fees = true: GET /api/v3/account/commission per symbol). Main thread,
202 // after load_reference_data(), blocking REST allowed. Empty when the connector does not fetch
203 // them; an error when it was asked to and could not.
204 virtual Result<std::vector<VenueFee>, std::string> account_fees(
205 const InstrumentTable& /*instruments*/) {
206 return std::vector<VenueFee>{};
207 }
208 // After load_reference_data() failed: true when it refused a setting of the account (a position
209 // mode the connector does not trade in), which a retry does not fix. fastmm-live then exits 3,
210 // like a configuration error, instead of 4.
211 [[nodiscard]] virtual bool refused_account_settings() const noexcept { return false; }
212
213 // Wires the sinks (md: lossy, orders: never dropped) and the outbound ring the engine
214 // writes Out*Msg into. Must be called before connect().
215 virtual void attach(const SymbolTable& symbols,
216 const InstrumentTable& instruments,
217 EventSink& md_sink,
218 EventSink& order_sink,
219 MsgRing* outbound) = 0;
220
221 // Opens every channel (market data, user stream, order entry) on `reactor`.
222 virtual void connect(net::Reactor& reactor) = 0;
223 virtual void disconnect() = 0;
224 // Warm standby (fastmm-live --standby while another process holds the instance lock). Called
225 // before connect(); true when the connector takes it: connect() then opens only what public
226 // market data needs (a pool member, which reads none, opens nothing), and enable_private(), on
227 // the network thread, opens the rest: order entry, the private stream, the execution replay and
228 // the start-up sweep of open orders. Nothing in between sends, cancels or reads anything of the
229 // account. False: the connector cannot split, and the session waits for the lock before it
230 // connects at all.
231 virtual bool defer_private() { return false; }
232 virtual void enable_private() {}
233 virtual void subscribe(std::span<const InstrumentId> instruments) = 0;
235 // Periodic housekeeping (listenKey keepalive, app-level pings, clock offset refresh,
236 // snapshot retries). The backend calls it about once per second; venues may also arm
237 // their own reactor timers.
238 virtual void on_timer(std::int64_t now_ns) = 0;
239 // The engine pushed Out*Msg into the outbound ring: drain, encode, send.
240 virtual void on_wake() = 0;
241 // Run-to-completion ([engine] threading = "single"): the engine runs on the reactor thread and
242 // hands its Out*Msg batch over here instead of the outbound ring. Encode and write them now, as
243 // on_wake() does; a message that cannot go out is refused through the order sink. Called from
244 // inside the venue's own callbacks (a market-data event reaches the engine as it is decoded).
245 virtual void send_now(std::span<const EventHeader* const> batch) = 0;
246 // Called by the network thread after every reactor iteration. Venues whose sockets are not
247 // registered with the reactor poll them here (nasdaq_itch with [engine] spin_mode = "busy").
248 virtual void poll() noexcept {}
249 // Every book starts over from a fresh snapshot: a ConnectionState{Resyncing} or Stale on the md
250 // sink, then a snapshot per instrument. fastmm-gateway calls it when its own copies of the books
251 // were lost (an attaching strategy gets snapshots of those copies instead). Reactor thread. The
252 // default does nothing: a venue that cannot resync on demand (nasdaq_itch) leaves the books to
253 // its next natural resync.
254 virtual void resync_books() {}
255
256 // Venue view of open orders -> ReconcileMsg Begin/OpenOrder*/End into the order sink. A
257 // connector that can fetch executions (VenueCapabilities::executions) replays everything the
258 // account traded since the watermark first, as ordinary OrderFillMsg carrying the venue's
259 // execution id and OrderFillMsg::kReplayed, and only then emits the snapshot with
260 // ReconcileMsg::kExecutionsExact on its Begin. That order is what closes the hole: a fill that
261 // finished an order is booked from the execution itself, so the snapshot - which no longer
262 // mentions the order at all - has nothing left to explain.
263 virtual void request_open_orders() = 0;
264 // The account's executions from `since_venue_ms` (the venue's clock, inclusive) onwards, for
265 // every subscribed instrument: the venue's trade-history query (myTrades / userTrades /
266 // execution/list / get_user_trades_by_currency_and_time). Each one is emitted into the order sink
267 // as an ordinary OrderFillMsg carrying the venue's execution id and OrderFillMsg::kReplayed, so
268 // the OMS books only the ones it has not seen. Zero means "from wherever this connector last got
269 // to", which is what a reconciliation uses; a caller that knows better - the time of the last
270 // execution the engine booked, which the store and the journal both hold - passes it.
271 //
272 // Asynchronous and part of a reconciliation: the connector runs it before the open-order snapshot
273 // and stamps ReconcileMsg::kExecutionsExact on the snapshot's Begin when every instrument
274 // answered in full. Returns false when this connector cannot ask (VenueCapabilities::executions
275 // is false) or has nowhere to send the query, which is the only case where a fill the private
276 // stream missed stays an estimate.
277 virtual bool request_executions(std::int64_t /*since_venue_ms*/ = 0) { return false; }
278 // Where the first execution replay starts, for a session that carries a position over from an
279 // earlier one (fastmm-live restores it from the store before connect()): executions from
280 // `since_venue_ms` onwards are booked, except those whose venue trade id is in `known`, which the
281 // earlier session booked already. A connector that cannot replay executions ignores it, and the
282 // session does not restore a position for it (VenueCapabilities::executions).
283 virtual void resume_executions(std::int64_t /*since_venue_ms*/,
284 const std::vector<std::string>& /*known*/) {}
285 // An exact start where the venue's trade ids increase per instrument (Binance): the first trade
286 // id to ask for, per instrument - one past the last the earlier session booked. Called after
287 // resume_executions(); an instrument listed here replays from its id and ignores the time and
288 // the known ids, the others go on from `since_venue_ms`. Connectors without such ids ignore it.
289 virtual void resume_trade_ids(
290 const std::vector<std::pair<InstrumentId, std::int64_t>>& /*next_ids*/) {}
291 // The trade ids at or after an instrument's start (resume_trade_ids) that are booked already,
292 // ascending: a session that died inside its replay stored them, and the start stays before
293 // them because that replay had not read everything below them. Called after
294 // resume_trade_ids(); the replay skips them.
295 virtual void resume_known_trade_ids(
296 const std::vector<std::pair<InstrumentId, std::vector<std::int64_t>>>& /*known*/) {}
297 // Fill audit (live/fill_auditor.hpp): the account's executions with the venue's time in
298 // [start_ms, end_ms] on every subscribed instrument, read from the same trade history as
299 // request_executions() but apart from it (venues/execution_audit.hpp): nothing is emitted into
300 // the order sink, and the replay's watermark does not move. AuditFill::symbol is the instrument's
301 // symbol. `done` runs once on the reactor thread, complete = false when a query failed or the
302 // connection went down. Returns false, and never calls `done`, when the connector has no such
303 // read, is not connected, or one is running. Reactor thread. By value: a connector keeps it.
304 virtual bool audit_executions(std::int64_t /*start_ms*/,
305 std::int64_t /*end_ms*/,
306 // NOLINTNEXTLINE(performance-unnecessary-value-param)
307 std::function<void(bool, std::vector<AuditFill>)> /*done*/) {
308 return false;
309 }
310 // Whether audit_executions() is implemented. Any thread.
311 [[nodiscard]] virtual bool can_audit_executions() const noexcept { return false; }
312 // ---- internal transfers (VenueCaps::internal_transfer, core/transfer.hpp) --------------------
313 // Moves req.amount of req.asset from account req.from_account to req.to_account, both accounts
314 // of this exchange (the venues of one pool), under req.client_id. Blocking, over a REST
315 // connection of its own: callable from any thread but the venue's reactor thread (the pool
316 // treasury calls it from its own). Pending or Done: the venue took it; Failed: it refused,
317 // nothing moved; Unknown: no usable answer, ask transfer_status(). The default refuses (Failed).
318 virtual TransferResult transfer(const TransferRequest& /*req*/) {
319 return {TransferState::Failed, {}, "this connector has no internal transfers"};
320 }
321 // The state of the transfer named req.client_id (the same request transfer() was given). A
322 // transfer the connector carries out in several steps is finished from here when an earlier call
323 // left a step unsent. Blocking, like transfer().
325 return {TransferState::Unknown, {}, "this connector has no internal transfers"};
326 }
327 // This account's name in a transfer request (a Binance sub-account's email; empty for the
328 // exchange's master account).
329 [[nodiscard]] virtual std::string transfer_account() const { return {}; }
330 // Asks the venue for the account's balances now, emitted as a BalanceMsg snapshot on the order
331 // sink (the balance leg of the reconciliation). Reactor thread. The default does nothing.
332 virtual void request_balances() {}
333
334 // Kill switch: cancel every open order on every subscribed symbol via an independent
335 // REST connection. Blocking; safe from any thread. Returns false if the venue refused.
336 virtual bool cancel_all() = 0;
337
338 [[nodiscard]] virtual VenueStatus status() const noexcept = 0;
339
340 // Published TSC calibrations used to convert the network thread's cycle histograms to ns
341 // when the status is published. Set before connect(); the source must outlive the venue's
342 // reactor thread.
343 void set_tsc_calibration_source(const Seqlocked<TscCalibration>* src) noexcept {
344 tsc_source_ = src;
345 }
346 // The order budget the connector publishes from its rate limiter (core/order_budget.hpp): its
347 // reactor thread writes it with the status and after each response that reported the venue's
348 // counts; the engine reads it through LiveTransport (ctx.order_budget). Lives with the venue.
349 [[nodiscard]] const Seqlocked<OrderBudget>& budget_source() const noexcept { return budget_pub_; }
350
351 protected:
352 // Latest published calibration, or a calibration with use_tsc == false without a source.
353 [[nodiscard]] TscCalibration tsc_calibration() const noexcept {
354 return tsc_source_ != nullptr ? tsc_source_->load() : TscCalibration{};
355 }
356 Seqlocked<OrderBudget> budget_pub_;
357 // New orders and replaces taken off the engine's ring (send_command), sent or refused: published
358 // with the budget (OrderBudget::orders_taken). Reactor thread only.
359 std::uint64_t orders_taken_ = 0;
360 void note_taken(const OrderCommand& cmd) noexcept {
361 if (cmd.kind != OrderCommandKind::Cancel) ++orders_taken_;
362 }
363
364 private:
365 const Seqlocked<TscCalibration>* tsc_source_ = nullptr;
366};
367
368} // namespace fastmm::venues
Dense-by-id table built at startup; symbol lookup is a sorted FlatMap keyed by (venue,...
Definition instrument.hpp:141
Definition result.hpp:30
Definition reactor.hpp:72
Definition event_sink.hpp:34
Definition symbology.hpp:46
const Seqlocked< OrderBudget > & budget_source() const noexcept
The order budget the connector publishes from its rate limiter (core/order_budget....
Definition venue.hpp:349
virtual VenueCaps caps() const noexcept=0
std::uint64_t orders_taken_
New orders and replaces taken off the engine's ring (send_command), sent or refused: published with t...
Definition venue.hpp:359
virtual void connect(net::Reactor &reactor)=0
Opens every channel (market data, user stream, order entry) on reactor.
virtual void on_timer(std::int64_t now_ns)=0
Periodic housekeeping (listenKey keepalive, app-level pings, clock offset refresh,...
virtual VenueStatus status() const noexcept=0
Seqlocked< OrderBudget > budget_pub_
Definition venue.hpp:356
virtual void resume_executions(std::int64_t, const std::vector< std::string > &)
Where the first execution replay starts, for a session that carries a position over from an earlier o...
Definition venue.hpp:285
virtual void resync_books()
Every book starts over from a fresh snapshot: a ConnectionState{Resyncing} or Stale on the md sink,...
Definition venue.hpp:256
virtual ~Venue()=default
virtual bool request_executions(std::int64_t=0)
The account's executions from since_venue_ms (the venue's clock, inclusive) onwards,...
Definition venue.hpp:279
virtual Result< void, std::string > load_reference_data(InstrumentTable &instruments)=0
Fetches exchangeInfo / instruments-info for every instrument of this venue and overwrites tick/lot/mi...
virtual void send_now(std::span< const EventHeader *const > batch)=0
Run-to-completion ([engine] threading = "single"): the engine runs on the reactor thread and hands it...
virtual void resume_trade_ids(const std::vector< std::pair< InstrumentId, std::int64_t > > &)
An exact start where the venue's trade ids increase per instrument (Binance): the first trade id to a...
Definition venue.hpp:291
virtual VenueId id() const noexcept=0
virtual bool defer_private()
Warm standby (fastmm-live --standby while another process holds the instance lock).
Definition venue.hpp:233
virtual void request_open_orders()=0
Venue view of open orders -> ReconcileMsg Begin/OpenOrder*‍/End into the order sink.
virtual bool can_audit_executions() const noexcept
Whether audit_executions() is implemented. Any thread.
Definition venue.hpp:312
virtual bool cancel_all()=0
Kill switch: cancel every open order on every subscribed symbol via an independent REST connection.
void note_taken(const OrderCommand &cmd) noexcept
Definition venue.hpp:360
virtual std::string transfer_account() const
This account's name in a transfer request (a Binance sub-account's email; empty for the exchange's ma...
Definition venue.hpp:329
virtual void poll() noexcept
Called by the network thread after every reactor iteration.
Definition venue.hpp:250
virtual std::string_view name() const noexcept=0
virtual bool refused_account_settings() const noexcept
After load_reference_data() failed: true when it refused a setting of the account (a position mode th...
Definition venue.hpp:213
virtual bool audit_executions(std::int64_t, std::int64_t, std::function< void(bool, std::vector< AuditFill >)>)
Fill audit (live/fill_auditor.hpp): the account's executions with the venue's time in [start_ms,...
Definition venue.hpp:306
void set_tsc_calibration_source(const Seqlocked< TscCalibration > *src) noexcept
Published TSC calibrations used to convert the network thread's cycle histograms to ns when the statu...
Definition venue.hpp:343
virtual Result< std::vector< VenueFee >, std::string > account_fees(const InstrumentTable &)
The account's fee rates on this venue's instruments in instruments, fetched from the venue (Binance S...
Definition venue.hpp:206
virtual void enable_private()
Definition venue.hpp:234
virtual TransferResult transfer(const TransferRequest &)
Moves req.amount of req.asset from account req.from_account to req.to_account, both accounts of this ...
Definition venue.hpp:318
virtual void request_balances()
Asks the venue for the account's balances now, emitted as a BalanceMsg snapshot on the order sink (th...
Definition venue.hpp:332
virtual void resume_known_trade_ids(const std::vector< std::pair< InstrumentId, std::vector< std::int64_t > > > &)
The trade ids at or after an instrument's start (resume_trade_ids) that are booked already,...
Definition venue.hpp:297
virtual void disconnect()=0
virtual void on_wake()=0
The engine pushed Out*Msg into the outbound ring: drain, encode, send.
virtual TransferResult transfer_status(const TransferRequest &)
The state of the transfer named req.client_id (the same request transfer() was given).
Definition venue.hpp:324
virtual void attach(const SymbolTable &symbols, const InstrumentTable &instruments, EventSink &md_sink, EventSink &order_sink, MsgRing *outbound)=0
Wires the sinks (md: lossy, orders: never dropped) and the outbound ring the engine writes Out*Msg in...
TscCalibration tsc_calibration() const noexcept
Latest published calibration, or a calibration with use_tsc == false without a source.
Definition venue.hpp:353
virtual void subscribe(std::span< const InstrumentId > instruments)=0
Minimal expected<T, E>: the hot path never throws, it returns Result.
EventSink (5.15): the net -> engine seam.
Fee rates per instrument, in centi-basis-points (integer) of the fill notional.
Instrument: the single definition of a tradable contract (5.3 / 5.15).
Definition venue.hpp:38
ChannelState
Definition venue.hpp:50
constexpr std::string_view to_string(ChannelState s) noexcept
Definition venue.hpp:51
OrderCommandKind
Definition order_commands.hpp:15
FeedState
Multicast feed (nasdaq_itch, ADR-0015 section 5); zero for the WebSocket venues.
Definition venue.hpp:66
@ None
not a multicast venue
@ Live
books built, messages applied as they arrive
@ Lost
cannot rebuild the books: the venue's kill switch is tripped (FeedLost)
@ Snapshot
joined and buffering; waiting for GLIMPSE (or sequence 1)
void unsend(VenueStatus &s, OrderCommandKind k) noexcept
An order counted as sent whose batch was then never written (the connection failed at uncork()): the ...
Definition venue.hpp:175
@ Unknown
no usable answer (a transport error, a timeout, a 5xx): it may have happened
@ Failed
the venue refused it or gave up: nothing moved
Single-threaded event loop with a timer min-heap and a thread-safe mailbox (post/wake via eventfd),...
Strongly typed identifiers.
One maker/taker pair. 1 cbps == 0.01 bps == 1e-6 of the notional.
Definition fees.hpp:26
Definition transfer.hpp:44
Definition transfer.hpp:59
Definition time.hpp:89
Definition order_commands.hpp:28
Definition venue.hpp:40
bool supports_post_only
LIMIT_MAKER / PostOnly.
Definition venue.hpp:42
bool internal_transfer
Moves an asset between accounts of the same exchange (Venue::transfer): the connector has the credent...
Definition venue.hpp:47
bool ws_order_entry
orders over WebSocket (REST fallback otherwise)
Definition venue.hpp:43
bool supports_replace
Binance cancelReplace / Bybit amend.
Definition venue.hpp:41
bool user_stream
private order/fill stream available (false in dry-run)
Definition venue.hpp:44
The account's own fee rates on one instrument (Venue::account_fees).
Definition venue.hpp:168
FeeRates rates
Definition venue.hpp:170
InstrumentId instrument
Definition venue.hpp:169
Definition venue.hpp:89
std::uint64_t malformed
datagrams that are not MoldUDP64 packets, bad frames (af_xdp)
Definition venue.hpp:106
std::uint64_t xdp_rx_dropped
af_xdp: XDP_STATISTICS summed over the sockets, and packets passed to the kernel because their RX que...
Definition venue.hpp:111
std::uint64_t requests
MoldUDP64 request packets sent.
Definition venue.hpp:105
std::uint64_t bytes
datagram payload bytes received
Definition venue.hpp:94
std::uint8_t backend
0 kernel, 1 af_xdp, 2 dpdk
Definition venue.hpp:91
WireLatencyStats kernel_to_t0
t0_wall_ns - sw_ts_ns (kernel backend only)
Definition venue.hpp:108
std::int64_t line_skew_max_ns[2]
Definition venue.hpp:98
std::uint64_t recovery_overflows
recovery buffer full during a snapshot
Definition venue.hpp:103
std::uint64_t unrecovered
sequences given up
Definition venue.hpp:101
std::uint64_t packets
MoldUDP64 packets accepted (all lines, retransmissions included)
Definition venue.hpp:93
std::uint64_t gaps
gaps declared
Definition venue.hpp:99
std::uint64_t xdp_fill_ring_empty
Definition venue.hpp:114
std::int64_t line_skew_mean_ns[2]
arrival of a duplicate after the first copy
Definition venue.hpp:97
std::uint64_t reorder_high_water
Definition venue.hpp:104
std::uint64_t line_duplicates[2]
copies that arrived after the first
Definition venue.hpp:96
std::uint64_t line_packets[2]
lines A, B
Definition venue.hpp:95
std::uint8_t xdp_mode
net::XdpMode the first interface settled on (af_xdp)
Definition venue.hpp:92
std::uint64_t snapshot_recoveries
GLIMPSE snapshots applied after the first.
Definition venue.hpp:102
std::uint64_t xdp_rx_invalid_descs
Definition venue.hpp:112
std::uint64_t book_errors
L3 inconsistencies (each starts a resync)
Definition venue.hpp:107
std::uint64_t xdp_rx_ring_full
Definition venue.hpp:113
std::uint64_t recovered
messages delivered from retransmissions
Definition venue.hpp:100
std::uint64_t xdp_fallback
Definition venue.hpp:115
FeedState state
Definition venue.hpp:90
Snapshot for the stats line; every field is a plain counter so it can be copied out from the control ...
Definition venue.hpp:120
std::uint64_t executions_fetched
trade-history rows replayed into the order sink
Definition venue.hpp:152
WireLatencyWindow wire_1m
the same three over the last minute (60-70 s)
Definition venue.hpp:162
std::uint64_t refused_orders_1d
Definition venue.hpp:148
std::uint64_t order_events
Definition venue.hpp:133
std::uint32_t books_synced
Definition venue.hpp:124
std::uint32_t books_total
Definition venue.hpp:125
std::uint64_t refused_orders_1m
Definition venue.hpp:147
std::uint64_t md_malformed
Definition venue.hpp:127
WireLatencyStats order_encode
JSON encoding + signing.
Definition venue.hpp:160
std::uint64_t funding_fetched
funding payments replayed from the venue
Definition venue.hpp:155
std::uint64_t refused_weight
Orders and replaces the connector's rate limiter refused (VenueRateLimit, never sent),...
Definition venue.hpp:145
std::uint64_t shadows
order shadows held: orders working, in flight, or not yet swept
Definition venue.hpp:135
std::int64_t clock_offset_ms
venue - local
Definition venue.hpp:150
WireLatencyStats wire_tick_to_trade
Network-thread order latency (wire_latency.hpp), cumulative for the session.
Definition venue.hpp:159
std::uint64_t refused_orders_10s
Definition venue.hpp:146
std::uint64_t replaces_sent
Definition venue.hpp:132
std::uint64_t resyncs
Definition venue.hpp:129
std::uint64_t rest_errors
Definition venue.hpp:140
std::uint64_t order_send_failures
Definition venue.hpp:134
std::int64_t last_md_rx_ns
reactor clock
Definition venue.hpp:156
VenueFeedStatus feed
multicast venues only
Definition venue.hpp:164
ChannelState order
Definition venue.hpp:123
std::uint64_t cancels_sent
Definition venue.hpp:131
ChannelState md
Definition venue.hpp:121
WireLatencyWindow wire_1h
and over the last hour (60-70 min)
Definition venue.hpp:163
std::uint64_t rest_requests
Definition venue.hpp:139
std::uint64_t rate_limit_cooldowns
Definition venue.hpp:141
std::uint64_t md_messages
Definition venue.hpp:126
ChannelState user
Definition venue.hpp:122
std::uint64_t md_dropped
ring overflow
Definition venue.hpp:128
std::uint64_t shadows_swept
order shadows a reconciliation proved dead (lost terminal events)
Definition venue.hpp:136
std::uint64_t reconnects
Definition venue.hpp:151
WireLatencyStats order_send
WebSocket write / REST request call.
Definition venue.hpp:161
std::uint64_t shadows_refused
orders not sent: no room for a shadow (OrderTableFull)
Definition venue.hpp:138
std::uint64_t orders_sent
Definition venue.hpp:130
std::uint64_t execution_queries
Definition venue.hpp:153
std::uint64_t refused_paused
Definition venue.hpp:149
std::uint64_t execution_query_errors
a reconciliation that could not be made exact
Definition venue.hpp:154
Definition wire_latency.hpp:36
The three over one window (WireLatencyRecorder::summarize).
Definition wire_latency.hpp:45
SymbolTable (6.2): venue symbol <-> InstrumentId.
Time primitives.
An internal transfer: an amount of one asset moved between two accounts of the same exchange (the acc...
Network-thread order latency: what happens to an outbound order after the engine pushed it into the v...