Slick Sim 0.10.1
Exchange simulator that shadows real venues for risk-free strategy testing
Loading...
Searching...
No Matches
control_messages.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4
5// wingdi.h defines ERROR, which would turn FeedState::ERROR into a number wherever
6// windows.h is included first, as slick-socket does in every gateway.
7#ifdef ERROR
8#undef ERROR
9#endif
10
11namespace slick::sim {
12
14enum class FeedState : uint8_t {
15 IDLE = 0,
16 LOADING = 1,
17 SYNCING = 2,
18 READY = 3,
21 ERROR = 6,
22};
23
24[[nodiscard]] constexpr const char *to_string(FeedState state) noexcept {
25 switch (state) {
26 case FeedState::IDLE: return "IDLE";
27 case FeedState::LOADING: return "LOADING";
28 case FeedState::SYNCING: return "SYNCING";
29 case FeedState::READY: return "READY";
30 case FeedState::REPLAYING: return "REPLAYING";
31 case FeedState::FINISHED: return "FINISHED";
32 case FeedState::ERROR: return "ERROR";
33 }
34 return "UNKNOWN";
35}
36
37enum class ControlMessageType : uint8_t {
39 START = 2,
42};
43
57
59[[nodiscard]] constexpr const char *to_string(CliCommandType command) noexcept {
60 switch (command) {
61 case CliCommandType::LIST_TARGETS: return "targets";
62 case CliCommandType::SET_LOG_LEVEL: return "log_level";
63 case CliCommandType::SHUTDOWN: return "shutdown";
64 case CliCommandType::REJECT_LOGON: return "reject_logon";
65 case CliCommandType::REJECT_NEW_ORDERS: return "reject_new_orders";
66 case CliCommandType::LIST_REJECTS: return "rejects";
67 case CliCommandType::START_REPLAY: return "replay";
68 case CliCommandType::PCAP_STATUS: return "status";
69 case CliCommandType::LIST_FEEDS: return "feeds";
70 case CliCommandType::GET_VERSION: return "version";
71 }
72 return "unknown";
73}
74
75enum class CliStatus : uint8_t {
76 OK = 0,
77 FAILED = 1,
78};
79
80#pragma pack(push, 1)
81
89
94 uint8_t venue;
96 char feed[32];
100 uint64_t begin_ns;
101 uint64_t end_ns;
102 uint64_t current_ns;
104 double speed;
106 char message[96];
107};
108
114
125
134
135#pragma pack(pop)
136
137static_assert(sizeof(ControlHeader) == 3);
138static_assert(sizeof(CliRequestMessage) == 105);
139static_assert(sizeof(CliReplyMessage) == 8);
140
141} // namespace slick::sim
CliCommandType
What a CLI request asks for. The values are on the wire: append, never renumber.
@ REJECT_LOGON
A venue. flag 1 refuses the logons of ID arg from now on, 0 stops.
@ START_REPLAY
pcap. Starts each feed's replay, as a control-channel START does.
@ GET_VERSION
Any target. The CLI server answers with slick-sim's version.
@ LIST_REJECTS
A venue. The IDs both of the above apply to.
@ REJECT_NEW_ORDERS
A venue. flag 1 rejects every new order of ID arg, 0 stops.
@ SET_LOG_LEVEL
sim. arg is the level; empty reports the current one.
@ LIST_TARGETS
Any target. The CLI server answers with every target it routes to.
@ PCAP_STATUS
pcap. Each feed's state, progress and window.
@ SHUTDOWN
sim. Stops the simulator.
@ LIST_FEEDS
Any target. The CLI server answers with every enabled market-data feed.
FeedState
Where a pcap replay feed is. The values are on the wire: append, never renumber.
@ READY
The book is built and held. Replay starts when a client sends START.
@ FINISHED
The window is replayed out.
@ REPLAYING
Publishing the capture.
@ ERROR
The feed failed; message says why.
@ SYNCING
Building the book from the snapshot and incremental captures. Nothing is published.
@ LOADING
Opening the capture files and reading up to the window's begin.
constexpr const char * to_string(FeedState state) noexcept
@ CLI_REQUEST
Client to sim, on the CLI port: CliRequestMessage.
@ START
Client to sim: start the replay.
@ CLI_REPLY
Sim to client, on the CLI port: CliReplyMessage.
The answer to a CliRequestMessage.
CliStatus status
OK only when every endpoint the command reached said OK.
One command to the simulator, on the CLI port.
char arg[64]
The ID or level. NUL-padded.
uint8_t flag
1 on, 0 off, for the commands that toggle.
char target[32]
sim, a venue (cme), an instance (cme/<segment>). NUL-padded.
uint32_t request_id
The client's own, echoed in the reply.
Every control message starts with this.
The replay feed's state.
char feed[32]
The feed's name, as configured.
char message[96]
Free text, NUL-terminated. The reason, in ERROR. Cut to fit; CLI status reports more of it.
uint16_t progress_permille
0-1000 through the window, by capture time.
double speed
The configured replay speed; 0 is unpaced.
uint64_t begin_ns
The configured window and the capture time reached, nanoseconds since the epoch.
uint8_t venue
common/types.hpp Venue.
Starts the replay of every loaded instrument.