diff --git a/.clang-format b/.clang-format index 956071a4b..eb1d2d51d 100644 --- a/.clang-format +++ b/.clang-format @@ -1,4 +1,5 @@ IndentWidth: 3 BinPackArguments: true +BinPackParameters: false AlignAfterOpenBracket: AlwaysBreak diff --git a/src/lib/api/core/ApiClientInterop.cpp b/src/lib/api/core/ApiClientInterop.cpp index bf312a792..2d194dffe 100644 --- a/src/lib/api/core/ApiClientInterop.cpp +++ b/src/lib/api/core/ApiClientInterop.cpp @@ -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 &updates, void *extra) { + raw_subscription_callback cb, + EventType type, + const std::vector &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 == diff --git a/src/lib/api/core/ApiClientInterop.h b/src/lib/api/core/ApiClientInterop.h index dff501fff..eb5783270 100644 --- a/src/lib/api/core/ApiClientInterop.h +++ b/src/lib/api/core/ApiClientInterop.h @@ -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 diff --git a/src/lib/api/core/ApiServerInterop.cpp b/src/lib/api/core/ApiServerInterop.cpp index 331c8ec47..954dfc89c 100644 --- a/src/lib/api/core/ApiServerInterop.cpp +++ b/src/lib/api/core/ApiServerInterop.cpp @@ -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 : {'+'}) { diff --git a/src/lib/api/core/ApiServerInterop.h b/src/lib/api/core/ApiServerInterop.h index 75387a021..ec8eb8e4a 100644 --- a/src/lib/api/core/ApiServerInterop.h +++ b/src/lib/api/core/ApiServerInterop.h @@ -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); diff --git a/src/lib/api/public/ApiServer.cpp b/src/lib/api/public/ApiServer.cpp index c2ab0b321..3d7090040 100644 --- a/src/lib/api/public/ApiServer.cpp +++ b/src/lib/api/public/ApiServer.cpp @@ -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)) {} diff --git a/src/lib/api/public/ApiServer.h b/src/lib/api/public/ApiServer.h index fd9fda7d4..853004dc4 100644 --- a/src/lib/api/public/ApiServer.h +++ b/src/lib/api/public/ApiServer.h @@ -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 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 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); diff --git a/src/lib/api/public/ClientChannel.h b/src/lib/api/public/ClientChannel.h index 028eb76c0..e48736d82 100644 --- a/src/lib/api/public/ClientChannel.h +++ b/src/lib/api/public/ClientChannel.h @@ -36,7 +36,8 @@ class ClientChannel { template void send( - int method_id, const Request &request, + int method_id, + const Request &request, std::function)> on_response) { RequestHeader header; header.set_method(method_id); diff --git a/src/lib/api/public/QuickbusClientChannel.cpp b/src/lib/api/public/QuickbusClientChannel.cpp index f0dfd7ed9..d0477a15a 100644 --- a/src/lib/api/public/QuickbusClientChannel.cpp +++ b/src/lib/api/public/QuickbusClientChannel.cpp @@ -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)) {} diff --git a/src/lib/api/public/QuickbusClientChannel.h b/src/lib/api/public/QuickbusClientChannel.h index 597245200..2159a02c0 100644 --- a/src/lib/api/public/QuickbusClientChannel.h +++ b/src/lib/api/public/QuickbusClientChannel.h @@ -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(); diff --git a/src/lib/api/public/RawUpdate.h b/src/lib/api/public/RawUpdate.h index fe88ee9d2..96285de2d 100644 --- a/src/lib/api/public/RawUpdate.h +++ b/src/lib/api/public/RawUpdate.h @@ -6,8 +6,10 @@ namespace api { template struct RawUpdate { RawUpdate( - std::vector &added_items, std::vector &added_keys, - std::vector &changed_items, std::vector &changed_keys, + std::vector &added_items, + std::vector &added_keys, + std::vector &changed_items, + std::vector &changed_keys, std::vector &removed_keys) : is_reset(false), added_items(std::move(added_items)), added_keys(std::move(added_keys)), diff --git a/src/lib/api/public/ServerChannel.cpp b/src/lib/api/public/ServerChannel.cpp index 3aad69afd..72197cbba 100644 --- a/src/lib/api/public/ServerChannel.cpp +++ b/src/lib/api/public/ServerChannel.cpp @@ -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(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)) {} diff --git a/src/lib/api/public/ServerChannel.h b/src/lib/api/public/ServerChannel.h index 2ca957a3d..e841da697 100644 --- a/src/lib/api/public/ServerChannel.h +++ b/src/lib/api/public/ServerChannel.h @@ -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(); diff --git a/src/lib/api/public/ServiceContext.cpp b/src/lib/api/public/ServiceContext.cpp index 65780791c..3c8d95f3e 100644 --- a/src/lib/api/public/ServiceContext.cpp +++ b/src/lib/api/public/ServiceContext.cpp @@ -47,7 +47,8 @@ std::unique_ptr 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); } diff --git a/src/lib/api/public/ServiceContext.h b/src/lib/api/public/ServiceContext.h index fbc1247f0..24d87edd8 100644 --- a/src/lib/api/public/ServiceContext.h +++ b/src/lib/api/public/ServiceContext.h @@ -52,7 +52,8 @@ class BTS_EXPORT ServiceContext { std::unique_ptr 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; }; diff --git a/src/lib/api/public/Update.h b/src/lib/api/public/Update.h index c13a0341d..49e4677bf 100644 --- a/src/lib/api/public/Update.h +++ b/src/lib/api/public/Update.h @@ -21,8 +21,10 @@ template class Change { template struct Update { Update( - std::vector &all, std::vector &added, - std::vector> changed, std::vector &removed) + std::vector &all, + std::vector &added, + std::vector> changed, + std::vector &removed) : _all_items(std::move(all)), _added_items(std::move(added)), _changed_items(std::move(changed)), _removed_items(std::move(removed)) {} diff --git a/src/lib/api/service_helpers/AdminServiceUtils.cpp b/src/lib/api/service_helpers/AdminServiceUtils.cpp index 10bac8f3a..cd79563c0 100644 --- a/src/lib/api/service_helpers/AdminServiceUtils.cpp +++ b/src/lib/api/service_helpers/AdminServiceUtils.cpp @@ -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 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 &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 &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 &rv) { std::map 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 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 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 &out_map, + const api::Security &s, + std::map &out_map, double mult) { if (s.has_spread()) for (const auto &leg : s.spread().legs()) { diff --git a/src/lib/api/service_helpers/AdminServiceUtils.h b/src/lib/api/service_helpers/AdminServiceUtils.h index 517b4aa7c..7b8a281e7 100644 --- a/src/lib/api/service_helpers/AdminServiceUtils.h +++ b/src/lib/api/service_helpers/AdminServiceUtils.h @@ -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 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 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 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 &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 &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 &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 &out_map, + const api::Security &s, + std::map &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); diff --git a/src/lib/api/service_helpers/PositionUtilities.cpp b/src/lib/api/service_helpers/PositionUtilities.cpp index 2ddea0908..0b9775f54 100644 --- a/src/lib/api/service_helpers/PositionUtilities.cpp +++ b/src/lib/api/service_helpers/PositionUtilities.cpp @@ -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( diff --git a/src/lib/api/service_helpers/PositionUtilities.h b/src/lib/api/service_helpers/PositionUtilities.h index 04de7406a..88e2de92d 100644 --- a/src/lib/api/service_helpers/PositionUtilities.h +++ b/src/lib/api/service_helpers/PositionUtilities.h @@ -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( diff --git a/src/lib/config/ConfigPropertyEvaluator.cpp b/src/lib/config/ConfigPropertyEvaluator.cpp index ad442cfc8..de9c260fd 100644 --- a/src/lib/config/ConfigPropertyEvaluator.cpp +++ b/src/lib/config/ConfigPropertyEvaluator.cpp @@ -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 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); diff --git a/src/lib/config/ConfigValueQueue.cpp b/src/lib/config/ConfigValueQueue.cpp index 85c138275..2ed282504 100644 --- a/src/lib/config/ConfigValueQueue.cpp +++ b/src/lib/config/ConfigValueQueue.cpp @@ -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 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 v = boost::get>(value); if (field->is_repeated()) { @@ -163,8 +171,11 @@ void ConfigValueQueue::assign( template 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 v = boost::get>(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 diff --git a/src/lib/config/ConfigValueQueue.h b/src/lib/config/ConfigValueQueue.h index 1ccc1688d..48809437f 100644 --- a/src/lib/config/ConfigValueQueue.h +++ b/src/lib/config/ConfigValueQueue.h @@ -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 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 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 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(message, reflection, field, value, index); } diff --git a/src/lib/config/ConfigurationState.cpp b/src/lib/config/ConfigurationState.cpp index 728aa1037..0bb60d651 100644 --- a/src/lib/config/ConfigurationState.cpp +++ b/src/lib/config/ConfigurationState.cpp @@ -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 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); diff --git a/src/lib/config/ConfigurationState.h b/src/lib/config/ConfigurationState.h index b5527017c..82df6f1c6 100644 --- a/src/lib/config/ConfigurationState.h +++ b/src/lib/config/ConfigurationState.h @@ -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 diff --git a/src/lib/config/tests/HTTPServer.cpp b/src/lib/config/tests/HTTPServer.cpp index 210569a96..8bf0cf743 100644 --- a/src/lib/config/tests/HTTPServer.cpp +++ b/src/lib/config/tests/HTTPServer.cpp @@ -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; } diff --git a/src/lib/config/tests/HTTPServer.h b/src/lib/config/tests/HTTPServer.h index 971fb9999..88d1c0aac 100644 --- a/src/lib/config/tests/HTTPServer.h +++ b/src/lib/config/tests/HTTPServer.h @@ -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(); diff --git a/src/lib/config/text_format/strutil.h b/src/lib/config/text_format/strutil.h index a3d11957f..f66007a65 100644 --- a/src/lib/config/text_format/strutil.h +++ b/src/lib/config/text_format/strutil.h @@ -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); diff --git a/src/lib/config/text_format/text_format.cpp b/src/lib/config/text_format/text_format.cpp index c001fd410..d9afb414d 100644 --- a/src/lib/config/text_format/text_format.cpp +++ b/src/lib/config/text_format/text_format.cpp @@ -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); } diff --git a/src/lib/config/text_format/text_format.h b/src/lib/config/text_format/text_format.h index 575bdd6fd..af0fd78d8 100644 --- a/src/lib/config/text_format/text_format.h +++ b/src/lib/config/text_format/text_format.h @@ -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_; diff --git a/src/lib/domain_model/Security.cpp b/src/lib/domain_model/Security.cpp index d6d81e959..f56dde353 100644 --- a/src/lib/domain_model/Security.cpp +++ b/src/lib/domain_model/Security.cpp @@ -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()) diff --git a/src/lib/domain_model/Security.h b/src/lib/domain_model/Security.h index 1bba0f0a4..4dc6db98d 100644 --- a/src/lib/domain_model/Security.h +++ b/src/lib/domain_model/Security.h @@ -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) { diff --git a/src/lib/expression/ExpressionEvaluator.cpp b/src/lib/expression/ExpressionEvaluator.cpp index 381241193..8b398d4d5 100644 --- a/src/lib/expression/ExpressionEvaluator.cpp +++ b/src/lib/expression/ExpressionEvaluator.cpp @@ -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( diff --git a/src/lib/expression/Value.h b/src/lib/expression/Value.h index 878cd8db6..ca6661771 100644 --- a/src/lib/expression/Value.h +++ b/src/lib/expression/Value.h @@ -18,7 +18,11 @@ struct ValueType { }; typedef boost::make_recursive_variant< - bool, int, double, std::string, std::vector, + bool, + int, + double, + std::string, + std::vector, void *>::type Value; bool value_to_bool(const Value &val); diff --git a/src/lib/jetfix/codec/FIXEncodingStream.h b/src/lib/jetfix/codec/FIXEncodingStream.h index 8b19fad44..2456e9a96 100644 --- a/src/lib/jetfix/codec/FIXEncodingStream.h +++ b/src/lib/jetfix/codec/FIXEncodingStream.h @@ -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 checksum_bm) : offset(offset), header_offset(header_offset), size(size), checksum(checksum), seq_num(seq_num), checksum_bm(checksum_bm) {} diff --git a/src/lib/jetfix/codec/FieldDefinitions.h b/src/lib/jetfix/codec/FieldDefinitions.h index 7eedb42f1..9370e4945 100644 --- a/src/lib/jetfix/codec/FieldDefinitions.h +++ b/src/lib/jetfix/codec/FieldDefinitions.h @@ -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; diff --git a/src/lib/jetfix/codec/MessageDefinitions.h b/src/lib/jetfix/codec/MessageDefinitions.h index 31ffdc26a..934a292b6 100644 --- a/src/lib/jetfix/codec/MessageDefinitions.h +++ b/src/lib/jetfix/codec/MessageDefinitions.h @@ -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 @@ -28,8 +57,16 @@ typedef FIXMsg typedef FIXMsg 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 @@ -39,16 +76,46 @@ typedef FIXMsg 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 diff --git a/src/lib/jetfix/codec/f_toa.h b/src/lib/jetfix/codec/f_toa.h index 121685a49..b6dcefea1 100644 --- a/src/lib/jetfix/codec/f_toa.h +++ b/src/lib/jetfix/codec/f_toa.h @@ -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(); diff --git a/src/lib/jetfix/connection/AsyncReader.cpp b/src/lib/jetfix/connection/AsyncReader.cpp index 240467bbc..28fd9cdbb 100644 --- a/src/lib/jetfix/connection/AsyncReader.cpp +++ b/src/lib/jetfix/connection/AsyncReader.cpp @@ -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 const &buffer, + char *start, + char *end, + std::shared_ptr const &buffer, std::vector *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(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)) { diff --git a/src/lib/jetfix/connection/AsyncReader.h b/src/lib/jetfix/connection/AsyncReader.h index ddd01197b..9d57181f1 100644 --- a/src/lib/jetfix/connection/AsyncReader.h +++ b/src/lib/jetfix/connection/AsyncReader.h @@ -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(); diff --git a/src/lib/jetfix/gateway/CoreGateway.cpp b/src/lib/jetfix/gateway/CoreGateway.cpp index 8e2f445c3..41a673fa5 100644 --- a/src/lib/jetfix/gateway/CoreGateway.cpp +++ b/src/lib/jetfix/gateway/CoreGateway.cpp @@ -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(); diff --git a/src/lib/jetfix/gateway/CoreGateway.h b/src/lib/jetfix/gateway/CoreGateway.h index adb5fd7c1..d6aa04849 100644 --- a/src/lib/jetfix/gateway/CoreGateway.h +++ b/src/lib/jetfix/gateway/CoreGateway.h @@ -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(); diff --git a/src/lib/jetfix/gateway/JetFIXGateway.h b/src/lib/jetfix/gateway/JetFIXGateway.h index f8a798111..bc27b92cd 100644 --- a/src/lib/jetfix/gateway/JetFIXGateway.h +++ b/src/lib/jetfix/gateway/JetFIXGateway.h @@ -23,7 +23,8 @@ template 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); diff --git a/src/lib/jetfix/gateway/Session.cpp b/src/lib/jetfix/gateway/Session.cpp index 6689392de..1c6b29550 100644 --- a/src/lib/jetfix/gateway/Session.cpp +++ b/src/lib/jetfix/gateway/Session.cpp @@ -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(session_cfg); diff --git a/src/lib/jetfix/gateway/Session.h b/src/lib/jetfix/gateway/Session.h index 7c0b5bd31..0e2fbdf55 100644 --- a/src/lib/jetfix/gateway/Session.h +++ b/src/lib/jetfix/gateway/Session.h @@ -26,8 +26,11 @@ class Session { typedef std::function 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(); diff --git a/src/lib/jetfix/store/FIXFileStore.cpp b/src/lib/jetfix/store/FIXFileStore.cpp index 165e8b66b..2f8b5e9c6 100644 --- a/src/lib/jetfix/store/FIXFileStore.cpp +++ b/src/lib/jetfix/store/FIXFileStore.cpp @@ -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); diff --git a/src/lib/jetfix/store/session_name.cpp b/src/lib/jetfix/store/session_name.cpp index f73c7f51b..ee763bbb2 100644 --- a/src/lib/jetfix/store/session_name.cpp +++ b/src/lib/jetfix/store/session_name.cpp @@ -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, ' '); diff --git a/src/lib/jetfix/store/session_name.h b/src/lib/jetfix/store/session_name.h index b48f57e03..9052d3450 100644 --- a/src/lib/jetfix/store/session_name.h +++ b/src/lib/jetfix/store/session_name.h @@ -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( diff --git a/src/lib/logging/Logger.h b/src/lib/logging/Logger.h index ea184f1be..5cdf65366 100644 --- a/src/lib/logging/Logger.h +++ b/src/lib/logging/Logger.h @@ -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 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 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 s_bloom(filter_size); auto arg_hash = aggregate_hash(msg_args...); diff --git a/src/lib/logging/logging.h b/src/lib/logging/logging.h index a93eae472..ccb51da49 100644 --- a/src/lib/logging/logging.h +++ b/src/lib/logging/logging.h @@ -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 #include #include diff --git a/src/lib/logging/tests/logging_tests.cpp b/src/lib/logging/tests/logging_tests.cpp index 1f71ee0a6..6f3eb2536 100644 --- a/src/lib/logging/tests/logging_tests.cpp +++ b/src/lib/logging/tests/logging_tests.cpp @@ -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)); } diff --git a/src/lib/md/Diag/MDPeriodicDumper.cpp b/src/lib/md/Diag/MDPeriodicDumper.cpp index 0eda31815..71386cf18 100644 --- a/src/lib/md/Diag/MDPeriodicDumper.cpp +++ b/src/lib/md/Diag/MDPeriodicDumper.cpp @@ -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 &bid, const std::array &ask) { @@ -161,7 +165,9 @@ void write_header( } void run_periodic_dumper( - const std::set &symbols, uint32_t seq_mod, PrintFormat format, + const std::set &symbols, + uint32_t seq_mod, + PrintFormat format, bool monitor_all) { auto qualifier = config::get().qualifier(); diff --git a/src/lib/md/Diag/MDPeriodicDumper.h b/src/lib/md/Diag/MDPeriodicDumper.h index 21965ec5d..d70085878 100644 --- a/src/lib/md/Diag/MDPeriodicDumper.h +++ b/src/lib/md/Diag/MDPeriodicDumper.h @@ -8,7 +8,9 @@ namespace md { enum class PrintFormat { Human, CSV }; void run_periodic_dumper( - const std::set &, uint32_t seq_mod, PrintFormat format, + const std::set &, + uint32_t seq_mod, + PrintFormat format, bool monitor_all); } // namespace md diff --git a/src/lib/md/MBOProcessor.cpp b/src/lib/md/MBOProcessor.cpp index 4e2df2f70..d6f625099 100644 --- a/src/lib/md/MBOProcessor.cpp +++ b/src/lib/md/MBOProcessor.cpp @@ -65,9 +65,9 @@ void print_pool_stats(const utils::ConcurrentPool &pool) { count, bid_percentiles.str(), ask_percentiles.str()); } -typedef tbb::concurrent_hash_map< - SecurityKey, MBOSnapshot *, SecurityKeyHashCompare> - MapType; +typedef tbb:: + concurrent_hash_map + MapType; struct Incremental { MBOWorkingState *state; inc::Update update; @@ -250,7 +250,8 @@ void copy_to_snapshot(MBOWorkingState &state, MBOSnapshot *dest) { template void apply_incremental( - uint32_t security_key, C &collection, + uint32_t security_key, + C &collection, std::unordered_map &index, const inc::Update &update) { auto key = std::make_tuple(update.price, update.priority); diff --git a/src/lib/md/MBOServiceServer.cpp b/src/lib/md/MBOServiceServer.cpp index 1178b42a1..17cbb72fa 100644 --- a/src/lib/md/MBOServiceServer.cpp +++ b/src/lib/md/MBOServiceServer.cpp @@ -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()), handle_index(c), @@ -211,7 +213,8 @@ bool is_active_exchange_order(const OrderRecord &record) { } void try_remove( - MBOServiceImpl &me, std::set &to_remove, + MBOServiceImpl &me, + std::set &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 &to_add, + MBOServiceImpl &me, + std::vector &to_add, const OrderRecord &record) { if (is_active_exchange_order(record)) { auto native = native_order_state(record); diff --git a/src/lib/md/MDClient.cpp b/src/lib/md/MDClient.cpp index d055082af..6f1fd4498 100644 --- a/src/lib/md/MDClient.cpp +++ b/src/lib/md/MDClient.cpp @@ -21,7 +21,9 @@ struct MDClientImpl { utils::Event _event; MDClientImpl( - utils::Dispatcher *d, api::ISyntheticSecurityService *s, MBOReader *mbo, + utils::Dispatcher *d, + api::ISyntheticSecurityService *s, + MBOReader *mbo, const std::set *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 *symbols) : _self(new MDClientImpl(d, s, mbo, symbols)) {} diff --git a/src/lib/md/MDClient.h b/src/lib/md/MDClient.h index 624136c23..aaf7b4652 100644 --- a/src/lib/md/MDClient.h +++ b/src/lib/md/MDClient.h @@ -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 *s = nullptr); ~MDClient(); diff --git a/src/lib/md/MDConsumer.cpp b/src/lib/md/MDConsumer.cpp index 1e9906fc1..b51216ea9 100644 --- a/src/lib/md/MDConsumer.cpp +++ b/src/lib/md/MDConsumer.cpp @@ -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 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 &symbols, SecurityCache &cache, - api::ISyntheticSecurityService *ss, MBOReader *mbo, bool shared, + const set &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 *symbols, bool shared, co2::Platform platform) + SecurityCache &cache, + api::ISyntheticSecurityService *ss, + MBOReader *mbo, + const std::set *symbols, + bool shared, + co2::Platform platform) : _pimpl() { set all_symbols; diff --git a/src/lib/md/MDConsumer.h b/src/lib/md/MDConsumer.h index 089fe1c03..b5e5db890 100644 --- a/src/lib/md/MDConsumer.h +++ b/src/lib/md/MDConsumer.h @@ -32,9 +32,12 @@ class MBOReader; class MDConsumer { public: MDConsumer( - SecurityCache &, api::ISyntheticSecurityService *ss, - MBOReader *mbo = nullptr, const std::set *sym = nullptr, - bool shared = true, co2::Platform platform = co2::PLATFORM_UNSET); + SecurityCache &, + api::ISyntheticSecurityService *ss, + MBOReader *mbo = nullptr, + const std::set *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 diff --git a/src/lib/md/MDConsumerHandle.cpp b/src/lib/md/MDConsumerHandle.cpp index 9ed65bd7e..21d5417d4 100644 --- a/src/lib/md/MDConsumerHandle.cpp +++ b/src/lib/md/MDConsumerHandle.cpp @@ -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 &leg_travs, Level *out_price) { + size_t count, + api::Side side, + const api::ContractSpecification &spec, + small_vector &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 bid_leg_travs; small_vector 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; diff --git a/src/lib/md/MDConsumerHandle.h b/src/lib/md/MDConsumerHandle.h index 65306eb32..d021b6158 100644 --- a/src/lib/md/MDConsumerHandle.h +++ b/src/lib/md/MDConsumerHandle.h @@ -111,7 +111,10 @@ inline void read_combined( template 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 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) diff --git a/src/lib/md/MDConsumerInterop.cpp b/src/lib/md/MDConsumerInterop.cpp index 48e1da341..c5ba04e00 100644 --- a/src/lib/md/MDConsumerInterop.cpp +++ b/src/lib/md/MDConsumerInterop.cpp @@ -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; diff --git a/src/lib/md/MDProducer.cpp b/src/lib/md/MDProducer.cpp index dac0c1f4c..27998978d 100644 --- a/src/lib/md/MDProducer.cpp +++ b/src/lib/md/MDProducer.cpp @@ -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 diff --git a/src/lib/md/MDProducer.h b/src/lib/md/MDProducer.h index 111955ad7..614391acc 100644 --- a/src/lib/md/MDProducer.h +++ b/src/lib/md/MDProducer.h @@ -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(); diff --git a/src/lib/md/MDProducerHandle.cpp b/src/lib/md/MDProducerHandle.cpp index e23fdb338..d1a4826de 100644 --- a/src/lib/md/MDProducerHandle.cpp +++ b/src/lib/md/MDProducerHandle.cpp @@ -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(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); diff --git a/src/lib/md/MDProducerHandle.h b/src/lib/md/MDProducerHandle.h index 02cda5c56..71c29fbcd 100644 --- a/src/lib/md/MDProducerHandle.h +++ b/src/lib/md/MDProducerHandle.h @@ -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 &bids, - const std::array &asks, uint32_t seq = 0) { + TimeStamp time, + const std::array &bids, + const std::array &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 &bid, + TimeStamp time, + const std::array &bid, const std::array &ask, const std::array &implied_bid, const std::array &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 diff --git a/src/lib/md/MemorySegmentUtils.cpp b/src/lib/md/MemorySegmentUtils.cpp index d36a022f4..9d1a609fd 100644 --- a/src/lib/md/MemorySegmentUtils.cpp +++ b/src/lib/md/MemorySegmentUtils.cpp @@ -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().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"; } diff --git a/src/lib/md/MemorySegmentUtils.h b/src/lib/md/MemorySegmentUtils.h index eb7f1f82b..5eae9733a 100644 --- a/src/lib/md/MemorySegmentUtils.h +++ b/src/lib/md/MemorySegmentUtils.h @@ -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 diff --git a/src/lib/md/PlatformLoader.cpp b/src/lib/md/PlatformLoader.cpp index 08f1ef4df..9ca9423e8 100644 --- a/src/lib/md/PlatformLoader.cpp +++ b/src/lib/md/PlatformLoader.cpp @@ -81,7 +81,9 @@ size_t get_system_md_symbols(set &result) { void add_symbols_to_result( const google::protobuf::RepeatedPtrField &symbols, - Venue exchange, SecurityType type, std::set *result) { + Venue exchange, + SecurityType type, + std::set *result) { bts_assert(result); for (const auto &s : symbols) { UserSymbol u(s, exchange, type); diff --git a/src/lib/md/SettlementRecorder.cpp b/src/lib/md/SettlementRecorder.cpp index e8d17aaec..de61e98fa 100644 --- a/src/lib/md/SettlementRecorder.cpp +++ b/src/lib/md/SettlementRecorder.cpp @@ -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); diff --git a/src/lib/md/Shm/FixedSecurity.h b/src/lib/md/Shm/FixedSecurity.h index 9472f4ae5..fff8d22f1 100644 --- a/src/lib/md/Shm/FixedSecurity.h +++ b/src/lib/md/Shm/FixedSecurity.h @@ -212,7 +212,9 @@ uint64_t exchange_id(const Security &security); // Stack allocates a security of the given type template 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: { diff --git a/src/lib/md/SyntheticSecurityService.cpp b/src/lib/md/SyntheticSecurityService.cpp index 7d405efe1..5781a1ef4 100644 --- a/src/lib/md/SyntheticSecurityService.cpp +++ b/src/lib/md/SyntheticSecurityService.cpp @@ -88,7 +88,8 @@ utils::EventSubscriber &SyntheticSecurityService::on_metadata() { } void send_reply( - const api::Response &fn, CreateResult::Error err, + const api::Response &fn, + CreateResult::Error err, uint32_t key = md::invalid_security_key) { CreateResult r; r.set_key(key); diff --git a/src/lib/md/common.cpp b/src/lib/md/common.cpp index 6380c8e8a..61f91b2c7 100644 --- a/src/lib/md/common.cpp +++ b/src/lib/md/common.cpp @@ -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().channel_prefix() << Platform_Name(platform) << "/" << Venue_Name(exchange) << "/" diff --git a/src/lib/md/common.h b/src/lib/md/common.h index 07b763abd..067467b39 100644 --- a/src/lib/md/common.h +++ b/src/lib/md/common.h @@ -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 diff --git a/src/lib/md/ice/ICEUtils.cpp b/src/lib/md/ice/ICEUtils.cpp index 9434d7dcc..bf67543be 100644 --- a/src/lib/md/ice/ICEUtils.cpp +++ b/src/lib/md/ice/ICEUtils.cpp @@ -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 parse_ice_channels(const vector &symbols) { vector result; const auto &ice_options = config::get(); diff --git a/src/lib/md/relay/QueryServer.cpp b/src/lib/md/relay/QueryServer.cpp index 53ea8fdb1..2c113c071 100644 --- a/src/lib/md/relay/QueryServer.cpp +++ b/src/lib/md/relay/QueryServer.cpp @@ -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 &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 &reply) override { ProductListReply list; std::set 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 &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 &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()) {} 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"); diff --git a/src/lib/md/relay/QueryServer.h b/src/lib/md/relay/QueryServer.h index a53a5cad6..ca2e6f092 100644 --- a/src/lib/md/relay/QueryServer.h +++ b/src/lib/md/relay/QueryServer.h @@ -24,7 +24,9 @@ typedef boost::container::flat_set 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 diff --git a/src/lib/md/relay/RelayClient.cpp b/src/lib/md/relay/RelayClient.cpp index 824ecf59d..aef481c9a 100644 --- a/src/lib/md/relay/RelayClient.cpp +++ b/src/lib/md/relay/RelayClient.cpp @@ -193,8 +193,10 @@ class RelayClient { public: RelayClient( - MarketDataRelay &rpc, MDConsumer *pconsumer, - const std::set &symbols, IRelayWriter &writer) + MarketDataRelay &rpc, + MDConsumer *pconsumer, + const std::set &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 &symbols, + api::ServiceContext &ctx, + const std::set &symbols, IRelayWriter &writer) { auto relay = ctx.locate(); RelayClient client(relay, nullptr, symbols, writer); diff --git a/src/lib/md/relay/RelayClient.h b/src/lib/md/relay/RelayClient.h index 0de94e4d4..19aca3692 100644 --- a/src/lib/md/relay/RelayClient.h +++ b/src/lib/md/relay/RelayClient.h @@ -31,7 +31,8 @@ struct IRelayWriter { utils::Dispatcher &scan_securities_thread(); void relay_selected( - api::ServiceContext &ctx, const std::set &symbols, + api::ServiceContext &ctx, + const std::set &symbols, IRelayWriter &writer); void local_relay(IRelayWriter &writer); diff --git a/src/lib/md/relay/RelayRecorder.cpp b/src/lib/md/relay/RelayRecorder.cpp index c693b5393..5be30acb3 100644 --- a/src/lib/md/relay/RelayRecorder.cpp +++ b/src/lib/md/relay/RelayRecorder.cpp @@ -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().fallback(); diff --git a/src/lib/md/relay/RelayRecorder.h b/src/lib/md/relay/RelayRecorder.h index b9a670890..babf77864 100644 --- a/src/lib/md/relay/RelayRecorder.h +++ b/src/lib/md/relay/RelayRecorder.h @@ -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); diff --git a/src/lib/md/service/MarketDataServiceServer.cpp b/src/lib/md/service/MarketDataServiceServer.cpp index 6d9a52919..2f46363df 100644 --- a/src/lib/md/service/MarketDataServiceServer.cpp +++ b/src/lib/md/service/MarketDataServiceServer.cpp @@ -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 &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 &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 &reply) { api::user::TokenPayload payload; if (api::auth::decode_token(token, &payload)) { diff --git a/src/lib/md/service/MarketDataServiceServer.h b/src/lib/md/service/MarketDataServiceServer.h index 8c3d0cd33..1ca6d479a 100644 --- a/src/lib/md/service/MarketDataServiceServer.h +++ b/src/lib/md/service/MarketDataServiceServer.h @@ -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 &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 &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 &reply) override; }; diff --git a/src/lib/md/test/Co2ManagedTestHelper.cpp b/src/lib/md/test/Co2ManagedTestHelper.cpp index 56e6244cb..683801099 100644 --- a/src/lib/md/test/Co2ManagedTestHelper.cpp +++ b/src/lib/md/test/Co2ManagedTestHelper.cpp @@ -18,11 +18,15 @@ create_test_securities(MDProducer &producer, const char *postfix = "M"); void assign_ids( std::vector::iterator begin, - std::vector::iterator end, security_key start_key = 1000); + std::vector::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(); auto pcold = std::make_unique(0); diff --git a/src/lib/md/test/Co2TestInstrument.cpp b/src/lib/md/test/Co2TestInstrument.cpp index a22ab5b0c..e747c9e21 100644 --- a/src/lib/md/test/Co2TestInstrument.cpp +++ b/src/lib/md/test/Co2TestInstrument.cpp @@ -22,13 +22,14 @@ Co2TestInstrument::Co2TestInstrument( } Co2TestInstrument::Co2TestInstrument( - const Security &security, std::shared_ptr cheader, + const Security &security, + std::shared_ptr cheader, std::shared_ptr hheader) : _cold(nullptr), _hot(std::make_shared()), _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( diff --git a/src/lib/md/test/Co2TestInstrument.h b/src/lib/md/test/Co2TestInstrument.h index 4b85b86a4..c319f80d8 100644 --- a/src/lib/md/test/Co2TestInstrument.h +++ b/src/lib/md/test/Co2TestInstrument.h @@ -10,7 +10,8 @@ namespace md { struct Co2TestInstrument { Co2TestInstrument(const std::string &symbol, SecurityType type); Co2TestInstrument( - const Security &security, std::shared_ptr, + const Security &security, + std::shared_ptr, std::shared_ptr); ~Co2TestInstrument(); diff --git a/src/lib/md/test/md2_tests.cpp b/src/lib/md/test/md2_tests.cpp index 3dd8ea1ea..4c902443f 100644 --- a/src/lib/md/test/md2_tests.cpp +++ b/src/lib/md/test/md2_tests.cpp @@ -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 vlegs; vlegs.push_back(leg1); @@ -1336,7 +1343,9 @@ struct Co2RelayTests { } std::unique_ptr setup_query_server( - MDClient &client, MDProducer &producer, Entitlements *out_entitlements, + MDClient &client, + MDProducer &producer, + Entitlements *out_entitlements, vector *out_producers) { // Create a bunch of securities diff --git a/src/lib/md/test/md_test_utils.cpp b/src/lib/md/test/md_test_utils.cpp index 8bb5b29cf..42997837e 100644 --- a/src/lib/md/test/md_test_utils.cpp +++ b/src/lib/md/test/md_test_utils.cpp @@ -36,7 +36,8 @@ create_test_securities(MDProducer &producer, const char *postfix = "") { void assign_ids( std::vector::iterator begin, - std::vector::iterator end, security_key start_key) { + std::vector::iterator end, + security_key start_key) { for (; begin != end; ++begin) { (*begin).set_key(++start_key); } diff --git a/src/lib/md/test/md_test_utils.h b/src/lib/md/test/md_test_utils.h index 53a4651eb..cce2e214b 100644 --- a/src/lib/md/test/md_test_utils.h +++ b/src/lib/md/test/md_test_utils.h @@ -32,7 +32,8 @@ std::ostream &operator<<(std::ostream &os, const PS &val); void assign_ids( std::vector::iterator begin, - std::vector::iterator end, security_key start_key = 1000); + std::vector::iterator end, + security_key start_key = 1000); } // namespace test } // namespace md diff --git a/src/lib/md/test/synthetic_book_merge_tests.cpp b/src/lib/md/test/synthetic_book_merge_tests.cpp index 03166e5e0..5f20462db 100644 --- a/src/lib/md/test/synthetic_book_merge_tests.cpp +++ b/src/lib/md/test/synthetic_book_merge_tests.cpp @@ -70,7 +70,8 @@ void dump_market(const MDConsumerHandle &handle) { } void expect_market( - const MDConsumerHandle &handle, const vector bids, + const MDConsumerHandle &handle, + const vector bids, const vector &asks) { array raw_bids, raw_asks; TimeStamp t; @@ -154,7 +155,8 @@ make_securities(const vector> &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(); diff --git a/src/lib/mercury/actors/ContentSubscription.h b/src/lib/mercury/actors/ContentSubscription.h index aa9f0dad8..f1dfffacf 100644 --- a/src/lib/mercury/actors/ContentSubscription.h +++ b/src/lib/mercury/actors/ContentSubscription.h @@ -60,7 +60,8 @@ template class ContentSubscription { _pre_event([](auto const &) {}) {} ContentSubscription( - Actor &actor, std::function const &pre_ev, + Actor &actor, + std::function const &pre_ev, trace::PerfLog &log) : _actor(&actor), _sub(_actor->subscribe( [this](auto const &u) { this->on_update(u); })), @@ -69,8 +70,10 @@ template class ContentSubscription { _name(utils::type_name()), _pre_event(pre_ev) {} ContentSubscription( - Actor &actor, std::function const &pscb, - std::function const &pre_ev, trace::PerfLog &log) + Actor &actor, + std::function const &pscb, + std::function const &pre_ev, + trace::PerfLog &log) : _actor(&actor), _sub(_actor->subscribe( [this](auto const &u) { this->on_update(u); })), _my_subs(), _dispatching(false), _current_sub_id(1), _pre_sub(pscb), @@ -87,7 +90,9 @@ template class ContentSubscription { template ContentSubscription( - Actor &actor, Tag const &tag, std::function const &pscb, + Actor &actor, + Tag const &tag, + std::function const &pscb, trace::PerfLog &log) : _actor(&actor), _sub(_actor->subscribe( @@ -98,8 +103,10 @@ template class ContentSubscription { template ContentSubscription( - Actor &actor, Tag const &tag, - std::function const &pre_ev, trace::PerfLog &log) + Actor &actor, + Tag const &tag, + std::function const &pre_ev, + trace::PerfLog &log) : _actor(&actor), _sub(_actor->subscribe( tag, [this](auto const &u) { this->on_update(u); })), @@ -109,8 +116,11 @@ template class ContentSubscription { template ContentSubscription( - Actor &actor, Tag const &tag, std::function const &pscb, - std::function const &pre_ev, trace::PerfLog &log) + Actor &actor, + Tag const &tag, + std::function const &pscb, + std::function const &pre_ev, + trace::PerfLog &log) : _actor(&actor), _sub(_actor->subscribe( tag, [this](auto const &u) { this->on_update(u); })), diff --git a/src/lib/mercury/broker/Broker.cpp b/src/lib/mercury/broker/Broker.cpp index bd4316d70..bf099e65e 100644 --- a/src/lib/mercury/broker/Broker.cpp +++ b/src/lib/mercury/broker/Broker.cpp @@ -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 diff --git a/src/lib/metrics/metrics.h b/src/lib/metrics/metrics.h index 6b2108c85..50117be8c 100644 --- a/src/lib/metrics/metrics.h +++ b/src/lib/metrics/metrics.h @@ -89,7 +89,8 @@ template class LazyCounterMetric : public Metric { LazyCounterMetric(const std::string &name, const std::function &fn) : Metric(name, {}), _get(fn) {} LazyCounterMetric( - const std::string &name, const std::function &fn, + const std::string &name, + const std::function &fn, const std::vector