1212#include < iomanip>
1313#include < memory>
1414#include < string>
15+ #include < string_view>
1516#include < vector>
1617
18+ #include " MessageHandlingMode.h"
1719#include " spdlog/spdlog.h"
1820
1921namespace Binance {
2022
2123// PRIVATE
2224
23- // / Binance Message Handling Mode
24- // / Controls how the matching engine processes your messages
25- // / [More
26- // / info](https://developers.binance.com/docs/binance-spot-api-docs/fix-api#on-message-processing-order)
27- enum class MessageHandlingMode : uint8_t {
28- // / UNORDERED(1) - Messages from the client are allowed to be sent to the
29- // / matching engine in any order
30- Unordered = 1 ,
31- // / SEQUENTIAL(2) - Messages from the client are always sent to the matching
32- // / engine in MsgSeqNum (34) order
33- Sequential = 2
34- };
35- std::string toString (const MessageHandlingMode m) {
36- switch (m) {
37- case MessageHandlingMode::Unordered:
38- return " 1" ;
39- case MessageHandlingMode::Sequential:
40- return " 2" ;
41- default :
42- return " Unknown" ;
43- }
44- }
45-
4625// better FIX message logging
4726std::string replaceSoh (const std::string &input) {
4827 std::string output = input;
@@ -70,7 +49,7 @@ void FixApp::toAdmin(FIX::Message &msg, const FIX::SessionID &sessionId) {
7049 sessionId.toString (), msgType.getString (),
7150 replaceSoh (msg.toString ())));
7251
73- if (msgType == FIX::MsgType_Logon) {
52+ if (msgType. getString () == static_cast < const char *>( FIX::MsgType_Logon) ) {
7453 spdlog::info (std::format (" authenticating" ));
7554
7655 // collect required fields
@@ -91,7 +70,8 @@ void FixApp::toAdmin(FIX::Message &msg, const FIX::SessionID &sessionId) {
9170 msg.setField (FIX::Username (auth_->getApiKey ()));
9271 msg.setField (FIX::RawData (signature));
9372 msg.setField (FIX::RawDataLength (static_cast <FIX::LENGTH>(signature.size ())));
94- msg.setField (FIX::StringField (25035 , toString (MessageHandlingMode::Sequential)));
73+ msg.setField (FIX::StringField (toInt (MessageHandlingMode::FIELD_ID),
74+ toString (MessageHandlingMode::Sequential)));
9575 }
9676};
9777void FixApp::toApp (FIX::Message &msg, const FIX::SessionID &sessionId) noexcept (false ) {
0 commit comments