Another clang-format run, changed how parameters are binned
This commit is contained in:
1 parent
8f21a77150
commit
de063e51f0
452 files changed
+5506
-2380
No files matched your search
@@ -1,4 +1,5 @@
|
||||
IndentWidth: 3
|
||||
BinPackArguments: true
|
||||
BinPackParameters: false
|
||||
AlignAfterOpenBracket: AlwaysBreak
|
||||
|
||||
@@ -137,8 +137,11 @@ int32_t rpc_connect_timeout_ms() {
|
||||
return t;
|
||||
}
|
||||
void api_client_send_internal(
|
||||
ApiClient *pclient, qbus::RPCRequest &&request, raw_response_callback cb,
|
||||
int32_t delay, void *extra) {
|
||||
ApiClient *pclient,
|
||||
qbus::RPCRequest &&request,
|
||||
raw_response_callback cb,
|
||||
int32_t delay,
|
||||
void *extra) {
|
||||
bts_assert(pclient);
|
||||
bool connected = pclient->rpc.wait_until_connected(0);
|
||||
if (!connected && delay > 0) {
|
||||
@@ -176,8 +179,11 @@ void api_client_send_internal(
|
||||
});
|
||||
}
|
||||
CAPI void api_client_send(
|
||||
ApiClient *pclient, const char *buffer, int buffer_length,
|
||||
raw_response_callback cb, void *extra) {
|
||||
ApiClient *pclient,
|
||||
const char *buffer,
|
||||
int buffer_length,
|
||||
raw_response_callback cb,
|
||||
void *extra) {
|
||||
LOG(Api, Diag, "send rpc {}", ((int64_t)buffer));
|
||||
std::string strbuf(buffer, buffer_length);
|
||||
qbus::RPCRequest request(move(strbuf));
|
||||
@@ -190,8 +196,10 @@ CAPI bool api_client_is_on_qb_thread(ApiClient *pclient) {
|
||||
}
|
||||
|
||||
void safe_call_subscription_callback(
|
||||
raw_subscription_callback cb, EventType type,
|
||||
const std::vector<StreamUpdate> &updates, void *extra) {
|
||||
raw_subscription_callback cb,
|
||||
EventType type,
|
||||
const std::vector<StreamUpdate> &updates,
|
||||
void *extra) {
|
||||
safe_call_fn([&]() {
|
||||
if (updates.size() > 0)
|
||||
cb(type, &updates[0], updates.size(), extra);
|
||||
@@ -210,8 +218,11 @@ bts::qbus::Topic stream_topic(
|
||||
}
|
||||
|
||||
CAPI TableSubscription api_client_subscribe(
|
||||
ApiClient *pclient, const char *method, const char *qualifier,
|
||||
raw_subscription_callback cb, void *extra) {
|
||||
ApiClient *pclient,
|
||||
const char *method,
|
||||
const char *qualifier,
|
||||
raw_subscription_callback cb,
|
||||
void *extra) {
|
||||
bts_assert(pclient);
|
||||
static_assert(
|
||||
(int)qbus::TableEvent::EventType::TABLE_CREATED ==
|
||||
|
||||
@@ -14,8 +14,11 @@ CAPI void api_post(
|
||||
typedef void (*raw_response_callback)(
|
||||
const char *buffer, size_t length, void *extra);
|
||||
CAPI void api_client_send(
|
||||
ApiClient *pclient, const char *buffer, int buffer_length,
|
||||
raw_response_callback cb, void *extra);
|
||||
ApiClient *pclient,
|
||||
const char *buffer,
|
||||
int buffer_length,
|
||||
raw_response_callback cb,
|
||||
void *extra);
|
||||
CAPI bool api_client_is_on_qb_thread(ApiClient *);
|
||||
|
||||
enum EventType { TABLE_CREATED, TABLE_UPDATED, TABLE_DESTROYED };
|
||||
@@ -24,8 +27,11 @@ typedef void *TableSubscription;
|
||||
typedef void (*raw_subscription_callback)(
|
||||
EventType event_type, const StreamUpdate *changes, int count, void *extra);
|
||||
CAPI TableSubscription api_client_subscribe(
|
||||
ApiClient *pclient, const char *method, const char *qualifier,
|
||||
raw_subscription_callback cb, void *extra);
|
||||
ApiClient *pclient,
|
||||
const char *method,
|
||||
const char *qualifier,
|
||||
raw_subscription_callback cb,
|
||||
void *extra);
|
||||
CAPI void api_client_unsubscribe(ApiClient *pclient, TableSubscription ptable);
|
||||
|
||||
} // namespace api
|
||||
|
||||
@@ -14,7 +14,8 @@ bts::qbus::Topic stream_topic(
|
||||
|
||||
struct ApiServerCore {
|
||||
ApiServerCore(
|
||||
Quickbus &qbus, const std::string topic,
|
||||
Quickbus &qbus,
|
||||
const std::string topic,
|
||||
const qbus::OnRPCRequest &handler)
|
||||
: qbus(qbus), topic(topic), rpc(qbus, rpc_topic(topic), handler) {}
|
||||
|
||||
@@ -24,8 +25,11 @@ struct ApiServerCore {
|
||||
};
|
||||
|
||||
CAPI ApiServerCore *api_server_create(
|
||||
Quickbus *pbus, const char *type_name, const char *service_qualifier,
|
||||
raw_rpc_request_callback cb, void *extra) {
|
||||
Quickbus *pbus,
|
||||
const char *type_name,
|
||||
const char *service_qualifier,
|
||||
raw_rpc_request_callback cb,
|
||||
void *extra) {
|
||||
bts_assert(pbus);
|
||||
// Invalid characters in qualifier: +
|
||||
for (auto ch : {'+'}) {
|
||||
|
||||
@@ -9,8 +9,11 @@ typedef void ReplyHandler;
|
||||
typedef void (*raw_rpc_request_callback)(
|
||||
const uint8_t *buffer, size_t length, ReplyHandler *callback, void *extra);
|
||||
CAPI ApiServerCore *api_server_create(
|
||||
Quickbus *pbus, const char *type_name, const char *service_qualifier,
|
||||
raw_rpc_request_callback reply, void *extra);
|
||||
Quickbus *pbus,
|
||||
const char *type_name,
|
||||
const char *service_qualifier,
|
||||
raw_rpc_request_callback reply,
|
||||
void *extra);
|
||||
|
||||
CAPI void api_server_call_callback(
|
||||
ReplyHandler **pphandler, const uint8_t *buffer, int length);
|
||||
|
||||
@@ -5,7 +5,8 @@ namespace bts {
|
||||
namespace api {
|
||||
|
||||
ApiServer::ApiServer(
|
||||
const ServiceContext &ctx, const std::string &type,
|
||||
const ServiceContext &ctx,
|
||||
const std::string &type,
|
||||
const std::string &qualifier)
|
||||
: _channel(ctx.publish(*this, type, qualifier)) {}
|
||||
|
||||
|
||||
@@ -21,13 +21,15 @@ class ServiceContext;
|
||||
class BTS_EXPORT ApiServer {
|
||||
public:
|
||||
ApiServer(
|
||||
const ServiceContext &, const std::string &type,
|
||||
const ServiceContext &,
|
||||
const std::string &type,
|
||||
const std::string &qualifier);
|
||||
virtual ~ApiServer();
|
||||
|
||||
typedef std::function<void(const uint8_t *, size_t)> OnResponse;
|
||||
virtual void dispatch(
|
||||
const RequestHeader &, google::protobuf::io::ZeroCopyInputStream &,
|
||||
const RequestHeader &,
|
||||
google::protobuf::io::ZeroCopyInputStream &,
|
||||
OnResponse) = 0;
|
||||
virtual const char *name() const = 0;
|
||||
|
||||
@@ -55,8 +57,11 @@ class BTS_EXPORT ApiServer {
|
||||
|
||||
template <class T>
|
||||
static void serialize(
|
||||
int header_size, int body_size, const ResponseHeader &header,
|
||||
const T &response, uint8_t *buffer) {
|
||||
int header_size,
|
||||
int body_size,
|
||||
const ResponseHeader &header,
|
||||
const T &response,
|
||||
uint8_t *buffer) {
|
||||
buffer[0] = (uint8_t)header_size;
|
||||
header.SerializePartialToArray(&buffer[1], header_size - 1);
|
||||
response.SerializePartialToArray(&buffer[header_size], body_size);
|
||||
|
||||
@@ -36,7 +36,8 @@ class ClientChannel {
|
||||
|
||||
template <typename Request, typename Response>
|
||||
void send(
|
||||
int method_id, const Request &request,
|
||||
int method_id,
|
||||
const Request &request,
|
||||
std::function<void(const Result<Response>)> on_response) {
|
||||
RequestHeader header;
|
||||
header.set_method(method_id);
|
||||
|
||||
@@ -5,7 +5,9 @@ namespace bts {
|
||||
namespace api {
|
||||
|
||||
QuickbusClientChannel::QuickbusClientChannel(
|
||||
Quickbus &bus, const ServiceContext &context, const char *type_name,
|
||||
Quickbus &bus,
|
||||
const ServiceContext &context,
|
||||
const char *type_name,
|
||||
const char *service_qualifier)
|
||||
: ClientChannel(context),
|
||||
_pclient(api_client_create(&bus, type_name, service_qualifier)) {}
|
||||
|
||||
@@ -12,7 +12,9 @@ class QuickbusClientChannel : public ClientChannel {
|
||||
|
||||
public:
|
||||
QuickbusClientChannel(
|
||||
Quickbus &, const ServiceContext &, const char *type_name,
|
||||
Quickbus &,
|
||||
const ServiceContext &,
|
||||
const char *type_name,
|
||||
const char *service_qualifier);
|
||||
~QuickbusClientChannel();
|
||||
|
||||
|
||||
@@ -6,8 +6,10 @@ namespace api {
|
||||
|
||||
template <typename T> struct RawUpdate {
|
||||
RawUpdate(
|
||||
std::vector<T> &added_items, std::vector<int> &added_keys,
|
||||
std::vector<T> &changed_items, std::vector<int> &changed_keys,
|
||||
std::vector<T> &added_items,
|
||||
std::vector<int> &added_keys,
|
||||
std::vector<T> &changed_items,
|
||||
std::vector<int> &changed_keys,
|
||||
std::vector<int> &removed_keys)
|
||||
: is_reset(false), added_items(std::move(added_items)),
|
||||
added_keys(std::move(added_keys)),
|
||||
|
||||
@@ -8,18 +8,25 @@ namespace api {
|
||||
|
||||
struct ServerChannel::ServerChannelImpl {
|
||||
ServerChannelImpl(
|
||||
Quickbus &qbus, const std::string &service_type,
|
||||
const std::string &qualifier, ApiServer &server)
|
||||
Quickbus &qbus,
|
||||
const std::string &service_type,
|
||||
const std::string &qualifier,
|
||||
ApiServer &server)
|
||||
: _server(server), _core(api_server_create(
|
||||
&qbus, service_type.c_str(), qualifier.c_str(),
|
||||
dispatch_trampoline, this)) {}
|
||||
&qbus,
|
||||
service_type.c_str(),
|
||||
qualifier.c_str(),
|
||||
dispatch_trampoline,
|
||||
this)) {}
|
||||
// Need to guaruntee this object is stationary for the api_server_create
|
||||
// trampoline
|
||||
ServerChannelImpl(const ServerChannelImpl &) = delete;
|
||||
ServerChannelImpl(ServerChannelImpl &&) = delete;
|
||||
|
||||
static void dispatch_trampoline(
|
||||
const uint8_t *buffer, size_t request_size, ReplyHandler *callback,
|
||||
const uint8_t *buffer,
|
||||
size_t request_size,
|
||||
ReplyHandler *callback,
|
||||
void *extra) {
|
||||
assert(extra != nullptr);
|
||||
ServerChannelImpl *pimpl = static_cast<ServerChannelImpl *>(extra);
|
||||
@@ -27,7 +34,8 @@ struct ServerChannel::ServerChannelImpl {
|
||||
}
|
||||
|
||||
void dispatch(
|
||||
const uint8_t *request_buffer, size_t request_length,
|
||||
const uint8_t *request_buffer,
|
||||
size_t request_length,
|
||||
ReplyHandler *callback) {
|
||||
assert(request_buffer != nullptr);
|
||||
assert(request_length > 1);
|
||||
@@ -50,8 +58,10 @@ struct ServerChannel::ServerChannelImpl {
|
||||
};
|
||||
|
||||
ServerChannel::ServerChannel(
|
||||
Quickbus &qbus, const std::string &service_type,
|
||||
const std::string &qualifier, ApiServer &server)
|
||||
Quickbus &qbus,
|
||||
const std::string &service_type,
|
||||
const std::string &qualifier,
|
||||
ApiServer &server)
|
||||
: _me(new ServerChannelImpl(qbus, service_type, qualifier, server)) {}
|
||||
ServerChannel::ServerChannel(ServerChannel &&other)
|
||||
: _me(std::move(other._me)) {}
|
||||
|
||||
@@ -11,8 +11,10 @@ class ApiServer;
|
||||
class ServerChannel {
|
||||
public:
|
||||
ServerChannel(
|
||||
Quickbus &qbus, const std::string &service_type,
|
||||
const std::string &qualifier, ApiServer &server);
|
||||
Quickbus &qbus,
|
||||
const std::string &service_type,
|
||||
const std::string &qualifier,
|
||||
ApiServer &server);
|
||||
ServerChannel(ServerChannel &&other); // : _me(std::move(other._me)) {}
|
||||
~ServerChannel();
|
||||
|
||||
|
||||
@@ -47,7 +47,8 @@ std::unique_ptr<ClientChannel> ServiceContext::create_channel(
|
||||
}
|
||||
|
||||
ServerChannel ServiceContext::publish(
|
||||
ApiServer &service, const std::string &service_type,
|
||||
ApiServer &service,
|
||||
const std::string &service_type,
|
||||
const std::string &qualifier) const {
|
||||
return ServerChannel(_self->_qbus, service_type, qualifier, service);
|
||||
}
|
||||
|
||||
@@ -52,7 +52,8 @@ class BTS_EXPORT ServiceContext {
|
||||
std::unique_ptr<ClientChannel>
|
||||
create_channel(const char *, const char *) const;
|
||||
ServerChannel publish(
|
||||
ApiServer &service, const std::string &service_type,
|
||||
ApiServer &service,
|
||||
const std::string &service_type,
|
||||
const std::string &qualifier) const;
|
||||
};
|
||||
|
||||
|
||||
@@ -21,8 +21,10 @@ template <typename T> class Change {
|
||||
|
||||
template <typename T, typename TKey, typename ServiceType> struct Update {
|
||||
Update(
|
||||
std::vector<T> &all, std::vector<T> &added,
|
||||
std::vector<Change<T>> changed, std::vector<T> &removed)
|
||||
std::vector<T> &all,
|
||||
std::vector<T> &added,
|
||||
std::vector<Change<T>> changed,
|
||||
std::vector<T> &removed)
|
||||
: _all_items(std::move(all)), _added_items(std::move(added)),
|
||||
_changed_items(std::move(changed)),
|
||||
_removed_items(std::move(removed)) {}
|
||||
|
||||
@@ -61,7 +61,8 @@ bool AdminServiceUtils::has_exchange(
|
||||
return rv;
|
||||
}
|
||||
const ExchangeConnection *AdminServiceUtils::find_default_account_connection(
|
||||
const AdminData &data, const BTSAccount &account,
|
||||
const AdminData &data,
|
||||
const BTSAccount &account,
|
||||
bts::api::Venue exchange) {
|
||||
// todo:get from parent accounts if not overridden
|
||||
if (account.has_connections())
|
||||
@@ -75,7 +76,8 @@ const ExchangeConnection *AdminServiceUtils::find_default_account_connection(
|
||||
}
|
||||
|
||||
const ExchangeConnection *AdminServiceUtils::resolve_cme_connection(
|
||||
const AdminData &data, const BTSAccount &account,
|
||||
const AdminData &data,
|
||||
const BTSAccount &account,
|
||||
const bts::api::Security &sec) {
|
||||
if (account.has_connections())
|
||||
for (const std::string &conn_name :
|
||||
@@ -95,7 +97,8 @@ const ExchangeConnection *AdminServiceUtils::resolve_cme_connection(
|
||||
const bts::api::admin::ExchangeConnection *
|
||||
AdminServiceUtils::resolve_ice_connection(
|
||||
const bts::api::admin::AdminData &data,
|
||||
const bts::api::admin::BTSAccount &account, const bts::api::Security &) {
|
||||
const bts::api::admin::BTSAccount &account,
|
||||
const bts::api::Security &) {
|
||||
if (account.has_connections()) {
|
||||
for (const std::string &conn_name :
|
||||
account.connections().exchange_connection_names()) {
|
||||
@@ -111,7 +114,8 @@ AdminServiceUtils::resolve_ice_connection(
|
||||
const bts::api::admin::ExchangeConnection *
|
||||
AdminServiceUtils::resolve_sim_connection(
|
||||
const bts::api::admin::AdminData &data,
|
||||
const bts::api::admin::BTSAccount &account, const bts::api::Security &) {
|
||||
const bts::api::admin::BTSAccount &account,
|
||||
const bts::api::Security &) {
|
||||
if (account.has_connections())
|
||||
for (const std::string &conn_name :
|
||||
account.connections().exchange_connection_names()) {
|
||||
@@ -126,7 +130,8 @@ AdminServiceUtils::resolve_sim_connection(
|
||||
const bts::api::admin::ExchangeConnection *
|
||||
AdminServiceUtils::resolve_connection(
|
||||
const bts::api::admin::AdminData &data,
|
||||
const bts::api::admin::BTSAccount &account, const bts::api::Security &sec) {
|
||||
const bts::api::admin::BTSAccount &account,
|
||||
const bts::api::Security &sec) {
|
||||
const bts::api::admin::ExchangeConnection *rv = nullptr;
|
||||
switch (sec.exchange()) {
|
||||
case api::Venue::VENUE_GLBX: {
|
||||
@@ -261,7 +266,8 @@ const BTSAccount *AdminServiceUtils::find_account(
|
||||
}
|
||||
|
||||
BTSAccount const *AdminServiceUtils::find_account(
|
||||
const AdminData &data, const std::string &clearing_account,
|
||||
const AdminData &data,
|
||||
const std::string &clearing_account,
|
||||
bts::api::Venue exchange) {
|
||||
auto all_accounts = accounts(data, true);
|
||||
for (BTSAccount const *a : all_accounts) {
|
||||
@@ -371,7 +377,9 @@ bool AdminServiceUtils::account_has_connection(
|
||||
return false;
|
||||
}
|
||||
std::string AdminServiceUtils::find_account_exchange_account(
|
||||
const AdminData &data, const BTSAccount &account, api::Venue exchange,
|
||||
const AdminData &data,
|
||||
const BTSAccount &account,
|
||||
api::Venue exchange,
|
||||
AdminServiceOperationResult &out_result) {
|
||||
out_result.set_is_success(true);
|
||||
std::string rv = "";
|
||||
@@ -457,8 +465,10 @@ void AdminServiceUtils::validate_account_exchange_data(
|
||||
}
|
||||
}
|
||||
bts::api::orderman::RoutingRecord AdminServiceUtils::get_routing_record(
|
||||
const bts::api::admin::AdminData &data, const std::string &account_name,
|
||||
const std::string &user_name, const bts::api::Security &sec,
|
||||
const bts::api::admin::AdminData &data,
|
||||
const std::string &account_name,
|
||||
const std::string &user_name,
|
||||
const bts::api::Security &sec,
|
||||
bts::api::admin::AdminServiceOperationResult &out_result) {
|
||||
bts::api::orderman::RoutingRecord rv;
|
||||
const bts::api::admin::BTSAccount *account_ptr =
|
||||
@@ -478,8 +488,10 @@ bts::api::orderman::RoutingRecord AdminServiceUtils::get_routing_record(
|
||||
data, account_ptr->id(), user_ptr->id(), sec, out_result);
|
||||
}
|
||||
bts::api::orderman::RoutingRecord AdminServiceUtils::get_routing_record(
|
||||
const bts::api::admin::AdminData &data, uint32_t account_id,
|
||||
uint32_t user_id, const bts::api::Security &sec,
|
||||
const bts::api::admin::AdminData &data,
|
||||
uint32_t account_id,
|
||||
uint32_t user_id,
|
||||
const bts::api::Security &sec,
|
||||
bts::api::admin::AdminServiceOperationResult &out_result) {
|
||||
bts::api::orderman::RoutingRecord rv;
|
||||
out_result.set_is_success(true);
|
||||
@@ -670,9 +682,12 @@ bts::api::orderman::RoutingRecord AdminServiceUtils::get_routing_record(
|
||||
// account mutators ////////////////////////
|
||||
////////////////////////////////////////////
|
||||
bts::api::admin::BTSAccount *AdminServiceUtils::create_account(
|
||||
bts::api::admin::AdminData &data, uint32_t parent_account_id,
|
||||
const std::string &account_name, const std::string &description,
|
||||
bool is_active, bts::api::admin::AdminServiceCreateAccountResult &result) {
|
||||
bts::api::admin::AdminData &data,
|
||||
uint32_t parent_account_id,
|
||||
const std::string &account_name,
|
||||
const std::string &description,
|
||||
bool is_active,
|
||||
bts::api::admin::AdminServiceCreateAccountResult &result) {
|
||||
result.set_is_success(true);
|
||||
// the error conditions are checked first and returned immediatly
|
||||
// i. account with the name already exists
|
||||
@@ -869,7 +884,8 @@ AdminServiceUtils::get_group_user_permissions(
|
||||
// group mutators //////////////////////////
|
||||
////////////////////////////////////////////
|
||||
bts::api::admin::BTSUserGroup *AdminServiceUtils::create_group(
|
||||
bts::api::admin::AdminData &data, uint32_t parent_group_id,
|
||||
bts::api::admin::AdminData &data,
|
||||
uint32_t parent_group_id,
|
||||
const std::string &group_name,
|
||||
bts::api::admin::AdminServiceOperationResult &result) {
|
||||
// the error conditions are checked first and returned immediatly
|
||||
@@ -899,7 +915,8 @@ bts::api::admin::BTSUserGroup *AdminServiceUtils::create_group(
|
||||
// user accessors //////////////////////////
|
||||
////////////////////////////////////////////
|
||||
bts::api::admin::BTSUser *AdminServiceUtils::find_user(
|
||||
bts::api::admin::AdminData &data, const std::string &user_name,
|
||||
bts::api::admin::AdminData &data,
|
||||
const std::string &user_name,
|
||||
bool include_deleted) {
|
||||
auto user_ptrs = users_mutable(data, include_deleted);
|
||||
for (auto user_ptr : user_ptrs) {
|
||||
@@ -909,7 +926,8 @@ bts::api::admin::BTSUser *AdminServiceUtils::find_user(
|
||||
return nullptr;
|
||||
}
|
||||
const bts::api::admin::BTSUser *AdminServiceUtils::find_user(
|
||||
const bts::api::admin::AdminData &data, const std::string &user_name,
|
||||
const bts::api::admin::AdminData &data,
|
||||
const std::string &user_name,
|
||||
bool include_deleted) {
|
||||
auto user_ptrs = users(data, include_deleted);
|
||||
for (auto user_ptr : user_ptrs)
|
||||
@@ -1010,7 +1028,8 @@ const bts::api::admin::SIMUserData *AdminServiceUtils::get_user_sim_data(
|
||||
// at ICE) for a user
|
||||
std::string AdminServiceUtils::find_user_exchange_id(
|
||||
const bts::api::admin::AdminData &data,
|
||||
const bts::api::admin::BTSUser &user, api::Venue exchange,
|
||||
const bts::api::admin::BTSUser &user,
|
||||
api::Venue exchange,
|
||||
bts::api::admin::AdminServiceOperationResult &out_result) {
|
||||
out_result.set_is_success(true);
|
||||
std::string rv = "";
|
||||
@@ -1050,7 +1069,8 @@ std::string AdminServiceUtils::find_user_exchange_id(
|
||||
|
||||
std::string AdminServiceUtils::find_user_company_id(
|
||||
const bts::api::admin::AdminData &data,
|
||||
const bts::api::admin::BTSUser &user, api::Venue exchange,
|
||||
const bts::api::admin::BTSUser &user,
|
||||
api::Venue exchange,
|
||||
bts::api::admin::AdminServiceOperationResult &out_result) {
|
||||
out_result.set_is_success(true);
|
||||
std::string rv = "";
|
||||
@@ -1079,8 +1099,10 @@ std::string AdminServiceUtils::find_user_company_id(
|
||||
|
||||
std::pair<const BTSAccount *, const BTSUser *>
|
||||
AdminServiceUtils::find_user_account_matches(
|
||||
const AdminData &admin_data, const std::string &connection,
|
||||
const std::string &exchange_account, const std::string &exchange_user,
|
||||
const AdminData &admin_data,
|
||||
const std::string &connection,
|
||||
const std::string &exchange_account,
|
||||
const std::string &exchange_user,
|
||||
api::Venue exchange) {
|
||||
AdminServiceOperationResult find_account_result, find_user_result;
|
||||
// i. uses the exchange and exchange_user to reverse lookup the user(s)
|
||||
@@ -1095,8 +1117,8 @@ AdminServiceUtils::find_user_account_matches(
|
||||
}
|
||||
// i.5
|
||||
// At the ice, they send back the login level tag50 in exec reports which
|
||||
// doesn't match any user level tag50s in the exchange_user so instead we look
|
||||
// for the CompanyID (or client_id, tag 109) field here. If this field
|
||||
// doesn't match any user level tag50s in the exchange_user so instead we
|
||||
// look for the CompanyID (or client_id, tag 109) field here. If this field
|
||||
// matches we have a good bet that the user we find is enough to fulfill the
|
||||
// routing record enough to cancel or modify orphaned orders, etc
|
||||
for (BTSUser const *u : user_ptrs) {
|
||||
@@ -1149,7 +1171,8 @@ AdminServiceUtils::get_user_permissions(
|
||||
// for a given user, fills in the associated_accounts ref arg
|
||||
// with the accounts the user has permission to trade in
|
||||
void AdminServiceUtils::find_user_trading_accounts(
|
||||
const bts::api::admin::AdminData &admin_data, uint32_t user_id,
|
||||
const bts::api::admin::AdminData &admin_data,
|
||||
uint32_t user_id,
|
||||
std::vector<const api::admin::BTSAccount *> &associated_accounts) {
|
||||
const bts::api::admin::UserAccountPermissions *user_perm_ptr =
|
||||
get_user_permissions(admin_data, user_id);
|
||||
@@ -1168,7 +1191,8 @@ void AdminServiceUtils::find_user_trading_accounts(
|
||||
// for a given account, fills in the associated_users ref arg
|
||||
// with the users that can trade into the account
|
||||
void AdminServiceUtils::find_users_for_trading_account(
|
||||
const AdminData &admin_data, uint32_t account_id,
|
||||
const AdminData &admin_data,
|
||||
uint32_t account_id,
|
||||
std::vector<const BTSUser *> &associated_users) {
|
||||
for (const auto &u : AdminServiceUtils::users(admin_data, false)) {
|
||||
const auto user_perm_ptr = get_user_permissions(admin_data, u->id());
|
||||
@@ -1305,7 +1329,8 @@ MDEntitlementReportUnit AdminServiceUtils::get_ice_md_entitlement_unit(
|
||||
}
|
||||
|
||||
void AdminServiceUtils::get_user_symbol_permissions(
|
||||
const AdminData &data, const BTSUser &user,
|
||||
const AdminData &data,
|
||||
const BTSUser &user,
|
||||
std::vector<UserSymbolMDPermissionUnit> &rv) {
|
||||
std::map<api::CMEMics, bool> mic_perm_map;
|
||||
auto exchange = api::Venue::VENUE_GLBX;
|
||||
@@ -1333,9 +1358,13 @@ void AdminServiceUtils::get_user_symbol_permissions(
|
||||
// user mutators ///////////////////////////
|
||||
////////////////////////////////////////////
|
||||
bts::api::admin::BTSUser *AdminServiceUtils::create_user(
|
||||
bts::api::admin::AdminData &data, uint32_t parent_group_id,
|
||||
const std::string &name, const std::string &password,
|
||||
const std::string &full_name, const std::string &company, bool is_active,
|
||||
bts::api::admin::AdminData &data,
|
||||
uint32_t parent_group_id,
|
||||
const std::string &name,
|
||||
const std::string &password,
|
||||
const std::string &full_name,
|
||||
const std::string &company,
|
||||
bool is_active,
|
||||
const bts::api::admin::LicenseData &license_data,
|
||||
const bts::api::admin::LicenseEntitlements &license_entitlements,
|
||||
bts::api::admin::AdminServiceCreateEntityResult &result) {
|
||||
@@ -1603,8 +1632,10 @@ AdminServiceUtils::security_type(const api::Security &security) {
|
||||
////////////////////////////////////////////
|
||||
|
||||
void add_product_position_limits(
|
||||
bts::api::admin::BTSAccount *to_account, api::Venue venue,
|
||||
api::SecurityType sec_type, uint32_t limit) {
|
||||
bts::api::admin::BTSAccount *to_account,
|
||||
api::Venue venue,
|
||||
api::SecurityType sec_type,
|
||||
uint32_t limit) {
|
||||
std::vector<md::UserSymbol> symbols;
|
||||
md::get_system_md_symbols(venue, sec_type, &symbols);
|
||||
|
||||
@@ -1619,8 +1650,10 @@ void add_product_position_limits(
|
||||
}
|
||||
|
||||
void add_security_clip_sizes_to_account(
|
||||
bts::api::admin::BTSAccount *to_account, api::Venue venue,
|
||||
api::SecurityType sec_type, uint32_t limit) {
|
||||
bts::api::admin::BTSAccount *to_account,
|
||||
api::Venue venue,
|
||||
api::SecurityType sec_type,
|
||||
uint32_t limit) {
|
||||
std::vector<md::UserSymbol> symbols;
|
||||
md::get_system_md_symbols(venue, sec_type, &symbols);
|
||||
|
||||
@@ -1635,7 +1668,8 @@ void add_security_clip_sizes_to_account(
|
||||
}
|
||||
|
||||
void add_security_position_limits(
|
||||
bts::api::admin::BTSAccount *to_account, api::Venue venue,
|
||||
bts::api::admin::BTSAccount *to_account,
|
||||
api::Venue venue,
|
||||
api::SecurityType sec_type) {
|
||||
auto acct_a1_sec_limit = to_account->add_security_position_limits();
|
||||
acct_a1_sec_limit->mutable_security()->set_exchange(venue);
|
||||
@@ -1952,7 +1986,8 @@ bool AdminServiceUtils::is_symbol_set(const std::string &symbol) {
|
||||
return symbol != "*";
|
||||
}
|
||||
void AdminServiceUtils::get_spread_prod_qty(
|
||||
const api::Security &s, std::map<std::string, double> &out_map,
|
||||
const api::Security &s,
|
||||
std::map<std::string, double> &out_map,
|
||||
double mult) {
|
||||
if (s.has_spread())
|
||||
for (const auto &leg : s.spread().legs()) {
|
||||
|
||||
@@ -28,19 +28,24 @@ class AdminServiceUtils {
|
||||
// finds the default connections for an exchange
|
||||
// in a given account
|
||||
static const ExchangeConnection *find_default_account_connection(
|
||||
const AdminData &data, const BTSAccount &account,
|
||||
const AdminData &data,
|
||||
const BTSAccount &account,
|
||||
bts::api::Venue exchange);
|
||||
static const ExchangeConnection *resolve_cme_connection(
|
||||
const AdminData &data, const BTSAccount &account,
|
||||
const AdminData &data,
|
||||
const BTSAccount &account,
|
||||
const api::Security &sec);
|
||||
static const ExchangeConnection *resolve_ice_connection(
|
||||
const AdminData &data, const BTSAccount &account,
|
||||
const AdminData &data,
|
||||
const BTSAccount &account,
|
||||
const api::Security &sec);
|
||||
static const ExchangeConnection *resolve_sim_connection(
|
||||
const AdminData &data, const BTSAccount &account,
|
||||
const AdminData &data,
|
||||
const BTSAccount &account,
|
||||
const api::Security &sec);
|
||||
static const ExchangeConnection *resolve_connection(
|
||||
const AdminData &data, const BTSAccount &account,
|
||||
const AdminData &data,
|
||||
const BTSAccount &account,
|
||||
const bts::api::Security &sec);
|
||||
////////////////////////////////////////////
|
||||
// connection mutators /////////////////////
|
||||
@@ -57,18 +62,21 @@ class AdminServiceUtils {
|
||||
// finds the account from the name and returns
|
||||
// a mutable pointer to the account
|
||||
static BTSAccount *find_account(
|
||||
AdminData &data, const std::string &acct_name,
|
||||
AdminData &data,
|
||||
const std::string &acct_name,
|
||||
bool include_deleted = false);
|
||||
static std::map<std::string, uint32_t>
|
||||
get_clearing_account_map(const AdminData &);
|
||||
|
||||
// finds the account from a clearing account (and its venue)
|
||||
static BTSAccount const *find_account(
|
||||
const AdminData &data, const std::string &clearing_account,
|
||||
const AdminData &data,
|
||||
const std::string &clearing_account,
|
||||
bts::api::Venue);
|
||||
// same as above for const pointer
|
||||
static const BTSAccount *find_account(
|
||||
const AdminData &data, const std::string &acct_name,
|
||||
const AdminData &data,
|
||||
const std::string &acct_name,
|
||||
bool include_deleted = false);
|
||||
// finds the account from the id and returns
|
||||
// a mutable pointer to the account
|
||||
@@ -99,38 +107,51 @@ class AdminServiceUtils {
|
||||
// finds the external/clearing account associated
|
||||
// with an account
|
||||
static std::string find_account_exchange_account(
|
||||
const AdminData &data, const BTSAccount &account, api::Venue exchange,
|
||||
const AdminData &data,
|
||||
const BTSAccount &account,
|
||||
api::Venue exchange,
|
||||
AdminServiceOperationResult &out_result);
|
||||
// returns a map of the accounts vs their 'is_active'
|
||||
static std::map<uint32_t, bool> accounts_map(const AdminData &admin_data);
|
||||
// validates that the update to the account is valid
|
||||
static void validate_account_update(
|
||||
const AdminData &admin_data, const BTSAccount &updated_account,
|
||||
const AdminData &admin_data,
|
||||
const BTSAccount &updated_account,
|
||||
AdminServiceOperationResult &result);
|
||||
// validates that the account exchange changes are valid
|
||||
// (ex > 12 characters for accounts at CME)
|
||||
static void validate_account_exchange_data(
|
||||
const BTSAccount &account, AdminServiceOperationResult &out_result);
|
||||
static RoutingRecord get_routing_record(
|
||||
const AdminData &data, const std::string &account_name,
|
||||
const std::string &user_name, const bts::api::Security &sec,
|
||||
const AdminData &data,
|
||||
const std::string &account_name,
|
||||
const std::string &user_name,
|
||||
const bts::api::Security &sec,
|
||||
AdminServiceOperationResult &out_result);
|
||||
static RoutingRecord get_routing_record(
|
||||
const AdminData &data, uint32_t account_id, uint32_t user_id,
|
||||
const bts::api::Security &sec, AdminServiceOperationResult &out_result);
|
||||
const AdminData &data,
|
||||
uint32_t account_id,
|
||||
uint32_t user_id,
|
||||
const bts::api::Security &sec,
|
||||
AdminServiceOperationResult &out_result);
|
||||
////////////////////////////////////////////
|
||||
// account mutators ////////////////////////
|
||||
////////////////////////////////////////////
|
||||
static BTSAccount *create_account(
|
||||
AdminData &data, uint32_t parent_account_id,
|
||||
const std::string &account_name, const std::string &description,
|
||||
bool is_active, AdminServiceCreateAccountResult &result);
|
||||
AdminData &data,
|
||||
uint32_t parent_account_id,
|
||||
const std::string &account_name,
|
||||
const std::string &description,
|
||||
bool is_active,
|
||||
AdminServiceCreateAccountResult &result);
|
||||
// writes over the account data completely
|
||||
static void update_account(
|
||||
AdminData &data, const BTSAccount &updated_account,
|
||||
AdminData &data,
|
||||
const BTSAccount &updated_account,
|
||||
AdminServiceOperationResult &result);
|
||||
static void delete_account(
|
||||
AdminData &admin_data, const IDAPIArgument &id,
|
||||
AdminData &admin_data,
|
||||
const IDAPIArgument &id,
|
||||
AdminServiceOperationResult &result);
|
||||
static void set_account_exchange_data(
|
||||
BTSAccount *account, const ExchangeAccountData &exchange_data);
|
||||
@@ -165,16 +186,20 @@ class AdminServiceUtils {
|
||||
// group mutators/ /////////////////////////
|
||||
////////////////////////////////////////////
|
||||
static BTSUserGroup *create_group(
|
||||
AdminData &data, uint32_t parent_group_id, const std::string &group_name,
|
||||
AdminData &data,
|
||||
uint32_t parent_group_id,
|
||||
const std::string &group_name,
|
||||
AdminServiceOperationResult &result);
|
||||
////////////////////////////////////////////
|
||||
// user accessors //////////////////////////
|
||||
////////////////////////////////////////////
|
||||
static BTSUser *find_user(
|
||||
AdminData &data, const std::string &user_name,
|
||||
AdminData &data,
|
||||
const std::string &user_name,
|
||||
bool include_deleted = false);
|
||||
static const BTSUser *find_user(
|
||||
const AdminData &data, const std::string &user_name,
|
||||
const AdminData &data,
|
||||
const std::string &user_name,
|
||||
bool include_deleted = false);
|
||||
static BTSUser *
|
||||
find_user(AdminData &data, uint32_t id, bool include_deleted = false);
|
||||
@@ -194,20 +219,26 @@ class AdminServiceUtils {
|
||||
// finds the "exchange user" (ex: "operator_id" at CME or "authorized_trader"
|
||||
// at ICE) for a user
|
||||
static std::string find_user_exchange_id(
|
||||
const AdminData &data, const BTSUser &user, api::Venue exchange,
|
||||
const AdminData &data,
|
||||
const BTSUser &user,
|
||||
api::Venue exchange,
|
||||
AdminServiceOperationResult &out_result);
|
||||
// i. uses the exchange and exchange_user to reverse lookup the user(s)
|
||||
// ii. uses the exchange, connection and exchange_account to reverse lookup
|
||||
// the account(s) iii. finds the first account from ii that a user from i is
|
||||
// authorized to trade
|
||||
static std::string find_user_company_id(
|
||||
const AdminData &data, const BTSUser &user, api::Venue exchange,
|
||||
const AdminData &data,
|
||||
const BTSUser &user,
|
||||
api::Venue exchange,
|
||||
AdminServiceOperationResult &out_result);
|
||||
|
||||
static std::pair<const BTSAccount *, const BTSUser *>
|
||||
find_user_account_matches(
|
||||
const AdminData &admin_data, const std::string &connection,
|
||||
const std::string &exchange_account, const std::string &exchange_user,
|
||||
const AdminData &admin_data,
|
||||
const std::string &connection,
|
||||
const std::string &exchange_account,
|
||||
const std::string &exchange_user,
|
||||
api::Venue exchange);
|
||||
// for a given user finds the account permissions (if permissions are
|
||||
// derived from the group, it traverses the group hierarcy to find the
|
||||
@@ -217,17 +248,20 @@ class AdminServiceUtils {
|
||||
// for a given user, fills in the associated_accounts ref arg
|
||||
// with the accounts the user has permission to trade in
|
||||
static void find_user_trading_accounts(
|
||||
const AdminData &admin_data, uint32_t user_id,
|
||||
const AdminData &admin_data,
|
||||
uint32_t user_id,
|
||||
std::vector<const BTSAccount *> &associated_accounts);
|
||||
// for a given account, fills in the associated_users ref arg
|
||||
// with the users that can trade into the account
|
||||
static void find_users_for_trading_account(
|
||||
const AdminData &admin_data, uint32_t account_id,
|
||||
const AdminData &admin_data,
|
||||
uint32_t account_id,
|
||||
std::vector<const BTSUser *> &associated_users);
|
||||
// validates that changes in user data satisfy all the
|
||||
// constraints
|
||||
static void validate_user_update(
|
||||
const AdminData &admin_data, const BTSUser &updated_user,
|
||||
const AdminData &admin_data,
|
||||
const BTSUser &updated_user,
|
||||
AdminServiceOperationResult &result);
|
||||
// vaidates the exchange part of user data updates
|
||||
static void validate_user_exchange_data(
|
||||
@@ -241,23 +275,30 @@ class AdminServiceUtils {
|
||||
static MDEntitlementReportUnit get_ice_md_entitlement_unit(
|
||||
const BTSUser &user, const ICEMicData &ice_mic_data);
|
||||
static void get_user_symbol_permissions(
|
||||
const AdminData &data, const BTSUser &user,
|
||||
const AdminData &data,
|
||||
const BTSUser &user,
|
||||
std::vector<UserSymbolMDPermissionUnit> &res);
|
||||
////////////////////////////////////////////
|
||||
// user mutators ///////////////////////////
|
||||
////////////////////////////////////////////
|
||||
static BTSUser *create_user(
|
||||
AdminData &data, uint32_t parent_group_id, const std::string &name,
|
||||
const std::string &password, const std::string &full_name,
|
||||
const std::string &company, bool is_active,
|
||||
AdminData &data,
|
||||
uint32_t parent_group_id,
|
||||
const std::string &name,
|
||||
const std::string &password,
|
||||
const std::string &full_name,
|
||||
const std::string &company,
|
||||
bool is_active,
|
||||
const LicenseData &license_data,
|
||||
const LicenseEntitlements &license_entitlements,
|
||||
AdminServiceCreateEntityResult &result);
|
||||
static BTSUser *update_user(
|
||||
AdminData &admin_data, const BTSUser &updated_user,
|
||||
AdminData &admin_data,
|
||||
const BTSUser &updated_user,
|
||||
AdminServiceOperationResult &result);
|
||||
static void delete_user(
|
||||
AdminData &admin_data, const IDAPIArgument &id,
|
||||
AdminData &admin_data,
|
||||
const IDAPIArgument &id,
|
||||
AdminServiceOperationResult &result);
|
||||
static void set_user_exchange_data(
|
||||
BTSUser *user, const ExchangeUserData &exchange_user_data);
|
||||
@@ -308,7 +349,8 @@ class AdminServiceUtils {
|
||||
static bool is_symbol_set(const std::string &symbol);
|
||||
static void bootstrap_data(bts::api::admin::AdminData &data);
|
||||
static void get_spread_prod_qty(
|
||||
const api::Security &s, std::map<std::string, double> &out_map,
|
||||
const api::Security &s,
|
||||
std::map<std::string, double> &out_map,
|
||||
double mult = 1.0);
|
||||
// returns true if this spread effects the position of any outrights
|
||||
static bool residual_pos_spread(const api::Security &s);
|
||||
|
||||
@@ -11,8 +11,14 @@ using namespace bts::api::position;
|
||||
using namespace bts::api::orderman;
|
||||
|
||||
void PositionUtilities::avg_price_qty(
|
||||
double base_p, double base_q, double fill_p, double fill_q, bool is_add,
|
||||
const std::string &fill_id, double &avg_price, double &tot_qty) {
|
||||
double base_p,
|
||||
double base_q,
|
||||
double fill_p,
|
||||
double fill_q,
|
||||
bool is_add,
|
||||
const std::string &fill_id,
|
||||
double &avg_price,
|
||||
double &tot_qty) {
|
||||
if (fill_q < 0) {
|
||||
LOG(OrderMan, Error,
|
||||
"avg_price_qty "
|
||||
@@ -40,8 +46,12 @@ void PositionUtilities::avg_price_qty(
|
||||
}
|
||||
|
||||
void PositionUtilities::apply_fill(
|
||||
PositionEntry &pos, api::Side side, double price, double qty,
|
||||
const std::string &fill_id, bool is_add) {
|
||||
PositionEntry &pos,
|
||||
api::Side side,
|
||||
double price,
|
||||
double qty,
|
||||
const std::string &fill_id,
|
||||
bool is_add) {
|
||||
double tot_avg_price, tot_qty;
|
||||
if (side == api::Side::SIDE_BUY) {
|
||||
avg_price_qty(
|
||||
|
||||
@@ -11,24 +11,37 @@ namespace position {
|
||||
class PositionUtilities {
|
||||
public:
|
||||
static void avg_price_qty(
|
||||
double base_p, double base_q, double fill_p, double fill_q, bool is_add,
|
||||
const std::string &fill_id, double &avg_price, double &tot_qty);
|
||||
|
||||
static void apply_fill(
|
||||
bts::api::position::PositionEntry &pos, api::Side side, double price,
|
||||
double qty, const std::string &fill_id, bool is_add);
|
||||
double base_p,
|
||||
double base_q,
|
||||
double fill_p,
|
||||
double fill_q,
|
||||
bool is_add,
|
||||
const std::string &fill_id,
|
||||
double &avg_price,
|
||||
double &tot_qty);
|
||||
|
||||
static void apply_fill(
|
||||
bts::api::position::PositionEntry &pos,
|
||||
const bts::api::orderman::Fill &fill, bool is_add);
|
||||
api::Side side,
|
||||
double price,
|
||||
double qty,
|
||||
const std::string &fill_id,
|
||||
bool is_add);
|
||||
|
||||
static void apply_fill(
|
||||
bts::api::position::PositionEntry &pos,
|
||||
const bts::api::orderman::Fill &fill,
|
||||
bool is_add);
|
||||
|
||||
static void apply_manual_fill(
|
||||
bts::api::position::PositionEntry &pos,
|
||||
const bts::api::position::ManualFill &mf, bool is_add);
|
||||
const bts::api::position::ManualFill &mf,
|
||||
bool is_add);
|
||||
|
||||
// subsumes p2 into p1
|
||||
static void total_position(
|
||||
const bts::api::position::PositionUnit &p, uint32_t &total_long,
|
||||
const bts::api::position::PositionUnit &p,
|
||||
uint32_t &total_long,
|
||||
uint32_t &total_short);
|
||||
|
||||
static bts::api::position::PositionEntry add_positions(
|
||||
|
||||
@@ -39,7 +39,8 @@ ConfigPropertyEvaluator::ConfigPropertyEvaluator(ConfigurationState &config)
|
||||
ConfigPropertyEvaluator::~ConfigPropertyEvaluator() {}
|
||||
|
||||
void get_field_scalar(
|
||||
const proto::Message &message, const proto::FieldDescriptor *field_desc,
|
||||
const proto::Message &message,
|
||||
const proto::FieldDescriptor *field_desc,
|
||||
Value &out_value) {
|
||||
const proto::Reflection *mirror = message.GetReflection();
|
||||
|
||||
@@ -80,7 +81,8 @@ void get_field_scalar(
|
||||
}
|
||||
|
||||
void get_field_vector(
|
||||
const proto::Message &message, const proto::FieldDescriptor *field_desc,
|
||||
const proto::Message &message,
|
||||
const proto::FieldDescriptor *field_desc,
|
||||
Value &out_value) {
|
||||
const proto::Reflection *mirror = message.GetReflection();
|
||||
size_t field_size = mirror->FieldSize(message, field_desc);
|
||||
@@ -157,7 +159,8 @@ void get_field_vector(
|
||||
|
||||
const proto::Message *lookup_key(
|
||||
std::shared_ptr<expression::ExpressionEvaluator> evaluator,
|
||||
const proto::Message *message, const proto::FieldDescriptor *field,
|
||||
const proto::Message *message,
|
||||
const proto::FieldDescriptor *field,
|
||||
const std::string &search_key) {
|
||||
bts_assert(message);
|
||||
bts_assert(field);
|
||||
|
||||
@@ -33,9 +33,14 @@ void ConfigValueQueue::process() {
|
||||
}
|
||||
|
||||
void ConfigValueQueue::defer_value(
|
||||
proto::Message *msg, const proto::Reflection *reflection,
|
||||
const proto::FieldDescriptor *field, int index, int line, int col,
|
||||
const std::string &source, const std::string &destination,
|
||||
proto::Message *msg,
|
||||
const proto::Reflection *reflection,
|
||||
const proto::FieldDescriptor *field,
|
||||
int index,
|
||||
int line,
|
||||
int col,
|
||||
const std::string &source,
|
||||
const std::string &destination,
|
||||
const proto::Message *root) {
|
||||
|
||||
bts_assert(msg);
|
||||
@@ -126,8 +131,11 @@ void ConfigValueQueue::process_field(const DeferredValue &dv) {
|
||||
|
||||
template <typename TProto, typename TValue>
|
||||
void ConfigValueQueue::assign(
|
||||
proto::Message *message, const proto::Reflection *reflection,
|
||||
const proto::FieldDescriptor *field, const Value &value, int &index) {
|
||||
proto::Message *message,
|
||||
const proto::Reflection *reflection,
|
||||
const proto::FieldDescriptor *field,
|
||||
const Value &value,
|
||||
int &index) {
|
||||
if (value.which() == ValueType::list) {
|
||||
vector<Value> v = boost::get<vector<Value>>(value);
|
||||
if (field->is_repeated()) {
|
||||
@@ -163,8 +171,11 @@ void ConfigValueQueue::assign(
|
||||
|
||||
template <typename TProto, typename TValue>
|
||||
void ConfigValueQueue::lexical_assign(
|
||||
proto::Message *message, const proto::Reflection *reflection,
|
||||
const proto::FieldDescriptor *field, const Value &value, int &index) {
|
||||
proto::Message *message,
|
||||
const proto::Reflection *reflection,
|
||||
const proto::FieldDescriptor *field,
|
||||
const Value &value,
|
||||
int &index) {
|
||||
if (value.which() == ValueType::list) {
|
||||
vector<Value> v = boost::get<vector<Value>>(value);
|
||||
bts_assert(field->is_repeated());
|
||||
@@ -190,8 +201,10 @@ void ConfigValueQueue::lexical_assign(
|
||||
}
|
||||
|
||||
void ConfigValueQueue::assign_value_to_field(
|
||||
proto::Message *message, const proto::Reflection *reflection,
|
||||
const proto::FieldDescriptor *field, const Value &value,
|
||||
proto::Message *message,
|
||||
const proto::Reflection *reflection,
|
||||
const proto::FieldDescriptor *field,
|
||||
const Value &value,
|
||||
int index) throw() {
|
||||
#define MY_ARGS message, reflection, field, value, index
|
||||
|
||||
|
||||
@@ -44,9 +44,14 @@ class ConfigValueQueue : public google::protobuf::IDeferValueLookup {
|
||||
|
||||
// Add a lookup value
|
||||
virtual void defer_value(
|
||||
proto::Message *, const proto::Reflection *reflection,
|
||||
const proto::FieldDescriptor *field, int index, int line, int col,
|
||||
const std::string &value, const std::string &key_name,
|
||||
proto::Message *,
|
||||
const proto::Reflection *reflection,
|
||||
const proto::FieldDescriptor *field,
|
||||
int index,
|
||||
int line,
|
||||
int col,
|
||||
const std::string &value,
|
||||
const std::string &key_name,
|
||||
const proto::Message *root) override;
|
||||
|
||||
void set_filename(const std::string &filename) { _current_file = filename; }
|
||||
@@ -63,28 +68,36 @@ class ConfigValueQueue : public google::protobuf::IDeferValueLookup {
|
||||
void process_field(const DeferredValue &);
|
||||
|
||||
void assign_value_to_field(
|
||||
proto::Message *message, const proto::Reflection *reflection,
|
||||
const proto::FieldDescriptor *field, const expression::Value &value,
|
||||
proto::Message *message,
|
||||
const proto::Reflection *reflection,
|
||||
const proto::FieldDescriptor *field,
|
||||
const expression::Value &value,
|
||||
int insert_index = 0) throw();
|
||||
void bump_indexes(
|
||||
proto::Message *message, const proto::FieldDescriptor *field, int count);
|
||||
|
||||
template <typename TProto, typename TValue>
|
||||
void assign(
|
||||
proto::Message *message, const proto::Reflection *reflection,
|
||||
const proto::FieldDescriptor *field, const expression::Value &value,
|
||||
proto::Message *message,
|
||||
const proto::Reflection *reflection,
|
||||
const proto::FieldDescriptor *field,
|
||||
const expression::Value &value,
|
||||
int &index);
|
||||
|
||||
template <typename TProto, typename TValue>
|
||||
void lexical_assign(
|
||||
proto::Message *message, const proto::Reflection *reflection,
|
||||
const proto::FieldDescriptor *field, const expression::Value &value,
|
||||
proto::Message *message,
|
||||
const proto::Reflection *reflection,
|
||||
const proto::FieldDescriptor *field,
|
||||
const expression::Value &value,
|
||||
int &index);
|
||||
|
||||
template <typename T>
|
||||
void assign(
|
||||
proto::Message *message, const proto::Reflection *reflection,
|
||||
const proto::FieldDescriptor *field, const expression::Value &value,
|
||||
proto::Message *message,
|
||||
const proto::Reflection *reflection,
|
||||
const proto::FieldDescriptor *field,
|
||||
const expression::Value &value,
|
||||
int &index) {
|
||||
assign<T, T>(message, reflection, field, value, index);
|
||||
}
|
||||
|
||||
@@ -453,8 +453,10 @@ int ConfigurationState::load_string(
|
||||
}
|
||||
|
||||
void ConfigurationState::add_metadata_field(
|
||||
proto::FileDescriptorProto *file_dp, proto::DescriptorProto *message_dp,
|
||||
const proto::Descriptor *base_field, int index) {
|
||||
proto::FileDescriptorProto *file_dp,
|
||||
proto::DescriptorProto *message_dp,
|
||||
const proto::Descriptor *base_field,
|
||||
int index) {
|
||||
// Create the metadata message
|
||||
proto::DescriptorProto *meta_message = file_dp->add_message_type();
|
||||
std::string meta_name = base_field->name() + "meta";
|
||||
@@ -775,7 +777,9 @@ inline tuple<string, uint32_t> hostname(const std::string &path) {
|
||||
|
||||
// Loads a single message file or directory
|
||||
bool load_message(
|
||||
std::string url, proto::Message &out_message, IConfigLog &log,
|
||||
std::string url,
|
||||
proto::Message &out_message,
|
||||
IConfigLog &log,
|
||||
ConfigValueQueue &lookup) {
|
||||
ConfigDownloader downloader;
|
||||
|
||||
@@ -801,8 +805,11 @@ bool load_message(
|
||||
}
|
||||
|
||||
int load_directory(
|
||||
std::string url, ConfigDownloader &downloader, proto::Message &out_message,
|
||||
IConfigLog &log, ConfigValueQueue &lookup) {
|
||||
std::string url,
|
||||
ConfigDownloader &downloader,
|
||||
proto::Message &out_message,
|
||||
IConfigLog &log,
|
||||
ConfigValueQueue &lookup) {
|
||||
LogAggregator aggregate_log(log);
|
||||
aggregate_log.info("URL: " + url);
|
||||
|
||||
@@ -872,8 +879,12 @@ int load_directory(
|
||||
}
|
||||
|
||||
ConfigDownloader::Result load_file(
|
||||
std::string path, ConfigDownloader &downloader, proto::Message &out_message,
|
||||
IConfigLog &log, ConfigValueQueue &lookup, bool required) {
|
||||
std::string path,
|
||||
ConfigDownloader &downloader,
|
||||
proto::Message &out_message,
|
||||
IConfigLog &log,
|
||||
ConfigValueQueue &lookup,
|
||||
bool required) {
|
||||
stringstream url_stream;
|
||||
string url = url_from_string(path, required).to_string();
|
||||
ConfigDownloader::Result result = downloader.get(url, url_stream);
|
||||
@@ -891,8 +902,11 @@ ConfigDownloader::Result load_file(
|
||||
}
|
||||
|
||||
void parse_stream(
|
||||
const std::string &file, proto::io::ZeroCopyInputStream &input_stream,
|
||||
proto::Message &out_message, IConfigLog &log, ConfigValueQueue &lookup) {
|
||||
const std::string &file,
|
||||
proto::io::ZeroCopyInputStream &input_stream,
|
||||
proto::Message &out_message,
|
||||
IConfigLog &log,
|
||||
ConfigValueQueue &lookup) {
|
||||
ConfigErrorCollector error_collector(log, file.c_str());
|
||||
bts::google::protobuf::TextFormat::Parser parser;
|
||||
parser.RecordErrorsTo(&error_collector);
|
||||
|
||||
@@ -79,8 +79,10 @@ class ConfigurationState {
|
||||
void initialize_macros();
|
||||
void add_macro(const proto::Message *);
|
||||
void add_metadata_field(
|
||||
proto::FileDescriptorProto *file_dp, proto::DescriptorProto *message_dp,
|
||||
const proto::Descriptor *base_field, int index);
|
||||
proto::FileDescriptorProto *file_dp,
|
||||
proto::DescriptorProto *message_dp,
|
||||
const proto::Descriptor *base_field,
|
||||
int index);
|
||||
void generate_all_config_proto(IConfigLog &);
|
||||
const proto::Message *try_get_value(
|
||||
const std::string &field_name, const proto::Message &message) const;
|
||||
@@ -117,17 +119,29 @@ PathType::type get_path_type(std::string path);
|
||||
// Loads a file or directory and merges the values into one Message.
|
||||
// Caller is responsible for processing includes
|
||||
bool load_message(
|
||||
std::string url, proto::Message &out_message, IConfigLog &,
|
||||
std::string url,
|
||||
proto::Message &out_message,
|
||||
IConfigLog &,
|
||||
ConfigValueQueue &);
|
||||
int load_directory(
|
||||
std::string url, ConfigDownloader &, proto::Message &out_message,
|
||||
IConfigLog &, ConfigValueQueue &);
|
||||
std::string url,
|
||||
ConfigDownloader &,
|
||||
proto::Message &out_message,
|
||||
IConfigLog &,
|
||||
ConfigValueQueue &);
|
||||
ConfigDownloader::Result load_file(
|
||||
std::string url, ConfigDownloader &, proto::Message &out_message,
|
||||
IConfigLog &, ConfigValueQueue &, bool required = true);
|
||||
std::string url,
|
||||
ConfigDownloader &,
|
||||
proto::Message &out_message,
|
||||
IConfigLog &,
|
||||
ConfigValueQueue &,
|
||||
bool required = true);
|
||||
void parse_stream(
|
||||
const std::string &file, proto::io::ZeroCopyInputStream &stream,
|
||||
proto::Message &out_message, IConfigLog &, ConfigValueQueue &lookup);
|
||||
const std::string &file,
|
||||
proto::io::ZeroCopyInputStream &stream,
|
||||
proto::Message &out_message,
|
||||
IConfigLog &,
|
||||
ConfigValueQueue &lookup);
|
||||
|
||||
} // namespace internal
|
||||
} // namespace config
|
||||
|
||||
@@ -20,7 +20,8 @@ unsigned int HTTPServer::port() const {
|
||||
}
|
||||
|
||||
void HTTPServer::add_response(
|
||||
const std::string &path, const std::string &response,
|
||||
const std::string &path,
|
||||
const std::string &response,
|
||||
const std::string &content) {
|
||||
_request_response_pairs[path] = response + content;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,8 @@ class HTTPServer {
|
||||
|
||||
void start();
|
||||
void add_response(
|
||||
const std::string &path, const std::string &response,
|
||||
const std::string &path,
|
||||
const std::string &response,
|
||||
const std::string &content);
|
||||
void stop();
|
||||
|
||||
|
||||
@@ -196,7 +196,9 @@ inline string ToUpper(const string &s) {
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
LIBPROTOBUF_EXPORT string StringReplace(
|
||||
const string &s, const string &oldsub, const string &newsub,
|
||||
const string &s,
|
||||
const string &oldsub,
|
||||
const string &newsub,
|
||||
bool replace_all);
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
@@ -692,20 +694,44 @@ StrCat(const AlphaNum &a, const AlphaNum &b, const AlphaNum &c);
|
||||
LIBPROTOBUF_EXPORT string StrCat(
|
||||
const AlphaNum &a, const AlphaNum &b, const AlphaNum &c, const AlphaNum &d);
|
||||
LIBPROTOBUF_EXPORT string StrCat(
|
||||
const AlphaNum &a, const AlphaNum &b, const AlphaNum &c, const AlphaNum &d,
|
||||
const AlphaNum &a,
|
||||
const AlphaNum &b,
|
||||
const AlphaNum &c,
|
||||
const AlphaNum &d,
|
||||
const AlphaNum &e);
|
||||
LIBPROTOBUF_EXPORT string StrCat(
|
||||
const AlphaNum &a, const AlphaNum &b, const AlphaNum &c, const AlphaNum &d,
|
||||
const AlphaNum &e, const AlphaNum &f);
|
||||
const AlphaNum &a,
|
||||
const AlphaNum &b,
|
||||
const AlphaNum &c,
|
||||
const AlphaNum &d,
|
||||
const AlphaNum &e,
|
||||
const AlphaNum &f);
|
||||
LIBPROTOBUF_EXPORT string StrCat(
|
||||
const AlphaNum &a, const AlphaNum &b, const AlphaNum &c, const AlphaNum &d,
|
||||
const AlphaNum &e, const AlphaNum &f, const AlphaNum &g);
|
||||
const AlphaNum &a,
|
||||
const AlphaNum &b,
|
||||
const AlphaNum &c,
|
||||
const AlphaNum &d,
|
||||
const AlphaNum &e,
|
||||
const AlphaNum &f,
|
||||
const AlphaNum &g);
|
||||
LIBPROTOBUF_EXPORT string StrCat(
|
||||
const AlphaNum &a, const AlphaNum &b, const AlphaNum &c, const AlphaNum &d,
|
||||
const AlphaNum &e, const AlphaNum &f, const AlphaNum &g, const AlphaNum &h);
|
||||
const AlphaNum &a,
|
||||
const AlphaNum &b,
|
||||
const AlphaNum &c,
|
||||
const AlphaNum &d,
|
||||
const AlphaNum &e,
|
||||
const AlphaNum &f,
|
||||
const AlphaNum &g,
|
||||
const AlphaNum &h);
|
||||
LIBPROTOBUF_EXPORT string StrCat(
|
||||
const AlphaNum &a, const AlphaNum &b, const AlphaNum &c, const AlphaNum &d,
|
||||
const AlphaNum &e, const AlphaNum &f, const AlphaNum &g, const AlphaNum &h,
|
||||
const AlphaNum &a,
|
||||
const AlphaNum &b,
|
||||
const AlphaNum &c,
|
||||
const AlphaNum &d,
|
||||
const AlphaNum &e,
|
||||
const AlphaNum &f,
|
||||
const AlphaNum &g,
|
||||
const AlphaNum &h,
|
||||
const AlphaNum &i);
|
||||
|
||||
inline string StrCat(const AlphaNum &a) { return string(a.data(), a.size()); }
|
||||
@@ -737,7 +763,10 @@ StrAppend(string *dest, const AlphaNum &a, const AlphaNum &b);
|
||||
LIBPROTOBUF_EXPORT void StrAppend(
|
||||
string *dest, const AlphaNum &a, const AlphaNum &b, const AlphaNum &c);
|
||||
LIBPROTOBUF_EXPORT void StrAppend(
|
||||
string *dest, const AlphaNum &a, const AlphaNum &b, const AlphaNum &c,
|
||||
string *dest,
|
||||
const AlphaNum &a,
|
||||
const AlphaNum &b,
|
||||
const AlphaNum &c,
|
||||
const AlphaNum &d);
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
@@ -825,7 +854,10 @@ LIBPROTOBUF_EXPORT int CalculateBase64EscapedLen(int input_len);
|
||||
LIBPROTOBUF_EXPORT int
|
||||
Base64Escape(const unsigned char *src, int slen, char *dest, int szdest);
|
||||
LIBPROTOBUF_EXPORT int WebSafeBase64Escape(
|
||||
const unsigned char *src, int slen, char *dest, int szdest,
|
||||
const unsigned char *src,
|
||||
int slen,
|
||||
char *dest,
|
||||
int szdest,
|
||||
bool do_padding);
|
||||
// Encode src into dest with padding.
|
||||
LIBPROTOBUF_EXPORT void Base64Escape(StringPiece src, string *dest);
|
||||
|
||||
@@ -98,7 +98,8 @@ class TextFormat::Parser::ParserImpl {
|
||||
ParserImpl(
|
||||
const Descriptor *root_message_type,
|
||||
io::ZeroCopyInputStream *input_stream,
|
||||
io::ErrorCollector *error_collector, IDeferValueLookup *lookup,
|
||||
io::ErrorCollector *error_collector,
|
||||
IDeferValueLookup *lookup,
|
||||
TextFormat::Finder *finder,
|
||||
SingularOverwritePolicy singular_overwrite_policy)
|
||||
: error_collector_(error_collector), lookup_(lookup), finder_(finder),
|
||||
@@ -362,7 +363,8 @@ class TextFormat::Parser::ParserImpl {
|
||||
|
||||
// Handle BTS deferred values
|
||||
bool TryConsumeDeferredValue(
|
||||
Message *message, const Reflection *reflection,
|
||||
Message *message,
|
||||
const Reflection *reflection,
|
||||
const FieldDescriptor *field) {
|
||||
if (lookup_) {
|
||||
string token;
|
||||
@@ -388,7 +390,8 @@ class TextFormat::Parser::ParserImpl {
|
||||
}
|
||||
|
||||
bool ConsumeFieldMessage(
|
||||
Message *message, const Reflection *reflection,
|
||||
Message *message,
|
||||
const Reflection *reflection,
|
||||
const FieldDescriptor *field) {
|
||||
location_.push_back(&field->name());
|
||||
if (TryConsumeDeferredValue(message, reflection, field)) {
|
||||
@@ -420,7 +423,8 @@ class TextFormat::Parser::ParserImpl {
|
||||
}
|
||||
|
||||
bool ConsumeFieldValue(
|
||||
Message *message, const Reflection *reflection,
|
||||
Message *message,
|
||||
const Reflection *reflection,
|
||||
const FieldDescriptor *field) {
|
||||
|
||||
location_.push_back(&field->name());
|
||||
@@ -1052,7 +1056,9 @@ void TextFormat::Printer::Print(
|
||||
}
|
||||
|
||||
void TextFormat::Printer::PrintFieldValueToString(
|
||||
const Message &message, const FieldDescriptor *field, int index,
|
||||
const Message &message,
|
||||
const FieldDescriptor *field,
|
||||
int index,
|
||||
string *output) const {
|
||||
|
||||
GOOGLE_DCHECK(output) << "output specified is NULL";
|
||||
@@ -1065,8 +1071,10 @@ void TextFormat::Printer::PrintFieldValueToString(
|
||||
}
|
||||
|
||||
void TextFormat::Printer::PrintField(
|
||||
const Message &message, const Reflection *reflection,
|
||||
const FieldDescriptor *field, TextGenerator &generator) const {
|
||||
const Message &message,
|
||||
const Reflection *reflection,
|
||||
const FieldDescriptor *field,
|
||||
TextGenerator &generator) const {
|
||||
if (use_short_repeated_primitives_ && field->is_repeated() &&
|
||||
field->cpp_type() != FieldDescriptor::CPPTYPE_STRING &&
|
||||
field->cpp_type() != FieldDescriptor::CPPTYPE_MESSAGE) {
|
||||
@@ -1122,8 +1130,10 @@ void TextFormat::Printer::PrintField(
|
||||
}
|
||||
|
||||
void TextFormat::Printer::PrintShortRepeatedField(
|
||||
const Message &message, const Reflection *reflection,
|
||||
const FieldDescriptor *field, TextGenerator &generator) const {
|
||||
const Message &message,
|
||||
const Reflection *reflection,
|
||||
const FieldDescriptor *field,
|
||||
TextGenerator &generator) const {
|
||||
// Print primitive repeated field in short form.
|
||||
PrintFieldName(message, reflection, field, generator);
|
||||
|
||||
@@ -1142,7 +1152,9 @@ void TextFormat::Printer::PrintShortRepeatedField(
|
||||
}
|
||||
|
||||
void TextFormat::Printer::PrintFieldName(
|
||||
const Message &, const Reflection *, const FieldDescriptor *field,
|
||||
const Message &,
|
||||
const Reflection *,
|
||||
const FieldDescriptor *field,
|
||||
TextGenerator &generator) const {
|
||||
if (field->is_extension()) {
|
||||
generator.Print("[");
|
||||
@@ -1167,8 +1179,11 @@ void TextFormat::Printer::PrintFieldName(
|
||||
}
|
||||
|
||||
void TextFormat::Printer::PrintFieldValue(
|
||||
const Message &message, const Reflection *reflection,
|
||||
const FieldDescriptor *field, int index, TextGenerator &generator) const {
|
||||
const Message &message,
|
||||
const Reflection *reflection,
|
||||
const FieldDescriptor *field,
|
||||
int index,
|
||||
TextGenerator &generator) const {
|
||||
GOOGLE_DCHECK(field->is_repeated() || (index == -1))
|
||||
<< "Index must be -1 for non-repeated fields";
|
||||
|
||||
@@ -1257,7 +1272,9 @@ TextFormat::PrintToString(const Message &message, string *output) {
|
||||
}
|
||||
|
||||
/* static */ void TextFormat::PrintFieldValueToString(
|
||||
const Message &message, const FieldDescriptor *field, int index,
|
||||
const Message &message,
|
||||
const FieldDescriptor *field,
|
||||
int index,
|
||||
string *output) {
|
||||
return Printer().PrintFieldValueToString(message, field, index, output);
|
||||
}
|
||||
|
||||
@@ -70,9 +70,15 @@ class IDeferValueLookup {
|
||||
public:
|
||||
virtual ~IDeferValueLookup(){};
|
||||
virtual void defer_value(
|
||||
Message *, const Reflection *reflection, const FieldDescriptor *field,
|
||||
int index, int line, int col, const std::string &value,
|
||||
const std::string &key_name, const Message *root) = 0;
|
||||
Message *,
|
||||
const Reflection *reflection,
|
||||
const FieldDescriptor *field,
|
||||
int index,
|
||||
int line,
|
||||
int col,
|
||||
const std::string &value,
|
||||
const std::string &key_name,
|
||||
const Message *root) = 0;
|
||||
};
|
||||
|
||||
// This class implements protocol buffer text format. Printing and parsing
|
||||
@@ -104,7 +110,9 @@ class TextFormat {
|
||||
// be supplied. Note that this method will print the default value for a
|
||||
// field if it is not set.
|
||||
static void PrintFieldValueToString(
|
||||
const Message &message, const FieldDescriptor *field, int index,
|
||||
const Message &message,
|
||||
const FieldDescriptor *field,
|
||||
int index,
|
||||
string *output);
|
||||
|
||||
// Class for those users which require more fine-grained control over how
|
||||
@@ -128,7 +136,9 @@ class TextFormat {
|
||||
const UnknownFieldSet &unknown_fields, string *output) const;
|
||||
// Like TextFormat::PrintFieldValueToString
|
||||
void PrintFieldValueToString(
|
||||
const Message &message, const FieldDescriptor *field, int index,
|
||||
const Message &message,
|
||||
const FieldDescriptor *field,
|
||||
int index,
|
||||
string *output) const;
|
||||
|
||||
// Adjust the initial indent level of all output. Each indent level is
|
||||
@@ -171,25 +181,33 @@ class TextFormat {
|
||||
|
||||
// Print a single field.
|
||||
void PrintField(
|
||||
const Message &message, const Reflection *reflection,
|
||||
const FieldDescriptor *field, TextGenerator &generator) const;
|
||||
const Message &message,
|
||||
const Reflection *reflection,
|
||||
const FieldDescriptor *field,
|
||||
TextGenerator &generator) const;
|
||||
|
||||
// Print a repeated primitive field in short form.
|
||||
void PrintShortRepeatedField(
|
||||
const Message &message, const Reflection *reflection,
|
||||
const FieldDescriptor *field, TextGenerator &generator) const;
|
||||
const Message &message,
|
||||
const Reflection *reflection,
|
||||
const FieldDescriptor *field,
|
||||
TextGenerator &generator) const;
|
||||
|
||||
// Print the name of a field -- i.e. everything that comes before the
|
||||
// ':' for a single name/value pair.
|
||||
void PrintFieldName(
|
||||
const Message &message, const Reflection *reflection,
|
||||
const FieldDescriptor *field, TextGenerator &generator) const;
|
||||
const Message &message,
|
||||
const Reflection *reflection,
|
||||
const FieldDescriptor *field,
|
||||
TextGenerator &generator) const;
|
||||
|
||||
// Outputs a textual representation of the value of the field supplied on
|
||||
// the message supplied or the default value if not set.
|
||||
void PrintFieldValue(
|
||||
const Message &message, const Reflection *reflection,
|
||||
const FieldDescriptor *field, int index,
|
||||
const Message &message,
|
||||
const Reflection *reflection,
|
||||
const FieldDescriptor *field,
|
||||
int index,
|
||||
TextGenerator &generator) const;
|
||||
|
||||
// Print the fields in an UnknownFieldSet. They are printed by tag number
|
||||
@@ -284,7 +302,8 @@ class TextFormat {
|
||||
// Like TextFormat::Merge(). The provided implementation is used
|
||||
// to do the parsing.
|
||||
bool MergeUsingImpl(
|
||||
io::ZeroCopyInputStream *input, Message *output,
|
||||
io::ZeroCopyInputStream *input,
|
||||
Message *output,
|
||||
ParserImpl *parser_impl);
|
||||
|
||||
io::ErrorCollector *error_collector_;
|
||||
|
||||
@@ -80,7 +80,9 @@ boost::gregorian::date expiration(api::Security const &security) {
|
||||
}
|
||||
|
||||
bool is_expired(
|
||||
api::Security const &security, datetime::PTime const &now, uint32_t sod_hh,
|
||||
api::Security const &security,
|
||||
datetime::PTime const &now,
|
||||
uint32_t sod_hh,
|
||||
uint32_t sod_mm) {
|
||||
auto e = expiration(security);
|
||||
if (e == boost::gregorian::date())
|
||||
|
||||
@@ -218,7 +218,9 @@ bool is_expired(api::Security const &security);
|
||||
// for testing
|
||||
bool is_expired(api::Security const &security, datetime::PTime const &now);
|
||||
bool is_expired(
|
||||
api::Security const &security, datetime::PTime const &now, uint32_t sod_hh,
|
||||
api::Security const &security,
|
||||
datetime::PTime const &now,
|
||||
uint32_t sod_hh,
|
||||
uint32_t sod_mm);
|
||||
|
||||
inline Price tick_size(api::Security const &sec) {
|
||||
|
||||
@@ -122,7 +122,8 @@ bool ExpressionEvaluatorImpl::check_valid(
|
||||
}
|
||||
|
||||
bool ExpressionEvaluatorImpl::parse(
|
||||
std::string::const_iterator &begin, const std::string::const_iterator &end,
|
||||
std::string::const_iterator &begin,
|
||||
const std::string::const_iterator &end,
|
||||
sp::utree &ast) const {
|
||||
// We reference a grammar defined elsewhere for compile time performance
|
||||
bool result = qi::phrase_parse(
|
||||
|
||||
@@ -18,7 +18,11 @@ struct ValueType {
|
||||
};
|
||||
|
||||
typedef boost::make_recursive_variant<
|
||||
bool, int, double, std::string, std::vector<boost::recursive_variant_>,
|
||||
bool,
|
||||
int,
|
||||
double,
|
||||
std::string,
|
||||
std::vector<boost::recursive_variant_>,
|
||||
void *>::type Value;
|
||||
|
||||
bool value_to_bool(const Value &val);
|
||||
|
||||
@@ -90,8 +90,11 @@ class FIXEncodingStream {
|
||||
|
||||
struct MessageDesc {
|
||||
MessageDesc(
|
||||
uint32_t offset, uint32_t header_offset, uint32_t size,
|
||||
uint32_t checksum, uint32_t seq_num,
|
||||
uint32_t offset,
|
||||
uint32_t header_offset,
|
||||
uint32_t size,
|
||||
uint32_t checksum,
|
||||
uint32_t seq_num,
|
||||
FIXFragment::Bookmark<fix::Checksum> checksum_bm)
|
||||
: offset(offset), header_offset(header_offset), size(size),
|
||||
checksum(checksum), seq_num(seq_num), checksum_bm(checksum_bm) {}
|
||||
|
||||
@@ -143,13 +143,26 @@ typedef BigIntField<9706> MifidClientIDCode;
|
||||
typedef BigIntField<9707> MifidId;
|
||||
|
||||
typedef Group<
|
||||
NoQuoteEntries, QuoteEntryID, Symbol, SecurityType, SecurityDesc,
|
||||
SecurityID, SecurityIDSource, TransactTime, BidPx, OfferPx, BidSize,
|
||||
OfferSize, QuoteEntryRejectReason>
|
||||
NoQuoteEntries,
|
||||
QuoteEntryID,
|
||||
Symbol,
|
||||
SecurityType,
|
||||
SecurityDesc,
|
||||
SecurityID,
|
||||
SecurityIDSource,
|
||||
TransactTime,
|
||||
BidPx,
|
||||
OfferPx,
|
||||
BidSize,
|
||||
OfferSize,
|
||||
QuoteEntryRejectReason>
|
||||
QuoteEntries;
|
||||
|
||||
typedef Group<
|
||||
NoQuoteSets, QuoteSetID, UnderlyingSecurityDesc, TotQuoteEntries,
|
||||
NoQuoteSets,
|
||||
QuoteSetID,
|
||||
UnderlyingSecurityDesc,
|
||||
TotQuoteEntries,
|
||||
QuoteEntries>
|
||||
QuoteSets;
|
||||
|
||||
|
||||
@@ -10,16 +10,45 @@ namespace jetfix {
|
||||
namespace fix {
|
||||
|
||||
typedef FIXMsg<
|
||||
MessageTypes::QuoteAck, QuoteAckStatus, QuoteID, UnsolicitedCancelType,
|
||||
QuoteRejectReason, Text, QuoteSets>
|
||||
MessageTypes::QuoteAck,
|
||||
QuoteAckStatus,
|
||||
QuoteID,
|
||||
UnsolicitedCancelType,
|
||||
QuoteRejectReason,
|
||||
Text,
|
||||
QuoteSets>
|
||||
QuoteAcknowledgementMsg;
|
||||
|
||||
typedef FIXMsg<
|
||||
MessageTypes::ExecutionReport, Account, ExecType, ClOrdID, Side, OrderID,
|
||||
TimeInForce, LastPx, AvgPx, Price, StopPx, LastShares, CumQty, LeavesQty,
|
||||
ExecID, ExecRefID, ManualOrderIndicator, OrdType, OrdStatus, OrderQty,
|
||||
MaxShow, SecurityID, MultiLegReportingType, SecurityDesc, Text, TargetSubID,
|
||||
MsgSeqNum, TransactTimeStr, CustOrderHandlingInst>
|
||||
MessageTypes::ExecutionReport,
|
||||
Account,
|
||||
ExecType,
|
||||
ClOrdID,
|
||||
Side,
|
||||
OrderID,
|
||||
TimeInForce,
|
||||
LastPx,
|
||||
AvgPx,
|
||||
Price,
|
||||
StopPx,
|
||||
LastShares,
|
||||
CumQty,
|
||||
LeavesQty,
|
||||
ExecID,
|
||||
ExecRefID,
|
||||
ManualOrderIndicator,
|
||||
OrdType,
|
||||
OrdStatus,
|
||||
OrderQty,
|
||||
MaxShow,
|
||||
SecurityID,
|
||||
MultiLegReportingType,
|
||||
SecurityDesc,
|
||||
Text,
|
||||
TargetSubID,
|
||||
MsgSeqNum,
|
||||
TransactTimeStr,
|
||||
CustOrderHandlingInst>
|
||||
ExecutionReportMsg;
|
||||
|
||||
typedef FIXMsg<MessageTypes::BusinessMessageReject, Text>
|
||||
@@ -28,8 +57,16 @@ typedef FIXMsg<MessageTypes::BusinessMessageReject, Text>
|
||||
typedef FIXMsg<MessageTypes::Reject, Text> RejectMsg;
|
||||
|
||||
typedef FIXMsg<
|
||||
MessageTypes::CancelReject, Account, ClOrdID, ExecID, CXlRejReason, Text,
|
||||
OrderID, OrigClOrdID, SecurityDesc, CorrelationClOrdID>
|
||||
MessageTypes::CancelReject,
|
||||
Account,
|
||||
ClOrdID,
|
||||
ExecID,
|
||||
CXlRejReason,
|
||||
Text,
|
||||
OrderID,
|
||||
OrigClOrdID,
|
||||
SecurityDesc,
|
||||
CorrelationClOrdID>
|
||||
CancelRejectMsg;
|
||||
|
||||
typedef FIXMsg<MessageTypes::ICETraderLoginResponse, CompanyID, UserName, Text>
|
||||
@@ -39,16 +76,46 @@ typedef FIXMsg<MessageTypes::ICETraderLogoutResponse, CompanyID, UserName, Text>
|
||||
ICETraderLogoutResponseMsg;
|
||||
|
||||
typedef FIXMsg<
|
||||
MessageTypes::ExecutionReport, Int_OrderID, Int_ClOrdID, CompanyID, ExecID,
|
||||
ExecRefID, ExecType, OrdStatus, OrdRejReason, Int_Symbol, Side, OrderQty,
|
||||
MaxShow, OrdType, Price, StopPx, TimeInForce, LeavesQty, CumQty, AvgPx,
|
||||
LastPx, LastShares, TransactTimeStr, MultiLegReportingType, ClearingAccount,
|
||||
Memo, Text, DeleteReason, TargetSubID, MsgSeqNum>
|
||||
MessageTypes::ExecutionReport,
|
||||
Int_OrderID,
|
||||
Int_ClOrdID,
|
||||
CompanyID,
|
||||
ExecID,
|
||||
ExecRefID,
|
||||
ExecType,
|
||||
OrdStatus,
|
||||
OrdRejReason,
|
||||
Int_Symbol,
|
||||
Side,
|
||||
OrderQty,
|
||||
MaxShow,
|
||||
OrdType,
|
||||
Price,
|
||||
StopPx,
|
||||
TimeInForce,
|
||||
LeavesQty,
|
||||
CumQty,
|
||||
AvgPx,
|
||||
LastPx,
|
||||
LastShares,
|
||||
TransactTimeStr,
|
||||
MultiLegReportingType,
|
||||
ClearingAccount,
|
||||
Memo,
|
||||
Text,
|
||||
DeleteReason,
|
||||
TargetSubID,
|
||||
MsgSeqNum>
|
||||
ICEExecutionReportMsg;
|
||||
|
||||
typedef FIXMsg<
|
||||
MessageTypes::CancelReject, Int_OrderID, Int_ClOrdID, Int_OrigClOrdID,
|
||||
CXlRejReason, Text, Memo>
|
||||
MessageTypes::CancelReject,
|
||||
Int_OrderID,
|
||||
Int_ClOrdID,
|
||||
Int_OrigClOrdID,
|
||||
CXlRejReason,
|
||||
Text,
|
||||
Memo>
|
||||
ICECancelRejectMsg;
|
||||
|
||||
} // namespace fix
|
||||
|
||||
@@ -8,7 +8,10 @@
|
||||
namespace bts {
|
||||
|
||||
inline int d_toa(
|
||||
double n, char *buffer, size_t buffer_size, int decimal_digits = -1,
|
||||
double n,
|
||||
char *buffer,
|
||||
size_t buffer_size,
|
||||
int decimal_digits = -1,
|
||||
int pad = -1) {
|
||||
static double_conversion::DoubleToStringConverter const &c =
|
||||
double_conversion::DoubleToStringConverter::EcmaScriptConverter();
|
||||
|
||||
@@ -18,7 +18,9 @@ namespace jetfix {
|
||||
// location in a vector InMsgBuffer. Returns how many bytes were
|
||||
// successfully framed.
|
||||
size_t extract(
|
||||
char *start, char *end, std::shared_ptr<std::string> const &buffer,
|
||||
char *start,
|
||||
char *end,
|
||||
std::shared_ptr<std::string> const &buffer,
|
||||
std::vector<InMsgBuffer> *msgs) {
|
||||
auto first_unprocessed_byte = 0;
|
||||
auto current = start;
|
||||
@@ -64,8 +66,11 @@ size_t extract(
|
||||
|
||||
struct AsyncReader::PImpl {
|
||||
PImpl(
|
||||
IConnection &connection, std::string const &connection_name,
|
||||
ICoreGatewayEventSink &sink, trace::PerfLog &l, size_t buffer_sz,
|
||||
IConnection &connection,
|
||||
std::string const &connection_name,
|
||||
ICoreGatewayEventSink &sink,
|
||||
trace::PerfLog &l,
|
||||
size_t buffer_sz,
|
||||
size_t high_water_mark)
|
||||
: connection(connection),
|
||||
working_buffer(std::make_shared<std::string>(buffer_sz, 0)),
|
||||
@@ -101,8 +106,11 @@ struct AsyncReader::PImpl {
|
||||
};
|
||||
|
||||
AsyncReader::AsyncReader(
|
||||
IConnection &connection, std::string const &connection_name,
|
||||
ICoreGatewayEventSink &sink, trace::PerfLog &log, size_t buffer_sz,
|
||||
IConnection &connection,
|
||||
std::string const &connection_name,
|
||||
ICoreGatewayEventSink &sink,
|
||||
trace::PerfLog &log,
|
||||
size_t buffer_sz,
|
||||
size_t high_water_mark)
|
||||
: me(new PImpl(
|
||||
connection, connection_name, sink, log, buffer_sz, high_water_mark)) {
|
||||
|
||||
@@ -16,8 +16,10 @@ class ICoreGatewayEventSink;
|
||||
class AsyncReader {
|
||||
public:
|
||||
AsyncReader(
|
||||
IConnection &connection, std::string const &connection_name,
|
||||
ICoreGatewayEventSink &sink, trace::PerfLog &l,
|
||||
IConnection &connection,
|
||||
std::string const &connection_name,
|
||||
ICoreGatewayEventSink &sink,
|
||||
trace::PerfLog &l,
|
||||
size_t buffer_sz, // initial buffer size to use
|
||||
size_t high_water_mark); // when do we allocate a new buffer
|
||||
void start();
|
||||
|
||||
@@ -89,8 +89,10 @@ struct CoreGateway::EventData {
|
||||
|
||||
struct CoreGateway::PImpl {
|
||||
PImpl(
|
||||
config::JetFIX::Connection const &cfg, ICoreGatewayObserver &observer,
|
||||
ConnectionFactory const &conn_factory, StoreFactory const &store_factory,
|
||||
config::JetFIX::Connection const &cfg,
|
||||
ICoreGatewayObserver &observer,
|
||||
ConnectionFactory const &conn_factory,
|
||||
StoreFactory const &store_factory,
|
||||
trace::PerfLog &l)
|
||||
: cfg(cfg), observer(observer), make_connection(conn_factory),
|
||||
make_store(store_factory), state(State::OFF), start_of_pause(),
|
||||
@@ -127,8 +129,10 @@ std::thread CoreGateway::make_timer_thread() {
|
||||
}
|
||||
|
||||
CoreGateway::CoreGateway(
|
||||
config::JetFIX::Connection const &cfg, ICoreGatewayObserver &observer,
|
||||
ConnectionFactory const &conn_factory, StoreFactory const &store_factory,
|
||||
config::JetFIX::Connection const &cfg,
|
||||
ICoreGatewayObserver &observer,
|
||||
ConnectionFactory const &conn_factory,
|
||||
StoreFactory const &store_factory,
|
||||
trace::PerfLog &perf_trace)
|
||||
: me(new PImpl(cfg, observer, conn_factory, store_factory, perf_trace)) {
|
||||
me->timer_thread = make_timer_thread();
|
||||
|
||||
@@ -27,8 +27,10 @@ class CoreGateway : ICoreGatewayEventSink {
|
||||
StoreFactory;
|
||||
|
||||
CoreGateway(
|
||||
config::JetFIX::Connection const &cfg, ICoreGatewayObserver &observer,
|
||||
ConnectionFactory const &conn_factory, StoreFactory const &store_factory,
|
||||
config::JetFIX::Connection const &cfg,
|
||||
ICoreGatewayObserver &observer,
|
||||
ConnectionFactory const &conn_factory,
|
||||
StoreFactory const &store_factory,
|
||||
trace::PerfLog &);
|
||||
|
||||
~CoreGateway();
|
||||
|
||||
@@ -23,7 +23,8 @@ template <typename... Messages> class JetFIXGateway : ICoreGatewayObserver {
|
||||
public:
|
||||
JetFIXGateway(config::JetFIX::Connection const &cfg, trace::PerfLog &log)
|
||||
: _core(
|
||||
cfg, *this,
|
||||
cfg,
|
||||
*this,
|
||||
|
||||
[&log](config::JetFIX::Connection const &cfg) {
|
||||
return new SocketConnection(cfg, log);
|
||||
|
||||
@@ -24,8 +24,10 @@ namespace bts {
|
||||
namespace jetfix {
|
||||
|
||||
OutFIXPtr make_logon(
|
||||
uint32_t seq_num, uint32_t last_seq_num_processed,
|
||||
std::string const &time_str, config::JetFIX::Connection const &session_cfg);
|
||||
uint32_t seq_num,
|
||||
uint32_t last_seq_num_processed,
|
||||
std::string const &time_str,
|
||||
config::JetFIX::Connection const &session_cfg);
|
||||
|
||||
OutFIXPtr make_logout(config::JetFIX::Connection const &session_cfg);
|
||||
OutFIXPtr make_resend_request(
|
||||
@@ -57,8 +59,11 @@ struct Session::RecoveryState {
|
||||
|
||||
struct Session::PImpl {
|
||||
PImpl(
|
||||
config::JetFIX::Connection const &cfg, IConnection &connection,
|
||||
IFIXStore &store, ICoreGatewayEventSink &sink, Clock const &clock,
|
||||
config::JetFIX::Connection const &cfg,
|
||||
IConnection &connection,
|
||||
IFIXStore &store,
|
||||
ICoreGatewayEventSink &sink,
|
||||
Clock const &clock,
|
||||
trace::PerfLog &perf_log)
|
||||
: cfg(cfg), state(State::TERMINATED), connection(connection),
|
||||
store(store), event_sink(sink), now(clock), perf_log(perf_log),
|
||||
@@ -89,8 +94,11 @@ struct Session::PImpl {
|
||||
};
|
||||
|
||||
Session::Session(
|
||||
config::JetFIX::Connection const &cfg, IConnection &connection,
|
||||
IFIXStore &store, ICoreGatewayEventSink &sink, Clock const &clock,
|
||||
config::JetFIX::Connection const &cfg,
|
||||
IConnection &connection,
|
||||
IFIXStore &store,
|
||||
ICoreGatewayEventSink &sink,
|
||||
Clock const &clock,
|
||||
trace::PerfLog &perf_log)
|
||||
: me(new PImpl(cfg, connection, store, sink, clock, perf_log)) {}
|
||||
|
||||
@@ -773,7 +781,8 @@ const char *Session::state_name(State state) {
|
||||
}
|
||||
|
||||
OutFIXPtr make_logon(
|
||||
uint32_t seq_num, uint32_t last_seq_num_processed,
|
||||
uint32_t seq_num,
|
||||
uint32_t last_seq_num_processed,
|
||||
std::string const &time_str,
|
||||
config::JetFIX::Connection const &session_cfg) {
|
||||
auto result = std::make_shared<OutFIX>(session_cfg);
|
||||
|
||||
@@ -26,8 +26,11 @@ class Session {
|
||||
typedef std::function<utils::TimeStamp()> Clock;
|
||||
|
||||
Session(
|
||||
config::JetFIX::Connection const &cfg, IConnection &connection,
|
||||
IFIXStore &store, ICoreGatewayEventSink &sink, Clock const &clock,
|
||||
config::JetFIX::Connection const &cfg,
|
||||
IConnection &connection,
|
||||
IFIXStore &store,
|
||||
ICoreGatewayEventSink &sink,
|
||||
Clock const &clock,
|
||||
trace::PerfLog &perf_log);
|
||||
~Session();
|
||||
|
||||
|
||||
@@ -103,7 +103,8 @@ std::string seqnum_path(std::string const &base_path) {
|
||||
}
|
||||
|
||||
std::string store_path(
|
||||
std::string base_path, std::string const &connection_name,
|
||||
std::string base_path,
|
||||
std::string const &connection_name,
|
||||
std::string const &session_name) {
|
||||
if (base_path.empty())
|
||||
base_path = os::bts_data_path();
|
||||
@@ -164,14 +165,16 @@ void save_fix(
|
||||
}
|
||||
|
||||
void save_seq_nums(
|
||||
std::string const &path, uint32_t last_seq_num,
|
||||
std::string const &path,
|
||||
uint32_t last_seq_num,
|
||||
uint32_t last_seq_num_processed) {
|
||||
std::ofstream f(path);
|
||||
f << last_seq_num << " " << last_seq_num_processed << std::endl;
|
||||
}
|
||||
|
||||
void load_seq_nums(
|
||||
std::string const &path, uint32_t *last_seq_num,
|
||||
std::string const &path,
|
||||
uint32_t *last_seq_num,
|
||||
uint32_t *last_seq_num_processed) {
|
||||
if (boost::filesystem::exists(path)) {
|
||||
std::ifstream f(path);
|
||||
|
||||
@@ -20,7 +20,8 @@ boost::gregorian::greg_weekday parse_weekday(std::string weekday_str) {
|
||||
}
|
||||
|
||||
datetime::PTime closest_before(
|
||||
datetime::PTime const &ref_date, boost::gregorian::greg_weekday weekday,
|
||||
datetime::PTime const &ref_date,
|
||||
boost::gregorian::greg_weekday weekday,
|
||||
boost::posix_time::time_duration time_of_day) {
|
||||
if (ref_date.date().day_of_week() == weekday) {
|
||||
if (time_of_day < ref_date.time_of_day())
|
||||
@@ -65,7 +66,8 @@ bool in_session(
|
||||
}
|
||||
|
||||
SessionName session_name_from_ptime(
|
||||
datetime::PTime t, boost::posix_time::time_duration time_of_day_start,
|
||||
datetime::PTime t,
|
||||
boost::posix_time::time_duration time_of_day_start,
|
||||
boost::posix_time::time_duration time_of_day_end) {
|
||||
SessionName result;
|
||||
result.as_string = std::string(10, ' ');
|
||||
|
||||
@@ -20,7 +20,8 @@ namespace jetfix {
|
||||
boost::gregorian::greg_weekday parse_weekday(std::string weekday_str);
|
||||
|
||||
datetime::PTime closest_before(
|
||||
datetime::PTime const &ref_date, boost::gregorian::greg_weekday weekday,
|
||||
datetime::PTime const &ref_date,
|
||||
boost::gregorian::greg_weekday weekday,
|
||||
boost::posix_time::time_duration time_of_day);
|
||||
|
||||
bool in_session(
|
||||
|
||||
@@ -17,7 +17,9 @@ class Logger {
|
||||
Logger &operator=(const Logger &) = delete;
|
||||
|
||||
Logger(
|
||||
size_t tid, Filter const &f, size_t initial_queue_size,
|
||||
size_t tid,
|
||||
Filter const &f,
|
||||
size_t initial_queue_size,
|
||||
size_t max_queue_growth)
|
||||
: _mutex(), _read_q(&_queue_b), _write_q(&_queue_a), _wcursor(0),
|
||||
_filter(f), _drop_count(0), _queue_a(initial_queue_size),
|
||||
@@ -36,8 +38,13 @@ class Logger {
|
||||
|
||||
template <typename... Args>
|
||||
bool enqueue(
|
||||
uint64_t ts, Subsystem subsystem, Level lv, const char *file, int line,
|
||||
const char *msg_template, Args &&... msg_args) {
|
||||
uint64_t ts,
|
||||
Subsystem subsystem,
|
||||
Level lv,
|
||||
const char *file,
|
||||
int line,
|
||||
const char *msg_template,
|
||||
Args &&... msg_args) {
|
||||
assert(_active);
|
||||
lock();
|
||||
if (_wcursor == _write_q->size())
|
||||
@@ -63,8 +70,13 @@ class Logger {
|
||||
|
||||
template <typename... Args>
|
||||
bool enqueue_once_maybe(
|
||||
uint64_t ts, Subsystem subsystem, Level lv, const char *file, int line,
|
||||
const char *msg_template, Args &&... msg_args) {
|
||||
uint64_t ts,
|
||||
Subsystem subsystem,
|
||||
Level lv,
|
||||
const char *file,
|
||||
int line,
|
||||
const char *msg_template,
|
||||
Args &&... msg_args) {
|
||||
const size_t filter_size = 1024 * 8; // 1kb
|
||||
static std::vector<bool> s_bloom(filter_size);
|
||||
auto arg_hash = aggregate_hash(msg_args...);
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "lib/utils/bts_chrono.h"
|
||||
#include "Common.h"
|
||||
#include "Logger.h"
|
||||
#include "LoggerHub.h"
|
||||
#include "lib/utils/Dispatcher.h"
|
||||
#include "lib/utils/bts_chrono.h"
|
||||
#include <atomic>
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include <thread>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#include "catch/catch.hpp"
|
||||
#include "lib/config/config.h"
|
||||
#include "lib/config/protos/logging.pb.h"
|
||||
#include "lib/logging/logging.h"
|
||||
#include "lib/utils/bts_chrono.h"
|
||||
#include "lib/logging/logging.h"
|
||||
|
||||
namespace bts {
|
||||
int logging_tests;
|
||||
@@ -22,8 +22,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}", bts::Timer::now());
|
||||
auto stop = bts::Timer::now();
|
||||
LOG(Gen, Info, "Hello World. It is now: {0}", Timer::now());
|
||||
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));
|
||||
}
|
||||
|
||||
@@ -30,8 +30,12 @@ struct Entry {
|
||||
};
|
||||
|
||||
std::string print_book(
|
||||
PrintFormat format, const Entry &e, utils::TimeStamp twrite,
|
||||
utils::TimeStamp tread, uint32_t seq, bool ambiguous,
|
||||
PrintFormat format,
|
||||
const Entry &e,
|
||||
utils::TimeStamp twrite,
|
||||
utils::TimeStamp tread,
|
||||
uint32_t seq,
|
||||
bool ambiguous,
|
||||
const std::array<PriceSize, COCONUT_MAX_DEPTH> &bid,
|
||||
const std::array<PriceSize, COCONUT_MAX_DEPTH> &ask) {
|
||||
|
||||
@@ -161,7 +165,9 @@ void write_header(
|
||||
}
|
||||
|
||||
void run_periodic_dumper(
|
||||
const std::set<UserSymbol> &symbols, uint32_t seq_mod, PrintFormat format,
|
||||
const std::set<UserSymbol> &symbols,
|
||||
uint32_t seq_mod,
|
||||
PrintFormat format,
|
||||
bool monitor_all) {
|
||||
|
||||
auto qualifier = config::get<config::System>().qualifier();
|
||||
|
||||
@@ -8,7 +8,9 @@ namespace md {
|
||||
enum class PrintFormat { Human, CSV };
|
||||
|
||||
void run_periodic_dumper(
|
||||
const std::set<UserSymbol> &, uint32_t seq_mod, PrintFormat format,
|
||||
const std::set<UserSymbol> &,
|
||||
uint32_t seq_mod,
|
||||
PrintFormat format,
|
||||
bool monitor_all);
|
||||
|
||||
} // namespace md
|
||||
|
||||
@@ -65,9 +65,9 @@ void print_pool_stats(const utils::ConcurrentPool<MBOSnapshot> &pool) {
|
||||
count, bid_percentiles.str(), ask_percentiles.str());
|
||||
}
|
||||
|
||||
typedef tbb::concurrent_hash_map<
|
||||
SecurityKey, MBOSnapshot *, SecurityKeyHashCompare>
|
||||
MapType;
|
||||
typedef tbb::
|
||||
concurrent_hash_map<SecurityKey, MBOSnapshot *, SecurityKeyHashCompare>
|
||||
MapType;
|
||||
struct Incremental {
|
||||
MBOWorkingState *state;
|
||||
inc::Update update;
|
||||
@@ -250,7 +250,8 @@ void copy_to_snapshot(MBOWorkingState &state, MBOSnapshot *dest) {
|
||||
|
||||
template <class C>
|
||||
void apply_incremental(
|
||||
uint32_t security_key, C &collection,
|
||||
uint32_t security_key,
|
||||
C &collection,
|
||||
std::unordered_map<ExchangeOrderKey, MBOWorkingState::key_t> &index,
|
||||
const inc::Update &update) {
|
||||
auto key = std::make_tuple(update.price, update.priority);
|
||||
|
||||
@@ -109,7 +109,9 @@ class ActiveOrder {
|
||||
|
||||
struct MBOServiceImpl {
|
||||
MBOServiceImpl(
|
||||
api::ServiceContext &ctx, utils::Dispatcher &d, md::MDClient &c,
|
||||
api::ServiceContext &ctx,
|
||||
utils::Dispatcher &d,
|
||||
md::MDClient &c,
|
||||
MBOServiceBase::PiqPublisher &&pub)
|
||||
: dispatcher(d), client(c),
|
||||
orders(ctx.locate<api::orderman::OrderService>()), handle_index(c),
|
||||
@@ -211,7 +213,8 @@ bool is_active_exchange_order(const OrderRecord &record) {
|
||||
}
|
||||
|
||||
void try_remove(
|
||||
MBOServiceImpl &me, std::set<uint32_t> &to_remove,
|
||||
MBOServiceImpl &me,
|
||||
std::set<uint32_t> &to_remove,
|
||||
const OrderRecord &record) {
|
||||
auto key = SparkOrderKey(record.key());
|
||||
auto iter = me.active.find(key);
|
||||
@@ -221,7 +224,8 @@ void try_remove(
|
||||
}
|
||||
}
|
||||
void try_add(
|
||||
MBOServiceImpl &me, std::vector<OrderPIQ> &to_add,
|
||||
MBOServiceImpl &me,
|
||||
std::vector<OrderPIQ> &to_add,
|
||||
const OrderRecord &record) {
|
||||
if (is_active_exchange_order(record)) {
|
||||
auto native = native_order_state(record);
|
||||
|
||||
@@ -21,7 +21,9 @@ struct MDClientImpl {
|
||||
utils::Event<MDConsumer> _event;
|
||||
|
||||
MDClientImpl(
|
||||
utils::Dispatcher *d, api::ISyntheticSecurityService *s, MBOReader *mbo,
|
||||
utils::Dispatcher *d,
|
||||
api::ISyntheticSecurityService *s,
|
||||
MBOReader *mbo,
|
||||
const std::set<UserSymbol> *symbols)
|
||||
: _dispatcher(d), _ss(s), _security_timer(), _recovery_timer(),
|
||||
_symbols(symbols ? *symbols : get_system_md_symbols()), _mbo(mbo),
|
||||
@@ -69,7 +71,9 @@ struct MDClientImpl {
|
||||
};
|
||||
|
||||
MDClient::MDClient(
|
||||
utils::Dispatcher *d, api::ISyntheticSecurityService *s, MBOReader *mbo,
|
||||
utils::Dispatcher *d,
|
||||
api::ISyntheticSecurityService *s,
|
||||
MBOReader *mbo,
|
||||
const std::set<UserSymbol> *symbols)
|
||||
: _self(new MDClientImpl(d, s, mbo, symbols)) {}
|
||||
|
||||
|
||||
@@ -21,7 +21,8 @@ class MDClient {
|
||||
// Will check for recovery
|
||||
MDClient(
|
||||
utils::Dispatcher *d = nullptr,
|
||||
api::ISyntheticSecurityService *ss = nullptr, MBOReader *mbo = nullptr,
|
||||
api::ISyntheticSecurityService *ss = nullptr,
|
||||
MBOReader *mbo = nullptr,
|
||||
const std::set<UserSymbol> *s = nullptr);
|
||||
~MDClient();
|
||||
|
||||
|
||||
@@ -75,7 +75,10 @@ bool is_heart_beat_ok(const ColdHeader &);
|
||||
class MDConsumerInst {
|
||||
public:
|
||||
MDConsumerInst(
|
||||
const string &symbol, SecurityType type, Venue exchange, bool shared,
|
||||
const string &symbol,
|
||||
SecurityType type,
|
||||
Venue exchange,
|
||||
bool shared,
|
||||
co2::Platform platform)
|
||||
: _symbol(symbol), _type(type), _exchange(exchange),
|
||||
_platform(
|
||||
@@ -99,7 +102,8 @@ class MDConsumerInst {
|
||||
|
||||
template <typename CB>
|
||||
size_t walk_sec_list(
|
||||
CB cb, const string &symbol = "",
|
||||
CB cb,
|
||||
const string &symbol = "",
|
||||
SecurityType type = SECURITYTYPE_UNSET) {
|
||||
size_t result = 0;
|
||||
_cold.all_entries([&symbol, type, &cb, &result](const ColdEntry &entry) {
|
||||
@@ -572,8 +576,11 @@ class MDConsumerImpl {
|
||||
|
||||
public:
|
||||
MDConsumerImpl(
|
||||
const set<UserSymbol> &symbols, SecurityCache &cache,
|
||||
api::ISyntheticSecurityService *ss, MBOReader *mbo, bool shared,
|
||||
const set<UserSymbol> &symbols,
|
||||
SecurityCache &cache,
|
||||
api::ISyntheticSecurityService *ss,
|
||||
MBOReader *mbo,
|
||||
bool shared,
|
||||
co2::Platform platform)
|
||||
: _workmutex(), _instances(), _sci(), _mbo(mbo), _deferred_handles(),
|
||||
_callbacks(), _cache(cache) {
|
||||
@@ -991,8 +998,12 @@ class MDConsumerImpl {
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
MDConsumer::MDConsumer(
|
||||
SecurityCache &cache, api::ISyntheticSecurityService *ss, MBOReader *mbo,
|
||||
const std::set<UserSymbol> *symbols, bool shared, co2::Platform platform)
|
||||
SecurityCache &cache,
|
||||
api::ISyntheticSecurityService *ss,
|
||||
MBOReader *mbo,
|
||||
const std::set<UserSymbol> *symbols,
|
||||
bool shared,
|
||||
co2::Platform platform)
|
||||
: _pimpl() {
|
||||
|
||||
set<UserSymbol> all_symbols;
|
||||
|
||||
@@ -32,9 +32,12 @@ class MBOReader;
|
||||
class MDConsumer {
|
||||
public:
|
||||
MDConsumer(
|
||||
SecurityCache &, api::ISyntheticSecurityService *ss,
|
||||
MBOReader *mbo = nullptr, const std::set<UserSymbol> *sym = nullptr,
|
||||
bool shared = true, co2::Platform platform = co2::PLATFORM_UNSET);
|
||||
SecurityCache &,
|
||||
api::ISyntheticSecurityService *ss,
|
||||
MBOReader *mbo = nullptr,
|
||||
const std::set<UserSymbol> *sym = nullptr,
|
||||
bool shared = true,
|
||||
co2::Platform platform = co2::PLATFORM_UNSET);
|
||||
~MDConsumer();
|
||||
|
||||
bool all_heartbeats_ok() const;
|
||||
@@ -47,7 +50,8 @@ class MDConsumer {
|
||||
|
||||
// Walk the entire available security list
|
||||
size_t walk_security_list(
|
||||
SecurityCallback callback, const std::string &symbol = "",
|
||||
SecurityCallback callback,
|
||||
const std::string &symbol = "",
|
||||
SecurityType type = api::SECURITYTYPE_UNSET);
|
||||
|
||||
// scan the security list for changes
|
||||
|
||||
@@ -35,7 +35,9 @@ MDConsumerHandle::MDConsumerHandle(const MDConsumerHandle &other) {
|
||||
}
|
||||
|
||||
MDConsumerHandle::MDConsumerHandle(
|
||||
const ColdHeader &cheader, const ColdEntry ¢ry, const void *pvhot,
|
||||
const ColdHeader &cheader,
|
||||
const ColdEntry ¢ry,
|
||||
const void *pvhot,
|
||||
const MBOReader *mbo) {
|
||||
init(cheader, centry, pvhot, mbo);
|
||||
}
|
||||
@@ -43,7 +45,9 @@ MDConsumerHandle::MDConsumerHandle(
|
||||
MDConsumerHandle::~MDConsumerHandle() {}
|
||||
|
||||
void MDConsumerHandle::init(
|
||||
const ColdHeader &cheader, const ColdEntry ¢ry, const void *pvhot,
|
||||
const ColdHeader &cheader,
|
||||
const ColdEntry ¢ry,
|
||||
const void *pvhot,
|
||||
const MBOReader *mbo) {
|
||||
set_cold(&cheader, ¢ry);
|
||||
set_hot(pvhot);
|
||||
@@ -106,7 +110,10 @@ struct DepthTraversal {
|
||||
api::Side side;
|
||||
double qty, price_mult;
|
||||
DepthTraversal(
|
||||
api::Side side, double qty, double price_mult, const PriceSize *depth,
|
||||
api::Side side,
|
||||
double qty,
|
||||
double price_mult,
|
||||
const PriceSize *depth,
|
||||
size_t depth_count)
|
||||
: levels(), head(0), side(side), qty(qty), price_mult(price_mult) {
|
||||
// Copy prices into mutable storage
|
||||
@@ -186,8 +193,11 @@ struct DepthTraversal {
|
||||
};
|
||||
|
||||
void copy_synthetic_side(
|
||||
size_t count, api::Side side, const api::ContractSpecification &spec,
|
||||
small_vector<DepthTraversal> &leg_travs, Level *out_price) {
|
||||
size_t count,
|
||||
api::Side side,
|
||||
const api::ContractSpecification &spec,
|
||||
small_vector<DepthTraversal> &leg_travs,
|
||||
Level *out_price) {
|
||||
size_t out_index = 0;
|
||||
bool first = true;
|
||||
while (out_index < count) {
|
||||
@@ -256,7 +266,9 @@ get_spreader_params(const SyntheticStrategy &synth, security_key key) {
|
||||
}
|
||||
|
||||
TimeStamp copy_synthetic_depth(
|
||||
const SyntheticStrategy &synth, size_t count, PriceSize *bid,
|
||||
const SyntheticStrategy &synth,
|
||||
size_t count,
|
||||
PriceSize *bid,
|
||||
PriceSize *ask) {
|
||||
small_vector<DepthTraversal> bid_leg_travs;
|
||||
small_vector<DepthTraversal> ask_leg_travs;
|
||||
@@ -323,8 +335,11 @@ TimeStamp copy_synthetic_depth(
|
||||
/////////////////////////////
|
||||
|
||||
bool MDConsumerHandle::get_last_trade(
|
||||
TimeStamp &time, PriceSize &trade, datetime::LLDateTime &trade_timestamp,
|
||||
size_t *total_volume, int *from_spread) const {
|
||||
TimeStamp &time,
|
||||
PriceSize &trade,
|
||||
datetime::LLDateTime &trade_timestamp,
|
||||
size_t *total_volume,
|
||||
int *from_spread) const {
|
||||
switch (_type) {
|
||||
case HANDLETYPE_VOID:
|
||||
return false;
|
||||
|
||||
@@ -111,7 +111,10 @@ inline void read_combined(
|
||||
|
||||
template <class Read>
|
||||
TimeStamp optimistic_copy(
|
||||
Read read, const HotDepthEntry &hot, size_t count, PriceSize *bid,
|
||||
Read read,
|
||||
const HotDepthEntry &hot,
|
||||
size_t count,
|
||||
PriceSize *bid,
|
||||
PriceSize *ask) {
|
||||
TimeStamp t;
|
||||
int attempts = 0;
|
||||
@@ -141,11 +144,15 @@ class BTS_EXPORT MDConsumerHandle {
|
||||
~MDConsumerHandle();
|
||||
MDConsumerHandle(const MDConsumerHandle &other);
|
||||
MDConsumerHandle(
|
||||
const ColdHeader &, const ColdEntry &, const void *hot,
|
||||
const ColdHeader &,
|
||||
const ColdEntry &,
|
||||
const void *hot,
|
||||
const MBOReader *);
|
||||
|
||||
void init(
|
||||
const ColdHeader &, const ColdEntry &, const void *hot,
|
||||
const ColdHeader &,
|
||||
const ColdEntry &,
|
||||
const void *hot,
|
||||
const MBOReader *);
|
||||
|
||||
bool is_initialized() const { return _type != HANDLETYPE_VOID; }
|
||||
@@ -281,25 +288,33 @@ class BTS_EXPORT MDConsumerHandle {
|
||||
}
|
||||
|
||||
HandleReadResult get_direct_book(
|
||||
TimeStamp &time, uint32_t copydepth, PriceSize *bids,
|
||||
TimeStamp &time,
|
||||
uint32_t copydepth,
|
||||
PriceSize *bids,
|
||||
PriceSize *asks) const {
|
||||
return get_book(read_direct, time, copydepth, bids, asks);
|
||||
}
|
||||
HandleReadResult get_implied_book(
|
||||
TimeStamp &time, uint32_t copydepth, PriceSize *bids,
|
||||
TimeStamp &time,
|
||||
uint32_t copydepth,
|
||||
PriceSize *bids,
|
||||
PriceSize *asks) const {
|
||||
return get_book(read_implied, time, copydepth, bids, asks);
|
||||
}
|
||||
HandleReadResult get_book(
|
||||
TimeStamp &time, uint32_t copydepth, PriceSize *bids,
|
||||
TimeStamp &time,
|
||||
uint32_t copydepth,
|
||||
PriceSize *bids,
|
||||
PriceSize *asks) const {
|
||||
return get_book(read_combined, time, copydepth, bids, asks);
|
||||
}
|
||||
|
||||
bool get_last_trade(
|
||||
TimeStamp &time, PriceSize &out_trade,
|
||||
TimeStamp &time,
|
||||
PriceSize &out_trade,
|
||||
datetime::LLDateTime &out_trade_timestamp,
|
||||
size_t *total_volume = nullptr, int *from_spread = nullptr) const;
|
||||
size_t *total_volume = nullptr,
|
||||
int *from_spread = nullptr) const;
|
||||
|
||||
IntPrice settlement_price() const {
|
||||
switch (_type) {
|
||||
@@ -344,7 +359,10 @@ class BTS_EXPORT MDConsumerHandle {
|
||||
private:
|
||||
template <class Read>
|
||||
HandleReadResult get_book(
|
||||
Read read, TimeStamp &time, uint32_t copydepth, PriceSize *bids,
|
||||
Read read,
|
||||
TimeStamp &time,
|
||||
uint32_t copydepth,
|
||||
PriceSize *bids,
|
||||
PriceSize *asks) const {
|
||||
bts_assert_d(copydepth <= COCONUT_MAX_DEPTH);
|
||||
if (!is_initialized() || copydepth == 0)
|
||||
|
||||
@@ -88,7 +88,10 @@ CAPI void md_consumer_scan_securities(MDConsumer *consumer) {
|
||||
|
||||
#ifdef _WIN32
|
||||
void safe_call_clr_callback(
|
||||
security_cb cb, security_key key, const char *buffer, size_t buffer_size,
|
||||
security_cb cb,
|
||||
security_key key,
|
||||
const char *buffer,
|
||||
size_t buffer_size,
|
||||
MDConsumerHandle &handle) {
|
||||
// Protect against clr shutting down
|
||||
__try {
|
||||
@@ -118,7 +121,9 @@ CAPI bool md_consumer_is_heart_beating(const ColdHeader *header) {
|
||||
|
||||
typedef void (*raw_receive_pb)(const char *, size_t);
|
||||
CAPI int md_consumer_read_trades(
|
||||
MDConsumer *consumer, BlitUserSymbol &symbol, int64_t &cursor,
|
||||
MDConsumer *consumer,
|
||||
BlitUserSymbol &symbol,
|
||||
int64_t &cursor,
|
||||
raw_receive_pb cb) {
|
||||
bts_assert(consumer);
|
||||
google::protobuf::Arena arena;
|
||||
@@ -136,7 +141,9 @@ CAPI int md_consumer_read_trades(
|
||||
return 0;
|
||||
}
|
||||
CAPI int md_consumer_read_rfqs(
|
||||
MDConsumer *consumer, BlitUserSymbol &symbol, int64_t &cursor,
|
||||
MDConsumer *consumer,
|
||||
BlitUserSymbol &symbol,
|
||||
int64_t &cursor,
|
||||
raw_receive_pb cb) {
|
||||
bts_assert(consumer);
|
||||
google::protobuf::Arena arena;
|
||||
|
||||
@@ -16,8 +16,11 @@ namespace md {
|
||||
class MDProducerImpl {
|
||||
public:
|
||||
MDProducerImpl(
|
||||
const string &symbol, SecurityType type, Venue exchange,
|
||||
Platform platform, MDProducerFlags flags)
|
||||
const string &symbol,
|
||||
SecurityType type,
|
||||
Venue exchange,
|
||||
Platform platform,
|
||||
MDProducerFlags flags)
|
||||
: _symbol(symbol), _type(type), _exchange(exchange),
|
||||
_hot(
|
||||
hot_segment_name(symbol, type, exchange, platform),
|
||||
@@ -31,10 +34,12 @@ class MDProducerImpl {
|
||||
flags & MDProducerFlags::Shared),
|
||||
_trades(
|
||||
_cold.header().trade_buffer,
|
||||
BTS_ARRAYSIZE(_cold.header().trade_buffer), true),
|
||||
BTS_ARRAYSIZE(_cold.header().trade_buffer),
|
||||
true),
|
||||
_rfqs(
|
||||
_cold.header().rfq_buffer,
|
||||
BTS_ARRAYSIZE(_cold.header().rfq_buffer), true) {
|
||||
BTS_ARRAYSIZE(_cold.header().rfq_buffer),
|
||||
true) {
|
||||
// NOTE: Block sizes have been tuned based on sim.
|
||||
// We should monitor and adjust based on production use for optimal
|
||||
// performance
|
||||
|
||||
@@ -42,7 +42,8 @@ class BTS_EXPORT MDProducer {
|
||||
MDProducer(
|
||||
Platform platform, MDProducerFlags flags = DefaultMDProducerFlags);
|
||||
MDProducer(
|
||||
Platform platform, SecurityIDRecorder recorder,
|
||||
Platform platform,
|
||||
SecurityIDRecorder recorder,
|
||||
MDProducerFlags flags = DefaultMDProducerFlags);
|
||||
MDProducer(MDProducer &&other);
|
||||
~MDProducer();
|
||||
|
||||
@@ -8,7 +8,10 @@ using namespace datetime;
|
||||
using namespace co2;
|
||||
|
||||
MDProducerHandle::MDProducerHandle(
|
||||
ColdHeader &cheader, HotHeader &hheader, ColdEntry ¢ry, void *phot,
|
||||
ColdHeader &cheader,
|
||||
HotHeader &hheader,
|
||||
ColdEntry ¢ry,
|
||||
void *phot,
|
||||
MDProducerChannel channel)
|
||||
: _hdata(phot), _hheader(&hheader), _cdata(¢ry), _cheader(&cheader),
|
||||
_channel(channel) {}
|
||||
@@ -94,8 +97,12 @@ void MDProducerHandle::set_status(CoconutSecurityStatus status) {
|
||||
}
|
||||
|
||||
void MDProducerHandle::add_trade(
|
||||
TimeStamp time, const PriceSize price, LLDateTime tradetime,
|
||||
co2::AggressorSide agside, uint32_t volume, bool from_spread) {
|
||||
TimeStamp time,
|
||||
const PriceSize price,
|
||||
LLDateTime tradetime,
|
||||
co2::AggressorSide agside,
|
||||
uint32_t volume,
|
||||
bool from_spread) {
|
||||
// Add this trade to the last trade if price/side match
|
||||
auto current = std::get<PriceSize>(cdata().last_trade.load());
|
||||
if (current.int_price() == price.int_price()) {
|
||||
@@ -123,8 +130,11 @@ void MDProducerHandle::add_trade(
|
||||
}
|
||||
}
|
||||
void MDProducerHandle::set_last_trade(
|
||||
TimeStamp time, const PriceSize ps, datetime::LLDateTime tradetime,
|
||||
uint32_t total_volume, bool from_spread) {
|
||||
TimeStamp time,
|
||||
const PriceSize ps,
|
||||
datetime::LLDateTime tradetime,
|
||||
uint32_t total_volume,
|
||||
bool from_spread) {
|
||||
cdata().last_trade.store(ps, time);
|
||||
cdata().last_trade_time = tradetime;
|
||||
cdata().from_spread = (from_spread ? 1 : 0);
|
||||
|
||||
@@ -18,7 +18,10 @@ namespace md {
|
||||
class BTS_EXPORT MDProducerHandle {
|
||||
public:
|
||||
MDProducerHandle(
|
||||
ColdHeader &, HotHeader &, ColdEntry &, void *hot,
|
||||
ColdHeader &,
|
||||
HotHeader &,
|
||||
ColdEntry &,
|
||||
void *hot,
|
||||
MDProducerChannel channel);
|
||||
~MDProducerHandle();
|
||||
|
||||
@@ -38,11 +41,15 @@ class BTS_EXPORT MDProducerHandle {
|
||||
}
|
||||
|
||||
void update_bbo(
|
||||
TimeStamp time, const PriceSize bid_price, const PriceSize ask_price,
|
||||
TimeStamp time,
|
||||
const PriceSize bid_price,
|
||||
const PriceSize ask_price,
|
||||
uint16_t seq = 0);
|
||||
void update_direct(
|
||||
TimeStamp time, const std::array<PriceSize, COCONUT_MAX_DEPTH> &bids,
|
||||
const std::array<PriceSize, COCONUT_MAX_DEPTH> &asks, uint32_t seq = 0) {
|
||||
TimeStamp time,
|
||||
const std::array<PriceSize, COCONUT_MAX_DEPTH> &bids,
|
||||
const std::array<PriceSize, COCONUT_MAX_DEPTH> &asks,
|
||||
uint32_t seq = 0) {
|
||||
if (!has_depth()) {
|
||||
update_bbo(time, bids[0], asks[0], seq);
|
||||
} else {
|
||||
@@ -77,7 +84,8 @@ class BTS_EXPORT MDProducerHandle {
|
||||
}
|
||||
|
||||
void update_books(
|
||||
TimeStamp time, const std::array<PriceSize, COCONUT_MAX_DEPTH> &bid,
|
||||
TimeStamp time,
|
||||
const std::array<PriceSize, COCONUT_MAX_DEPTH> &bid,
|
||||
const std::array<PriceSize, COCONUT_MAX_DEPTH> &ask,
|
||||
const std::array<PriceSize, COCONUT_MAX_IMPLIED_DEPTH> &implied_bid,
|
||||
const std::array<PriceSize, COCONUT_MAX_IMPLIED_DEPTH> &implied_ask,
|
||||
@@ -104,13 +112,19 @@ class BTS_EXPORT MDProducerHandle {
|
||||
|
||||
// Updates trade log and last trade
|
||||
void add_trade(
|
||||
TimeStamp time, const PriceSize pricesize, datetime::LLDateTime date,
|
||||
co2::AggressorSide agside, uint32_t total_volume = 0,
|
||||
TimeStamp time,
|
||||
const PriceSize pricesize,
|
||||
datetime::LLDateTime date,
|
||||
co2::AggressorSide agside,
|
||||
uint32_t total_volume = 0,
|
||||
bool from_spread = false); // cold
|
||||
// Update last_trade without updating trade log
|
||||
void set_last_trade(
|
||||
TimeStamp time, const PriceSize ps, datetime::LLDateTime date,
|
||||
uint32_t total_volume = 0, bool from_spread = false);
|
||||
TimeStamp time,
|
||||
const PriceSize ps,
|
||||
datetime::LLDateTime date,
|
||||
uint32_t total_volume = 0,
|
||||
bool from_spread = false);
|
||||
void set_total_volume(uint32_t total_volume);
|
||||
void add_rfq(TimeStamp time, const co2::QuoteRequestMessage &rfq); // cold
|
||||
|
||||
|
||||
@@ -15,7 +15,9 @@ bool enable_depth(const string &, SecurityType) {
|
||||
}
|
||||
|
||||
string segment_name(
|
||||
const string &symbol, SecurityType type, Venue exchange,
|
||||
const string &symbol,
|
||||
SecurityType type,
|
||||
Venue exchange,
|
||||
Platform platform) {
|
||||
return "bts_edge_" +
|
||||
config::get<md::PublisherNamespace>().shared_memory_namespace() +
|
||||
@@ -24,12 +26,16 @@ string segment_name(
|
||||
}
|
||||
|
||||
std::string hot_segment_name(
|
||||
const std::string &symbol, SecurityType type, Venue exchange,
|
||||
const std::string &symbol,
|
||||
SecurityType type,
|
||||
Venue exchange,
|
||||
Platform platform) {
|
||||
return segment_name(symbol, type, exchange, platform) + "_hot";
|
||||
}
|
||||
std::string cold_segment_name(
|
||||
const std::string &symbol, SecurityType type, Venue exchange,
|
||||
const std::string &symbol,
|
||||
SecurityType type,
|
||||
Venue exchange,
|
||||
Platform platform) {
|
||||
return segment_name(symbol, type, exchange, platform) + "_cold";
|
||||
}
|
||||
|
||||
@@ -7,13 +7,19 @@ namespace md {
|
||||
|
||||
bool enable_depth(const std::string &symbol, SecurityType type);
|
||||
std::string segment_name(
|
||||
const std::string &symbol, SecurityType type, Venue exchange,
|
||||
const std::string &symbol,
|
||||
SecurityType type,
|
||||
Venue exchange,
|
||||
Platform platform);
|
||||
std::string hot_segment_name(
|
||||
const std::string &symbol, SecurityType type, Venue exchange,
|
||||
const std::string &symbol,
|
||||
SecurityType type,
|
||||
Venue exchange,
|
||||
Platform platform);
|
||||
std::string cold_segment_name(
|
||||
const std::string &symbol, SecurityType type, Venue exchange,
|
||||
const std::string &symbol,
|
||||
SecurityType type,
|
||||
Venue exchange,
|
||||
Platform platform);
|
||||
|
||||
} // namespace md
|
||||
|
||||
@@ -81,7 +81,9 @@ size_t get_system_md_symbols(set<UserSymbol> &result) {
|
||||
|
||||
void add_symbols_to_result(
|
||||
const google::protobuf::RepeatedPtrField<std::string> &symbols,
|
||||
Venue exchange, SecurityType type, std::set<UserSymbol> *result) {
|
||||
Venue exchange,
|
||||
SecurityType type,
|
||||
std::set<UserSymbol> *result) {
|
||||
bts_assert(result);
|
||||
for (const auto &s : symbols) {
|
||||
UserSymbol u(s, exchange, type);
|
||||
|
||||
@@ -57,14 +57,14 @@ void publish_settles(sqlite3_stmt *select, MDProducerHandle handle) {
|
||||
int exponent = sqlite3_column_int(select, 1);
|
||||
Date date = Date(sqlite3_column_int(select, 2));
|
||||
handle.update_settlement(
|
||||
utils::TimeStamp::now(), {mantissa, (int8_t)exponent}, date);
|
||||
utils::TimeStamp::now(), {mantissa, (int8_t)exponent}, date);
|
||||
result = sqlite3_step(select);
|
||||
if (result == SQLITE_ROW) {
|
||||
int64_t mantissa = sqlite3_column_int(select, 0);
|
||||
int exponent = sqlite3_column_int(select, 1);
|
||||
date = Date(sqlite3_column_int(select, 2));
|
||||
handle.update_previous_settlement(
|
||||
utils::TimeStamp::now(), {mantissa, (int8_t)exponent}, date);
|
||||
utils::TimeStamp::now(), {mantissa, (int8_t)exponent}, date);
|
||||
}
|
||||
}
|
||||
sqlite3_reset(select);
|
||||
|
||||
@@ -212,7 +212,9 @@ uint64_t exchange_id(const Security &security);
|
||||
// Stack allocates a security of the given type
|
||||
template <class C>
|
||||
void with_security(
|
||||
SecurityType type, size_t leg_count, const api::Security *psynthetic,
|
||||
SecurityType type,
|
||||
size_t leg_count,
|
||||
const api::Security *psynthetic,
|
||||
C cb) {
|
||||
switch (type) {
|
||||
case api::SECURITYTYPE_STOCK: {
|
||||
|
||||
@@ -88,7 +88,8 @@ utils::EventSubscriber<Metadata> &SyntheticSecurityService::on_metadata() {
|
||||
}
|
||||
|
||||
void send_reply(
|
||||
const api::Response<CreateResult> &fn, CreateResult::Error err,
|
||||
const api::Response<CreateResult> &fn,
|
||||
CreateResult::Error err,
|
||||
uint32_t key = md::invalid_security_key) {
|
||||
CreateResult r;
|
||||
r.set_key(key);
|
||||
|
||||
@@ -27,8 +27,11 @@ namespace co2 {
|
||||
using namespace std;
|
||||
using namespace md;
|
||||
string topic(
|
||||
const char *data_type, const string &symbol, SecurityType type,
|
||||
Venue exchange, Platform platform) {
|
||||
const char *data_type,
|
||||
const string &symbol,
|
||||
SecurityType type,
|
||||
Venue exchange,
|
||||
Platform platform) {
|
||||
std::ostringstream topic;
|
||||
topic << "/md/" << config::get<md::PublisherOptions>().channel_prefix()
|
||||
<< Platform_Name(platform) << "/" << Venue_Name(exchange) << "/"
|
||||
|
||||
+5
-2
@@ -32,8 +32,11 @@ SecurityType securitytype_of(const Security &);
|
||||
|
||||
namespace co2 {
|
||||
std::string topic(
|
||||
const char *data_type, const std::string &symbol, api::SecurityType type,
|
||||
api::Venue exchange, Platform platform);
|
||||
const char *data_type,
|
||||
const std::string &symbol,
|
||||
api::SecurityType type,
|
||||
api::Venue exchange,
|
||||
Platform platform);
|
||||
}
|
||||
|
||||
} // namespace bts
|
||||
@@ -31,10 +31,10 @@ std::string ICEChannel::to_string() const {
|
||||
}
|
||||
|
||||
// We are sort of punting on symbols here because there is no symbol -> channel
|
||||
// mapping supplied by ice therefore we must 1) enumerate the channels we want in
|
||||
// config, and smash them together with the list of symbols we care about. This
|
||||
// has the unfortunate side effect of not knowing what channel should heartbeat
|
||||
// what symbol but Eric says this is ok
|
||||
// mapping supplied by ice therefore we must 1) enumerate the channels we want
|
||||
// in config, and smash them together with the list of symbols we care about.
|
||||
// This has the unfortunate side effect of not knowing what channel should
|
||||
// heartbeat what symbol but Eric says this is ok
|
||||
const vector<ICEChannel> parse_ice_channels(const vector<UserSymbol> &symbols) {
|
||||
vector<ICEChannel> result;
|
||||
const auto &ice_options = config::get<bts::md::ICEOptions>();
|
||||
|
||||
@@ -78,7 +78,8 @@ struct DatedHandle {
|
||||
struct MDConsumerGroup {
|
||||
// probably just have to send the consumer in from outside
|
||||
MDConsumerGroup(
|
||||
const UserSymbol &symbol, const MDConsumer &consumer,
|
||||
const UserSymbol &symbol,
|
||||
const MDConsumer &consumer,
|
||||
metrics::MetricsContainer &stats)
|
||||
: symbol(symbol), platform(platform_for_exchange(symbol.exchange())),
|
||||
channel(consumer.get_channel(symbol)), handles(), mic() {
|
||||
@@ -270,8 +271,11 @@ class QueryServerImpl : public IQueryServer {
|
||||
|
||||
// the hot part
|
||||
void fill(
|
||||
const SecurityChannel &chan, MDConsumerGroup &group, ChannelReply *reply,
|
||||
const Entitlements *entitlements, bool bypass_entitlement) const {
|
||||
const SecurityChannel &chan,
|
||||
MDConsumerGroup &group,
|
||||
ChannelReply *reply,
|
||||
const Entitlements *entitlements,
|
||||
bool bypass_entitlement) const {
|
||||
bts_assert(reply);
|
||||
|
||||
reply->mutable_channel()->CopyFrom(chan);
|
||||
@@ -453,8 +457,10 @@ class QueryServerImpl : public IQueryServer {
|
||||
}
|
||||
|
||||
void query(
|
||||
const MDRequest &request, MDReply *reply,
|
||||
const Entitlements *entitlements, bool bypass_entitlement) const {
|
||||
const MDRequest &request,
|
||||
MDReply *reply,
|
||||
const Entitlements *entitlements,
|
||||
bool bypass_entitlement) const {
|
||||
bts_assert(reply != nullptr);
|
||||
for (auto &ch : request.channels()) {
|
||||
auto groupiter =
|
||||
@@ -516,8 +522,10 @@ struct MDRelayServer : bts::co2::AuthenticatedMarketDataRelayBase {
|
||||
#endif
|
||||
|
||||
MDRelayServer(
|
||||
const QueryServerImpl &db, utils::Dispatcher &threadpool,
|
||||
bts::api::ServiceContext ctx, metrics::MetricsContainer &stats)
|
||||
const QueryServerImpl &db,
|
||||
utils::Dispatcher &threadpool,
|
||||
bts::api::ServiceContext ctx,
|
||||
metrics::MetricsContainer &stats)
|
||||
: bts::co2::AuthenticatedMarketDataRelayBase(ctx), _db(db),
|
||||
_threadpool(threadpool), _entitlements()
|
||||
#ifndef _WIN32
|
||||
@@ -558,7 +566,8 @@ struct MDRelayServer : bts::co2::AuthenticatedMarketDataRelayBase {
|
||||
}
|
||||
|
||||
virtual void requestmd(
|
||||
const api::AuthToken &token, const MDRequest &request,
|
||||
const api::AuthToken &token,
|
||||
const MDRequest &request,
|
||||
const std::function<void(const MDReply &)> &reply) override {
|
||||
TimeStamp start = TimeStamp::now();
|
||||
_threadpool.post([=]() {
|
||||
@@ -587,7 +596,8 @@ struct MDRelayServer : bts::co2::AuthenticatedMarketDataRelayBase {
|
||||
}
|
||||
|
||||
virtual void request_products(
|
||||
const api::AuthToken &, const api::VoidMessage &,
|
||||
const api::AuthToken &,
|
||||
const api::VoidMessage &,
|
||||
const std::function<void(const ProductListReply &)> &reply) override {
|
||||
ProductListReply list;
|
||||
std::set<UserSymbol> syms;
|
||||
@@ -602,7 +612,8 @@ struct MDRelayServer : bts::co2::AuthenticatedMarketDataRelayBase {
|
||||
}
|
||||
|
||||
virtual void request_names(
|
||||
const api::AuthToken &, const api::VoidMessage &,
|
||||
const api::AuthToken &,
|
||||
const api::VoidMessage &,
|
||||
const std::function<void(const ExpirationNameListReply &)> &reply)
|
||||
override {
|
||||
_threadpool.post([=]() {
|
||||
@@ -616,7 +627,8 @@ struct MDRelayServer : bts::co2::AuthenticatedMarketDataRelayBase {
|
||||
}
|
||||
|
||||
virtual void get_securities(
|
||||
const api::AuthToken &, const SecurityKeyList &keys,
|
||||
const api::AuthToken &,
|
||||
const SecurityKeyList &keys,
|
||||
const std::function<void(const api::SecurityList &)> &reply) override {
|
||||
_threadpool.post([=]() {
|
||||
google::protobuf::Arena arena;
|
||||
@@ -630,8 +642,10 @@ struct MDRelayServer : bts::co2::AuthenticatedMarketDataRelayBase {
|
||||
|
||||
struct QueryServer {
|
||||
QueryServer(
|
||||
utils::Dispatcher &threadpool, const bts::api::ServiceContext &ctx,
|
||||
MDClient &client, metrics::MetricsContainer &stats)
|
||||
utils::Dispatcher &threadpool,
|
||||
const bts::api::ServiceContext &ctx,
|
||||
MDClient &client,
|
||||
metrics::MetricsContainer &stats)
|
||||
: db(client, stats), relay(db, threadpool, ctx, stats),
|
||||
admin_client(ctx.locate<api::admin::AdminService>()) {}
|
||||
QueryServerImpl db;
|
||||
@@ -641,7 +655,8 @@ struct QueryServer {
|
||||
};
|
||||
|
||||
QueryServerPtr run_query_server(
|
||||
const bts::api::ServiceContext &ctx, MDClient &client,
|
||||
const bts::api::ServiceContext &ctx,
|
||||
MDClient &client,
|
||||
metrics::MetricsContainer &stats) {
|
||||
auto &threadpool = utils::Dispatcher::get_named("MDQuery");
|
||||
|
||||
|
||||
@@ -24,7 +24,9 @@ typedef boost::container::flat_set<std::string> Entitlements;
|
||||
struct IQueryServer {
|
||||
virtual ~IQueryServer() {}
|
||||
virtual void query(
|
||||
const co2::MDRequest &request, co2::MDReply *reply, const Entitlements *,
|
||||
const co2::MDRequest &request,
|
||||
co2::MDReply *reply,
|
||||
const Entitlements *,
|
||||
bool) const = 0;
|
||||
};
|
||||
std::unique_ptr<IQueryServer>
|
||||
|
||||
@@ -193,8 +193,10 @@ class RelayClient {
|
||||
|
||||
public:
|
||||
RelayClient(
|
||||
MarketDataRelay &rpc, MDConsumer *pconsumer,
|
||||
const std::set<UserSymbol> &symbols, IRelayWriter &writer)
|
||||
MarketDataRelay &rpc,
|
||||
MDConsumer *pconsumer,
|
||||
const std::set<UserSymbol> &symbols,
|
||||
IRelayWriter &writer)
|
||||
: _request(), _rpc(rpc), _pconsumer(pconsumer), _writer(writer),
|
||||
_request_log(utils::TimeStamp::now()) {
|
||||
ostringstream fmt;
|
||||
@@ -350,7 +352,8 @@ api::ServiceContext elevated_relay_context() {
|
||||
}
|
||||
|
||||
void relay_selected(
|
||||
api::ServiceContext &ctx, const std::set<UserSymbol> &symbols,
|
||||
api::ServiceContext &ctx,
|
||||
const std::set<UserSymbol> &symbols,
|
||||
IRelayWriter &writer) {
|
||||
auto relay = ctx.locate<MarketDataRelay>();
|
||||
RelayClient client(relay, nullptr, symbols, writer);
|
||||
|
||||
@@ -31,7 +31,8 @@ struct IRelayWriter {
|
||||
utils::Dispatcher &scan_securities_thread();
|
||||
|
||||
void relay_selected(
|
||||
api::ServiceContext &ctx, const std::set<UserSymbol> &symbols,
|
||||
api::ServiceContext &ctx,
|
||||
const std::set<UserSymbol> &symbols,
|
||||
IRelayWriter &writer);
|
||||
void local_relay(IRelayWriter &writer);
|
||||
|
||||
|
||||
@@ -155,7 +155,9 @@ void replay_recording(istream &in, IRelayWriter &writer, int32_t naggle_ms) {
|
||||
}
|
||||
|
||||
void replay_file(
|
||||
const std::string &filename, IRelayWriter &writer, int32_t naggle_ms,
|
||||
const std::string &filename,
|
||||
IRelayWriter &writer,
|
||||
int32_t naggle_ms,
|
||||
bool loop) {
|
||||
do {
|
||||
ifstream in;
|
||||
@@ -171,7 +173,9 @@ void replay_file(
|
||||
}
|
||||
|
||||
bool replay_url(
|
||||
const std::string &url, IRelayWriter &writer, int32_t naggle_ms,
|
||||
const std::string &url,
|
||||
IRelayWriter &writer,
|
||||
int32_t naggle_ms,
|
||||
bool loop) {
|
||||
// split up url parts
|
||||
size_t http_len = BTS_ARRAYSIZE("http://") - 1;
|
||||
@@ -190,7 +194,9 @@ bool replay_url(
|
||||
}
|
||||
|
||||
void replay_url_with_fallback(
|
||||
const std::string &url, IRelayWriter &writer, int32_t naggle_ms,
|
||||
const std::string &url,
|
||||
IRelayWriter &writer,
|
||||
int32_t naggle_ms,
|
||||
bool loop) {
|
||||
if (!replay_url(url, writer, naggle_ms, loop)) {
|
||||
const auto fallback = config::get<ReplayOptions>().fallback();
|
||||
|
||||
@@ -12,7 +12,8 @@ namespace md {
|
||||
class RelayRecorder : public IRelayWriter {
|
||||
public:
|
||||
RelayRecorder(
|
||||
const std::string &base_path, const std::string &filename,
|
||||
const std::string &base_path,
|
||||
const std::string &filename,
|
||||
uint32_t naggle);
|
||||
~RelayRecorder();
|
||||
virtual void write(const co2::MDReply &, bool *) override;
|
||||
@@ -33,13 +34,19 @@ void trace_recording(const std::string &file, security_key key);
|
||||
void replay_recording(
|
||||
const std::string &, int32_t delay_ms, const std::string fallback = "");
|
||||
bool replay_url(
|
||||
const std::string &url, IRelayWriter &writer, int32_t naggle_ms,
|
||||
const std::string &url,
|
||||
IRelayWriter &writer,
|
||||
int32_t naggle_ms,
|
||||
bool loop = true);
|
||||
void replay_url_with_fallback(
|
||||
const std::string &url, IRelayWriter &writer, int32_t naggle_ms,
|
||||
const std::string &url,
|
||||
IRelayWriter &writer,
|
||||
int32_t naggle_ms,
|
||||
bool loop = true);
|
||||
void replay_file(
|
||||
const std::string &filename, IRelayWriter &writer, int32_t naggle_ms,
|
||||
const std::string &filename,
|
||||
IRelayWriter &writer,
|
||||
int32_t naggle_ms,
|
||||
bool loop = false);
|
||||
void get_securities_from_replay(std::function<void(const api::Security &)>);
|
||||
|
||||
|
||||
@@ -48,7 +48,8 @@ MarketDataService::MarketDataService(
|
||||
|
||||
// This method duplicates MarketDataRelayServer::request_products()
|
||||
void MarketDataService::get_products(
|
||||
const api::AuthToken &, const ::bts::api::VoidMessage &,
|
||||
const api::AuthToken &,
|
||||
const ::bts::api::VoidMessage &,
|
||||
const api::Response<::bts::api::ProductList> &reply) {
|
||||
|
||||
api::ProductList list;
|
||||
@@ -70,14 +71,16 @@ api::StreamAccessResponse authorized(bool is_authorized) {
|
||||
}
|
||||
|
||||
void MarketDataService::allow_securities(
|
||||
const bts::api::AuthToken &, const std::string &qualifier,
|
||||
const bts::api::AuthToken &,
|
||||
const std::string &qualifier,
|
||||
const api::Response<bts::api::StreamAccessResponse> &reply) {
|
||||
// Non-empty qualifier is invalid and rejected
|
||||
reply(authorized(qualifier.empty()));
|
||||
}
|
||||
|
||||
void MarketDataService::allow_book(
|
||||
const bts::api::AuthToken &token, const std::string &qualifier,
|
||||
const bts::api::AuthToken &token,
|
||||
const std::string &qualifier,
|
||||
const api::Response<bts::api::StreamAccessResponse> &reply) {
|
||||
api::user::TokenPayload payload;
|
||||
if (api::auth::decode_token(token, &payload)) {
|
||||
@@ -91,7 +94,8 @@ void MarketDataService::allow_book(
|
||||
}
|
||||
|
||||
void MarketDataService::allow_trades(
|
||||
const bts::api::AuthToken &token, const std::string &qualifier,
|
||||
const bts::api::AuthToken &token,
|
||||
const std::string &qualifier,
|
||||
const api::Response<bts::api::StreamAccessResponse> &reply) {
|
||||
api::user::TokenPayload payload;
|
||||
if (api::auth::decode_token(token, &payload)) {
|
||||
|
||||
@@ -21,19 +21,23 @@ class MarketDataService : public api::AuthenticatedMarketDataServiceBase {
|
||||
MDClient &md, api::ServiceContext ctx, metrics::MetricsContainer &stats);
|
||||
|
||||
void get_products(
|
||||
const api::AuthToken &, const ::bts::api::VoidMessage &,
|
||||
const api::AuthToken &,
|
||||
const ::bts::api::VoidMessage &,
|
||||
const api::Response<::bts::api::ProductList> &) override;
|
||||
|
||||
void allow_securities(
|
||||
const bts::api::AuthToken &, const std::string &qualifier,
|
||||
const bts::api::AuthToken &,
|
||||
const std::string &qualifier,
|
||||
const api::Response<bts::api::StreamAccessResponse> &reply) override;
|
||||
|
||||
void allow_book(
|
||||
const bts::api::AuthToken &token, const std::string &qualifier,
|
||||
const bts::api::AuthToken &token,
|
||||
const std::string &qualifier,
|
||||
const api::Response<bts::api::StreamAccessResponse> &reply) override;
|
||||
|
||||
void allow_trades(
|
||||
const bts::api::AuthToken &token, const std::string &qualifier,
|
||||
const bts::api::AuthToken &token,
|
||||
const std::string &qualifier,
|
||||
const api::Response<bts::api::StreamAccessResponse> &reply) override;
|
||||
};
|
||||
|
||||
|
||||
@@ -18,11 +18,15 @@ create_test_securities(MDProducer &producer, const char *postfix = "M");
|
||||
|
||||
void assign_ids(
|
||||
std::vector<MDProducerHandle>::iterator begin,
|
||||
std::vector<MDProducerHandle>::iterator end, security_key start_key = 1000);
|
||||
std::vector<MDProducerHandle>::iterator end,
|
||||
security_key start_key = 1000);
|
||||
|
||||
extern "C" BTS_EXPORT void co2_get_1234_handle(
|
||||
size_t &size, MDConsumerHandle &handle, uintptr_t *hotaddr,
|
||||
uintptr_t *coldaddr, uintptr_t *headeraddr) {
|
||||
size_t &size,
|
||||
MDConsumerHandle &handle,
|
||||
uintptr_t *hotaddr,
|
||||
uintptr_t *coldaddr,
|
||||
uintptr_t *headeraddr) {
|
||||
// Test that marshaling is working
|
||||
auto phot = std::make_unique<HotEntry>();
|
||||
auto pcold = std::make_unique<ColdEntry>(0);
|
||||
|
||||
@@ -22,13 +22,14 @@ Co2TestInstrument::Co2TestInstrument(
|
||||
}
|
||||
|
||||
Co2TestInstrument::Co2TestInstrument(
|
||||
const Security &security, std::shared_ptr<ColdHeader> cheader,
|
||||
const Security &security,
|
||||
std::shared_ptr<ColdHeader> cheader,
|
||||
std::shared_ptr<HotHeader> hheader)
|
||||
: _cold(nullptr), _hot(std::make_shared<HotDepthEntry>()),
|
||||
_cheader(cheader), _hheader(hheader) {
|
||||
bts_assert_d(_cheader->has_depth == false);
|
||||
//_cheader->has_depth = enable_depth(md::SecurityHelper::symbol(security),
|
||||
//security.security_type());
|
||||
// security.security_type());
|
||||
with_security_like(security, [&](FixedSecurity &fsec) {
|
||||
convert_security(security, fsec, false);
|
||||
_cold_buffer = std::shared_ptr<uint8_t>(
|
||||
|
||||
@@ -10,7 +10,8 @@ namespace md {
|
||||
struct Co2TestInstrument {
|
||||
Co2TestInstrument(const std::string &symbol, SecurityType type);
|
||||
Co2TestInstrument(
|
||||
const Security &security, std::shared_ptr<ColdHeader>,
|
||||
const Security &security,
|
||||
std::shared_ptr<ColdHeader>,
|
||||
std::shared_ptr<HotHeader>);
|
||||
~Co2TestInstrument();
|
||||
|
||||
|
||||
@@ -86,7 +86,11 @@ mkfuture(string symbol, security_key key, int year, int month, int day) {
|
||||
return result;
|
||||
}
|
||||
Security mkoption(
|
||||
string symbol, security_key key, int year, int month, int day,
|
||||
string symbol,
|
||||
security_key key,
|
||||
int year,
|
||||
int month,
|
||||
int day,
|
||||
double strike) {
|
||||
Security result;
|
||||
result.set_symbol(symbol);
|
||||
@@ -131,7 +135,10 @@ mkspread(string symbol, security_key key, Security leg1, Security leg2) {
|
||||
return mkspread(symbol, key, vlegs);
|
||||
}
|
||||
Security mkspread(
|
||||
string symbol, security_key key, Security leg1, Security leg2,
|
||||
string symbol,
|
||||
security_key key,
|
||||
Security leg1,
|
||||
Security leg2,
|
||||
Security leg3) {
|
||||
vector<Security> vlegs;
|
||||
vlegs.push_back(leg1);
|
||||
@@ -1336,7 +1343,9 @@ struct Co2RelayTests {
|
||||
}
|
||||
|
||||
std::unique_ptr<IQueryServer> setup_query_server(
|
||||
MDClient &client, MDProducer &producer, Entitlements *out_entitlements,
|
||||
MDClient &client,
|
||||
MDProducer &producer,
|
||||
Entitlements *out_entitlements,
|
||||
vector<MDProducerHandle> *out_producers) {
|
||||
|
||||
// Create a bunch of securities
|
||||
|
||||
@@ -36,7 +36,8 @@ create_test_securities(MDProducer &producer, const char *postfix = "") {
|
||||
|
||||
void assign_ids(
|
||||
std::vector<MDProducerHandle>::iterator begin,
|
||||
std::vector<MDProducerHandle>::iterator end, security_key start_key) {
|
||||
std::vector<MDProducerHandle>::iterator end,
|
||||
security_key start_key) {
|
||||
for (; begin != end; ++begin) {
|
||||
(*begin).set_key(++start_key);
|
||||
}
|
||||
|
||||
@@ -32,7 +32,8 @@ std::ostream &operator<<(std::ostream &os, const PS &val);
|
||||
|
||||
void assign_ids(
|
||||
std::vector<MDProducerHandle>::iterator begin,
|
||||
std::vector<MDProducerHandle>::iterator end, security_key start_key = 1000);
|
||||
std::vector<MDProducerHandle>::iterator end,
|
||||
security_key start_key = 1000);
|
||||
|
||||
} // namespace test
|
||||
} // namespace md
|
||||
|
||||
@@ -70,7 +70,8 @@ void dump_market(const MDConsumerHandle &handle) {
|
||||
}
|
||||
|
||||
void expect_market(
|
||||
const MDConsumerHandle &handle, const vector<PS> bids,
|
||||
const MDConsumerHandle &handle,
|
||||
const vector<PS> bids,
|
||||
const vector<PS> &asks) {
|
||||
array<PriceSize, COCONUT_MAX_DEPTH> raw_bids, raw_asks;
|
||||
TimeStamp t;
|
||||
@@ -154,7 +155,8 @@ make_securities(const vector<tuple<double, double, api::Side>> &leg_descr) {
|
||||
}
|
||||
|
||||
void set_leg_params(
|
||||
SyntheticStrategy &strat, uint32_t security_key,
|
||||
SyntheticStrategy &strat,
|
||||
uint32_t security_key,
|
||||
const spark::LegSpreaderParams ¶ms) {
|
||||
if (!strat.strategy) {
|
||||
strat.strategy = std::make_unique<spark::ExecutionStrategy>();
|
||||
|
||||
@@ -60,7 +60,8 @@ template <typename EV, typename KE = KeyExtractor> class ContentSubscription {
|
||||
_pre_event([](auto const &) {}) {}
|
||||
|
||||
ContentSubscription(
|
||||
Actor &actor, std::function<void(EV const &)> const &pre_ev,
|
||||
Actor &actor,
|
||||
std::function<void(EV const &)> const &pre_ev,
|
||||
trace::PerfLog &log)
|
||||
: _actor(&actor), _sub(_actor->subscribe<EV>(
|
||||
[this](auto const &u) { this->on_update(u); })),
|
||||
@@ -69,8 +70,10 @@ template <typename EV, typename KE = KeyExtractor> class ContentSubscription {
|
||||
_name(utils::type_name<EV>()), _pre_event(pre_ev) {}
|
||||
|
||||
ContentSubscription(
|
||||
Actor &actor, std::function<void(Key)> const &pscb,
|
||||
std::function<void(EV const &)> const &pre_ev, trace::PerfLog &log)
|
||||
Actor &actor,
|
||||
std::function<void(Key)> const &pscb,
|
||||
std::function<void(EV const &)> const &pre_ev,
|
||||
trace::PerfLog &log)
|
||||
: _actor(&actor), _sub(_actor->subscribe<EV>(
|
||||
[this](auto const &u) { this->on_update(u); })),
|
||||
_my_subs(), _dispatching(false), _current_sub_id(1), _pre_sub(pscb),
|
||||
@@ -87,7 +90,9 @@ template <typename EV, typename KE = KeyExtractor> class ContentSubscription {
|
||||
|
||||
template <class Tag>
|
||||
ContentSubscription(
|
||||
Actor &actor, Tag const &tag, std::function<void(Key)> const &pscb,
|
||||
Actor &actor,
|
||||
Tag const &tag,
|
||||
std::function<void(Key)> const &pscb,
|
||||
trace::PerfLog &log)
|
||||
: _actor(&actor),
|
||||
_sub(_actor->subscribe<EV>(
|
||||
@@ -98,8 +103,10 @@ template <typename EV, typename KE = KeyExtractor> class ContentSubscription {
|
||||
|
||||
template <class Tag>
|
||||
ContentSubscription(
|
||||
Actor &actor, Tag const &tag,
|
||||
std::function<void(EV const &)> const &pre_ev, trace::PerfLog &log)
|
||||
Actor &actor,
|
||||
Tag const &tag,
|
||||
std::function<void(EV const &)> const &pre_ev,
|
||||
trace::PerfLog &log)
|
||||
: _actor(&actor),
|
||||
_sub(_actor->subscribe<EV>(
|
||||
tag, [this](auto const &u) { this->on_update(u); })),
|
||||
@@ -109,8 +116,11 @@ template <typename EV, typename KE = KeyExtractor> class ContentSubscription {
|
||||
|
||||
template <class Tag>
|
||||
ContentSubscription(
|
||||
Actor &actor, Tag const &tag, std::function<void(Key)> const &pscb,
|
||||
std::function<void(EV const &)> const &pre_ev, trace::PerfLog &log)
|
||||
Actor &actor,
|
||||
Tag const &tag,
|
||||
std::function<void(Key)> const &pscb,
|
||||
std::function<void(EV const &)> const &pre_ev,
|
||||
trace::PerfLog &log)
|
||||
: _actor(&actor),
|
||||
_sub(_actor->subscribe<EV>(
|
||||
tag, [this](auto const &u) { this->on_update(u); })),
|
||||
|
||||
@@ -351,7 +351,9 @@ void Broker::unadvertise(BrokerID sender, StreamID sid) {
|
||||
|
||||
#ifndef NDEBUG
|
||||
void Broker::notify(
|
||||
BrokerID sender, StreamID sid, SubID ex_subid,
|
||||
BrokerID sender,
|
||||
StreamID sid,
|
||||
SubID ex_subid,
|
||||
Notification const &payload) {
|
||||
NoReenter nr(me->inside);
|
||||
#else
|
||||
|
||||
@@ -89,7 +89,8 @@ template <class T> class LazyCounterMetric : public Metric {
|
||||
LazyCounterMetric(const std::string &name, const std::function<T()> &fn)
|
||||
: Metric(name, {}), _get(fn) {}
|
||||
LazyCounterMetric(
|
||||
const std::string &name, const std::function<T()> &fn,
|
||||
const std::string &name,
|
||||
const std::function<T()> &fn,
|
||||
const std::vector<Label> &labels)
|
||||
: Metric(name, labels), _get(fn) {}
|
||||
void print(std::ostream &os) const override {
|
||||
@@ -106,15 +107,18 @@ vector_concat(const std::vector<Label> &orig, const std::vector<Label> &extra);
|
||||
|
||||
template <size_t N, size_t... Is>
|
||||
std::array<CounterMetric<long>, N> mk_counters(
|
||||
const std::string &name, const std::vector<Label> &labels,
|
||||
const std::array<double, N> &in, std::index_sequence<Is...>) {
|
||||
const std::string &name,
|
||||
const std::vector<Label> &labels,
|
||||
const std::array<double, N> &in,
|
||||
std::index_sequence<Is...>) {
|
||||
return {{CounterMetric<long>(
|
||||
name + "_bucket",
|
||||
vector_concat(labels, {{"le", double_to_string(in[Is])}}))...}};
|
||||
}
|
||||
template <size_t N, size_t... Is>
|
||||
std::array<CounterMetric<long>, N> mk_counters(
|
||||
const std::string &name, const std::vector<Label> &labels,
|
||||
const std::string &name,
|
||||
const std::vector<Label> &labels,
|
||||
const std::array<double, N> &in) {
|
||||
return mk_counters(name, labels, in, std::make_index_sequence<N>());
|
||||
}
|
||||
@@ -135,7 +139,8 @@ template <size_t N> class HistogramMetric : public Metric {
|
||||
_bucket_values(buckets), _sum(name + "_sum"), _count(name + "_count") {
|
||||
}
|
||||
HistogramMetric(
|
||||
const std::string &name, const std::array<double, N> &buckets,
|
||||
const std::string &name,
|
||||
const std::array<double, N> &buckets,
|
||||
const std::vector<Label> &labels)
|
||||
: Metric(name, labels), _buckets(mk_counters(name, labels, buckets)),
|
||||
_bucket_values(buckets), _sum(name + "_sum"), _count(name + "_count") {
|
||||
|
||||
@@ -21,12 +21,15 @@ namespace orderman {
|
||||
using namespace jetfix;
|
||||
|
||||
using JFGw = JetFIXGateway<
|
||||
fix::ExecutionReportMsg, fix::BusinessMessageRejectMsg, fix::RejectMsg,
|
||||
fix::ExecutionReportMsg,
|
||||
fix::BusinessMessageRejectMsg,
|
||||
fix::RejectMsg,
|
||||
fix::CancelRejectMsg>;
|
||||
|
||||
struct GLBXExecutionGateway::PImpl {
|
||||
PImpl(
|
||||
config::JetFIX::Connection const &cfg, trace::PerfLog &l,
|
||||
config::JetFIX::Connection const &cfg,
|
||||
trace::PerfLog &l,
|
||||
md::SecurityOracle o)
|
||||
: gw(cfg, l), exe_report_pool(), state(State::WAITING_FOR_SECURITIES),
|
||||
securities(), securities_by_descriptor(), gw_name(cfg.name()),
|
||||
@@ -48,7 +51,8 @@ struct GLBXExecutionGateway::PImpl {
|
||||
};
|
||||
|
||||
GLBXExecutionGateway::GLBXExecutionGateway(
|
||||
config::JetFIX::Connection const &cfg, trace::PerfLog &log,
|
||||
config::JetFIX::Connection const &cfg,
|
||||
trace::PerfLog &log,
|
||||
md::SecurityOracle o)
|
||||
: me(new PImpl(cfg, log, o)) {
|
||||
me->state = State::WAITING_FOR_SECURITIES;
|
||||
|
||||
@@ -9,7 +9,8 @@ namespace orderman {
|
||||
class GLBXExecutionGateway : public IExecutionGateway {
|
||||
public:
|
||||
GLBXExecutionGateway(
|
||||
config::JetFIX::Connection const &, trace::PerfLog &,
|
||||
config::JetFIX::Connection const &,
|
||||
trace::PerfLog &,
|
||||
md::SecurityOracle);
|
||||
virtual ~GLBXExecutionGateway();
|
||||
|
||||
|
||||
@@ -27,7 +27,8 @@ enum class GLBXiLink3ExecutionGateway::State {
|
||||
|
||||
struct GLBXiLink3ExecutionGateway::PImpl {
|
||||
PImpl(
|
||||
config::JetFIX::Connection const &cfg, trace::PerfLog &log,
|
||||
config::JetFIX::Connection const &cfg,
|
||||
trace::PerfLog &log,
|
||||
md::SecurityOracle o)
|
||||
: state(), cfg(cfg), reactor(), start_of_pause(), on_exe_report(),
|
||||
on_gw_status_change(), on_cancel_reject(), perf_log(log), db(o),
|
||||
@@ -65,7 +66,8 @@ struct GLBXiLink3ExecutionGateway::PImpl {
|
||||
};
|
||||
|
||||
GLBXiLink3ExecutionGateway::GLBXiLink3ExecutionGateway(
|
||||
config::JetFIX::Connection const &cfg, trace::PerfLog &log,
|
||||
config::JetFIX::Connection const &cfg,
|
||||
trace::PerfLog &log,
|
||||
md::SecurityOracle o)
|
||||
: me(new PImpl(cfg, log, o)) {
|
||||
me->state = State::WAITING_FOR_SECURITIES;
|
||||
|
||||
@@ -15,7 +15,8 @@ struct Session;
|
||||
class GLBXiLink3ExecutionGateway : public IExecutionGateway {
|
||||
public:
|
||||
GLBXiLink3ExecutionGateway(
|
||||
config::JetFIX::Connection const &, trace::PerfLog &,
|
||||
config::JetFIX::Connection const &,
|
||||
trace::PerfLog &,
|
||||
md::SecurityOracle);
|
||||
virtual ~GLBXiLink3ExecutionGateway();
|
||||
|
||||
|
||||
@@ -27,13 +27,17 @@ namespace orderman {
|
||||
using namespace jetfix;
|
||||
|
||||
using JFGw = JetFIXGateway<
|
||||
fix::ICEExecutionReportMsg, fix::BusinessMessageRejectMsg, fix::RejectMsg,
|
||||
fix::ICECancelRejectMsg, fix::ICETraderLoginResponseMsg,
|
||||
fix::ICEExecutionReportMsg,
|
||||
fix::BusinessMessageRejectMsg,
|
||||
fix::RejectMsg,
|
||||
fix::ICECancelRejectMsg,
|
||||
fix::ICETraderLoginResponseMsg,
|
||||
fix::ICETraderLogoutResponseMsg>;
|
||||
|
||||
struct ICEExecutionGateway::PImpl {
|
||||
PImpl(
|
||||
const config::JetFIX::Connection &cfg, trace::PerfLog &l,
|
||||
const config::JetFIX::Connection &cfg,
|
||||
trace::PerfLog &l,
|
||||
md::SecurityOracle o)
|
||||
: gw(cfg, l), exe_report_pool(), state(State::WAITING_FOR_SECURITIES),
|
||||
securities(), securities_by_exchange_id(), gw_name(cfg.name()),
|
||||
@@ -60,7 +64,8 @@ struct ICEExecutionGateway::PImpl {
|
||||
};
|
||||
|
||||
ICEExecutionGateway::ICEExecutionGateway(
|
||||
const config::JetFIX::Connection &cfg, trace::PerfLog &log,
|
||||
const config::JetFIX::Connection &cfg,
|
||||
trace::PerfLog &log,
|
||||
md::SecurityOracle o)
|
||||
: IExecutionGateway(), me(new PImpl(cfg, log, o)) {
|
||||
me->state = State::WAITING_FOR_ADMIN;
|
||||
@@ -263,7 +268,8 @@ OnCancelReject &ICEExecutionGateway::on_cancel_reject() {
|
||||
}
|
||||
|
||||
bool ICEExecutionGateway::process_memo(
|
||||
const jetfix::fix::ICEExecutionReportMsg &msg, OrderKey *ok,
|
||||
const jetfix::fix::ICEExecutionReportMsg &msg,
|
||||
OrderKey *ok,
|
||||
SecurityKey *sk) {
|
||||
if (msg.has<fix::Memo>()) {
|
||||
decode_memo(msg.get<fix::Memo>(), ok, sk);
|
||||
|
||||
@@ -9,7 +9,8 @@ namespace orderman {
|
||||
class ICEExecutionGateway : public IExecutionGateway {
|
||||
public:
|
||||
ICEExecutionGateway(
|
||||
const config::JetFIX::Connection &, trace::PerfLog &,
|
||||
const config::JetFIX::Connection &,
|
||||
trace::PerfLog &,
|
||||
md::SecurityOracle);
|
||||
virtual ~ICEExecutionGateway();
|
||||
|
||||
@@ -50,7 +51,8 @@ class ICEExecutionGateway : public IExecutionGateway {
|
||||
void on_session_reject(const jetfix::fix::RejectMsg &);
|
||||
|
||||
bool process_memo(
|
||||
const jetfix::fix::ICEExecutionReportMsg &msg, OrderKey *,
|
||||
const jetfix::fix::ICEExecutionReportMsg &msg,
|
||||
OrderKey *,
|
||||
SecurityKey *);
|
||||
};
|
||||
|
||||
|
||||
@@ -11,7 +11,8 @@ namespace bts {
|
||||
namespace orderman {
|
||||
|
||||
std::unique_ptr<IExecutionGateway> ExecutionGatewayFactory::create_gateway(
|
||||
const config::JetFIX::Connection &conn, trace::PerfLog &pl,
|
||||
const config::JetFIX::Connection &conn,
|
||||
trace::PerfLog &pl,
|
||||
md::SecurityOracle o) {
|
||||
if (conn.platform() == bts::config::JetFIX_Connection_JetFIXPlatform_ICE ||
|
||||
conn.platform() == bts::config::JetFIX_Connection_JetFIXPlatform_SIMICE)
|
||||
|
||||
Loaded 100 of 452 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user