Add vcpkg submodule to update fmt to v10 (build still broken)

This commit is contained in:
John Colvin committed 2023-12-23 13:23:29 -05:00
1 parent a84f29ba38
commit 822aa051d8
69 files changed
+599 -189

No files matched your search

+3
View File
@@ -7,3 +7,6 @@
[submodule "docker/windows"]
path = docker/windows
url = git@bitbucket.org:bluetradesys/windows_docker.git
[submodule "vcpkg"]
path = vcpkg
url = https://github.com/microsoft/vcpkg.git
+2 -4
View File
@@ -109,13 +109,11 @@ target_include_directories(
${CMAKE_BINARY_DIR}/src)
if(WIN32)
find_package(fmt CONFIG REQUIRED)
target_link_libraries(
libspark
libcurl
debug
fmtd
optimized
fmt
fmt::fmt-header-only
libtbb
libboost_system
libboost_thread
+31
View File
@@ -0,0 +1,31 @@
#pragma once
#include "lib/api/services/OrderService.pb.h"
#include "lib/core/EnumMacros.h"
#include "lib/core/FMT_IMPL.h"
#include "lib/io/JsonReader.h"
#include "lib/logging/logging.h"
#include <nlohmann/json.hpp>
namespace bts::api::orderman {
PB_ENUM_FROM_JSON(OrderStatus)
PB_ENUM_TO_JSON(OrderStatus)
PB_ENUM_FROM_JSON(TriggerPriceType)
PB_ENUM_TO_JSON(TriggerPriceType)
} // namespace bts::api::orderman
FMT_IMPL(
bts::api::orderman::OrderStatus,
s,
"{}",
bts::api::orderman::OrderStatus_Name(s));
FMT_IMPL(
bts::api::orderman::TriggerPriceType,
t,
"{}",
bts::api::orderman::TriggerPriceType_Name(t));
+28
View File
@@ -0,0 +1,28 @@
#pragma once
#include <fmt/core.h>
#include <fmt/format.h>
#include <range/v3/view.hpp>
#include <vector>
#define FMT(template_str, ...) fmt::format(template_str, __VA_ARGS__)
#define FMT_JOIN(range, delimiter) \
fmt::to_string(fmt::join(range.begin(), range.end(), delimiter))
namespace bts {
template <class Range>
std::string _fmt_join(Range range, const char *delimiter) {
return fmt::join(range.begin(), range.end(), delimiter);
}
template <class Range, class Op>
std::string _fmt_join_fn(Range range, const char *delimiter, Op op) {
return fmt::to_string(
fmt::join(range | ranges::views::transform(op), delimiter));
}
} // namespace bts
#define FMT_JOIN_FN(range, delimiter, fn) \
bts::_fmt_join_fn(range, delimiter, fn)
+65
View File
@@ -0,0 +1,65 @@
#pragma once
#include <fmt/format.h>
#define FMT_IMPL(Type, var_name, ...) \
template <> \
struct fmt::formatter<Type> { \
constexpr auto parse(fmt::format_parse_context &ctx) \
-> decltype(ctx.end()) { \
return ctx.end(); \
} \
\
template <typename FormatContext> \
auto format(const Type &var_name, FormatContext &ctx) const \
-> decltype(ctx.out()) { \
return fmt::format_to(ctx.out(), __VA_ARGS__); \
} \
}
#define FMT_IMPL_T(Type, var_name, ...) \
struct fmt::formatter<Type> { \
constexpr auto parse(fmt::format_parse_context &ctx) \
-> decltype(ctx.end()) { \
return ctx.end(); \
} \
\
template <typename FormatContext> \
auto format(const Type &var_name, FormatContext &ctx) const \
-> decltype(ctx.out()) { \
return fmt::format_to(ctx.out(), __VA_ARGS__); \
} \
}
#define FMT_IMPL_OSTREAM(T) \
template <> \
struct fmt::formatter<T> { \
constexpr auto parse(fmt::format_parse_context &ctx) \
-> decltype(ctx.end()) { \
return ctx.end(); \
} \
\
template <typename FormatContext> \
auto format(const T &t, FormatContext &ctx) const \
-> decltype(ctx.out()) { \
std::stringstream ss; \
ss << t; \
return fmt::format_to(ctx.out(), "{}", ss.str()); \
} \
}
#define FMT_IMPL_OSTREAM_T(T, ...) \
struct fmt::formatter<T<__VA_ARGS__>> { \
constexpr auto parse(fmt::format_parse_context &ctx) \
-> decltype(ctx.end()) { \
return ctx.end(); \
} \
\
template <typename FormatContext> \
auto format(const T<__VA_ARGS__> &t, FormatContext &ctx) const \
-> decltype(ctx.out()) { \
std::stringstream ss; \
ss << t; \
return fmt::format_to(ctx.out(), "{}", ss.str()); \
} \
}
+6
View File
@@ -1,10 +1,14 @@
#pragma once
#include "Side.h"
#include "lib/core/FMT_IMPL.h"
#include "lib/utils/bts_assert.h"
#include <cmath>
#include <cstdint>
#include <limits>
#include <ostream>
#include <string>
#if bts_assert_msg
#define __ASSERT_MSG(EXP, msg) bts_assert_msg(EXP, msg)
@@ -490,6 +494,8 @@ inline std::ostream &operator<<(std::ostream &out, Price p) noexcept {
} // namespace bts::domain
FMT_IMPL(bts::domain::Price, p, "{}", p.to_double());
namespace std { // NOLINT
constexpr size_t hash<bts::domain::Price>::operator()(
+6
View File
@@ -1,5 +1,9 @@
#pragma once
#include "lib/core/FMT_IMPL.h"
#include "lib/logging/logging.h"
#include "lib/utils/ValueWrapper.h"
#include <cstdint>
namespace bts::domain {
@@ -110,3 +114,5 @@ QTY_UINT32_BIN_REF_OP(%=)
#undef QTY_UINT32_BIN_REF_OP
} // namespace bts::domain
FMT_IMPL(bts::domain::Quantity, q, "{}", *q);
+4
View File
@@ -1,4 +1,6 @@
#pragma once
#include "lib/core/FMT_IMPL.h"
#include "lib/utils/ValueWrapper.h"
#include <cstdint>
@@ -7,3 +9,5 @@ namespace bts::domain {
using SecurityID = utils::ValueWrapper<struct SecuirtyIDTag, std::uint64_t>;
} // namespace bts::domain
FMT_IMPL(bts::domain::SecurityID, id, "{}", *id);
+7 -4
View File
@@ -1,12 +1,15 @@
#pragma once
#include "lib/utils/datetime.h"
#include <cmath>
#include <memory>
#include "lib/core/FMT_IMPL.h"
#include "lib/domain_model/Security.pb.h"
#include "lib/domain_model/Side.h"
#include "lib/domain_model/Venue.h"
#include "lib/domain_model/common.h"
#include "lib/utils/bts_assert.h"
#include "lib/utils/datetime.h"
#include <cmath>
#include <memory>
namespace boost {
namespace gregorian {
+18
View File
@@ -0,0 +1,18 @@
#pragma once
#include "lib/core/EnumMacros.h"
#include "lib/core/FMT_IMPL.h"
#include "lib/domain_model/Security.pb.h"
#include "lib/io/JsonReader.h"
#include "lib/logging/logging.h"
#include <nlohmann/json.hpp>
namespace bts::api {
PB_ENUM_FROM_JSON(Side)
PB_ENUM_TO_JSON(Side)
} // namespace bts::api
FMT_IMPL(bts::api::Side, s, "{}", bts::api::Side_Name(s));
+18
View File
@@ -0,0 +1,18 @@
#pragma once
#include "lib/core/EnumMacros.h"
#include "lib/core/FMT_IMPL.h"
#include "lib/domain_model/Security.pb.h"
#include "lib/io/JsonReader.h"
#include "lib/logging/logging.h"
#include <nlohmann/json.hpp>
namespace bts::api {
PB_ENUM_FROM_JSON(Venue)
PB_ENUM_TO_JSON(Venue)
} // namespace bts::api
FMT_IMPL(bts::api::Venue, v, "{}", bts::api::Venue_Name(v));
+4
View File
@@ -6,6 +6,7 @@
#include <cstdint>
#include <string>
#include "lib/core/FMT_IMPL.h"
#include "lib/domain_model/SecurityKey.h"
#include "lib/utils/ValueWrapper.h"
@@ -102,3 +103,6 @@ using Price = utils::ValueWrapper<struct OrderPriceTag, double>;
using Quantity = CQuantity;
using UserLogin = utils::ValueWrapper<struct UserLoginTag, std::string>;
} // namespace bts
FMT_IMPL(bts::Price, p, "{}", p.value());
FMT_IMPL(bts::Quantity, q, "{}", q.value());
@@ -89,7 +89,7 @@ void WebsocketSSLClientInternal::_handle_error(
str << "Error_code:" << error_code << " Text:" << err_msg;
LOG(OrderMan, Info,
"WebsocketSSLClientInternal::_handle_error error_code:{} err_msg:{}",
error_code, err_msg);
error_code.message(), err_msg);
_listener->on_error({err_type, str.str()});
close_connection();
}
@@ -131,7 +131,8 @@ void WebsocketSSLClientInternal::_on_connect(
return;
}
LOG(OrderMan, Info,
"WebsocketSSLClientInternal::_on_connect successfull ep:{}", ep);
"WebsocketSSLClientInternal::_on_connect successfull ep: {}:{}",
ep.address().to_string(), ep.port());
ip_port = _conf.ip + ':' + std::to_string(ep.port());
// Set a timeout on the operation
boost::beast::get_lowest_layer(_ws).expires_after(std::chrono::seconds(30));
+7 -1
View File
@@ -4,6 +4,7 @@
#include <fmt/ostream.h>
#include <iostream>
#include <type_traits>
#include <vector>
namespace bts {
namespace log {
@@ -12,7 +13,12 @@ template <class Tuple, std::size_t... Is>
std::string format_tuple(
const char *msg_template, Tuple const &t, std::index_sequence<Is...>) {
try {
return fmt::format(msg_template, std::get<Is>(t)...);
using ctx = fmt::format_context;
std::vector<fmt::basic_format_arg<ctx>> fmt_args;
(fmt_args.push_back(fmt::detail::make_arg<ctx>(std::get<Is>(t))), ...);
return fmt::vformat(
msg_template,
fmt::basic_format_args<ctx>(fmt_args.data(), fmt_args.size()));
} catch (fmt::format_error const &e) {
return fmt::format(
"Bad log message template: '{}' Error: '{}'", msg_template, e.what());
+6 -2
View File
@@ -1,8 +1,11 @@
#include "catch/catch.hpp"
#include "lib/config/config.h"
#include "lib/config/protos/logging.pb.h"
#include "lib/utils/bts_chrono.h"
#include "lib/logging/logging.h"
#include "lib/utils/bts_chrono.h"
#include <fmt/format.h>
#include <fmt/chrono.h>
namespace bts {
int logging_tests;
@@ -22,7 +25,8 @@ TEST_CASE("Logging Tests", "[logging] [benchmark]") {
SECTION("timestamp_interpolation") {
auto start = bts::Timer::now();
for (int i = 0; i < sz; i++)
LOG(Gen, Info, "Hello World. It is now: {0}", Timer::now());
LOG(Gen, Info, "Hello World. It is now: {}",
Timer::now().time_since_epoch());
auto stop = Timer::now();
LOG(Testing, Info, "Logging: ns/msg for log with timestamps: {} tt: {} ",
bts::ns_diff(stop, start) / sz, bts::ns_diff(stop, start));
+3
View File
@@ -2,6 +2,7 @@
#include "ExchangeOrderKey.h"
#include "IntPrice.h"
#include "MDProducerHandle.h"
#include "lib/core/FMT_IMPL.h"
#include "lib/domain_model/Security.h"
#include "lib/domain_model/SecurityKey.h"
#include "lib/utils/TimeStamp.h"
@@ -169,3 +170,5 @@ class MBOProcessor {
namespace std {
std::ostream &operator<<(std::ostream &os, const bts::md::inc::Update &);
}
FMT_IMPL_OSTREAM(bts::md::inc::Update);
+6
View File
@@ -1,5 +1,9 @@
#pragma once
#include "lib/core/FMT_IMPL.h"
#include <ostream>
#include <sstream>
#include <string>
namespace bts::md {
@@ -30,3 +34,5 @@ constexpr const char *MarketDataError::type_name() const noexcept {
}
} // namespace bts::md
FMT_IMPL_OSTREAM(bts::md::MarketDataError);
+6
View File
@@ -1,4 +1,7 @@
#pragma once
#ifndef _WIN32
#include "lib/core/FMT_IMPL.h"
#include "lib/core/ValueWrapper.h"
namespace bts::md {
@@ -7,3 +10,6 @@ using MarketDataListenerID =
core::ValueWrapper<struct MarketDataListenedIDTag, std::uint32_t>;
} // namespace bts::md
FMT_IMPL(bts::md::MarketDataListenerID, id, "{}", *id);
#endif
+3
View File
@@ -1,6 +1,7 @@
#pragma once
#include "../common.h"
#include "lib/core/FMT_IMPL.h"
#include "lib/utils/ValueWrapper.h"
#include "lib/utils/bts_array_size.h"
#include "lib/utils/bts_assert.h"
@@ -284,3 +285,5 @@ void with_security_like(const api::Security &security, C cb) {
} // namespace md
} // namespace bts
FMT_IMPL(bts::md::SecurityKey, k, "{}", *k);
+1 -1
View File
@@ -152,7 +152,7 @@ void SyntheticSecurityService::create_synthetic(
} else {
LOG(Api, Info,
"Failed to un-delete security {}. Error {}", id,
result.error());
UpdateResult_Error_Name(result.error()));
send_reply(
reply,
CreateResult::ERROR_SECURITY_ALREADY_EXISTS, id);
+1 -1
View File
@@ -58,7 +58,7 @@ OnixsTemplLicense onixs_create_temporary_license() {
LOG(md, Warn,
"Licensing error. Failed to write to '{}'. Please ensure it is "
"writeable.",
linfo.path);
linfo.path.string());
}
}
return linfo;
+2 -3
View File
@@ -369,14 +369,13 @@ void Broker::notify(
if (srec->is_local() || srec->sub_id == ex_subid) {
LOG(Latency, Diag, "Started handling event {} on broker {}",
log::CharPtrWrapper{srec->topic_str}, me->my_id.value());
std::string{srec->topic_str}, me->my_id);
auto start = Timer::now();
srec->notify(payload);
auto stop = Timer::now();
LOG(Latency, Diag, "Finished handling event {} on broker {}. Time: {}us",
log::CharPtrWrapper{srec->topic_str}, me->my_id.value(),
us_diff(stop, start));
std::string{srec->topic_str}, me->my_id, us_diff(stop, start));
}
}
+4
View File
@@ -1,5 +1,6 @@
#pragma once
#include "lib/core/FMT_IMPL.h"
#include "lib/mercury/common/FatWrapper.h"
#include "lib/utils/ValueWrapper.h"
#include <array>
@@ -30,3 +31,6 @@ using TimeStampStr = utils::ValueWrapper<
} // namespace mercury
} // namespace bts
FMT_IMPL(bts::mercury::BrokerID, id, "{}", *id);
FMT_IMPL(bts::mercury::LocalSubID, id, "{}", *id);
+12
View File
@@ -1,8 +1,10 @@
#pragma once
#include "lib/core/FMT_IMPL.h"
#include "lib/mercury/events/Event.h"
#include "lib/mercury/topics/ITopic.h"
#include "lib/utils/type_name.h"
#include <fmt/format.h>
#include <memory>
@@ -52,3 +54,13 @@ template <class EV> class Topic<EV, false> : public ITopic {
} // namespace mercury
} // namespace bts
#define _TOPIC(...) bts::mercury::Topic<__VA_ARGS__>
template <class EV>
FMT_IMPL_T(_TOPIC(EV, true), t, "{}", t.to_str());
template <class EV>
FMT_IMPL_T(_TOPIC(EV, false), t, "{}", t.to_str());
#undef _TOPIC
+6
View File
@@ -1,7 +1,11 @@
#pragma once
#include "lib/api/services/OrderService.pb.h"
#include "lib/core/FMT_IMPL.h"
#include "lib/orderman/orderman_utils/orderman_common.h"
#include <sstream>
namespace bts::orderman {
struct CancelOrderMsg {
@@ -14,3 +18,5 @@ struct CancelOrderMsg {
};
} // namespace bts::orderman
FMT_IMPL_OSTREAM(bts::orderman::CancelOrderMsg);
+6
View File
@@ -1,7 +1,11 @@
#pragma once
#include "lib/core/FMT_IMPL.h"
#include "lib/orderman/CreateOrderMsg.h"
#include "lib/orderman/orderman_utils/orderman_common.h"
#include <sstream>
namespace bts::orderman {
struct CancelReplaceOrderMsg {
@@ -10,3 +14,5 @@ struct CancelReplaceOrderMsg {
};
} // namespace bts::orderman
FMT_IMPL_OSTREAM(bts::orderman::CancelReplaceOrderMsg);
+8
View File
@@ -1,6 +1,12 @@
#pragma once
#include "lib/core/FMT_IMPL.h"
#include "lib/domain_model/Security.h"
#include "lib/domain_model/common.h"
#include "lib/orderman/orderman_utils/orderman_common.h"
#include <sstream>
namespace bts::orderman {
struct CreateOrderMsg {
@@ -18,3 +24,5 @@ struct CreateOrderMsg {
};
} // namespace bts::orderman
FMT_IMPL_OSTREAM(bts::orderman::CreateOrderMsg);
+32
View File
@@ -1,9 +1,12 @@
#pragma once
#include "lib/domain_model/Security.pb.h"
#include "lib/orderman/CancelOrderMsg.h"
#include "lib/orderman/CancelReplaceOrderMsg.h"
#include "lib/orderman/CreateOrderMsg.h"
#include "lib/orderman/RFQMsg.h"
#include "lib/utils/overloaded.h"
#include <variant>
namespace bts::orderman {
@@ -32,3 +35,32 @@ inline std::ostream &operator<<(std::ostream &out, OrderMsg const &msg) {
return out;
}
} // namespace bts::orderman
template <>
struct fmt ::formatter<bts ::orderman ::OrderMsg> {
constexpr auto parse(fmt ::format_parse_context &ctx)
-> decltype(ctx.end()) {
return ctx.end();
}
template <typename FormatContext>
auto format(const bts ::orderman ::OrderMsg &m, FormatContext &ctx) const
-> decltype(ctx.out()) {
std::visit(
bts::overloaded{
[&ctx](const bts::orderman::CreateOrderMsg &m) {
fmt::format_to(ctx.out(), "{}", m);
},
[&ctx](const bts::orderman::CancelReplaceOrderMsg &m) {
fmt::format_to(ctx.out(), "{}", m);
},
[&ctx](const bts::orderman::CancelOrderMsg &m) {
fmt::format_to(ctx.out(), "{}", m);
},
[&ctx](const bts::orderman::RFQMsg &r) {
fmt::format_to(ctx.out(), "{}", r);
},
[]() {}},
m);
return fmt::format_to(ctx.out(), "{}", m);
}
};
+5
View File
@@ -1,8 +1,11 @@
#pragma once
#include "lib/api/services/OrderService.pb.h"
#include "lib/core/FMT_IMPL.h"
#include "lib/domain_model/Security.pb.h"
#include "lib/orderman/events/RFQEvent.h"
#include "lib/orderman/orderman_utils/orderman_common.h"
#include <optional>
namespace bts::orderman {
@@ -13,3 +16,5 @@ struct RFQMsg {
};
} // namespace bts::orderman
FMT_IMPL(bts::orderman::RFQMsg, m, "{}", m.rfq.DebugString());
@@ -642,7 +642,7 @@ void OrderManager::after_event() {
LOG(Latency, Info,
"entry_type:after_event channel:{} sn:{} app_arrival:{} now:{} "
"delta:{}",
log::CharPtrWrapper{corid.channel}, corid.sn,
std::string{corid.channel}, corid.sn,
corid.app_arrival.to_uint64(), now.to_uint64(),
(now - corid.app_arrival).nanoseconds());
osd->gw->send_msgs(queued_ops, osd->current_trace);
+3
View File
@@ -1,6 +1,7 @@
#pragma once
#include "lib/api/services/OrderService.pb.h"
#include "lib/core/FMT_IMPL.h"
#include "lib/domain_model/Security.pb.h"
#include "lib/mercury/events/Event.h"
#include "lib/tracing/PerfLog.h"
@@ -20,3 +21,5 @@ class RFQEvent : public mercury::Event<RFQEvent> {
} // namespace orderman
} // namespace bts
FMT_IMPL(bts::orderman::RFQEvent, e, "{}", e.rfq.DebugString());
@@ -4,6 +4,7 @@
#include "lib/domain_model/Security.h"
#include "lib/jetfix/common/OutFIX.h"
#include "lib/jetfix/store/session_name.h"
#include "lib/logging/logging.h"
#include "lib/orderman/events/NewSecuritiesEvent.h"
#include "lib/orderman/gateways/GLBXExecutionGateway.h"
#include "lib/orderman/ilink3/IL3GW.h"
@@ -24,14 +25,6 @@ struct OrderStats {
size_t n_cxls = 0;
};
enum class GLBXiLink3ExecutionGateway::State {
WAITING_FOR_SECURITIES,
PAUSED,
CONNECTING,
READY
};
struct GLBXiLink3ExecutionGateway::PImpl {
PImpl(
config::JetFIX::Connection const &cfg,
@@ -92,7 +85,7 @@ void GLBXiLink3ExecutionGateway::start() {
void GLBXiLink3ExecutionGateway::dispatch_incoming_fix_messages() {
if (me->started) {
switch (me->state) {
switch (me->state.value) {
case State::WAITING_FOR_SECURITIES:
break;
case State::PAUSED:
@@ -181,9 +174,8 @@ void GLBXiLink3ExecutionGateway::connect(jetfix::SessionName const &sn) {
me->gw->subscribe_state([this](auto gw_state) {
LOG(iLink3, Info, "Internal gateway state change in {}. State is now {}",
me->gw_name.value(),
log::CharPtrWrapper{ilink3::state_string(gw_state)});
switch (me->state) {
me->gw_name.value(), gw_state);
switch (me->state.value) {
case State::CONNECTING:
if (gw_state == ilink3::State::READY) {
transition(State::READY);
@@ -262,7 +254,7 @@ void GLBXiLink3ExecutionGateway::send_msgs(
auto cancel_replace_ptr = std::get_if<CancelReplaceOrderMsg>(&m);
if (cancel_replace_ptr) {
LOG(Latency, Info, "Cancel Replace. CorID:{}.{} Order:{}",
log::CharPtrWrapper{corid.channel}, corid.sn,
std::string{corid.channel}, corid.sn,
cancel_replace_ptr->exchange_order_id);
me->gw->send_cancel_replace(*cancel_replace_ptr, corid);
@@ -307,24 +299,9 @@ GLBXiLink3ExecutionGateway::on_exchange_open_orders() {
return me->on_exchange_open_orders;
}
log::CharPtrWrapper GLBXiLink3ExecutionGateway::state_name(State st) {
switch (st) {
case State::WAITING_FOR_SECURITIES:
return {"WAITING_FOR_SECURITIES"};
case State::PAUSED:
return {"PAUSED"};
case State::CONNECTING:
return {"CONNECTING"};
case State::READY:
return {"READY"};
}
bts_assert(false);
return {""};
}
void GLBXiLink3ExecutionGateway::transition(State new_state) {
LOG(iLink3, Info, "Transitioning {} from {} to {}", me->gw_name.value(),
state_name(me->state), state_name(new_state));
me->state, new_state);
me->state = new_state;
}
@@ -1,7 +1,7 @@
#pragma once
#include "IExecutionGateway.h"
#include "lib/logging/logging.h"
#include "lib/orderman/gateways/GLBXiLink3ExecutionGatewayState.h"
namespace bts {
namespace jetfix {
@@ -36,7 +36,7 @@ class GLBXiLink3ExecutionGateway : public IExecutionGateway {
OnExchangeOpenOrdersState &on_exchange_open_orders() override;
private:
enum class State;
using State = GLBXiLink3ExecutionGatewayState;
struct PImpl;
std::unique_ptr<PImpl> me;
@@ -44,7 +44,6 @@ class GLBXiLink3ExecutionGateway : public IExecutionGateway {
void on_time();
bool pause_in_effect() const;
bool max_failures_reached() const;
static log::CharPtrWrapper state_name(State);
void transition(State);
void pause();
@@ -0,0 +1,32 @@
#pragma once
#ifdef SPARK_ENABLE_CCAPI
#include "lib/core/EnumMacros.h"
#include "lib/core/FMT_IMPL.h"
#include <fmt/format.h>
#include <nlohmann/json.hpp>
#include <ostream>
#include <string>
namespace bts::orderman::ilink3 {
// clang-format off
#define FOR_EACH_GLBX_ILINK3_EXECUTION_GATEWAY_STATE(per_value) \
per_value(GLBXiLink3ExecutionGatewayState, WAITING_FOR_SECURITIES) \
per_value(GLBXiLink3ExecutionGatewayState, PAUSED) \
per_value(GLBXiLink3ExecutionGatewayState, CONNECTING) \
per_value(GLBXiLink3ExecutionGatewayState, READY)
// clang-format on
ENUM_CLASS_DEF(
GLBXiLink3ExecutionGatewayState,
FOR_EACH_GLBX_ILINK3_EXECUTION_GATEWAY_STATE)
#undef FOR_EACH_GLBX_ILINK3_EXECUTION_GATEWAY_STATE
} // namespace bts::orderman::ilink3
#endif
FMT_IMPL(
bts::orderman::ilink3::GLBXiLink3ExecutionGatewayState, s, "{}", s.name());
+9 -33
View File
@@ -33,7 +33,7 @@ namespace bts {
namespace orderman {
namespace ilink3 {
log::CharPtrWrapper wrap(const char *str) { return log::CharPtrWrapper{str}; }
using std::string;
IL3GW::IL3GW(
IL3Connection &con,
@@ -233,11 +233,9 @@ void IL3GW::send_order(
_current_corid = corid;
auto now = utils::TimeStamp::now();
LOG(Latency, Info,
"entry_type:send_order channel:{} sn:{} app_arrival:{} now:{} "
"delta:{}",
log::CharPtrWrapper{corid.channel}, corid.sn,
corid.app_arrival.to_uint64(), now.to_uint64(),
(now - corid.app_arrival).nanoseconds());
"entry_type:send_order channel:{} sn:{} app_arrival:{} now:{} delta:{}",
string{corid.channel}, corid.sn, corid.app_arrival.to_uint64(),
now.to_uint64(), (now - corid.app_arrival).nanoseconds());
bts_assert_d(create.routing_record);
bts_assert_d(create.security);
bts_assert_d(create.security->has_glbx());
@@ -386,31 +384,9 @@ void IL3GW::flush(bool publish) {
publish_session_update();
}
const char *state_string(State s) {
switch (s) {
case State::INIT:
return "INIT";
case State::CONNECTING:
return "CONNECTING";
case State::NEGOTIATING:
return "NEGOTIATING";
case State::ESTABLISHING:
return "ESTABLISHING";
case State::RETRANSMITTING:
return "RETRANSMITTING";
case State::READY:
return "READY";
case State::ERROR:
return "ERROR";
}
return "UNKNOWN";
}
log::CharPtrWrapper wstate_string(State s) { return wrap(state_string(s)); }
void IL3GW::set_state(State s) {
if (s != _x_state) {
LOG(iLink3, Info, "ILinkGW {}: {}->{}", _session.uuid,
wstate_string(_x_state), wstate_string(s));
LOG(iLink3, Info, "ILinkGW {}: {}->{}", _session.uuid, _x_state, s);
_x_state = s;
if (_on_state_change)
_on_state_change(s);
@@ -572,8 +548,8 @@ void IL3GW::handle(const iLinkBinary::Sequence506 &msg) {
void IL3GW::handle(const iLinkBinary::Terminate507 &msg) {
// https://www.cmegroup.com/confluence/display/EPICSANDBOX/Terminate
LOG(iLink3, Error, "Terminated by exchange. Code: {} Reason: {} Text: {}",
msg.errorCodes(), wrap(msg.reason()),
wrap(translate_terminate(msg.errorCodes())));
msg.errorCodes(), std::string{msg.reason()},
std::string{translate_terminate(msg.errorCodes())});
if (msg.errorCodes() == 11 || msg.errorCodes() == 10) {
// This indicates our sequence number is too low. We will jump
// forward one at a time. That should eventually fix it.
@@ -607,7 +583,7 @@ void IL3GW::handle(
}
void IL3GW::handle(const iLinkBinary::BusinessReject521 &msg) {
LOG(iLink3, Error, "Business Reject: {} '{}'.", msg.businessRejectReason(),
wrap(translate_business_reject_reason(msg.businessRejectReason())));
string{translate_business_reject_reason(msg.businessRejectReason())});
handle_common(msg);
// A business reject can de-sync the sequence number because it rejects
// the sequence number of the rejected message. Send a sequence message
@@ -619,7 +595,7 @@ void IL3GW::handle(const iLinkBinary::ExecutionReportNew522 &msg) {
handle_exe_report(msg);
}
void IL3GW::handle(const iLinkBinary::ExecutionReportReject523 &msg) {
LOG(iLink3, Error, "Execution report reject: {}", wrap(msg.text()));
LOG(iLink3, Error, "Execution report reject: {}", string{msg.text()});
handle_exe_report(msg);
}
void IL3GW::handle(const iLinkBinary::ExecutionReportElimination524 &msg) {
+3 -10
View File
@@ -6,6 +6,7 @@
#include "TimeKeeper.h"
#include "generated/MessageHeader.h"
#include "lib/config/protos/jetfix.pb.h"
#include "lib/orderman/ilink3/IL3State.h"
#include "lib/orderman/ilink3/RawMsg.h"
#include "lib/orderman/gateways/IExecutionGateway.h"
#include "lib/orderman/orderman_utils/CancelReject.h"
@@ -42,16 +43,8 @@ struct Config {
raw_message_logger;
};
enum class State {
INIT,
CONNECTING,
NEGOTIATING,
ESTABLISHING,
RETRANSMITTING,
READY,
ERROR
};
const char *state_string(State s);
using State = IL3State;
typedef std::function<void(State)> OnStateChange;
typedef std::function<void(const ExecutionReport *)> OnExecutionReport;
typedef std::function<void(const Session &s)> OnSessionChange;
+1 -1
View File
@@ -130,7 +130,7 @@ struct IL3Reactor::Connection : public IL3Connection {
LOG(Latency, Info,
"entry_type:socket_write channel:{} sn:{} app_arrival:{} now:{} "
"delta:{}",
log::CharPtrWrapper{corid.channel}, corid.sn,
std::string{corid.channel}, corid.sn,
corid.app_arrival.to_uint64(), before_write.to_uint64(),
(before_write - corid.app_arrival).nanoseconds());
+32
View File
@@ -0,0 +1,32 @@
#pragma once
#ifdef SPARK_ENABLE_CCAPI
#include "lib/core/EnumMacros.h"
#include "lib/core/FMT_IMPL.h"
#include <fmt/format.h>
#include <nlohmann/json.hpp>
#include <ostream>
#include <string>
namespace bts::orderman::ilink3 {
// clang-format off
#define FOR_EACH_IL3_STATE(per_value) \
per_value(IL3State, INIT) \
per_value(IL3State, CONNECTING) \
per_value(IL3State, NEGOTIATING) \
per_value(IL3State, ESTABLISHING) \
per_value(IL3State, RETRANSMITTING) \
per_value(IL3State, READY) \
per_value(IL3State, ERROR)
// clang-format on
ENUM_CLASS_DEF(IL3State, FOR_EACH_IL3_STATE)
#undef FOR_EACH_IL3_STATE
} // namespace bts::orderman::ilink3
#endif
FMT_IMPL(bts::orderman::ilink3::IL3State, s, "{}", s.name());
@@ -8,6 +8,7 @@
#include <variant>
#include "lib/api/services/OrderService.pb.h"
#include "lib/core/FMT_IMPL.h"
#include "lib/domain_model/common.h"
#include "lib/utils/ValueWrapper.h"
#include "lib/utils/bts_assert.h"
@@ -289,3 +290,8 @@ inline void set_update_quantity(
} // namespace orderman
} // namespace bts
FMT_IMPL(bts::orderman::AccountID, id, "{}", *id);
FMT_IMPL(bts::orderman::ExchangeOrderID64, id, "{}", *id);
FMT_IMPL(bts::orderman::GatewayName, n, "{}", *n);
FMT_IMPL(bts::orderman::OrderKey, k, "{}", *k);
+8 -8
View File
@@ -27,6 +27,8 @@ namespace orderman {
using namespace api::orderman;
using std::string;
OrderStatus map_external_status(NativeOrderStatus);
bool use_ilink3(std::string const &for_session) {
@@ -458,9 +460,8 @@ OrderOpResult GLBXNativeOrder::on_activate(
LOG(Latency, Info,
"entry_type:on_activate_1 channel:{} sn:{} app_arrival:{} now:{} "
"delta:{}",
log::CharPtrWrapper{corid.channel}, corid.sn,
corid.app_arrival.to_uint64(), now.to_uint64(),
(now - corid.app_arrival).nanoseconds());
string{corid.channel}, corid.sn, corid.app_arrival.to_uint64(),
now.to_uint64(), (now - corid.app_arrival).nanoseconds());
result = _on_activate(Warn, Info, p, q, services);
if (result.ok()) {
@@ -468,9 +469,8 @@ OrderOpResult GLBXNativeOrder::on_activate(
LOG(Latency, Info,
"entry_type:on_activate_2 channel:{} sn:{} app_arrival:{} now:{} "
"delta:{}",
log::CharPtrWrapper{corid.channel}, corid.sn,
corid.app_arrival.to_uint64(), now.to_uint64(),
(now - corid.app_arrival).nanoseconds());
string{corid.channel}, corid.sn, corid.app_arrival.to_uint64(),
now.to_uint64(), (now - corid.app_arrival).nanoseconds());
me->encoder->send_create(*me->services, *me->session_services);
me->services->governor(*me->session_services).record_sent();
@@ -1264,8 +1264,8 @@ bool GLBXNativeOrder::terminal_state(api::orderman::OrderStatus status) const {
return false;
}
api::orderman::NativeOrderState &
GLBXNativeOrder::get_native_state(api::orderman::OrderState &st) {
api::orderman::NativeOrderState &GLBXNativeOrder::get_native_state(
api::orderman::OrderState &st) {
switch (st.custom_case()) {
case OrderState::kMarket:
return *st.mutable_market()->mutable_native_state();
+12 -11
View File
@@ -1,4 +1,5 @@
#include "TriggerOrder.h"
#include "lib/api/services/OrderService.h"
#include "lib/domain_model/Security.h"
#include "lib/logging/logging.h"
#include "lib/orderman/OrderBuilder.h"
@@ -62,7 +63,7 @@ void TriggerOrder::on_init_new(
const PreActivationOrderServices &pre_os) {
LOG(OrderMan, Info, "TriggerOrder::on_init_new key:{} state:{}", key(),
_state);
switch (_state) {
switch (_state.value) {
case State::START:
me->is_succ_inited = _on_init_new(order_def, pre_os);
break;
@@ -81,7 +82,7 @@ void TriggerOrder::on_init_recovered(
const PreActivationOrderServices &pre_os) {
LOG(OrderMan, Info, "TriggerOrder::on_init_recovered key:{} state:{}", key(),
_state);
switch (_state) {
switch (_state.value) {
case State::START:
me->is_succ_inited = _on_init_new(rec.def(), pre_os);
// get the state from what was recovered (we will only use
@@ -109,7 +110,7 @@ TriggerOrder::on_activate(Price price, Quantity qty, OrderServices &services) {
LOG(OrderMan, Info,
"TriggerOrder::on_activate key:{} state:{} price:{} qty:{}", key(),
_state, price, qty);
switch (_state) {
switch (_state.value) {
case State::START:
me->services = &services;
me->state.set_price(price.value());
@@ -150,7 +151,7 @@ OrderOpResult TriggerOrder::on_update(Price price, Quantity qty) {
LOG(OrderMan, Info,
"TriggerOrder::on_update key:{} state:{} price:{} qty:{}", key(), _state,
price, qty);
switch (_state) {
switch (_state.value) {
case State::START:
me->state.set_price(price.value());
me->state.set_quantity(qty.value());
@@ -177,7 +178,7 @@ OrderOpResult TriggerOrder::on_cancel() {
LOG(OrderMan, Info, "TriggerOrder::on_cancel key:{} state:{}", key(),
_state);
me->cancel_mode = CancelMode::external;
switch (_state) {
switch (_state.value) {
case State::START:
_switch_state(State::END);
break;
@@ -200,7 +201,7 @@ OrderOpResult TriggerOrder::on_cancel() {
return OrderOpResult{};
}
void TriggerOrder::_on_book_update(const BookUpdateEvent &b_event) {
switch (_state) {
switch (_state.value) {
case State::START:
break;
case State::WAITING_FOR_TRIGGER:
@@ -227,7 +228,7 @@ void TriggerOrder::_on_child_order_update(const OrderStateUpdateEvent &o_ev) {
if (o_ev.key == me->child_order.key()) {
auto ev_state = o_ev.rebuild_state();
me->child_state = ev_state;
switch (_state) {
switch (_state.value) {
case State::START:
case State::WAITING_FOR_TRIGGER:
bts_assert(false);
@@ -251,7 +252,7 @@ void TriggerOrder::_on_child_order_update(const OrderStateUpdateEvent &o_ev) {
}
}
void TriggerOrder::_on_time(const bts::mercury::TimerEvent &) {
switch (_state) {
switch (_state.value) {
case State::START:
case State::WAITING_FOR_TRIGGER:
case State::WAITING_FOR_FIRST_ACK:
@@ -342,7 +343,7 @@ void TriggerOrder::_report_state() {
}
}
void TriggerOrder::_switch_state(State new_state) {
switch (new_state) {
switch (new_state.value) {
case State::START:
break;
case State::WAITING_FOR_TRIGGER:
@@ -415,7 +416,7 @@ void TriggerOrder::_analyze_trigger_and_cancel() {
}
}
api::orderman::OrderStatus TriggerOrder::_status() const {
switch (_state) {
switch (_state.value) {
// will only be called once the order
// has been activated
case State::START:
@@ -440,7 +441,7 @@ api::orderman::OrderStatus TriggerOrder::_status() const {
return api::orderman::OrderStatus::ORDER_STATUS_COMPLETED;
else if (SpreaderUtils::order_in_cancelled_state(
me->child_state.status())) {
switch (me->cancel_mode) {
switch (me->cancel_mode.value) {
case CancelMode::none: // this means an unscolicted child cxl
case CancelMode::external:
return api::orderman::OrderStatus::ORDER_STATUS_CANCELED;
+4 -28
View File
@@ -2,6 +2,8 @@
#include "lib/api/services/OrderService.server.pb.h"
#include "lib/orderman/orders/Order.h"
#include "lib/orderman/orders/TriggerOrderCancelMode.h"
#include "lib/orderman/orders/TriggerOrderState.h"
#include <memory>
namespace bts {
@@ -24,34 +26,8 @@ class PreActivationOrderServices;
class TriggerOrder : public Order {
private:
enum State {
// remains here till on_actiavte is called
START = 0,
// waiting for trigger conditions, sends
// order and waits to steady
WAITING_FOR_TRIGGER = 1,
// once the order is submitted it gets into
// this state until getting a callback
// from the child order
WAITING_FOR_FIRST_ACK = 2,
// order is out
STEADY = 3,
END = 4
};
// this is the ways a child order
// can be cancelled
enum CancelMode {
// not cancelled, initial value
none = 0,
// meaning the trigger order
// cancelled the child order because
// of time or conditional reasons
trigger,
// the trigger order is itself
// externally cancelled
// through the cancel call
external
};
using State = TriggerOrderState;
using CancelMode = TriggerOrderCancelMode;
public:
TriggerOrder();
@@ -0,0 +1,34 @@
#pragma once
#include "lib/core/EnumMacros.h"
#include "lib/core/FMT_IMPL.h"
#include <fmt/format.h>
#include <nlohmann/json.hpp>
#include <ostream>
#include <string>
namespace bts::orderman {
// clang-format off
#define FOR_ALL_VALUES(per_value) \
/* not cancelled, initial value */ \
per_value(TriggerOrderCancelMode, none) \
/* meaning the trigger order cancelled the child order because of time */ \
/* or conditional reasons */ \
per_value(TriggerOrderCancelMode, trigger) \
/* the trigger order is itself externally cancelled through the cancel */ \
/* call */ \
per_value(TriggerOrderCancelMode, external)
// clang-format on
/**
* @brief Represents the ways a TriggerOrder child order can be cancelled
*/
ENUM_CLASS_DEF(TriggerOrderCancelMode, FOR_ALL_VALUES)
#undef FOR_ALL_VALUES
} // namespace bts::orderman
FMT_IMPL(bts::orderman::TriggerOrderCancelMode, cm, "{}", cm.name());
@@ -0,0 +1,33 @@
#pragma once
#include "lib/core/EnumMacros.h"
#include "lib/core/FMT_IMPL.h"
#include <fmt/format.h>
#include <nlohmann/json.hpp>
#include <ostream>
#include <string>
namespace bts::orderman {
// clang-format off
#define FOR_EACH_TRIGGER_ORDER_STATE(per_value) \
/* remains here till on_actiavte is called */ \
per_value(TriggerOrderState, START) \
/* waiting for trigger conditions, sends order and waits to steady */ \
per_value(TriggerOrderState, WAITING_FOR_TRIGGER) \
/* once the order is submitted it gets into this state until getting a */ \
/* callback from the child order */ \
per_value(TriggerOrderState, WAITING_FOR_FIRST_ACK) \
/* order is out */ \
per_value(TriggerOrderState, STEADY) \
per_value(TriggerOrderState, END)
// clang-format on
ENUM_CLASS_DEF(TriggerOrderState, FOR_EACH_TRIGGER_ORDER_STATE)
#undef FOR_EACH_TRIGGER_ORDER_STATE
} // namespace bts::orderman
FMT_IMPL(bts::orderman::TriggerOrderState, s, "{}", s.name());
@@ -1129,7 +1129,7 @@ bool AlgoWrapperOrder::is_working() const {
return me->status == Status::WORKING;
}
log::CharPtrWrapper AlgoWrapperOrder::state_name(Status st) {
std::string AlgoWrapperOrder::state_name(Status st) {
switch (st) {
case Status::COMPLETED:
return {"COMPLETED"};
@@ -105,7 +105,7 @@ class AlgoWrapperOrder : public Order, private IAlgoServices {
OrderKey index_and_launch_child(ChildOrder &&, Price, Quantity, bool);
bool is_working() const;
size_t working_children_count() const;
log::CharPtrWrapper state_name(Status);
std::string state_name(Status);
ChildStatus map_child_status(api::orderman::OrderStatus);
bool _is_attaching(api::orderman::OrderDefinition const &) const;
};
@@ -10,6 +10,8 @@ namespace orderman {
using namespace api::orderman;
using std::string;
enum class CoverAlgo::Status { WORKING, WAITING_FOR_HEDGES, DONE, CANCELING };
struct CoverAlgo::PImpl {
@@ -262,8 +264,7 @@ void CoverAlgo::update_definition(
void CoverAlgo::terminate_if_hedges_complete() {
LOG(OrderMan, Diag,
"CoverAlgo {} check_terminate. State: {} Hedge count: {}",
algo().order_key(), log::CharPtrWrapper{status_name(me->status)},
me->hedges.size());
algo().order_key(), string{status_name(me->status)}, me->hedges.size());
if (me->status == Status::WAITING_FOR_HEDGES && me->hedges.empty()) {
LOG(OrderMan, Info, "CoverAlgo {}. Last hedge completed, terminating",
@@ -13,6 +13,8 @@ namespace orderman {
using namespace api::orderman;
using std::string;
enum class ProRataAlgo::Status {
WAITING_FOR_MD,
WORKING,
@@ -373,8 +375,7 @@ void ProRataAlgo::set_parameters(
void ProRataAlgo::check_terminate() {
LOG(OrderMan, Diag,
"ProRataAlgo {} check_terminate. State: {} Hedge count: {}",
algo().order_key(), log::CharPtrWrapper{status_name(me->status)},
me->hedges.size());
algo().order_key(), string{status_name(me->status)}, me->hedges.size());
if (me->status == Status::DONE_WORKING && me->hedges.empty() &&
me->overfill_hedges.empty()) {
@@ -30,6 +30,8 @@ using namespace google::protobuf;
using namespace boost;
using namespace google::protobuf::util;
using std::string;
enum class SniperAlgo::FireImpetus { Book = 0, Lookahead = 1, OrderUpdate = 2, Time = 3 };
struct SniperAlgo::PImpl {
@@ -303,9 +305,8 @@ void SniperAlgo::on_trade_summary_signal(
LOG(Latency, Info,
"entry_type:SniperAlgo::on_trade_signal channel:{} sn:{} "
"app_arrival:{} now:{} delta:{}",
log::CharPtrWrapper{corid.channel}, corid.sn,
corid.app_arrival.to_uint64(), ts_now.to_uint64(),
(ts_now - corid.app_arrival).nanoseconds());
string{corid.channel}, corid.sn, corid.app_arrival.to_uint64(),
ts_now.to_uint64(), (ts_now - corid.app_arrival).nanoseconds());
auto it = me->sec_map.find(key);
bts_assert(it != me->sec_map.end());
auto &sec_data = it->second;
@@ -30,6 +30,8 @@ namespace orderman {
//using namespace api::orderman;
//using namespace google::protobuf;
using std::string;
// main types /////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
@@ -439,7 +441,7 @@ void log_perf_compute(trace::CorID corid){
LOG(Latency, Info,
"entry_type:SniperAlgo::compute channel:{} sn:{} "
"app_arrival:{} now:{} delta:{}",
log::CharPtrWrapper{corid.channel}, corid.sn,
string{corid.channel}, corid.sn,
corid.app_arrival.to_uint64(), ts_now.to_uint64(),
(ts_now - corid.app_arrival).nanoseconds());
}
@@ -449,9 +451,8 @@ void log_lookahead_fire(trace::CorID corid){
LOG(Latency, Info,
"entry_type:SniperAlgo::fire channel:{} sn:{} "
"app_arrival:{} now:{} delta:{}",
log::CharPtrWrapper{corid.channel}, corid.sn,
corid.app_arrival.to_uint64(), ts_now.to_uint64(),
(ts_now - corid.app_arrival).nanoseconds());
string{corid.channel}, corid.sn, corid.app_arrival.to_uint64(),
ts_now.to_uint64(), (ts_now - corid.app_arrival).nanoseconds());
}
void log_polygon_state(SniperPolygon& p, bool log_legs = true){
@@ -592,4 +593,4 @@ void validate_zero_net_position(const SniperPolygon& p){
bts_assert(kv.second == 0);
}
}}
}}
@@ -734,7 +734,7 @@ void BookOrderBase::launch_child(
me->child.activate(Price(me->state.price()), Quantity(me->state.quantity()));
}
log::CharPtrWrapper BookOrderBase::state_name(InternalStatus st) {
std::string BookOrderBase::state_name(InternalStatus st) {
switch (st) {
case InternalStatus::W_MD:
return {"W_MD"};
@@ -80,7 +80,7 @@ class BookOrderBase : public Order {
ChildOrder const &,
api::orderman::OrderDefinition const &,
api::orderman::OrderState const &);
log::CharPtrWrapper state_name(InternalStatus);
std::string state_name(InternalStatus);
void terminate_error(std::string const &msg);
void terminate(api::orderman::OrderStatus, std::string const &error = "");
void check_invariants();
@@ -1,4 +1,5 @@
#include "QueueHolderOrder.h"
#include "lib/api/services/OrderService.h"
#include "lib/domain_model/Security.h"
#include "lib/logging/logging.h"
#include "lib/orderman/OrderBuilder.h"
@@ -68,8 +69,8 @@ void QueueHolderOrder::_on_book_update(const BookUpdateEvent &b) {
}
void QueueHolderOrder::_on_child_order_update(const OrderStateUpdateEvent &c) {
LOG(OrderMan, Diag,
"QueueHolderOrder::_on_child_order_update key:{} state:{} "
"order_key:{} order_state:{}",
"QueueHolderOrder::_on_child_order_update key:{} state:{} order_key:{} "
"order_state:{}",
key(), _state_int(), c.key, c.status);
_state_worker->on_child_order_update(c);
_report_state();
@@ -113,8 +114,8 @@ void QueueHolderOrder::_switch_state(QueueHolderOrderState new_state) {
LOG(OrderMan, Info, "QueueHolderOrder::_switch_state key:{} {}->{}", key(),
s0, _state_int());
}
api::orderman::OrderStatus
QueueHolderOrder::_status(std::string &message) const {
api::orderman::OrderStatus QueueHolderOrder::_status(
std::string &message) const {
QueueHolderOrderState curr_state =
_state_worker == nullptr ? QueueHolderOrderState::START : _state();
switch (curr_state) {
@@ -1,6 +1,6 @@
#pragma once
#include "lib/api/services/OrderService.pb.h"
#include "lib/api/services/OrderService.h"
#include "lib/domain_model/Security.pb.h"
#include "lib/logging/logging.h"
#include "lib/mercury/events/TimerEvent.h"
@@ -164,10 +164,9 @@ class SpreaderOrder : public Order, public ISpreaderManager {
ChildOrderError order_error =
_get_order_error(ord_ev, leg_data.quoter().expecting_cancel_update());
LOG(OrderMan, _cw_helper.llevel,
"SpreaderOrder::_on_child_order_update quoter order "
"key:{} state:{} order_key:{} status:{} "
"filled_qty:{} price:{} last_price:{} "
"msg:{} child_order_error:{}",
"SpreaderOrder::_on_child_order_update quoter order key:{} state:{} "
"order_key:{} status:{} filled_qty:{} price:{} last_price:{} msg:{} "
"child_order_error:{}",
key(), static_cast<int>(_state_worker->state()), ord_ev.key,
ord_ev.status, ord_ev.filled_quantity, ord_ev.price,
ord_ev.last_price, ord_ev.last_msg, static_cast<int>(order_error));
+1 -1
View File
@@ -62,7 +62,7 @@ void init_plugins(SparkServices &services) {
} catch (boost::system::system_error const &e) {
LOG(Plugin, Error,
"Failed to initialize plugin {}. Error: {} (OS error code: {})",
pl, std::string(e.what()), e.code());
pl, std::string(e.what()), e.code().value());
}
}
}
+24
View File
@@ -1,4 +1,5 @@
#pragma once
#include <ostream>
#include <utility>
@@ -107,6 +108,29 @@ BIN_OP(bool, <=)
#undef BIN_OP
template <class Tag, class V>
V &operator*(ValueWrapper<Tag, V> &v);
template <class Tag, class V>
const V &operator*(const ValueWrapper<Tag, V> &v);
template <class Tag, class V>
std::ostream &operator<<(std::ostream &s, ValueWrapper<Tag, V> const &v);
//////////////////////////////////////////////////
// Definition
//////////////////////////////////////////////////
template <class Tag, class V>
V &operator*(ValueWrapper<Tag, V> &v) {
return v.value();
}
template <class Tag, class V>
const V &operator*(const ValueWrapper<Tag, V> &v) {
return v.value();
}
template <class Tag, class V>
std::ostream &operator<<(std::ostream &s, ValueWrapper<Tag, V> const &v) {
s << v.value();
+1 -1
View File
@@ -159,7 +159,7 @@ DownloadResult sftp_download(
std::ofstream out{temp.string()};
if (out.bad()) {
return DownloadFailure{
fmt::format("Failed to open temp file '{}'", temp)};
fmt::format("Failed to open temp file '{}'", temp.string())};
}
do {
@@ -1,9 +1,13 @@
#pragma once
#include "lib/core/FMT_IMPL.h"
#include <emumba-deribit-connector/deribit_utils.h>
#include <iostream>
#include <list>
#include <map>
#include <optional>
#include <sstream>
#include <string>
namespace bts::cmds {
@@ -46,3 +50,5 @@ inline std::ostream &operator<<(
}
} // namespace bts::cmds
FMT_IMPL_OSTREAM(bts::cmds::DeribitDemoConfiguration);
+1 -1
View File
@@ -26,7 +26,7 @@ void clean_dir(std::string base_path) {
boost::system::error_code err;
fs::remove(dir_iter->path(), err);
if (!err)
LOG(md, Info, "Cleaned up {}", dir_iter->path());
LOG(md, Info, "Cleaned up {}", dir_iter->path().string());
}
} else if (fs::is_directory(dir_iter->status())) {
std::string path = dir_iter->path().string();
@@ -303,14 +303,14 @@ void ExchangeSimApplication::onMessage(
message.get(side);
message.get(account);
LOG(ExSim, Info, "Got order change: {} {}@{}", clOrdID.getString(), orderQty,
price);
LOG(ExSim, Info, "Got order change: {} {}@{}", clOrdID.getString(),
orderQty.getValue(), price.getValue());
try {
auto &matcher = me->matchers[sec_desc];
auto order = matcher.get_order(clOrdID);
if (!order) {
LOG(ExSim, Info, "Receive cancel/replace for unknown order {}",
clOrdID);
clOrdID.getString());
throw std::logic_error("Unknown order");
} else {
if (order->executed_quantity() >= orderQty) {
@@ -1,8 +1,12 @@
#pragma once
#include "lib/core/FMT_IMPL.h"
#include "lib/domain_model/Security.pb.h"
#include "lib/orderman/orderman_utils/orderman_common.h"
#include "server/sparkd/exchange_sim/book/Order.h"
#include <memory>
#include <sstream>
namespace bts {
namespace ex_sim {
@@ -141,3 +145,5 @@ inline std::ostream &operator<<(std::ostream &out, const Book &book) {
}
} // namespace ex_sim
} // namespace bts
FMT_IMPL_OSTREAM(bts::ex_sim::Book);
@@ -573,17 +573,17 @@ void EmMDListener::on_order_update(
order_state.exchange_order_state);
// these are all logs
LOG(OrderMan, Info,
"IEMOrderMuxer::on_order_update em_ord_key: {} tid: {} sub_acct_idx: "
"{} "
"IEMOrderMuxer::on_order_update em_ord_key: {} tid: {} sub_acct_idx: {} "
"ec.value: {} ec.message: {} ec.details: {} update_type: {} "
"exchange_key: {} status: "
"{} pr: {} qty: {} filled_pr: {} fills: {} n_trades: {}",
"exchange_key: {} status: {} pr: {} qty: {} filled_pr: {} fills: {} "
"n_trades: {}",
order_key.value(), os::get_thread_id(), order_state.subaccount_index,
ec.value(), ec.message(), ec.details(), order_state.order_update_type,
exchange_order_state.exchange_order_id, order_state.order_status,
order_state.px.to_double(), extract_qty(order_state.qty),
order_state.avg_price.to_double(), extract_qty(order_state.total_fills),
order_state.trades.size());
ec.value(), ec.message(), ec.details(),
static_cast<int>(order_state.order_update_type),
exchange_order_state.exchange_order_id,
static_cast<int>(order_state.order_status), order_state.px.to_double(),
extract_qty(order_state.qty), order_state.avg_price.to_double(),
extract_qty(order_state.total_fills), order_state.trades.size());
for (const auto &t : order_state.trades) {
LOG(OrderMan, Info,
"IEMOrderMuxer::on_order_update trade sec: {} agg: {} pr: {} qty: "
@@ -262,3 +262,7 @@ class IEMOrderMuxer {
};
} // namespace bts::orderman
FMT_IMPL_OSTREAM(bts::orderman::EMOpenOrder);
FMT_IMPL_OSTREAM(bts::orderman::EMOrderState);
FMT_IMPL_OSTREAM(bts::orderman::EMPosition);
@@ -3,6 +3,8 @@
#include "lib/md/protos/co2.pb.h"
#include "lib/utils/datetime.h"
#include "lib/utils/helper_macros.h"
#include <OnixS/CME/MDH/Fields.h>
#include <vector>
using namespace std;
@@ -63,7 +65,8 @@ void ICEListener::onFeedError(
onixs_ice::FeedId feedid,
onixs_ice::ErrorCode code,
const std::string &desc) {
LOG(md, Warn, "OnixS ICE FeedError: {} - {}", feedid, desc, code);
LOG(md, Warn, "OnixS ICE FeedError: {} - {}", feedid, desc,
string{onixs_ice::KnownErrors::toString(code)});
}
void ICEListener::onWarning(const onixs_ice::Warning &warning) {
LOG(md, Warn, "OnixS ICE Warn: {} - {}", warning.toString(),
@@ -85,8 +88,10 @@ void ICEListener::onFuturesProductDefinition(
msg.marketDesc, // NG Swing GDD Futures - Henry - 10 Jul 20,
msg.stripName, // 10 Jul 20
msg.contractSymbol, // CGS SDN1020.N1020,
msg.productId, msg.marketId, msg.requestMarketType, msg.securitySubType,
msg.contractSymbolExtra, msg.clearedAlias, msg.isSpread);
msg.productId, msg.marketId, msg.requestMarketType,
string{onixs_ice::SecuritySubType::toString(msg.securitySubType)},
msg.contractSymbolExtra ? *msg.contractSymbolExtra : string{},
msg.clearedAlias, msg.isSpread);
}
void ICEListener::onNewExpiry(
@@ -99,10 +104,11 @@ void ICEListener::onNewExpiry(
void ICEListener::onFuturesStrategyDefinition(
const onixs_ice::FuturesStrategyDefinition &msg, bool &is_interested) {
on_uds_future_spread(msg, is_interested);
LOG(md, Diag, "ICE_Strategy,{},{},{},{},{},{},{},{},{},{},{},{},{},{}",
LOG(md, Diag, "ICE_Strategy,{},{},{},{},{},{},{},{},{},{},{},{},{}",
is_interested, msg.productName, msg.hubAlias, msg.marketDesc,
msg.stripName, msg.contractSymbol, msg.productId, msg.marketId,
msg.requestMarketType, msg.securitySubType, log::CharPtrWrapper{""},
msg.requestMarketType,
string{onixs_ice::SecuritySubType::toString(msg.securitySubType)},
msg.clearedAlias, msg.productName, 0);
}
+3 -1
View File
@@ -4,10 +4,12 @@
#include "lib/api/services/AdminService.pb.h"
#include "lib/config/config.h"
#include "lib/config/protos/toggles.pb.h"
#include "lib/domain_model/Side.h"
#include "lib/logging/logging.h"
#include "lib/orderman/actors/SODPosition.h"
#include "lib/utils/PBUtils.h"
#include "lib/utils/bts_assert.h"
#include <google/protobuf/timestamp.pb.h>
#include <sstream>
#include <sys/time.h>
@@ -254,4 +256,4 @@ const std::map<std::string, Fill> &PositionMap::test_only_fills() const {
}
} // namespace orderman
} // namespace bts
} // namespace bts
@@ -1,7 +1,10 @@
#pragma once
#include "lib/core/FMT_IMPL.h"
#include "lib/utils/datetime.h"
#include <boost/date_time/posix_time/posix_time.hpp>
#include <sstream>
namespace bts {
namespace position {
@@ -31,3 +34,5 @@ std::ostream &operator<<(std::ostream &, DownloadWindow const &);
} // namespace position
} // namespace bts
FMT_IMPL_OSTREAM(bts::position::DownloadWindow);
Submodule
+1
Submodule vcpkg added at 04f7d34c26.
+5
View File
@@ -0,0 +1,5 @@
{
"dependencies": [
"fmt"
]
}