cleanup: Move CreateOrderMsg impl to .cpp, get rid of unused code
This commit is contained in:
1 parent
77e5c1481b
commit
ab217401eb
3 files changed
+32
-63
No files matched your search
@@ -0,0 +1,29 @@
|
||||
#include "CreateOrderMsg.h"
|
||||
#include "lib/utils/PBUtils.h"
|
||||
|
||||
namespace bts::orderman {
|
||||
|
||||
using bts::api::Side_Name;
|
||||
using bts::api::orderman::ManualOrderIndicator_Name;
|
||||
using bts::api::orderman::NativeOrderType_Name;
|
||||
using bts::api::orderman::TimeInForce_Name;
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, CreateOrderMsg const &msg) {
|
||||
out << "key: " << msg.key.value() << " price: " << msg.price.value()
|
||||
<< " qty: " << msg.quantity.full_value() << " security: "
|
||||
<< (msg.security == nullptr ? "NULL"
|
||||
: utils::pb::to_string(*msg.security))
|
||||
<< " side: " << Side_Name(msg.side)
|
||||
<< " display_qty: " << msg.display_quantity.full_value()
|
||||
<< " order_type: " << NativeOrderType_Name(msg.order_type)
|
||||
<< " time_in_force: " << TimeInForce_Name(msg.time_in_force)
|
||||
<< " manual_order_indicator: "
|
||||
<< ManualOrderIndicator_Name(msg.manual_order_indicator)
|
||||
<< " routing_record: "
|
||||
<< (msg.routing_record == nullptr
|
||||
? "NULL"
|
||||
: utils::pb::to_string(*msg.routing_record));
|
||||
return out;
|
||||
}
|
||||
|
||||
} // namespace bts::orderman
|
||||
@@ -1,13 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "lib/api/services/OrderService.h"
|
||||
#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 "lib/utils/PBUtils.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <ostream>
|
||||
|
||||
namespace bts::orderman {
|
||||
|
||||
@@ -25,66 +23,7 @@ struct CreateOrderMsg {
|
||||
api::orderman::RoutingRecord const *routing_record;
|
||||
};
|
||||
|
||||
/**
|
||||
* A CreateOrderMsg wrapper with a custom fmt::formatter that doesn't access the
|
||||
* raw security pointer. This is mainly used for logging purposes (because the
|
||||
* security pointer may be invalid by the time the fmt::formatter is invoked).
|
||||
*/
|
||||
struct CreateOrderMsg_JsonData {
|
||||
CreateOrderMsg_JsonData() = default;
|
||||
CreateOrderMsg_JsonData(CreateOrderMsg source) : source(std::move(source)) {
|
||||
if (this->source.security != nullptr) {
|
||||
sec_name = securities::descriptor(*this->source.security);
|
||||
}
|
||||
}
|
||||
|
||||
CreateOrderMsg source;
|
||||
std::string sec_name;
|
||||
};
|
||||
|
||||
void to_json(nlohmann::json &j, const CreateOrderMsg &msg);
|
||||
|
||||
inline std::ostream &operator<<(std::ostream &out, CreateOrderMsg const &msg) {
|
||||
out << "key: " << msg.key.value() << " price: " << msg.price.value()
|
||||
<< " qty: " << msg.quantity.full_value() << " security: "
|
||||
<< (msg.security == nullptr ? "NULL"
|
||||
: utils::pb::to_string(*msg.security))
|
||||
<< " side: " << securities::side_name(msg.side)
|
||||
<< " display_qty: " << msg.display_quantity.full_value()
|
||||
<< " order_type: " << api::orderman::NativeOrderType_Name(msg.order_type)
|
||||
<< " time_in_force: "
|
||||
<< api::orderman::TimeInForce_Name(msg.time_in_force)
|
||||
<< " manual_order_indicator: "
|
||||
<< api::orderman::ManualOrderIndicator_Name(msg.manual_order_indicator)
|
||||
<< " routing_record: "
|
||||
<< (msg.routing_record == nullptr
|
||||
? "NULL"
|
||||
: utils::pb::to_string(*msg.routing_record));
|
||||
return out;
|
||||
}
|
||||
|
||||
inline void to_json(
|
||||
nlohmann::json &j, const CreateOrderMsg_JsonData &msg_data) {
|
||||
const auto &msg = msg_data.source;
|
||||
j["key"] = msg.key.value();
|
||||
j["price"] = msg.price.value();
|
||||
j["quantity"] = msg.quantity.value();
|
||||
if (msg.display_quantity.value() != 0) {
|
||||
j["display_quantity"] = msg.quantity.value();
|
||||
}
|
||||
if (!msg_data.sec_name.empty()) {
|
||||
j["security"] = msg_data.sec_name;
|
||||
}
|
||||
j["side"] = msg.side;
|
||||
if (msg.stop_px.value() != 0) {
|
||||
j["stop_px"] = msg.stop_px.value();
|
||||
}
|
||||
j["time_in_force"] = msg.time_in_force;
|
||||
j["manual_order_indicator"] = msg.manual_order_indicator;
|
||||
if (msg.routing_record != nullptr) {
|
||||
j["routing_record"] = *msg.routing_record;
|
||||
}
|
||||
}
|
||||
std::ostream &operator<<(std::ostream &out, CreateOrderMsg const &msg);
|
||||
|
||||
} // namespace bts::orderman
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "lib/orderman/gateways/OnixFIXAdapter.h"
|
||||
#include "lib/orderman/gateways/sim/SimExecutionGatewayFactory.h"
|
||||
#include "lib/orderman/gateways/sim/SimExecutionGatewayUniqueWrapper.h"
|
||||
#include "lib/utils/PBUtils.h"
|
||||
|
||||
namespace bts::orderman {
|
||||
|
||||
|
||||
Reference in new issue
Block a user