47 [[nodiscard]]
static std::optional<OrderCommand>
from(
const EventHeader& h)
noexcept {
50 c.instrument = h.instrument;
54 const auto& m = msg_cast<OutNewOrderMsg>(&h);
56 c.cl_ord_id = m.cl_ord_id;
60 c.reduce_only = m.reduce_only != 0;
66 const auto& m = msg_cast<OutCancelMsg>(&h);
68 c.cl_ord_id = m.cl_ord_id;
69 c.venue_order_id = &m.venue_order_id;
73 const auto& m = msg_cast<OutReplaceMsg>(&h);
75 c.cl_ord_id = m.cl_ord_id;
76 c.orig_cl_ord_id = m.orig_cl_ord_id;
77 c.venue_order_id = &m.venue_order_id;
124 InFlight{c.cl_ord_id, high_, seq_, now_ns,
false,
false};
130 for (std::size_t k = 0; k < n_; ++k) {
139 void answered(
const EventHeader& h)
noexcept {
142 answered(msg_cast<OrderAckMsg>(&h).cl_ord_id);
145 answered(msg_cast<OrderRejectMsg>(&h).cl_ord_id);
148 answered(msg_cast<OrderFillMsg>(&h).cl_ord_id);
151 answered(msg_cast<OrderCancelAckMsg>(&h).cl_ord_id);
154 answered(msg_cast<OrderExpiredMsg>(&h).cl_ord_id);
163 for (std::size_t k = n_; k > 0; --k) {
174 for (std::size_t k = 0; k < n_; ++k) {
176 if (!f.rest) f.answered =
true;
181 [[nodiscard]] Mark
mark(std::int64_t now_ns)
noexcept {
183 if (n_ == 0)
return Mark{high_, seq_};
184 const InFlight& f = in_flight_[head_];
185 return Mark{f.prev, f.seq - 1};
190 [[nodiscard]] std::uint64_t
last_seq() const noexcept {
return seq_; }
192 begin.sent_watermark = watermark;
201 std::int64_t sent_ns;
205 void pop() noexcept {
209 void prune(std::int64_t now_ns)
noexcept {
211 const InFlight& f = in_flight_[head_];
212 if (!f.answered && now_ns - f.sent_ns <
kUnansweredNs)
break;
218 std::size_t head_ = 0;
221 std::uint64_t seq_ = 0;
ClientOrderId last_sent() const noexcept
The last id sent, answered or not, and its send sequence (the order being sent, inside the connector'...
Definition order_commands.hpp:191
static constexpr std::int64_t kUnansweredNs
Definition order_commands.hpp:111
void connection_lost() noexcept
The WebSocket order connection is gone: the requests sent on it will not be answered on it.
Definition order_commands.hpp:175
Mark mark(std::int64_t now_ns) noexcept
Definition order_commands.hpp:183
static constexpr std::size_t kMaxInFlight
Definition order_commands.hpp:112
void answered(ClientOrderId id) noexcept
The venue said something about order id.
Definition order_commands.hpp:131
void sent_over_rest(ClientOrderId id) noexcept
Order id (noted last, or nearly) went out over REST rather than on the WebSocket order connection: lo...
Definition order_commands.hpp:164
std::uint64_t last_seq() const noexcept
Definition order_commands.hpp:192
static void stamp(ReconcileMsg &begin, ClientOrderId watermark) noexcept
Definition order_commands.hpp:193
ClientOrderId value(std::int64_t now_ns) noexcept
The watermark for a snapshot requested now.
Definition order_commands.hpp:182
void note(const OrderCommand &c, std::int64_t now_ns) noexcept
Definition order_commands.hpp:120
Event bus message structs (5.5).
bool is_reconcile_request(const EventHeader &h) noexcept
The engine asks for a reconciliation (ControlCommand::Reconcile on the outbound ring).
Definition order_commands.hpp:227
constexpr std::string_view to_string(ChannelState s) noexcept
Definition venue.hpp:51
OrderCommandKind
Definition order_commands.hpp:15
OrderType
Definition enums.hpp:23
StrongId< struct ClientOrderTag, std::uint64_t, 0 > ClientOrderId
48-bit: session_epoch(16) << 32 | seq(32). 0 is never issued.
Definition strong_id.hpp:41
FixedString< 40 > VenueOrderId
Definition strong_id.hpp:42
Side
Definition enums.hpp:12
TimeInForce
Definition enums.hpp:36
@ Reconcile
Engine -> venue, on the outbound ring (hdr.venue: the venue): the engine and the venue disagree about...
Control thread injects the venue's view after a reconnect (5.8).
Definition messages.hpp:469
static constexpr std::uint8_t kSentWatermark
Definition messages.hpp:471
Definition order_commands.hpp:28
const EventHeader * header
Definition order_commands.hpp:41
OrderType type
Definition order_commands.hpp:36
Qty qty
Definition order_commands.hpp:40
Price price
Definition order_commands.hpp:39
Side side
Definition order_commands.hpp:35
ClientOrderId cl_ord_id
New: the order; Cancel: order to cancel; Replace: new id.
Definition order_commands.hpp:32
static std::optional< OrderCommand > from(const EventHeader &h) noexcept
nullopt for any non-outbound message type.
Definition order_commands.hpp:49
OrderCommandKind kind
Definition order_commands.hpp:29
TimeInForce tif
Definition order_commands.hpp:37
InstrumentId instrument
Definition order_commands.hpp:30
const VenueOrderId * venue_order_id
Cancel/Replace: may be empty.
Definition order_commands.hpp:34
ClientOrderId orig_cl_ord_id
Replace only.
Definition order_commands.hpp:33
Cycles t0_cycles() const noexcept
Receive stamp of the inbound event that triggered the order (0 when none, e.g. timers).
Definition order_commands.hpp:44
bool reduce_only
Definition order_commands.hpp:38
VenueId venue
Definition order_commands.hpp:31
The watermark for a snapshot: the id, for the engine, and its send sequence (0: none sent).
Definition order_commands.hpp:115
std::uint64_t seq
Definition order_commands.hpp:117
ClientOrderId id
Definition order_commands.hpp:116