38#include "fastmm/core/config_macros.hpp"
39#include "fastmm/core/containers/bucket_bits.hpp"
40#include "fastmm/core/containers/open_hash_map.hpp"
41#include "fastmm/core/containers/pool.hpp"
42#include "fastmm/core/containers/recent_map.hpp"
43#include "fastmm/core/containers/ring_buffer.hpp"
44#include "fastmm/core/containers/static_vector.hpp"
66inline constexpr std::size_t
kExecMemory = std::size_t{1} << 16;
68inline constexpr std::uint64_t
kMaxSeq = 0xFFFF'FFFFULL;
127 std::uint32_t
open = 0;
163 for (
auto& per_inst : best_own_) per_inst[0] = per_inst[1] =
Price{};
164 for (
auto& per_inst : open_qty_) per_inst[0] = per_inst[1] =
Qty{};
169 [[nodiscard]] std::uint16_t
session_epoch() const noexcept {
return epoch_; }
174 if (FASTMM_UNLIKELY(seq_ >= max_seq_))
return ClientOrderId{};
178 [[nodiscard]] std::uint64_t
ids_left() const noexcept {
return max_seq_ - seq_; }
179 [[nodiscard]]
const OmsStats&
stats() const noexcept {
return stats_; }
182 return open_per_inst_[
id.value];
186 return open_qty_[
id.value][
static_cast<std::size_t
>(s)];
190 return best_own_[
id.value][
static_cast<std::size_t
>(s)];
205 if (FASTMM_UNLIKELY(!add_open(
id, h))) {
210 Order& o = pool_.get(h);
230 if (context !=
nullptr) t.
context = *context;
231 estimates_[h.
idx] = Estimate{};
244 Order& o = pool_.get(h);
247 trails_[h.
idx].pending_sent = now;
255 Order& o = pool_.get(h);
258 trails_[h.idx].pending_sent = now;
272 Order& o = pool_.get(h);
282 OrderTrail& t = trails_[h.idx];
283 t.pending_sent = now;
284 t.pending_context = context !=
nullptr ? *context : QuoteContext{};
306 Order& o = pool_.get(h);
314 trails_[h.
idx].times.venue_ack = m.hdr.exch_ts;
315 trails_[h.
idx].times.local_ack = m.hdr.recv_ts;
329 apply_replace(u, h, o, rekey, new_venue_order);
330 if (o.
cl_ord_id != old_id) u.replaced_cl_ord_id = old_id;
345 if (m.cl_ord_id == o.
cl_ord_id && !trails_[h.
idx].times.venue_ack.valid())
346 trails_[h.
idx].times.venue_ack = m.hdr.exch_ts;
349 finish_update(u, h, o);
360 Order& o = pool_.get(h);
364 u.refused = m.reason;
372 u.refused = m.reason;
382 finish_update(u, h, o);
386 finish_update(u, h, o);
397 Order& o = pool_.get(h);
399 absorb_cum(h, o, m.
cum_qty, u);
403 finish_update(u, h, o);
427 Order& o = pool_.get(h);
431 finish_update(u, h, o);
444 finish_update(u, h, o);
452 if (!m.exec_id.empty() && !remember_exec(m)) {
470 if (!replayed && m.cum_qty.is_positive()) {
471 const Qty booked = h.
valid() ? pool_.get(h).cum_qty : u.order.cum_qty;
472 Qty covered = booked - (m.cum_qty - m.qty);
473 if (covered > m.qty) covered = m.qty;
474 if (covered.
is_positive()) take_synthetic(h, m.cl_ord_id, covered, u);
475 }
else if (replayed || !h.
valid()) {
476 take_synthetic(h, m.cl_ord_id, m.qty, u);
491 Order& o = pool_.get(h);
496 const Qty fresh = m.qty - u.corrected_qty;
498 if (cum < before) cum = before;
499 if (cum > o.
qty) cum = o.
qty;
511 finish_update(u, h, o);
522 Order& o = pool_.get(h);
524 absorb_cum(h, o, m.
cum_qty, u);
541 std::optional<ClientOrderId> sent_watermark = std::nullopt)
noexcept {
542 ReconcileScope& sc = recon_scope_[venue.value];
543 sc.bounded = sent_watermark.has_value();
558 Order& o = pool_.get(h);
562 absorb_cum(h, o, m.
cum_qty, u);
570 finish_update(u, h, o);
579 const ReconcileScope& sc = recon_scope_[venue.value];
584 static_cast<void>(unseen.push_back(h));
587 if (!pool_.is_live(h))
continue;
588 Order& o = pool_.get(h);
613 if (timeout.ns <= 0)
return 0;
617 if (now - o.
created < timeout)
return;
618 static_cast<void>(stale.push_back(h));
621 if (!pool_.is_live(h))
continue;
634 [[nodiscard]]
const OrderTimes&
times(Handle<Order> h)
const noexcept {
635 return trails_[h.idx].times;
640 const std::uint32_t* v = ids_.find(
id);
641 if (v ==
nullptr)
return nullptr;
642 if ((*v & kTerminalRef) == 0)
return &trails_[*v];
643 const std::uint64_t pos = terminal_pos(
id);
644 if (recently_terminal_.at_pos(pos) ==
nullptr)
return nullptr;
660 by_inst_.for_each(InstBits::bucket(
id.value), [&](std::uint32_t idx) {
661 const Order& o = pool_.get(Handle<Order>{idx});
665 void warm_up() noexcept { pool_.warm_up(); }
674 struct TerminalRecord {
686 struct ReconcileScope {
688 bool bounded =
false;
691 [[nodiscard]]
static bool in_scope(
const Order& o,
VenueId venue)
noexcept {
692 return !venue.
valid() || o.venue == venue;
699 void absorb_cum(Handle<Order> h, Order& o,
Qty reported, OmsUpdate& u)
noexcept {
701 if (cum > o.qty) cum = o.qty;
702 if (cum <= o.cum_qty)
return;
703 const Qty diff = cum - o.cum_qty;
704 open_qty_[o.instrument.value][
static_cast<std::size_t
>(o.side)] -= diff;
706 u.missed_qty += diff;
709 note_synthetic(estimates_[h.idx], diff, o.price);
717 void note_synthetic(Estimate& e,
Qty qty,
Price px)
noexcept {
725 void take_synthetic(Handle<Order> h,
ClientOrderId id,
Qty qty, OmsUpdate& u)
noexcept {
726 Estimate* e =
nullptr;
728 e = &estimates_[h.idx];
729 }
else if (TerminalRecord* r = find_terminal(
id); r !=
nullptr) {
732 if (e ==
nullptr || !e->qty.is_positive())
return;
733 u.corrected_qty = qty < e->qty ? qty : e->qty;
734 u.synthetic_px = e->price;
735 e->qty -= u.corrected_qty;
737 if (!e->qty.is_positive()) {
746 [[nodiscard]] Handle<Order> open_handle(
ClientOrderId id)
const noexcept {
747 const std::uint32_t* v = ids_.find(
id);
748 return v ==
nullptr || (*v & kTerminalRef) != 0 ? Handle<Order>{} : Handle<Order>{*v};
752 [[nodiscard]]
bool add_open(
ClientOrderId id, Handle<Order> h)
noexcept {
753 return ids_.assign(
id, h.idx) !=
nullptr;
757 const std::uint32_t* v = ids_.find(
id);
758 if (v !=
nullptr && (*v & kTerminalRef) == 0) ids_.erase(
id);
760 [[nodiscard]]
static constexpr std::uint32_t terminal_ref(std::uint64_t pos)
noexcept {
765 [[nodiscard]] std::uint64_t terminal_pos(
ClientOrderId id)
const noexcept {
766 const std::uint32_t* v = ids_.find(
id);
767 if (v ==
nullptr || (*v & kTerminalRef) == 0)
return recently_terminal_.next_pos();
768 const std::uint64_t head = recently_terminal_.head_pos();
773 [[nodiscard]]
const TerminalRecord* find_terminal(
ClientOrderId id)
const noexcept {
774 return recently_terminal_.at_pos(terminal_pos(
id));
776 [[nodiscard]] TerminalRecord* find_terminal(
ClientOrderId id)
noexcept {
777 return recently_terminal_.at_pos(terminal_pos(
id));
783 void remember_terminal(
const TerminalRecord& r,
const OrderTrail&
trail, OmsUpdate& u)
noexcept {
784 if (recently_terminal_.full()) {
785 const TerminalRecord& gone = recently_terminal_.front();
786 if (FASTMM_UNLIKELY(gone.estimate.qty.is_positive())) {
787 u.forgotten_qty = gone.estimate.qty;
788 u.forgotten_id = gone.cl_ord_id;
793 const std::uint32_t* v = ids_.find(gone.cl_ord_id);
794 if (v !=
nullptr && *v == terminal_ref(recently_terminal_.head_pos()))
795 ids_.erase(gone.cl_ord_id);
798 static_cast<void>(ids_.assign(r.cl_ord_id, terminal_ref(recently_terminal_.next_pos())));
800 recently_terminal_.push(r);
807 void late_fill(
const OrderFillMsg& m, OmsUpdate& u)
noexcept {
808 TerminalRecord* r = find_terminal(m.cl_ord_id);
809 if (r ==
nullptr)
return;
811 const Qty fresh = m.qty - u.corrected_qty;
812 Qty cum = m.cum_qty.
is_positive() ? m.cum_qty : r->cum_qty + fresh;
813 if (cum > r->qty) cum = r->qty;
814 if (cum <= r->cum_qty)
return;
820 u.order.cum_qty = r->cum_qty;
821 u.order.state = r->state;
826 Handle<Order> lookup(
ClientOrderId id, OmsUpdate& u)
noexcept {
827 const std::uint32_t* v = ids_.find(
id);
828 if (v ==
nullptr)
return Handle<Order>{};
829 if ((*v & kTerminalRef) == 0) {
831 u.handle = Handle<Order>{*v};
834 const TerminalRecord* r = find_terminal(
id);
838 u.order.cl_ord_id = r->cl_ord_id;
839 u.order.instrument = r->instrument;
840 u.order.venue = r->venue;
841 u.order.side = r->side;
842 u.order.state = r->state;
843 u.order.price = r->price;
844 u.order.qty = r->qty;
845 u.order.cum_qty = r->cum_qty;
848 return Handle<Order>{};
851 void finish_update(OmsUpdate& u, Handle<Order> h,
const Order& o)
noexcept {
854 u.times = trails_[h.idx].times;
862 OmsUpdate& u, Handle<Order> h, Order& o,
bool rekey,
bool new_venue_order)
noexcept {
863 const std::size_t s =
static_cast<std::size_t
>(o.side);
864 Qty& open = open_qty_[o.instrument.value][s];
865 open -= o.leaves_qty();
866 Estimate& e = estimates_[h.idx];
867 if (rekey && new_venue_order && FASTMM_UNLIKELY(e.qty.is_positive())) {
875 o.cl_ord_id, o.price, o.qty, o.cum_qty, o.instrument, o.venue, end, o.side,
false, e},
881 drop_open(o.cl_ord_id);
882 o.cl_ord_id = o.pending_cl_ord_id;
884 if (new_venue_order) o.cum_qty =
Qty{};
885 const Price old_px = o.price;
886 o.price = o.pending_price;
887 o.qty = o.pending_qty;
888 if (o.cum_qty > o.qty) o.cum_qty = o.qty;
889 open += o.leaves_qty();
891 o.pending_price =
Price{};
892 o.pending_qty =
Qty{};
893 o.flags &=
static_cast<std::uint8_t
>(~Order::kReplaceOldCanceled);
895 Price& best = best_own_[o.instrument.value][s];
896 if (best.is_zero() ||
better(o.side, o.price, best)) {
898 }
else if (old_px == best) {
899 recompute_best_own(o.instrument, o.side);
902 void clear_pending(Order& o)
noexcept {
903 if (o.pending_cl_ord_id.valid() && o.pending_cl_ord_id != o.cl_ord_id)
904 drop_open(o.pending_cl_ord_id);
906 o.pending_price =
Price{};
907 o.pending_qty =
Qty{};
908 o.flags &=
static_cast<std::uint8_t
>(~Order::kReplaceOldCanceled);
911 void terminate(OmsUpdate& u,
915 bool by_reconcile =
false) noexcept {
916 o.state = final_state;
919 --open_per_inst_[o.instrument.value];
920 const std::size_t s =
static_cast<std::size_t
>(o.side);
921 open_qty_[o.instrument.value][s] -= o.leaves_qty();
922 if (o.pending_cl_ord_id.valid() && o.pending_cl_ord_id != o.cl_ord_id)
923 drop_open(o.pending_cl_ord_id);
926 remember_terminal(TerminalRecord{o.cl_ord_id,
938 estimates_[h.idx] = Estimate{};
940 u.handle = Handle<Order>{};
941 u.times = trails_[h.idx].times;
946 const Side side = o.side;
947 const Price px = o.price;
948 by_inst_.clear(InstBits::bucket(inst.value), h.idx);
950 if (px == best_own_[inst.value][s]) recompute_best_own(inst, side);
956 by_inst_.for_each(InstBits::bucket(inst.value), [&](std::uint32_t idx) {
957 const Order& o = pool_.get(Handle<Order>{idx});
958 if (o.side != side || o.instrument != inst)
return;
959 if (best.is_zero() ||
better(side, o.price, best)) best = o.price;
961 best_own_[inst.value][
static_cast<std::size_t
>(side)] = best;
968 bool remember_exec(
const OrderFillMsg& m)
noexcept {
969 const std::uint64_t key = m.exec_id.hash() ^
970 (
static_cast<std::uint64_t
>(m.hdr.instrument.value) << 1U) ^
971 (
static_cast<std::uint64_t
>(m.side) * 0x9E3779B97F4A7C15ULL);
972 return exec_seen_.assign(key, 1);
975 std::uint16_t epoch_;
976 std::uint64_t max_seq_;
977 std::uint64_t seq_ = 0;
979 Pool<Order, kMaxOpenOrders> pool_;
982 using InstBits = BucketBits<kMaxOpenOrders, kMaxInstruments>;
988 static constexpr std::uint32_t kTerminalRef = 1U << 31;
990 OpenHashMap<ClientOrderId, std::uint32_t, kMaxOpenOrders * 4> ids_;
991 RingBuffer<TerminalRecord, kRecentlyTerminal> recently_terminal_;
992 RecentMap<std::uint64_t, std::uint8_t, kExecMemory> exec_seen_;
996 ReconcileScope recon_scope_[std::numeric_limits<VenueId::rep_type>::max() + 1U] = {};
999 std::unique_ptr<OrderTrail[]> trails_ = std::make_unique<OrderTrail[]>(
kMaxOpenOrders);
1000 std::unique_ptr<OrderTrail[]> terminal_trails_ =
1004 std::unique_ptr<Estimate[]> estimates_ = std::make_unique<Estimate[]>(
kMaxOpenOrders);
BookView: the read interface every book implementation (L2Book, L3Book::to_l2 view,...
Result< void, RejectReason > request_replace(Handle< Order > h, ClientOrderId new_id, Price px, Qty qty, Timestamp now={}, const QuoteContext *context=nullptr) noexcept
new_id may equal the current id for venues that amend in place.
Definition oms.hpp:266
void reconcile_begin(VenueId venue=VenueId::invalid(), std::optional< ClientOrderId > sent_watermark=std::nullopt) noexcept
Starts reconciling venue's orders (an invalid venue: every venue).
Definition oms.hpp:539
const OrderTimes & times(Handle< Order > h) const noexcept
Send and ack times of an open order.
Definition oms.hpp:631
std::size_t sweep_pending(Timestamp now, Duration timeout, F &&f) noexcept
Orders still PendingNew timeout after they were submitted: the request or its ack was lost,...
Definition oms.hpp:610
Result< void, RejectReason > request_cancel_unacked(Handle< Order > h, Timestamp now={}) noexcept
Cancel of an order that is still waiting for its ack (the ack-timeout sweep only).
Definition oms.hpp:254
OrderClass classify(ClientOrderId id) const noexcept
Definition oms.hpp:645
std::uint64_t ids_left() const noexcept
Client order ids left in this session.
Definition oms.hpp:180
OmsUpdate on_ack(const OrderAckMsg &m) noexcept
Definition oms.hpp:290
Price best_own_px(InstrumentId id, Side s) const noexcept
Best price among our own open orders on (instrument, side); Price{} if none. For STP.
Definition oms.hpp:191
void reconcile_end(F &&f, VenueId venue=VenueId::invalid()) noexcept
Every open order of venue (invalid: every venue) the snapshot did not report is marked Canceled,...
Definition oms.hpp:577
Qty open_qty(InstrumentId id, Side s) const noexcept
Sum of leaves of open orders on (instrument, side): "in-flight same-side exposure".
Definition oms.hpp:187
OmsUpdate on_expired(const OrderExpiredMsg &m) noexcept
Definition oms.hpp:515
OmsUpdate on_reject(const OrderRejectMsg &m) noexcept
Definition oms.hpp:353
Oms & operator=(const Oms &)=delete
OmsUpdate on_fill(const OrderFillMsg &m) noexcept
Definition oms.hpp:448
bool is_live(Handle< Order > h) const noexcept
Definition oms.hpp:629
std::uint16_t session_epoch() const noexcept
Definition oms.hpp:171
ClientOrderId next_cl_ord_id() noexcept
An invalid id once the session's 32-bit sequence is used up: the wire form carries 48 bits (epoch 16 ...
Definition oms.hpp:175
OmsUpdate on_cancel_ack(const OrderCancelAckMsg &m) noexcept
Definition oms.hpp:390
void warm_up() noexcept
Definition oms.hpp:662
OmsUpdate on_cancel_reject(const OrderCancelRejectMsg &m) noexcept
Definition oms.hpp:420
OmsUpdate reconcile_open_order(const ReconcileMsg &m) noexcept
Venue reports an open order. Unknown -> CancelUnknown (engine cancels by venue id).
Definition oms.hpp:549
Handle< Order > find(ClientOrderId id) const noexcept
Definition oms.hpp:644
Result< Handle< Order >, RejectReason > submit(const NewOrderRequest &req, ClientOrderId id, Timestamp now, const QuoteContext *context=nullptr) noexcept
context: the strategy's quote context of the order's side now (OrderTrail::context).
Definition oms.hpp:197
const OmsStats & stats() const noexcept
Definition oms.hpp:181
Result< void, RejectReason > request_cancel(Handle< Order > h, Timestamp now={}) noexcept
now: the cancel's send time (OrderTrail::pending_sent).
Definition oms.hpp:243
void for_each_open_order(F &&f) const noexcept
Ascending handle order (deterministic). F(Handle<Order>, const Order&).
Definition oms.hpp:652
std::uint32_t open_count() const noexcept
Definition oms.hpp:182
const Order & get(Handle< Order > h) const noexcept
Definition oms.hpp:627
const OrderTrail * trail(ClientOrderId id) const noexcept
How the order id names got where it is: an open order's (its own id or a pending replace's),...
Definition oms.hpp:636
Minimal expected<T, E>: the hot path never throws, it returns Result.
Instrument: the single definition of a tradable contract (5.3 / 5.15).
Event bus message structs (5.5).
Definition strategy.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
OrderState
Definition enums.hpp:79
constexpr ClientOrderId make_cl_ord_id(std::uint16_t epoch, std::uint32_t seq) noexcept
Definition strong_id.hpp:103
RejectReason
Ordered exactly like RiskEngine::check_new evaluates them (5.7), followed by OMS / transport / venue ...
Definition enums.hpp:123
@ PoolExhausted
OMS / transport.
OrderClass
Definition oms.hpp:157
Side
Definition enums.hpp:12
Fixed< struct QtyTag > Qty
Definition fixed_point.hpp:333
constexpr std::size_t kMaxOpenOrders
Definition oms.hpp:60
constexpr Unexpected< std::decay_t< E > > fail(E &&e) noexcept
Definition result.hpp:25
constexpr std::uint64_t kMaxSeq
Client order ids per session: the wire form is 48 bits, epoch(16) << 32 | seq(32).
Definition oms.hpp:70
constexpr std::size_t kExecMemory
Executions the OMS remembers by the venue's id, so that one it is given again (a replay of the venue'...
Definition oms.hpp:68
StrongId< struct InstrumentTag, std::uint32_t > InstrumentId
Dense index into the engine's instrument table.
Definition strong_id.hpp:38
constexpr std::size_t kRecentlyTerminal
Definition oms.hpp:61
Fixed< struct PriceTag > Price
Definition fixed_point.hpp:332
constexpr std::size_t kMaxInstruments
Definition instrument.hpp:26
constexpr bool better(Side s, Price p, Price q) noexcept
Definition book_view.hpp:48
OmsAction
Definition oms.hpp:72
@ LateFill
fill for a recently terminal order: position, and the terminal record's cum_qty and state (changed = ...
@ CancelUnknown
ack/fill for an id we do not know: engine must cancel it
@ UnknownFill
fill for a completely unknown id: update position, alert
@ Ignored
message did not apply (duplicate ack, late cancel-reject, ...)
@ ReconcileNeeded
too many cancel rejects
@ Duplicate
duplicate exec_id
StrongId< struct VenueTag, std::uint8_t > VenueId
Definition strong_id.hpp:39
Order: the OMS's 128-byte record for one order across its lifetime.
constexpr bool is_zero() const noexcept
Definition fixed_point.hpp:301
constexpr bool is_positive() const noexcept
Definition fixed_point.hpp:302
Definition strong_id.hpp:54
constexpr bool valid() const noexcept
Definition strong_id.hpp:58
std::uint32_t idx
Definition strong_id.hpp:55
bool reduce_only
Definition order.hpp:116
Side side
Definition order.hpp:112
VenueId venue
Definition order.hpp:107
OrderType type
Definition order.hpp:113
bool post_only
Definition order.hpp:115
std::uint32_t user_tag
Definition order.hpp:119
Price price
Definition order.hpp:117
TimeInForce tif
Definition order.hpp:114
InstrumentId instrument
Definition order.hpp:106
Qty qty
Definition order.hpp:118
std::uint64_t late_fills
Definition oms.hpp:139
std::uint64_t corrected_fills
Missed fills a replayed execution later named, so their price and fee stopped being estimates.
Definition oms.hpp:143
std::uint32_t open
Definition oms.hpp:129
std::uint64_t duplicates
Definition oms.hpp:138
std::uint64_t synthetic_forgotten
Estimates whose order left the OMS's memory (kRecentlyTerminal later terminal orders) before an execu...
Definition oms.hpp:150
std::uint64_t reconcile_unresolved
Orders a reconciliation snapshot did not report that still had working quantity: the venue ended them...
Definition oms.hpp:154
std::uint64_t unsolicited_cancels
Definition oms.hpp:140
std::uint32_t synthetic_pending
Orders holding an estimate no execution has named yet (a gauge): the position and the PnL include tha...
Definition oms.hpp:146
std::uint64_t unknown_ids
Definition oms.hpp:137
std::uint64_t filled
Definition oms.hpp:134
std::uint64_t missed_fills
cum_qty jumps a fill message never reported
Definition oms.hpp:141
std::uint64_t rejected
Definition oms.hpp:132
std::uint64_t canceled
Definition oms.hpp:133
std::uint64_t fills
Definition oms.hpp:135
std::uint64_t expired
Definition oms.hpp:136
std::uint64_t ack_timeouts
PendingNew orders swept by sweep_pending()
Definition oms.hpp:151
std::uint64_t submitted
Definition oms.hpp:130
std::uint64_t acked
Definition oms.hpp:131
OrderTimes times
The order's times (Oms::times), and the pool slot it had: set on every update of an open order,...
Definition oms.hpp:124
Price fill_px
Definition oms.hpp:97
bool known
the id mapped to an order (open or recently terminal)
Definition oms.hpp:90
Price synthetic_px
Definition oms.hpp:115
Qty corrected_qty
Part of a replayed execution (OrderFillMsg::kReplayed) whose quantity a synthetic fill already put in...
Definition oms.hpp:114
Qty unresolved_qty
Quantity that was still working when a reconciliation snapshot failed to mention the order.
Definition oms.hpp:109
Qty forgotten_qty
An estimate no execution named whose order this update pushed out of the OMS's memory of recently ter...
Definition oms.hpp:120
Qty fill_qty
for fills
Definition oms.hpp:96
Handle< Order > slot
Definition oms.hpp:125
Handle< Order > handle
invalid once terminal (slot freed) or unknown
Definition oms.hpp:87
Order order
snapshot after the transition; for a recently terminal id only the terminal record's fields (id,...
Definition oms.hpp:84
ClientOrderId forgotten_id
Definition oms.hpp:121
bool terminal
the order reached a terminal state in this update
Definition oms.hpp:92
OrderState prev
Definition oms.hpp:88
RejectReason refused
The venue (or the connector for it) refused the order's new or replace leg in this update: the order ...
Definition oms.hpp:95
bool changed
state or quantities changed
Definition oms.hpp:91
ClientOrderId replaced_cl_ord_id
A cancel-replace to a new id completed: the order carries on under order.cl_ord_id and this one is go...
Definition oms.hpp:105
Qty missed_qty
Quantity the venue reports as filled that we never saw a fill message for (a private-stream outage co...
Definition oms.hpp:101
OmsAction action
Definition oms.hpp:89
Definition messages.hpp:267
static constexpr std::uint8_t kAmendedInPlace
The venue amended the resting order in place (Binance Spot order.amend.keepPriority,...
Definition messages.hpp:271
Definition messages.hpp:292
Definition messages.hpp:301
Definition messages.hpp:340
Definition messages.hpp:312
static constexpr std::uint8_t kReplayed
The execution comes from the venue's trade history (Venue::request_executions), not from the private ...
Definition messages.hpp:316
Definition messages.hpp:281
When the order's working leg (the order, or its latest replacement once acknowledged) was sent and ac...
Definition order.hpp:60
Timestamp sent
engine clock when the order or replace went out
Definition order.hpp:61
How an order came to be where it was when something happened to it: kept by the OMS next to Order (Om...
Definition order.hpp:83
OrderTimes times
the working leg: sent (the order, or its last accepted replace)
Definition order.hpp:84
Price placed_px
the first leg's price
Definition order.hpp:88
Timestamp pending_sent
the cancel or replace in flight went out; invalid: none.
Definition order.hpp:86
std::uint32_t amends
replaces the venue accepted
Definition order.hpp:89
Timestamp placed
the first leg went out
Definition order.hpp:85
QuoteContext pending_context
the side's context when the replace in flight went out
Definition order.hpp:92
QuoteContext context
the side's context when the working leg went out
Definition order.hpp:91
OrderState state
1
Definition order.hpp:36
TimeInForce tif
1 -> 64
Definition order.hpp:35
VenueOrderId venue_order_id
41 -> 49
Definition order.hpp:28
ClientOrderId cl_ord_id
8
Definition order.hpp:27
Qty qty
8 -> 88
Definition order.hpp:42
constexpr Qty leaves_qty() const noexcept
Definition order.hpp:49
std::uint8_t flags
1
Definition order.hpp:38
Price pending_price
8 -> 120
Definition order.hpp:46
constexpr bool has(Flags f) const noexcept
Definition order.hpp:54
std::uint8_t cancel_attempts
1
Definition order.hpp:39
ClientOrderId pending_cl_ord_id
8 -> 112 replace: id of the replacement order
Definition order.hpp:45
Timestamp created
8 -> 104
Definition order.hpp:44
VenueId venue
1
Definition order.hpp:32
constexpr bool is_working() const noexcept
Definition order.hpp:51
Qty pending_qty
8 -> 128
Definition order.hpp:47
InstrumentId instrument
4 -> 60
Definition order.hpp:31
Side side
1
Definition order.hpp:33
std::uint32_t user_tag
4 -> 72 (QuoteManager slot id etc.)
Definition order.hpp:40
RejectReason reject_reason
1
Definition order.hpp:37
Qty cum_qty
8 -> 96
Definition order.hpp:43
OrderType type
1
Definition order.hpp:34
Price price
8 -> 80
Definition order.hpp:41
@ kReplaceOldCanceled
cancel-then-new replace: old leg already cancelled
Definition order.hpp:24
@ kReconciled
state fixed up by reconciliation
Definition order.hpp:21
@ kReduceOnly
Definition order.hpp:19
@ kPostOnly
Definition order.hpp:18
@ kSeenInReconcile
scratch flag during a reconcile pass
Definition order.hpp:22
@ kUnsolicitedCancel
venue cancelled it (not requested by us)
Definition order.hpp:20
Control thread injects the venue's view after a reconnect (5.8).
Definition messages.hpp:668
static constexpr StrongId invalid() noexcept
Definition strong_id.hpp:30
Rep value
Definition strong_id.hpp:26
constexpr bool valid() const noexcept
Definition strong_id.hpp:31
constexpr bool valid() const noexcept
Definition time.hpp:55