Slick Sim 0.10.1
Exchange simulator that shadows real venues for risk-free strategy testing
Loading...
Searching...
No Matches
market_data.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <common/types.hpp>
4#include <common/order.hpp>
5#include <array>
6#include <cstdint>
7
8namespace slick::sim {
9
10// Everything below is byte-packed: these structs are the md_queue's on-the-wire
11// layout, and MDLevel's 41 bytes are read back out of a flat frame. The cost is
12// that only the first element of a level array is naturally aligned - take
13// members *by value*, never bind a reference or pointer to one. `const T&`
14// promises an alignment a packed member does not have, so binding one is UB and
15// the UBSan job fails on it (json's converting constructor and
16// vector::emplace_back both bind, which is how it slipped in once already).
17#pragma pack(push, 1)
19
35
36enum UpdateFlags : uint8_t {
37 F_NONE = 0,
39 F_END_EVENT = 1 << 1,
44 F_NOT_IN_BOOK = 1 << 2,
45};
46
52
64
68 uint8_t update_index[2];
69};
70
72 uint64_t event_time;
75};
76
89
98 uint32_t num_orders;
100};
101
108
110#pragma pack(pop)
111
123
124#pragma pack(push, 1)
126
132
133inline constexpr std::string_view to_string(MDSubscriptionRejectReason reason) {
134 switch (reason) {
136 return "NONE";
138 return "UNKNOWN_CONTRACT";
140 return "MARKET_CLOSED";
141 }
142 return "UNKNOWN_REJECT_REASON";
143}
144
150
152 uint32_t num_bid;
153 uint32_t num_ask;
155};
156
166
168 uint32_t num_trades;
170};
171
189
191#pragma pack(pop)
192
193} // end namespace slick::sim
A null-terminated character buffer of fixed capacity, stored inline.
@ F_NOT_IN_BOOK
On an MDTrade: this print was never applied to the order book.
utils::fixed_string< sizeof(MarketDataUpdate::symbol)> symbol_name_t
An instrument name at its wire width.
constexpr const char * to_string(FeedState state) noexcept
@ TRADE_SUMMARY
One executed trade.
@ TRADE
Reserved.
int_fast64_t qty_t
Definition types.hpp:22
int_fast64_t price_t
Definition types.hpp:21
MDUpdateAction update_action
Every order-book change one request (or feed event) produced, in book order.
MDUpdateAction update_action
NEW when the order entered the book, DELETE when it left it (qty is then 0), CHANGE for anything in b...
MDSubscriptionRejectReason reject_reason
Payload of a SUB_RESPONSE for a venue's trade channel.
uint32_t num_update
trades it does not - deliver as a normal update
MDTrade trades[0]
The snapshot block, then the update block, each contiguous and each chronological within itself.
uint32_t num_snapshot
trades the subscriber's book snapshot reflects
#define SLICK_SIM_ZERO_SIZE_ARRAY_BEGIN
Definition types.hpp:15
#define SLICK_SIM_ZERO_SIZE_ARRAY_END
Definition types.hpp:16