FastMM documentation
FastMM C++ API 0.6.0
Public headers, tier 1 and tier 2
Loading...
Searching...
No Matches
error_action.hpp
Go to the documentation of this file.
1#pragma once
2// Venue error classification shared by every connector's error map: the engine-facing
3// RejectReason plus what the connector itself must do (cool down, resync the clock,
4// reconcile, stop).
6
7#include <cstdint>
8#include <string_view>
9
10namespace fastmm::venues {
11
12// What the connector does beyond reporting the reject to the engine.
13enum class VenueAction : std::uint8_t {
14 None = 0,
15 Backoff = 1, // transient venue-side failure: retry later
16 RateLimit = 2, // enter RateLimiter cooldown
17 ResyncClock = 3, // timestamp outside the window: fetch server time, recompute offset
18 Reconcile = 4, // unknown order / status unknown: request open orders
19 DisableInstrument = 5, // precision/filter failure: config is wrong for this symbol
20 HardStop = 6, // IP ban: stop REST
21 Fatal = 7, // bad key/signature/permissions: cannot continue
22};
23[[nodiscard]] constexpr std::string_view to_string(VenueAction a) noexcept {
24 switch (a) {
26 return "None";
28 return "Backoff";
30 return "RateLimit";
32 return "ResyncClock";
34 return "Reconcile";
36 return "DisableInstrument";
38 return "HardStop";
40 return "Fatal";
41 }
42 return "?";
43}
44
45struct ErrorMapping {
48 bool known = false; // false: code not in the table (still mapped to VenueReject)
49};
51// Case-insensitive substring search (venue error messages vary in case).
52[[nodiscard]] constexpr bool contains_ci(std::string_view hay, std::string_view needle) noexcept {
53 if (needle.size() > hay.size()) return false;
54 for (std::size_t i = 0; i + needle.size() <= hay.size(); ++i) {
55 bool ok = true;
56 for (std::size_t j = 0; j < needle.size(); ++j) {
57 char a = hay[i + j];
58 char b = needle[j];
59 if (a >= 'A' && a <= 'Z') a = static_cast<char>(a + 32);
60 if (b >= 'A' && b <= 'Z') b = static_cast<char>(b + 32);
61 if (a != b) {
62 ok = false;
63 break;
64 }
65 }
66 if (ok) return true;
67 }
68 return false;
69}
70
71} // namespace fastmm::venues
All engine enumerations.
Definition venue.hpp:38
constexpr std::string_view to_string(ChannelState s) noexcept
Definition venue.hpp:51
@ None
not a multicast venue
constexpr bool contains_ci(std::string_view hay, std::string_view needle) noexcept
Case-insensitive substring search (venue error messages vary in case).
Definition error_action.hpp:54
VenueAction
What the connector does beyond reporting the reject to the engine.
Definition error_action.hpp:15
@ DisableInstrument
precision/filter failure: config is wrong for this symbol
@ RateLimit
enter RateLimiter cooldown
@ Backoff
transient venue-side failure: retry later
@ Fatal
bad key/signature/permissions: cannot continue
@ HardStop
IP ban: stop REST.
@ ResyncClock
timestamp outside the window: fetch server time, recompute offset
@ Reconcile
unknown order / status unknown: request open orders
RejectReason
Ordered exactly like RiskEngine::check_new evaluates them (5.7), followed by OMS / transport / venue ...
Definition enums.hpp:123
@ VenueReject
Venue-originated.
VenueAction action
Definition error_action.hpp:49
bool known
false: code not in the table (still mapped to VenueReject)
Definition error_action.hpp:50
RejectReason reason
Definition error_action.hpp:48