FastMM documentation
FastMM C++ API 0.6.0
Public headers, tier 1 and tier 2
Loading...
Searching...
No Matches
fastmm::venues::SentWatermark Class Reference

The watermark stamped into an open-order snapshot's ReconcileMsg Begin: the engine's orders at or below it can be judged by the snapshot, the ones above it cannot. More...

#include <fastmm/venues/order_commands.hpp>

Classes

struct  Mark
 The watermark for a snapshot: the id, for the engine, and its send sequence (0: none sent). More...
 

Public Member Functions

void note (const OrderCommand &c, std::int64_t now_ns) noexcept
 
void answered (ClientOrderId id) noexcept
 The venue said something about order id.
 
void answered (const EventHeader &h) noexcept
 answered() for the order an event from the venue is about.
 
void sent_over_rest (ClientOrderId id) noexcept
 Order id (noted last, or nearly) went out over REST rather than on the WebSocket order connection: losing that connection does not settle it.
 
void connection_lost () noexcept
 The WebSocket order connection is gone: the requests sent on it will not be answered on it.
 
ClientOrderId value (std::int64_t now_ns) noexcept
 The watermark for a snapshot requested now.
 
Mark mark (std::int64_t now_ns) noexcept
 
ClientOrderId last_sent () const noexcept
 The last id sent, answered or not, and its send sequence (the order being sent, inside the connector's send path).
 
std::uint64_t last_seq () const noexcept
 

Static Public Member Functions

static void stamp (ReconcileMsg &begin, ClientOrderId watermark) noexcept
 

Static Public Attributes

static constexpr std::int64_t kUnansweredNs = 10'000'000'000
 
static constexpr std::size_t kMaxInFlight = 256
 

Detailed Description

The watermark stamped into an open-order snapshot's ReconcileMsg Begin: the engine's orders at or below it can be judged by the snapshot, the ones above it cannot.

It is the last client order id (New or Replace) the venue sent before the first one the venue has not answered yet (ack, reject, fill or cancel), in send order: an order still in flight when the snapshot is asked for may reach the matching engine, or the venue's open-order view, after the snapshot is taken (Binance Spot, 2026-09-26: an order sent 1 ms before openOrders.status and accepted by the matching engine was missing from the reply, and the engine cancelled it as gone). An order with no answer after kUnansweredNs no longer holds the watermark back, and neither does one sent on a WebSocket connection that is gone (it will not be answered on it); one sent over REST does, as its reply still comes.

One engine allocates its ids in the order it sends them; fastmm-gateway interleaves several engines' ids on one venue and finds the point the snapshot was taken at from the id itself (live/gateway.hpp), which is why the watermark is always an id that was sent.

The connector itself compares by send sequence: every New and Replace noted takes the next number (last_seq()), in send order over every engine behind the connector, and the watermark's sequence (Mark::seq) is that of the id it names. An order shadow stamped with its sequence is judged by the snapshot when its sequence is at or below the mark's, whichever engine sent it.

Member Function Documentation

◆ note()

void fastmm::venues::SentWatermark::note ( const OrderCommand &  c,
std::int64_t  now_ns 
)
inlinenoexcept

< treat the oldest as answered: never blocks new orders

◆ answered() [1/2]

void fastmm::venues::SentWatermark::answered ( ClientOrderId  id)
inlinenoexcept

The venue said something about order id.

◆ answered() [2/2]

void fastmm::venues::SentWatermark::answered ( const EventHeader &  h)
inlinenoexcept

answered() for the order an event from the venue is about.

◆ sent_over_rest()

void fastmm::venues::SentWatermark::sent_over_rest ( ClientOrderId  id)
inlinenoexcept

Order id (noted last, or nearly) went out over REST rather than on the WebSocket order connection: losing that connection does not settle it.

◆ connection_lost()

void fastmm::venues::SentWatermark::connection_lost ( )
inlinenoexcept

The WebSocket order connection is gone: the requests sent on it will not be answered on it.

REST requests still will, and keep holding the watermark back.

◆ value()

ClientOrderId fastmm::venues::SentWatermark::value ( std::int64_t  now_ns)
inlinenoexcept

The watermark for a snapshot requested now.

◆ mark()

Mark fastmm::venues::SentWatermark::mark ( std::int64_t  now_ns)
inlinenoexcept

◆ last_sent()

ClientOrderId fastmm::venues::SentWatermark::last_sent ( ) const
inlinenoexcept

The last id sent, answered or not, and its send sequence (the order being sent, inside the connector's send path).

◆ last_seq()

std::uint64_t fastmm::venues::SentWatermark::last_seq ( ) const
inlinenoexcept

◆ stamp()

static void fastmm::venues::SentWatermark::stamp ( ReconcileMsg &  begin,
ClientOrderId  watermark 
)
inlinestaticnoexcept

Member Data Documentation

◆ kUnansweredNs

constexpr std::int64_t fastmm::venues::SentWatermark::kUnansweredNs = 10'000'000'000
staticconstexpr

◆ kMaxInFlight

constexpr std::size_t fastmm::venues::SentWatermark::kMaxInFlight = 256
staticconstexpr