Fixing merge conflict
This commit is contained in:
1 parent
c9856b96ae
commit
89fcb3092b
4 files changed
+64
-14
No files matched your search
@@ -1,5 +1,6 @@
|
||||
#include "OrderServiceServer.h"
|
||||
#include "lib/api/public/ServiceContext.h"
|
||||
#include "lib/api/public/StatefulPublisher.h"
|
||||
#include "lib/api/services/AdminService.client.pb.h"
|
||||
#include "lib/api/services/MarginService.client.pb.h"
|
||||
#include "lib/api/services/OrderService.pb.h"
|
||||
@@ -8,6 +9,7 @@
|
||||
#include "lib/config/protos/jetfix.pb.h"
|
||||
#include "lib/config/protos/orderman_cfg.pb.h"
|
||||
#include "lib/domain_model/Security.pb.h"
|
||||
#include "lib/domain_model/common.h"
|
||||
#include "lib/logging/logging.h"
|
||||
#include "lib/md/MDClient.h"
|
||||
#include "lib/md/MDConsumer.h"
|
||||
@@ -33,7 +35,9 @@
|
||||
#include "lib/utils/thread_manager.h"
|
||||
#include "lib/utils/type_name.h"
|
||||
|
||||
#include <bits/stdint-uintn.h>
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
#include <functional>
|
||||
#include <optional>
|
||||
#include <unordered_map>
|
||||
|
||||
@@ -103,8 +107,7 @@ ActorThread *find_thread_for_actor(
|
||||
class OpenOrderRecordIDStore {
|
||||
public:
|
||||
std::uint32_t get_rec_id(const std::string &exch_order_id) {
|
||||
auto [it, is_new] =
|
||||
rec_ids_.try_emplace(exch_order_id, rec_id_counter_);
|
||||
auto [it, is_new] = rec_ids_.try_emplace(exch_order_id, rec_id_counter_);
|
||||
if (is_new) {
|
||||
rec_id_counter_++;
|
||||
}
|
||||
@@ -210,8 +213,8 @@ OrderServiceServer::OrderServiceServer(
|
||||
// Timer
|
||||
thread = find_thread_for_actor("Timer", me->actor_threads);
|
||||
bts_assert_msg(
|
||||
thread,
|
||||
"Could not find a configured thread for Timer. See the OrdermanCfg key");
|
||||
thread, "Could not find a configured thread for Timer. See the "
|
||||
"OrdermanCfg key");
|
||||
thread->executor.spawn<mercury::Timer>();
|
||||
|
||||
// AsyncFactory
|
||||
@@ -492,7 +495,8 @@ void OrderServiceServer::_on_exchange_position(
|
||||
me->exchange_pos_publisher.add_or_update(ret_pos);
|
||||
LOG(OrderMan, Info,
|
||||
"OrderServiceServer::_on_exchange_position publishing pos id: {} "
|
||||
"key: {} res: {} account_name: {} account_id: {} account_resolved: "
|
||||
"key: {} res: {} account_name: {} account_id: {} "
|
||||
"account_resolved: "
|
||||
"{} desc: {} exchange: {} filled_price: {} fills: {}",
|
||||
ret_pos.record_id(), ret_pos.security_key(),
|
||||
ret_pos.security_resolved(), ret_pos.account_name(),
|
||||
@@ -508,11 +512,22 @@ void OrderServiceServer::_on_exchange_position(
|
||||
|
||||
void OrderServiceServer::_on_exchange_open_orders(
|
||||
const ExchangeOpenOrdersEvent &ev) {
|
||||
using namespace bts::api::orderman;
|
||||
LOG(OrderMan, Info,
|
||||
" OrderServiceServer::_on_exchange_open_orders n_open_orders: {}",
|
||||
ev.open_orders.all_open_orders.size());
|
||||
"OrderServiceServer::_on_exchange_open_orders n_open_orders: {} "
|
||||
"current_sz: {}",
|
||||
ev.open_orders.all_open_orders.size(),
|
||||
me->open_orders_publisher.keys().size());
|
||||
std::map<uint32_t, RetrievedExchangeOpenOrder> new_state = {};
|
||||
auto get_signed_qty = [](const auto &o, Quantity qty) {
|
||||
double qty_d = std::abs(qty.full_value());
|
||||
if (o.side == api::Side::SIDE_SELL) {
|
||||
qty_d = -1.0 * qty_d;
|
||||
}
|
||||
return qty_d;
|
||||
};
|
||||
for (const auto &o : ev.open_orders.all_open_orders) {
|
||||
bts::api::orderman::RetrievedExchangeOpenOrder o_ord = {};
|
||||
RetrievedExchangeOpenOrder o_ord = {};
|
||||
auto rec_id = me->open_order_id_store.get_rec_id(o.exchange_order_id);
|
||||
o_ord.set_record_id(rec_id);
|
||||
o_ord.set_exchange_order_id(o.exchange_order_id);
|
||||
@@ -525,15 +540,29 @@ void OrderServiceServer::_on_exchange_open_orders(
|
||||
o_ord.set_account_resolved(o.account_id.has_value());
|
||||
o_ord.set_tif(o.tif);
|
||||
o_ord.set_price(o.price.value());
|
||||
o_ord.set_qty(o.qty.full_value());
|
||||
o_ord.set_qty(get_signed_qty(o, o.qty));
|
||||
o_ord.set_filled_price(o.filled_price.value());
|
||||
o_ord.set_filled_qty(o.filled_qty.full_value());
|
||||
o_ord.set_filled_qty(get_signed_qty(o, o.filled_qty));
|
||||
o_ord.set_creation_timestamp_ms(o.creation_timestamp);
|
||||
o_ord.set_last_update_timestamp_ms(o.last_update_timestamp);
|
||||
o_ord.set_api(o.api);
|
||||
o_ord.set_web(o.web);
|
||||
me->open_orders_publisher.add_or_update(o_ord);
|
||||
new_state[rec_id] = o_ord;
|
||||
}
|
||||
const auto &prev_state = me->open_orders_publisher.keys();
|
||||
std::vector<RetrievedExchangeOpenOrder const *> added = {};
|
||||
std::vector<RetrievedExchangeOpenOrder const *> updated = {};
|
||||
std::vector<uint32_t> deleted = {};
|
||||
bts::api::StatefulPublisher<RetrievedExchangeOpenOrder, uint32_t>::diff(
|
||||
new_state, prev_state, added, updated, deleted);
|
||||
|
||||
for (const auto &k : deleted)
|
||||
me->open_orders_publisher.erase(k);
|
||||
for (RetrievedExchangeOpenOrder const *o : updated)
|
||||
me->open_orders_publisher.add_or_update(*o);
|
||||
for (RetrievedExchangeOpenOrder const *o : added)
|
||||
me->open_orders_publisher.add_or_update(*o);
|
||||
|
||||
LOG(OrderMan, Info,
|
||||
"OrderServiceServer::_on_exchange_open_orders publishing {} records",
|
||||
ev.open_orders.all_open_orders.size());
|
||||
|
||||
Reference in new issue
Block a user