diff --git a/.clang-format b/.clang-format index 854ccf130..956071a4b 100644 --- a/.clang-format +++ b/.clang-format @@ -1,2 +1,4 @@ IndentWidth: 3 BinPackArguments: true +AlignAfterOpenBracket: AlwaysBreak + diff --git a/src/lib/api/core/ApiClientInterop.cpp b/src/lib/api/core/ApiClientInterop.cpp index 6c29be4b7..bf312a792 100644 --- a/src/lib/api/core/ApiClientInterop.cpp +++ b/src/lib/api/core/ApiClientInterop.cpp @@ -1,17 +1,17 @@ #include "ApiClientInterop.h" -#include "lib/quickbus/quickbus.h" #include "lib/config/config.h" #include "lib/logging/logging.h" -#include "lib/utils/bts_assert.h" +#include "lib/quickbus/quickbus.h" #include "lib/utils/Dispatcher.h" +#include "lib/utils/bts_assert.h" -#include "../public/ServiceContext.h" #include "../public/Result.h" +#include "../public/ServiceContext.h" #include "lib/api/apicore.pb.h" +#include "lib/config/protos/Ports.pb.h" #include "lib/config/protos/quickbus_cfg.pb.h" #include "lib/config/protos/system.pb.h" -#include "lib/config/protos/Ports.pb.h" #ifdef WIN32 #include @@ -20,246 +20,263 @@ namespace bts { namespace api { -config::QuickbusNodeCfg get_client_node_cfg() -{ +config::QuickbusNodeCfg get_client_node_cfg() { auto cfg = config::get(); config::QuickbusNodeCfg node_cfg; node_cfg.set_reconnect_period_secs(cfg.reconnect_period_secs()); node_cfg.set_hb_period_msecs(cfg.hb_period_msecs()); node_cfg.set_max_missed_hbs(cfg.max_missed_hbs()); node_cfg.set_parent_host( - cfg.has_qbus_host() ? - cfg.qbus_host() : - config::get().config_ip() - ); + cfg.has_qbus_host() ? cfg.qbus_host() + : config::get().config_ip()); node_cfg.set_parent_port( - cfg.has_qbus_port() ? - cfg.qbus_port() : - config::get().qbus_port() - ); + cfg.has_qbus_port() ? cfg.qbus_port() + : config::get().qbus_port()); node_cfg.set_my_port(0); return node_cfg; } - + // // Common -CAPI Quickbus* api_create_quickbus(const char* qbconfig, long length) { +CAPI Quickbus *api_create_quickbus(const char *qbconfig, long length) { // If config hasn't been initialized yet do it now and suppress exceptions. - // When we're called from a nuget package we may not have defaults which can cause errors + // When we're called from a nuget package we may not have defaults which can + // cause errors config::initialize_nothrow(nullptr, 0); config::QuickbusNodeCfg cfg; - if (length > 0 && qbconfig != nullptr && cfg.ParseFromArray(qbconfig, length)) { + if (length > 0 && qbconfig != nullptr && + cfg.ParseFromArray(qbconfig, length)) { return new Quickbus(cfg); } - // Note: Eventually api will probably want it's own instance of QB. For now we share + // Note: Eventually api will probably want it's own instance of QB. For now + // we share auto temp_conf = get_client_node_cfg(); - LOG(Api,Info,"Created Quickbus"); + LOG(Api, Info, "Created Quickbus"); return new Quickbus(temp_conf); } -CAPI void api_destroy_quickbus(Quickbus* qbus) { - #ifndef WIN32 +CAPI void api_destroy_quickbus(Quickbus *qbus) { +#ifndef WIN32 if (qbus != nullptr) { - delete qbus; + delete qbus; } - #endif +#endif } -CAPI void api_post(Quickbus& qbus, const std::function& callback, uint64_t delayms) { +CAPI void api_post( + Quickbus &qbus, const std::function &callback, uint64_t delayms) { qbus.post(callback, delayms); } -std::string base_topic(const char* type_name, const char* service_qualifier) { +std::string base_topic(const char *type_name, const char *service_qualifier) { const std::string topic_base = "api-"; - if (service_qualifier == nullptr || - strlen(service_qualifier) == 0) { + if (service_qualifier == nullptr || strlen(service_qualifier) == 0) { return topic_base + type_name; } return topic_base + type_name + "-" + service_qualifier; } -qbus::RPCServiceName rpc_topic(const std::string& base_topic) { +qbus::RPCServiceName rpc_topic(const std::string &base_topic) { return qbus::RPCServiceName(base_topic); } - // // Client struct ApiClient { - ApiClient(Quickbus& qbus, const std::string& topic) : - qbus(qbus), - service_name(topic), - rpc(qbus, rpc_topic(topic)) {} + ApiClient(Quickbus &qbus, const std::string &topic) + : qbus(qbus), service_name(topic), rpc(qbus, rpc_topic(topic)) {} - Quickbus& qbus; + Quickbus &qbus; std::string service_name; qbus::RPCClient rpc; }; -CAPI ApiClient* api_client_create(Quickbus* pqbus, const char* type_name, const char* service_qualifier) { +CAPI ApiClient *api_client_create( + Quickbus *pqbus, const char *type_name, const char *service_qualifier) { bts_assert(pqbus); auto service_name = base_topic(type_name, service_qualifier); - LOG(Api,Info, "Create client: {}",service_name); - ApiClient* pclient = new ApiClient(*pqbus, service_name); + LOG(Api, Info, "Create client: {}", service_name); + ApiClient *pclient = new ApiClient(*pqbus, service_name); return pclient; } -CAPI void api_client_destroy(ApiClient* pclient) { +CAPI void api_client_destroy(ApiClient *pclient) { if (pclient) { - LOG(Api,Info, "destroy client: {}",pclient->service_name); + LOG(Api, Info, "destroy client: {}", pclient->service_name); delete pclient; } } -template -void safe_call_fn(const C& cb) { +template void safe_call_fn(const C &cb) { #ifdef _MSC_VER __try { #endif cb(); #ifdef _MSC_VER - } - __except(EXCEPTION_EXECUTE_HANDLER) { + } __except (EXCEPTION_EXECUTE_HANDLER) { LOG(Api, Error, "Error calling CLR"); } #endif } -void reply_error(ApiError error, raw_response_callback cb, void* extra) { +void reply_error(ApiError error, raw_response_callback cb, void *extra) { ResponseHeader response; response.set_code(error); auto str = response.SerializeAsString(); - str = (char)(str.size()+1) + str; - safe_call_fn([&]() { - cb(str.c_str(), str.size(), extra); - }); + str = (char)(str.size() + 1) + str; + safe_call_fn([&]() { cb(str.c_str(), str.size(), extra); }); } - int32_t rpc_connect_timeout_ms() { - static int32_t t = config::get().rpc_connect_timeout_seconds() * 1000; + static int32_t t = + config::get().rpc_connect_timeout_seconds() * 1000; return t; } -void api_client_send_internal(ApiClient* pclient, qbus::RPCRequest&& request, raw_response_callback cb, int32_t delay, void* extra) { +void api_client_send_internal( + 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) { - // This branch is the uncommon 'slow path' where connection is taking longer than we expect - LOG(Api,Diag,"rpc call delay waiting for connection {}",((int64_t)request.value().c_str())); - pclient->qbus.post([=, request{std::move(request)}]() mutable { - api_client_send_internal(pclient, std::move(request), cb, delay - 100, extra); - }, 100); + // This branch is the uncommon 'slow path' where connection is taking + // longer than we expect + LOG(Api, Diag, "rpc call delay waiting for connection {}", + ((int64_t)request.value().c_str())); + pclient->qbus.post( + [=, request{std::move(request)}]() mutable { + api_client_send_internal( + pclient, std::move(request), cb, delay - 100, extra); + }, + 100); return; } - pclient->rpc.send(std::move(request), [=](qbus::RPCError e, const qbus::RPCReplyPtr& reply) { - LOG(Api,Diag,"rpc reply {}",((int64_t)request.value().c_str())); - switch (e) { - case qbus::RPCError::RPC_OK: - safe_call_fn([&]() { - cb(reply->value().c_str(), reply->value().size(), extra); - }); - break; - case qbus::RPCError::NO_SERVER: - reply_error(ApiError::NO_SERVER, cb, extra); - break; - case qbus::RPCError::SERVER_DISCONNECT: - reply_error(ApiError::SERVER_DISCONNECT, cb, extra); - break; - default: - reply_error(ApiError::UNEXPECTED_RESPONSE, cb, extra); - } - }); + pclient->rpc.send( + std::move(request), + [=](qbus::RPCError e, const qbus::RPCReplyPtr &reply) { + LOG(Api, Diag, "rpc reply {}", ((int64_t)request.value().c_str())); + switch (e) { + case qbus::RPCError::RPC_OK: + safe_call_fn([&]() { + cb(reply->value().c_str(), reply->value().size(), extra); + }); + break; + case qbus::RPCError::NO_SERVER: + reply_error(ApiError::NO_SERVER, cb, extra); + break; + case qbus::RPCError::SERVER_DISCONNECT: + reply_error(ApiError::SERVER_DISCONNECT, cb, extra); + break; + default: + reply_error(ApiError::UNEXPECTED_RESPONSE, cb, extra); + } + }); } -CAPI void api_client_send(ApiClient* pclient, const char* buffer, int buffer_length, raw_response_callback cb, void* extra) { - LOG(Api,Diag,"send rpc {}",((int64_t)buffer)); +CAPI void api_client_send( + 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)); - api_client_send_internal(pclient, std::move(request), cb, rpc_connect_timeout_ms(), extra); + api_client_send_internal( + pclient, std::move(request), cb, rpc_connect_timeout_ms(), extra); } -CAPI bool api_client_is_on_qb_thread(ApiClient* pclient) { +CAPI bool api_client_is_on_qb_thread(ApiClient *pclient) { return pclient->qbus.on_qb_thread(); } - -void safe_call_subscription_callback(raw_subscription_callback cb, EventType type, const std::vector& updates, void* extra) { +void safe_call_subscription_callback( + raw_subscription_callback cb, EventType type, + const std::vector &updates, void *extra) { safe_call_fn([&]() { - if (updates.size() > 0) + if (updates.size() > 0) cb(type, &updates[0], updates.size(), extra); else cb(type, nullptr, 0, extra); }); } - -bts::qbus::Topic stream_topic(const std::string& base_topic, const char* method, const char* qualifier) { +bts::qbus::Topic stream_topic( + const std::string &base_topic, const char *method, const char *qualifier) { if (qualifier == nullptr || strlen(qualifier) == 0) { return qbus::Topic(base_topic + "-" + method); - } - else { + } else { return qbus::Topic(base_topic + "-" + method + "/" + qualifier); } } -CAPI TableSubscription api_client_subscribe(ApiClient* pclient, const char* method, const char* qualifier, raw_subscription_callback cb, void* extra) { +CAPI TableSubscription api_client_subscribe( + 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 == EventType::TABLE_CREATED, "Keep these Enums in sync"); - static_assert((int)qbus::TableEvent::EventType::TABLE_DESTROYED == EventType::TABLE_DESTROYED, ""); - static_assert((int)qbus::TableEvent::EventType::TABLE_UPDATED == EventType::TABLE_UPDATED, ""); + static_assert( + (int)qbus::TableEvent::EventType::TABLE_CREATED == + EventType::TABLE_CREATED, + "Keep these Enums in sync"); + static_assert( + (int)qbus::TableEvent::EventType::TABLE_DESTROYED == + EventType::TABLE_DESTROYED, + ""); + static_assert( + (int)qbus::TableEvent::EventType::TABLE_UPDATED == + EventType::TABLE_UPDATED, + ""); static_assert((int)qbus::Change::Type::REMOVE == StreamUpdate::REMOVE, ""); static_assert((int)qbus::Change::Type::REPLACE == StreamUpdate::REPLACE, ""); static_assert((int)qbus::Change::Type::CREATE == StreamUpdate::CREATE, ""); auto topic = stream_topic(pclient->service_name, method, qualifier); - LOG(Api,Diag,"api subscribe: {}" ,topic.value()); + LOG(Api, Diag, "api subscribe: {}", topic.value()); - auto result = new qbus::TableSubscriber(pclient->qbus, equal_topic(topic), [cb, extra](const qbus::TableEvent& ev) { - if (ev.event_type == qbus::TableEvent::EventType::TABLE_CREATED || - ev.event_type == qbus::TableEvent::EventType::TABLE_DESTROYED) { - safe_call_fn([&]() { - cb((EventType)ev.event_type, nullptr, 0, extra); - }); - } - else { - bts_assert(ev.update != nullptr); - size_t update_count = ev.update->size(); - std::vector bupdates(update_count); - // Copy structure for interop - for (size_t x = 0; x < update_count; ++x) { - const auto& update = (*ev.update)[x]; - bupdates[x].type = static_cast(update.type); - bupdates[x].key = update.key.value(); - const auto& val = update.value->value(); - bupdates[x].buffer_len = val.size(); - bupdates[x].buffer = val.c_str(); - } - safe_call_subscription_callback(cb, (EventType)ev.event_type, bupdates, extra); - } - }, true); + auto result = new qbus::TableSubscriber( + pclient->qbus, equal_topic(topic), + [cb, extra](const qbus::TableEvent &ev) { + if (ev.event_type == qbus::TableEvent::EventType::TABLE_CREATED || + ev.event_type == qbus::TableEvent::EventType::TABLE_DESTROYED) { + safe_call_fn( + [&]() { cb((EventType)ev.event_type, nullptr, 0, extra); }); + } else { + bts_assert(ev.update != nullptr); + size_t update_count = ev.update->size(); + std::vector bupdates(update_count); + // Copy structure for interop + for (size_t x = 0; x < update_count; ++x) { + const auto &update = (*ev.update)[x]; + bupdates[x].type = static_cast(update.type); + bupdates[x].key = update.key.value(); + const auto &val = update.value->value(); + bupdates[x].buffer_len = val.size(); + bupdates[x].buffer = val.c_str(); + } + safe_call_subscription_callback( + cb, (EventType)ev.event_type, bupdates, extra); + } + }, + true); return result; } -CAPI void api_client_unsubscribe(ApiClient* pclient, TableSubscription pvtable) { - qbus::TableSubscriber* ptable = static_cast(pvtable); +CAPI void +api_client_unsubscribe(ApiClient *pclient, TableSubscription pvtable) { + qbus::TableSubscriber *ptable = + static_cast(pvtable); if (pclient && ptable) { ptable->disconnect(); delete ptable; } } -CAPI void api_client_log_error(const char* message) { - // managed api dll does not include logging but native api does `\_(o,o)_/` +CAPI void api_client_log_error(const char *message) { + // managed api dll does not include logging but native api does `\_(o,o)_/` std::string msg(message); - utils::Dispatcher::background().invoke([msg]() { - LOG(Api, Error, "{}", msg); - }); + utils::Dispatcher::background().invoke( + [msg]() { LOG(Api, Error, "{}", msg); }); } -}}// namespace - - +} // namespace api +} // namespace bts diff --git a/src/lib/api/core/ApiClientInterop.h b/src/lib/api/core/ApiClientInterop.h index b22b8049d..dff501fff 100644 --- a/src/lib/api/core/ApiClientInterop.h +++ b/src/lib/api/core/ApiClientInterop.h @@ -6,26 +6,27 @@ namespace bts { namespace api { struct ApiClient; -CAPI ApiClient* api_client_create(Quickbus*, const char* type_name, const char* service_qualifier); -CAPI void api_client_destroy(ApiClient*); -CAPI void api_post(Quickbus& qbus, const std::function& callback, uint64_t delayms); -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); -CAPI bool api_client_is_on_qb_thread(ApiClient*); +CAPI ApiClient *api_client_create( + Quickbus *, const char *type_name, const char *service_qualifier); +CAPI void api_client_destroy(ApiClient *); +CAPI void api_post( + Quickbus &qbus, const std::function &callback, uint64_t delayms); +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); +CAPI bool api_client_is_on_qb_thread(ApiClient *); -enum EventType { - TABLE_CREATED, - TABLE_UPDATED, - TABLE_DESTROYED -}; +enum EventType { TABLE_CREATED, TABLE_UPDATED, TABLE_DESTROYED }; -typedef void* TableSubscription; -typedef void(*raw_subscription_callback)(EventType event_type, const StreamUpdate* changes, int count, void* extra); +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); -CAPI void api_client_unsubscribe(ApiClient* pclient, TableSubscription ptable); + ApiClient *pclient, const char *method, const char *qualifier, + raw_subscription_callback cb, void *extra); +CAPI void api_client_unsubscribe(ApiClient *pclient, TableSubscription ptable); -}}//namespace +} // namespace api +} // namespace bts diff --git a/src/lib/api/core/ApiInteropCommon.h b/src/lib/api/core/ApiInteropCommon.h index 0dd6b1a09..8a264b8cc 100644 --- a/src/lib/api/core/ApiInteropCommon.h +++ b/src/lib/api/core/ApiInteropCommon.h @@ -1,32 +1,29 @@ #pragma once -#include "lib/utils/bts_export.h" #include "lib/api/apicore.pb.h" +#include "lib/utils/bts_export.h" #include #include namespace bts { - namespace qbus { - class Quickbus; - } +namespace qbus { +class Quickbus; +} namespace api { typedef qbus::Quickbus Quickbus; -CAPI Quickbus* api_create_quickbus(const char* qbconfig, long length); -CAPI void api_destroy_quickbus(Quickbus*); +CAPI Quickbus *api_create_quickbus(const char *qbconfig, long length); +CAPI void api_destroy_quickbus(Quickbus *); struct StreamUpdate { - enum Type { - REMOVE, - REPLACE, - CREATE - }; + enum Type { REMOVE, REPLACE, CREATE }; Type type; int key; int buffer_len; - const char* buffer; + const char *buffer; }; - // Internal methods -}} +// Internal methods +} // namespace api +} // namespace bts diff --git a/src/lib/api/core/ApiServerInterop.cpp b/src/lib/api/core/ApiServerInterop.cpp index 46a224b4e..331c8ec47 100644 --- a/src/lib/api/core/ApiServerInterop.cpp +++ b/src/lib/api/core/ApiServerInterop.cpp @@ -1,81 +1,98 @@ #include "ApiServerInterop.h" -#include "lib/quickbus/quickbus.h" #include "lib/logging/logging.h" +#include "lib/quickbus/quickbus.h" #include "lib/utils/bts_assert.h" namespace bts { namespace api { // defined in ApiClientInterop.h -std::string base_topic(const char* type_name, const char* service_qualifier); -bts::qbus::RPCServiceName rpc_topic(const std::string& base_topic); -bts::qbus::Topic stream_topic(const std::string& base_topic, const char* method, const char* qualifier); +std::string base_topic(const char *type_name, const char *service_qualifier); +bts::qbus::RPCServiceName rpc_topic(const std::string &base_topic); +bts::qbus::Topic stream_topic( + const std::string &base_topic, const char *method, const char *qualifier); struct ApiServerCore { - ApiServerCore(Quickbus& qbus, const std::string topic, const qbus::OnRPCRequest& handler) : - qbus(qbus), - topic(topic), - rpc(qbus, rpc_topic(topic), handler) - {} + ApiServerCore( + Quickbus &qbus, const std::string topic, + const qbus::OnRPCRequest &handler) + : qbus(qbus), topic(topic), rpc(qbus, rpc_topic(topic), handler) {} - Quickbus& qbus; + Quickbus &qbus; std::string topic; qbus::RPCServer rpc; }; -CAPI ApiServerCore* api_server_create(Quickbus* pbus, const char* type_name, const char* service_qualifier, raw_rpc_request_callback cb, void* extra) { +CAPI ApiServerCore *api_server_create( + 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 : { '+' }) { + for (auto ch : {'+'}) { bts_assert(strchr(service_qualifier, ch) == nullptr); } auto service_name = base_topic(type_name, service_qualifier); - LOG(Api,Info,"Create server: {}",service_name); - return new ApiServerCore(*pbus, service_name, [=](qbus::RPCRequestPtr const& req, qbus::ReplyHandler const& reply) { - // Extend the lifetime of the ReplyHandler by moving it to the heap - qbus::ReplyHandler* phandler = new qbus::ReplyHandler(std::move(reply)); - LOG(Api,Diag,"Received rpc request: {}",reinterpret_cast(phandler)); - cb((uint8_t*)(req->value().c_str()), req->value().size(), reinterpret_cast(phandler), extra); - }); + LOG(Api, Info, "Create server: {}", service_name); + return new ApiServerCore( + *pbus, service_name, + [=](qbus::RPCRequestPtr const &req, qbus::ReplyHandler const &reply) { + // Extend the lifetime of the ReplyHandler by moving it to the heap + qbus::ReplyHandler *phandler = + new qbus::ReplyHandler(std::move(reply)); + LOG(Api, Diag, "Received rpc request: {}", + reinterpret_cast(phandler)); + cb((uint8_t *)(req->value().c_str()), req->value().size(), + reinterpret_cast(phandler), extra); + }); } -CAPI void api_server_call_callback(ReplyHandler** ppvhandler, const uint8_t* buffer, int length) { +CAPI void api_server_call_callback( + ReplyHandler **ppvhandler, const uint8_t *buffer, int length) { bts_assert(ppvhandler); bts_assert(*ppvhandler); - //LOG(Api,Diag,"Send rpc reply: {}",reinterpret_cast(*ppvhandler)); - qbus::ReplyHandler** pphandler = reinterpret_cast(ppvhandler); - std::string reply_buffer((const char*)buffer, (size_t)length); - qbus::RPCReplyPtr replyptr = std::make_shared(move(reply_buffer)); + // LOG(Api,Diag,"Send rpc reply: + // {}",reinterpret_cast(*ppvhandler)); + qbus::ReplyHandler **pphandler = + reinterpret_cast(ppvhandler); + std::string reply_buffer((const char *)buffer, (size_t)length); + qbus::RPCReplyPtr replyptr = + std::make_shared(move(reply_buffer)); (**pphandler)(replyptr); delete (*pphandler); *pphandler = nullptr; } -CAPI TableHandle api_server_create_table(ApiServerCore* pserver, const char* method, const char* qualifier) { +CAPI TableHandle api_server_create_table( + ApiServerCore *pserver, const char *method, const char *qualifier) { bts_assert(pserver); auto topic = stream_topic(pserver->topic, method, qualifier); - LOG(Api,Info,"Create table: {}",topic.value()); + LOG(Api, Info, "Create table: {}", topic.value()); return new qbus::TablePublisher(pserver->qbus, topic); } -CAPI void api_server_update_table(TableHandle htable, StreamUpdate* raw_changes, int change_count) { +CAPI void api_server_update_table( + TableHandle htable, StreamUpdate *raw_changes, int change_count) { bts_assert(htable); - qbus::TablePublisher* ptable = reinterpret_cast(htable); + qbus::TablePublisher *ptable = + reinterpret_cast(htable); std::vector changes(change_count); for (int x = 0; x < change_count; ++x) { - StreamUpdate& ch = raw_changes[x]; + StreamUpdate &ch = raw_changes[x]; std::string buffer(ch.buffer, ch.buffer_len); - qbus::RecordPtr record = std::make_shared(std::move(buffer)); - changes[x] = qbus::Change((qbus::Change::Type)ch.type, qbus::RecordKey(ch.key), record); + qbus::RecordPtr record = + std::make_shared(std::move(buffer)); + changes[x] = qbus::Change( + (qbus::Change::Type)ch.type, qbus::RecordKey(ch.key), record); } ptable->publish(std::move(changes)); } -CAPI void api_server_destroy_table(qbus::TablePublisher* ptable) { +CAPI void api_server_destroy_table(qbus::TablePublisher *ptable) { if (ptable) { ptable->disconnect(); delete ptable; } } -} }//namespace +} // namespace api +} // namespace bts diff --git a/src/lib/api/core/ApiServerInterop.h b/src/lib/api/core/ApiServerInterop.h index e25b637b2..75387a021 100644 --- a/src/lib/api/core/ApiServerInterop.h +++ b/src/lib/api/core/ApiServerInterop.h @@ -6,13 +6,20 @@ namespace api { struct ApiServerCore; 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); +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); -CAPI void api_server_call_callback(ReplyHandler** pphandler, const uint8_t* buffer, int length); +CAPI void api_server_call_callback( + ReplyHandler **pphandler, const uint8_t *buffer, int length); -typedef void* TableHandle; -CAPI TableHandle api_server_create_table(ApiServerCore* pserver, const char* method, const char* qualifier); -CAPI void api_server_update_table(TableHandle htable, StreamUpdate* raw_changes, int change_count); +typedef void *TableHandle; +CAPI TableHandle api_server_create_table( + ApiServerCore *pserver, const char *method, const char *qualifier); +CAPI void api_server_update_table( + TableHandle htable, StreamUpdate *raw_changes, int change_count); -}}//namespace +} // namespace api +} // namespace bts diff --git a/src/lib/api/public/ApiException.h b/src/lib/api/public/ApiException.h index 886d8485f..87028c39f 100644 --- a/src/lib/api/public/ApiException.h +++ b/src/lib/api/public/ApiException.h @@ -7,14 +7,15 @@ namespace bts { namespace api { -class ApiException : public std::exception -{ +class ApiException : public std::exception { std::string _what; -public: - ApiException(const std::string& what) : _what(what) {} + + public: + ApiException(const std::string &what) : _what(what) {} ~ApiException() {} - const char* what() const throw() { return _what.c_str(); } + const char *what() const throw() { return _what.c_str(); } }; -}}//namespace +} // namespace api +} // namespace bts diff --git a/src/lib/api/public/ApiServer.cpp b/src/lib/api/public/ApiServer.cpp index 54b000ed3..c2ab0b321 100644 --- a/src/lib/api/public/ApiServer.cpp +++ b/src/lib/api/public/ApiServer.cpp @@ -4,11 +4,13 @@ namespace bts { namespace api { -ApiServer::ApiServer(const ServiceContext& ctx, const std::string& type, const std::string& qualifier) : - _channel(ctx.publish(*this, type, qualifier)) -{ } +ApiServer::ApiServer( + const ServiceContext &ctx, const std::string &type, + const std::string &qualifier) + : _channel(ctx.publish(*this, type, qualifier)) {} -ApiServer::~ApiServer() { } +ApiServer::~ApiServer() {} -}}//namespace +} // namespace api +} // namespace bts #endif diff --git a/src/lib/api/public/ApiServer.h b/src/lib/api/public/ApiServer.h index d4200f93e..fd9fda7d4 100644 --- a/src/lib/api/public/ApiServer.h +++ b/src/lib/api/public/ApiServer.h @@ -1,38 +1,41 @@ #pragma once -#include "lib/utils/bts_export.h" #include "../core/ApiClientInterop.h" #include "ApiUtils.h" #include "ServerChannel.h" #include "StatefulPublisher.h" #include "lib/api/apicore.pb.h" +#include "lib/utils/bts_export.h" -#include -#include #include +#include +#include #include namespace bts { namespace api { -template using Response = std::function; +template using Response = std::function; class ServiceContext; -class BTS_EXPORT ApiServer -{ -public: - ApiServer(const ServiceContext&, const std::string& type, const std::string& qualifier); +class BTS_EXPORT ApiServer { + public: + ApiServer( + 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&, OnResponse) = 0; - virtual const char* name() const = 0; + typedef std::function OnResponse; + virtual void dispatch( + const RequestHeader &, google::protobuf::io::ZeroCopyInputStream &, + OnResponse) = 0; + virtual const char *name() const = 0; -protected: + protected: ServerChannel _channel; template - void respond(int request_id, const T& response, OnResponse onreply) { + void respond(int request_id, const T &response, OnResponse onreply) { ResponseHeader header; header.set_code(ApiError::SUCCESS); header.set_request_id(request_id); @@ -43,8 +46,7 @@ protected: uint8_t buffer[1024]; serialize(header_size, body_size, header, response, buffer); onreply(buffer, total_size); - } - else { + } else { std::vector buffer(total_size); serialize(header_size, body_size, header, response, &buffer[0]); onreply(&buffer[0], total_size); @@ -52,16 +54,20 @@ protected: } template - static void serialize(int header_size, int body_size, const ResponseHeader& header, const T& response, uint8_t* buffer) { + static void serialize( + 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); } - static void serialize(int header_size, const ResponseHeader& header, uint8_t* buffer) { + static void + serialize(int header_size, const ResponseHeader &header, uint8_t *buffer) { buffer[0] = header_size; header.SerializePartialToArray(&buffer[1], header_size - 1); } }; -}}//namespace +} // namespace api +} // namespace bts diff --git a/src/lib/api/public/ApiUtils.h b/src/lib/api/public/ApiUtils.h index 18cc96fd6..eb15b4d3d 100644 --- a/src/lib/api/public/ApiUtils.h +++ b/src/lib/api/public/ApiUtils.h @@ -1,22 +1,24 @@ #pragma once -#include #include #include +#include namespace bts { namespace api { - template - const std::string toJSON(const T& t) { - google::protobuf::util::JsonPrintOptions options; - options.add_whitespace = false; - options.always_print_primitive_fields = true; - std::string result; - auto status = google::protobuf::util::MessageToJsonString(t, &result, options); - if (status.ok()) return result; - else return ""; - } - -}}//namespace +template const std::string toJSON(const T &t) { + google::protobuf::util::JsonPrintOptions options; + options.add_whitespace = false; + options.always_print_primitive_fields = true; + std::string result; + auto status = + google::protobuf::util::MessageToJsonString(t, &result, options); + if (status.ok()) + return result; + else + return ""; +} +} // namespace api +} // namespace bts diff --git a/src/lib/api/public/ClientChannel.cpp b/src/lib/api/public/ClientChannel.cpp index f89d33d8a..83d12b1f3 100644 --- a/src/lib/api/public/ClientChannel.cpp +++ b/src/lib/api/public/ClientChannel.cpp @@ -3,11 +3,11 @@ namespace bts { namespace api { -ClientChannel::ClientChannel(const ServiceContext& ctx) : _id(1), _context(ctx) -{ -} +ClientChannel::ClientChannel(const ServiceContext &ctx) + : _id(1), _context(ctx) {} -ClientChannel::~ClientChannel() { } +ClientChannel::~ClientChannel() {} -}}//namespace +} // namespace api +} // namespace bts #endif diff --git a/src/lib/api/public/ClientChannel.h b/src/lib/api/public/ClientChannel.h index fb5fd31c7..028eb76c0 100644 --- a/src/lib/api/public/ClientChannel.h +++ b/src/lib/api/public/ClientChannel.h @@ -1,147 +1,170 @@ #pragma once #include "../core/ApiClientInterop.h" -#include "Result.h" #include "ApiException.h" #include "RawUpdate.h" +#include "Result.h" #include "ServiceContext.h" #include "lib/logging/logging.h" -#include #include #include +#include namespace bts { namespace api { template -std::shared_ptr deserialize(const char* buffer, size_t length) { +std::shared_ptr deserialize(const char *buffer, size_t length) { google::protobuf::io::ArrayInputStream stream(buffer, length); auto item = std::make_shared(); if (item->ParseFromZeroCopyStream(&stream)) { return item; } - LOG(Api,Error,"Failed to deserialize proto from api stream. This is likely fatal."); + LOG(Api, Error, + "Failed to deserialize proto from api stream. This is likely fatal."); return nullptr; } -class ClientChannel -{ +class ClientChannel { int _id; ServiceContext _context; -public: - ClientChannel(const ServiceContext&); + + public: + ClientChannel(const ServiceContext &); virtual ~ClientChannel(); template - void send(int method_id, const Request& request, std::function)> on_response) { + void send( + int method_id, const Request &request, + std::function)> on_response) { RequestHeader header; header.set_method(method_id); header.set_request_id(++_id); auto ptoken = _context.token(); - if (ptoken) header.mutable_token()->CopyFrom(*ptoken); - int header_size = header.ByteSize()+1; + if (ptoken) + header.mutable_token()->CopyFrom(*ptoken); + int header_size = header.ByteSize() + 1; assert(header_size < 128); - std::string request_buffer; + std::string request_buffer; request_buffer.reserve(header_size + request.ByteSize()); request_buffer += (char)(header_size); bool success = header.AppendToString(&request_buffer); success = success && request.AppendToString(&request_buffer); - if (!success) throw ApiException("Failed to serialize request."); + if (!success) + throw ApiException("Failed to serialize request."); - send_core(request_buffer, [on_response](const char* response_buffer, size_t response_size) { - assert(response_size > 1); - int header_size = response_buffer[0]; - assert(header_size > 0); - google::protobuf::io::ArrayInputStream header_stream(response_buffer+1, header_size-1); - ResponseHeader header; - if (header.ParseFromZeroCopyStream(&header_stream)) { - if (header.code() == ApiError::SUCCESS) { - auto response = std::make_shared(); - google::protobuf::io::ArrayInputStream data_stream(response_buffer + header_size, response_size - header_size); - if (response->ParseFromZeroCopyStream(&data_stream)) { - on_response(Result(move(response))); - return; - } - } - else { - on_response(Result((ApiError)header.code())); - } - } - else { - on_response(Result(ApiError::UNEXPECTED_RESPONSE)); - } - }); + send_core( + request_buffer, + [on_response](const char *response_buffer, size_t response_size) { + assert(response_size > 1); + int header_size = response_buffer[0]; + assert(header_size > 0); + google::protobuf::io::ArrayInputStream header_stream( + response_buffer + 1, header_size - 1); + ResponseHeader header; + if (header.ParseFromZeroCopyStream(&header_stream)) { + if (header.code() == ApiError::SUCCESS) { + auto response = std::make_shared(); + google::protobuf::io::ArrayInputStream data_stream( + response_buffer + header_size, + response_size - header_size); + if (response->ParseFromZeroCopyStream(&data_stream)) { + on_response(Result(move(response))); + return; + } + } else { + on_response(Result((ApiError)header.code())); + } + } else { + on_response(Result(ApiError::UNEXPECTED_RESPONSE)); + } + }); } - template - rxcpp::observable>> subscribe(int method_id, const char* method, const std::string& qualifier) { - return rxcpp::observable<>::create>>([=](rxcpp::subscriber>> observer) { - StreamAccessRequest request; - request.set_qualifier(qualifier); - send(method_id, request, [=](const Result& response) { - // There is a race on server startup. If the server is not yet we can't return a dead stream - // if (!response) { - // observer.on_error( - // std::make_exception_ptr( - // ApiException(response.error_message()))); - // } - if (response && !response.value()->authorized()) { - observer.on_completed(); - } - else { - bool first_update = true; - auto cb = [observer, first_update, qualifier](EventType event_type, const StreamUpdate* changes, int change_count) mutable { - if (event_type == EventType::TABLE_UPDATED) { - std::vector> added_items, changed_items; - std::vector added_keys, - changed_keys, - removed_keys; - for (size_t x = 0; x < change_count; ++x) { - const StreamUpdate& change = changes[x]; - switch(change.type) { - case StreamUpdate::REMOVE: - removed_keys.push_back(change.key); - break; - case StreamUpdate::REPLACE: - changed_items.push_back(deserialize(change.buffer, change.buffer_len)); - changed_keys.push_back(change.key); - break; - case StreamUpdate::CREATE: - added_items.push_back(deserialize(change.buffer, change.buffer_len)); - added_keys.push_back(change.key); - break; - } - } - observer.on_next(RawUpdate>(added_items, added_keys, changed_items, changed_keys, removed_keys)); - } - else if (event_type == EventType::TABLE_CREATED) { - if (!first_update) { - observer.on_next(RawUpdate>::Reset()); - } - first_update = false; - } - }; - observer.add( - subscribe_core(method, qualifier.c_str(), cb)); - } - }); - }); + rxcpp::observable>> + subscribe(int method_id, const char *method, const std::string &qualifier) { + return rxcpp::observable<>::create>>( + [=](rxcpp::subscriber>> observer) { + StreamAccessRequest request; + request.set_qualifier(qualifier); + send( + method_id, request, + [=](const Result &response) { + // There is a race on server startup. If the server is not + // yet we can't return a dead stream if (!response) { + // observer.on_error( + // std::make_exception_ptr( + // ApiException(response.error_message()))); + // } + if (response && !response.value()->authorized()) { + observer.on_completed(); + } else { + bool first_update = true; + auto cb = [observer, first_update, qualifier]( + EventType event_type, + const StreamUpdate *changes, + int change_count) mutable { + if (event_type == EventType::TABLE_UPDATED) { + std::vector> added_items, + changed_items; + std::vector added_keys, changed_keys, + removed_keys; + for (size_t x = 0; x < change_count; ++x) { + const StreamUpdate &change = changes[x]; + switch (change.type) { + case StreamUpdate::REMOVE: + removed_keys.push_back(change.key); + break; + case StreamUpdate::REPLACE: + changed_items.push_back(deserialize( + change.buffer, change.buffer_len)); + changed_keys.push_back(change.key); + break; + case StreamUpdate::CREATE: + added_items.push_back(deserialize( + change.buffer, change.buffer_len)); + added_keys.push_back(change.key); + break; + } + } + observer.on_next( + RawUpdate>( + added_items, added_keys, changed_items, + changed_keys, removed_keys)); + } else if (event_type == EventType::TABLE_CREATED) { + if (!first_update) { + observer.on_next( + RawUpdate< + std::shared_ptr>::Reset()); + } + first_update = false; + } + }; + observer.add( + subscribe_core(method, qualifier.c_str(), cb)); + } + }); + }); } - + virtual bool is_sync_call_ok() = 0; -protected: - typedef std::function OnReply; + protected: + typedef std::function OnReply; typedef std::function Unsubscribe; - typedef std::function OnSubscriptionCB; - virtual void send_core(const std::string& request_buffer, OnReply on_response) = 0; - virtual Unsubscribe subscribe_core(const char* method, const char* qualifier, OnSubscriptionCB cb) = 0; + typedef std::function + OnSubscriptionCB; + virtual void + send_core(const std::string &request_buffer, OnReply on_response) = 0; + virtual Unsubscribe subscribe_core( + const char *method, const char *qualifier, OnSubscriptionCB cb) = 0; -private: - ClientChannel(const ClientChannel& other);// = delete; + private: + ClientChannel(const ClientChannel &other); // = delete; }; -}}//namespace +} // namespace api +} // namespace bts diff --git a/src/lib/api/public/QuickbusClientChannel.cpp b/src/lib/api/public/QuickbusClientChannel.cpp index 157e00c40..f0dfd7ed9 100644 --- a/src/lib/api/public/QuickbusClientChannel.cpp +++ b/src/lib/api/public/QuickbusClientChannel.cpp @@ -1,14 +1,14 @@ #include "QuickbusClientChannel.h" -#include "QuickbusClientChannel.h" #include "ClientChannel.h" +#include "QuickbusClientChannel.h" namespace bts { namespace api { -QuickbusClientChannel::QuickbusClientChannel(Quickbus& bus, const ServiceContext& context, const char* type_name, const char* service_qualifier) : - ClientChannel(context), - _pclient(api_client_create(&bus, type_name, service_qualifier)) -{ -} +QuickbusClientChannel::QuickbusClientChannel( + Quickbus &bus, const ServiceContext &context, const char *type_name, + const char *service_qualifier) + : ClientChannel(context), + _pclient(api_client_create(&bus, type_name, service_qualifier)) {} QuickbusClientChannel::~QuickbusClientChannel() { if (_pclient != nullptr) { @@ -17,26 +17,34 @@ QuickbusClientChannel::~QuickbusClientChannel() { } } -void QuickbusClientChannel::send_core(const std::string& request_envalope, OnReply on_response) { - raw_response_callback trampoline = [](const char* buffer, size_t length, void* extraptr) { - OnReply* on_response = static_cast(extraptr); +void QuickbusClientChannel::send_core( + const std::string &request_envalope, OnReply on_response) { + raw_response_callback trampoline = [](const char *buffer, size_t length, + void *extraptr) { + OnReply *on_response = static_cast(extraptr); assert(on_response != nullptr); (*on_response)(buffer, length); delete on_response; }; - OnReply* heap_on_response = new OnReply(move(on_response)); - api_client_send(_pclient, request_envalope.c_str(), request_envalope.size(), trampoline, heap_on_response); + OnReply *heap_on_response = new OnReply(move(on_response)); + api_client_send( + _pclient, request_envalope.c_str(), request_envalope.size(), trampoline, + heap_on_response); } -ClientChannel::Unsubscribe QuickbusClientChannel::subscribe_core(const char* method, const char* qualifier, OnSubscriptionCB cb) { - raw_subscription_callback trampoline = [](EventType event_type, const StreamUpdate* changes, int count, void* extra) { - OnSubscriptionCB* heap_cb = static_cast(extra); +ClientChannel::Unsubscribe QuickbusClientChannel::subscribe_core( + const char *method, const char *qualifier, OnSubscriptionCB cb) { + raw_subscription_callback trampoline = [](EventType event_type, + const StreamUpdate *changes, + int count, void *extra) { + OnSubscriptionCB *heap_cb = static_cast(extra); assert(heap_cb != nullptr); (*heap_cb)(event_type, changes, count); }; - OnSubscriptionCB* heap_cb = new OnSubscriptionCB(cb); - auto subscription = api_client_subscribe(_pclient, method, qualifier, trampoline, heap_cb); - return [this,subscription,heap_cb]() { + OnSubscriptionCB *heap_cb = new OnSubscriptionCB(cb); + auto subscription = + api_client_subscribe(_pclient, method, qualifier, trampoline, heap_cb); + return [this, subscription, heap_cb]() { api_client_unsubscribe(_pclient, subscription); delete heap_cb; }; @@ -46,4 +54,5 @@ bool QuickbusClientChannel::is_sync_call_ok() { return !api_client_is_on_qb_thread(_pclient); } -}}//namespace +} // namespace api +} // namespace bts diff --git a/src/lib/api/public/QuickbusClientChannel.h b/src/lib/api/public/QuickbusClientChannel.h index bfda19f4f..597245200 100644 --- a/src/lib/api/public/QuickbusClientChannel.h +++ b/src/lib/api/public/QuickbusClientChannel.h @@ -1,27 +1,30 @@ #pragma once -#include "lib/utils/bts_no_copy.h" #include "ClientChannel.h" +#include "lib/utils/bts_no_copy.h" namespace bts { namespace api { class ServiceContext; -class QuickbusClientChannel : public ClientChannel -{ - ApiClient* _pclient; +class QuickbusClientChannel : public ClientChannel { + ApiClient *_pclient; -public: - QuickbusClientChannel(Quickbus&, const ServiceContext&, const char* type_name, const char* service_qualifier); + public: + QuickbusClientChannel( + Quickbus &, const ServiceContext &, const char *type_name, + const char *service_qualifier); ~QuickbusClientChannel(); -private: + private: BTS_NO_COPY(QuickbusClientChannel); - - virtual void send_core(const std::string& request_envalope, OnReply on_response) override; - virtual Unsubscribe subscribe_core(const char* method, const char* qualifier, OnSubscriptionCB cb) override; - virtual bool is_sync_call_ok() override; + virtual void + send_core(const std::string &request_envalope, OnReply on_response) override; + virtual Unsubscribe subscribe_core( + const char *method, const char *qualifier, OnSubscriptionCB cb) override; + virtual bool is_sync_call_ok() override; }; -}}//namespace +} // namespace api +} // namespace bts diff --git a/src/lib/api/public/RawUpdate.h b/src/lib/api/public/RawUpdate.h index 93e7cabe3..fe88ee9d2 100644 --- a/src/lib/api/public/RawUpdate.h +++ b/src/lib/api/public/RawUpdate.h @@ -1,42 +1,36 @@ #pragma once -#include #include +#include namespace bts { namespace api { - template - struct RawUpdate { - RawUpdate(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)), +template struct RawUpdate { + RawUpdate( + 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)), changed_items(std::move(changed_items)), changed_keys(std::move(changed_keys)), - removed_keys(std::move(removed_keys)) - {} + removed_keys(std::move(removed_keys)) {} - static RawUpdate Reset() { - return RawUpdate(); - } + static RawUpdate Reset() { return RawUpdate(); } - bool is_reset; - std::vector added_items; - std::vector added_keys; + bool is_reset; + std::vector added_items; + std::vector added_keys; - std::vector changed_items; - std::vector changed_keys; + std::vector changed_items; + std::vector changed_keys; - std::vector removed_keys; + std::vector removed_keys; - private: - RawUpdate() : - is_reset(true), - added_items(), added_keys(), changed_items(), changed_keys(), removed_keys() - {} - }; + private: + RawUpdate() + : is_reset(true), added_items(), added_keys(), changed_items(), + changed_keys(), removed_keys() {} +}; -} }//ns \ No newline at end of file +} // namespace api +} // namespace bts \ No newline at end of file diff --git a/src/lib/api/public/Result.h b/src/lib/api/public/Result.h index 22b868434..203332ac2 100644 --- a/src/lib/api/public/Result.h +++ b/src/lib/api/public/Result.h @@ -4,70 +4,64 @@ #include "lib/api/apicore.pb.h" -#include #include #include - +#include namespace bts { namespace api { -template -class Result -{ +template class Result { std::shared_ptr _t; ApiError _code; - static const char* error_string(ApiError code) { + static const char *error_string(ApiError code) { switch (code) { - case ApiError::SUCCESS: return "Success"; - case ApiError::NO_SERVER: return "No server found."; - case ApiError::SERVER_DISCONNECT: return "Server disconnected."; - case ApiError::MISSING_METHOD: return "Method not found."; - case ApiError::SERVER_FAULT: return "Server error."; - case ApiError::UNEXPECTED_RESPONSE: return "Internal error"; - case ApiError::ACCESS_DENIED: return "Access denied"; - default: return "Unknown error"; + case ApiError::SUCCESS: + return "Success"; + case ApiError::NO_SERVER: + return "No server found."; + case ApiError::SERVER_DISCONNECT: + return "Server disconnected."; + case ApiError::MISSING_METHOD: + return "Method not found."; + case ApiError::SERVER_FAULT: + return "Server error."; + case ApiError::UNEXPECTED_RESPONSE: + return "Internal error"; + case ApiError::ACCESS_DENIED: + return "Access denied"; + default: + return "Unknown error"; } } -public: - Result(std::shared_ptr& t): - _t(t), - _code(ApiError::SUCCESS) - { } - Result(std::shared_ptr&& t): - _t(t), - _code(ApiError::SUCCESS) - { } - Result(ApiError code) : - _t(), - _code(code) - { + public: + Result(std::shared_ptr &t) : _t(t), _code(ApiError::SUCCESS) {} + Result(std::shared_ptr &&t) : _t(t), _code(ApiError::SUCCESS) {} + Result(ApiError code) : _t(), _code(code) { assert(_code != ApiError::SUCCESS); } #if _MSC_VER // needed for std::future - Result() : - _t(), - _code(ApiError::UNEXPECTED_RESPONSE) - {} + Result() : _t(), _code(ApiError::UNEXPECTED_RESPONSE) {} #endif std::shared_ptr value() const { - if (success()) return _t; - else return nullptr; + if (success()) + return _t; + else + return nullptr; } bool success() const { return _code == ApiError::SUCCESS; } operator bool() const { return success(); } ApiError code() const { return _code; } - const char* error_message() const { return error_string(_code); } + const char *error_message() const { return error_string(_code); } ~Result() {} }; - -}}//namespace - +} // namespace api +} // namespace bts diff --git a/src/lib/api/public/ServerChannel.cpp b/src/lib/api/public/ServerChannel.cpp index 6a791638e..3aad69afd 100644 --- a/src/lib/api/public/ServerChannel.cpp +++ b/src/lib/api/public/ServerChannel.cpp @@ -6,58 +6,67 @@ namespace bts { namespace api { - struct ServerChannel::ServerChannelImpl { - ServerChannelImpl(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)) - { - } - //Need to guaruntee this object is stationary for the api_server_create trampoline - ServerChannelImpl(const ServerChannelImpl& ) = delete; - ServerChannelImpl(ServerChannelImpl&&) = delete; + ServerChannelImpl( + 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)) {} + // 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, void* extra) { + static void dispatch_trampoline( + const uint8_t *buffer, size_t request_size, ReplyHandler *callback, + void *extra) { assert(extra != nullptr); - ServerChannelImpl* pimpl = static_cast(extra); + ServerChannelImpl *pimpl = static_cast(extra); pimpl->dispatch(buffer, request_size, callback); } - void dispatch(const uint8_t* request_buffer, size_t request_length, ReplyHandler* callback) { + void dispatch( + const uint8_t *request_buffer, size_t request_length, + ReplyHandler *callback) { assert(request_buffer != nullptr); assert(request_length > 1); size_t header_length = request_buffer[0]; assert(request_length >= header_length); RequestHeader header; if (header.ParsePartialFromArray(request_buffer + 1, header_length - 1)) { - google::protobuf::io::ArrayInputStream stream(request_buffer + header_length, request_length - header_length); - _server.dispatch(header, stream, [=](const uint8_t* buffer, size_t length) { - ReplyHandler* handler = callback; - api_server_call_callback(&handler, buffer, (int)length); - }); + google::protobuf::io::ArrayInputStream stream( + request_buffer + header_length, request_length - header_length); + _server.dispatch( + header, stream, [=](const uint8_t *buffer, size_t length) { + ReplyHandler *handler = callback; + api_server_call_callback(&handler, buffer, (int)length); + }); } } - ApiServer& _server; - ApiServerCore* _core; + ApiServer &_server; + ApiServerCore *_core; }; +ServerChannel::ServerChannel( + 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)) {} -ServerChannel::ServerChannel(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)) {} +ServerChannel::~ServerChannel() {} -ServerChannel::~ServerChannel() { } - - -TableHandle ServerChannel::create_table(const char* method, const char* qualifier) const { +TableHandle +ServerChannel::create_table(const char *method, const char *qualifier) const { return api_server_create_table(_me->_core, method, qualifier); } -void ServerChannel::publish(TableHandle table, StreamUpdate* changes, int change_count) const { +void ServerChannel::publish( + TableHandle table, StreamUpdate *changes, int change_count) const { api_server_update_table(table, changes, change_count); } - -}}//namespace +} // namespace api +} // namespace bts #endif diff --git a/src/lib/api/public/ServerChannel.h b/src/lib/api/public/ServerChannel.h index bce1c6661..2ca957a3d 100644 --- a/src/lib/api/public/ServerChannel.h +++ b/src/lib/api/public/ServerChannel.h @@ -8,20 +8,22 @@ namespace bts { namespace api { class ApiServer; -class ServerChannel -{ -public: - ServerChannel(Quickbus& qbus, const std::string& service_type, const std::string& qualifier, ApiServer& server); - ServerChannel(ServerChannel&& other);// : _me(std::move(other._me)) {} +class ServerChannel { + public: + ServerChannel( + Quickbus &qbus, const std::string &service_type, + const std::string &qualifier, ApiServer &server); + ServerChannel(ServerChannel &&other); // : _me(std::move(other._me)) {} ~ServerChannel(); - TableHandle create_table(const char* method, const char* qualifier) const; - void publish(TableHandle table, StreamUpdate* changes, int change_count) const; + TableHandle create_table(const char *method, const char *qualifier) const; + void + publish(TableHandle table, StreamUpdate *changes, int change_count) const; -private: + private: struct ServerChannelImpl; std::unique_ptr _me; }; -}}//namespace - +} // namespace api +} // namespace bts diff --git a/src/lib/api/public/ServiceContext.cpp b/src/lib/api/public/ServiceContext.cpp index 39de8b4fa..65780791c 100644 --- a/src/lib/api/public/ServiceContext.cpp +++ b/src/lib/api/public/ServiceContext.cpp @@ -1,64 +1,59 @@ #ifndef NO_CPP0X #include "ServiceContext.h" -#include "QuickbusClientChannel.h" #include "ApiServer.h" -#include "lib/logging/logging.h" +#include "QuickbusClientChannel.h" #include "lib/api/services/AuthService.client.pb.h" +#include "lib/logging/logging.h" #include namespace bts { namespace api { -LoginResult::LoginResult(): - success(true), - reason() - {} +LoginResult::LoginResult() : success(true), reason() {} -LoginResult::LoginResult(const std::string& why): - success(true), - reason(why) - {} +LoginResult::LoginResult(const std::string &why) : success(true), reason(why) {} struct ServiceContextImpl { - ServiceContextImpl(Quickbus* maybe_bus): - _qbus(maybe_bus ? *maybe_bus : *api_create_quickbus(nullptr, 0)), - _owns_qb(maybe_bus == nullptr), - _token(), - _user() - {} + ServiceContextImpl(Quickbus *maybe_bus) + : _qbus(maybe_bus ? *maybe_bus : *api_create_quickbus(nullptr, 0)), + _owns_qb(maybe_bus == nullptr), _token(), _user() {} ~ServiceContextImpl() { if (_owns_qb) { api_destroy_quickbus(&_qbus); } } - void set_token(const AuthToken& t) { + void set_token(const AuthToken &t) { auto st = std::make_shared(); st->CopyFrom(t); _token = st; } - Quickbus& _qbus; + Quickbus &_qbus; bool _owns_qb; std::shared_ptr _token; std::string _user; }; -ServiceContext::ServiceContext(Quickbus* maybe_bus) : - _self(std::make_shared(maybe_bus)) -{ -} +ServiceContext::ServiceContext(Quickbus *maybe_bus) + : _self(std::make_shared(maybe_bus)) {} ServiceContext::~ServiceContext() {} -std::unique_ptr ServiceContext::create_channel(const char * type_name, const char * service_qualifier) const { - LOG(Api,Info,"Locate Service: {}{}",std::string(type_name) ,std::string(service_qualifier)); - return std::unique_ptr(new QuickbusClientChannel(_self->_qbus, *this, type_name, service_qualifier)); +std::unique_ptr ServiceContext::create_channel( + const char *type_name, const char *service_qualifier) const { + LOG(Api, Info, "Locate Service: {}{}", std::string(type_name), + std::string(service_qualifier)); + return std::unique_ptr(new QuickbusClientChannel( + _self->_qbus, *this, type_name, service_qualifier)); } -ServerChannel ServiceContext::publish(ApiServer& service, const std::string& service_type, const std::string& qualifier) const { +ServerChannel ServiceContext::publish( + ApiServer &service, const std::string &service_type, + const std::string &qualifier) const { return ServerChannel(_self->_qbus, service_type, qualifier, service); } -const LoginResult ServiceContext::login(const std::string& username, const std::string& password) { +const LoginResult ServiceContext::login( + const std::string &username, const std::string &password) { auto auth = locate(); user::AuthenticateLoginRequest request; request.set_login(username); @@ -69,29 +64,30 @@ const LoginResult ServiceContext::login(const std::string& username, const std:: _self->set_token(result.value()->token()); _self->_user = username; return {}; - } - else { + } else { return {result.value()->reason()}; } - } - else { + } else { return {result.error_message()}; } } -void ServiceContext::login(const AuthToken& token) { +void ServiceContext::login(const AuthToken &token) { _self->set_token(token); _self->_user.clear(); } -void ServiceContext::post(const Action& action, uint64_t delay) { +void ServiceContext::post(const Action &action, uint64_t delay) { api_post(_self->_qbus, action, delay); } -Quickbus& ServiceContext::bus() const { return _self->_qbus; } -bool ServiceContext::is_authenticated() const { return _self->_token != nullptr; } -const std::shared_ptr ServiceContext::token() const { +Quickbus &ServiceContext::bus() const { return _self->_qbus; } +bool ServiceContext::is_authenticated() const { + return _self->_token != nullptr; +} +const std::shared_ptr ServiceContext::token() const { return _self->_token; } -}}//namespace +} // namespace api +} // namespace bts #endif diff --git a/src/lib/api/public/ServiceContext.h b/src/lib/api/public/ServiceContext.h index 181e673f3..fbc1247f0 100644 --- a/src/lib/api/public/ServiceContext.h +++ b/src/lib/api/public/ServiceContext.h @@ -8,9 +8,9 @@ // server #include "ServerChannel.h" -#include -#include #include +#include +#include namespace bts { namespace api { @@ -20,38 +20,41 @@ struct ServiceContextImpl; struct LoginResult { LoginResult(); - LoginResult(const std::string&); + LoginResult(const std::string &); bool success; std::string reason; }; -class BTS_EXPORT ServiceContext -{ +class BTS_EXPORT ServiceContext { std::shared_ptr _self; -public: - ServiceContext(Quickbus* maybe_bus=nullptr); + public: + ServiceContext(Quickbus *maybe_bus = nullptr); // ServiceContext(ServiceContext& other) = default; ~ServiceContext(); - template - T locate(const char* qualifier="") const { + template T locate(const char *qualifier = "") const { return T(create_channel(T::name(), qualifier)); } - Quickbus& bus() const; + Quickbus &bus() const; bool is_authenticated() const; const std::shared_ptr token() const; - const LoginResult login(const std::string& username, const std::string& password); - void login(const AuthToken& token); + const LoginResult + login(const std::string &username, const std::string &password); + void login(const AuthToken &token); typedef std::function Action; - void post(const Action&, uint64_t delayms=0); + void post(const Action &, uint64_t delayms = 0); -private: + private: friend class ApiServer; - std::unique_ptr create_channel(const char*, const char*) const; - ServerChannel publish(ApiServer& service, const std::string& service_type, const std::string& qualifier) const; + std::unique_ptr + create_channel(const char *, const char *) const; + ServerChannel publish( + ApiServer &service, const std::string &service_type, + const std::string &qualifier) const; }; -}}//namespace +} // namespace api +} // namespace bts diff --git a/src/lib/api/public/StatefulPublisher.h b/src/lib/api/public/StatefulPublisher.h index 222bc0bde..fa00f60c1 100644 --- a/src/lib/api/public/StatefulPublisher.h +++ b/src/lib/api/public/StatefulPublisher.h @@ -1,77 +1,77 @@ #pragma once -#include +#include #include #include -#include +#include namespace bts { namespace api { -template -class StatefulPublisher { +template class StatefulPublisher { const bool _keep_state; std::vector _added; std::vector _updated; std::set _erased; std::unordered_set _state; - std::map _state_data; - typedef std::function*, std::vector*, std::set*)> PublishFn; + std::map _state_data; + typedef std::function *, std::vector *, std::set *)> + PublishFn; const PublishFn _publish; typedef std::function KeyFn; const KeyFn _key; - public: - StatefulPublisher(const PublishFn& fn, const KeyFn& key,bool keep_state=false) : - _keep_state(keep_state), _added(), _updated(), _erased(), _state(), _state_data(), _publish(fn), _key(key) - { } - void add_or_update(const T& m) { - auto key = _key(m); - if (!_has_key(key)) { - _added.push_back(m); - if(_keep_state) - _state_data[key]=m; - else - _state.insert(key); - } - else { - // If an item has already been added update to new value - auto match = [this,&key](const T& item) { return _key(item) == key; }; - auto add_iter = std::find_if(_added.begin(), _added.end(), match); - if (add_iter != _added.end()) { - *add_iter = m; - } - else { - auto update_iter = std::find_if(_updated.begin(), _updated.end(), match); - if (update_iter == _updated.end()) { - _updated.push_back(m); - } - else { - *update_iter = m; - } + public: + StatefulPublisher( + const PublishFn &fn, const KeyFn &key, bool keep_state = false) + : _keep_state(keep_state), _added(), _updated(), _erased(), _state(), + _state_data(), _publish(fn), _key(key) {} + + void add_or_update(const T &m) { + auto key = _key(m); + if (!_has_key(key)) { + _added.push_back(m); + if (_keep_state) + _state_data[key] = m; + else + _state.insert(key); + } else { + // If an item has already been added update to new value + auto match = [this, &key](const T &item) { return _key(item) == key; }; + auto add_iter = std::find_if(_added.begin(), _added.end(), match); + if (add_iter != _added.end()) { + *add_iter = m; + } else { + auto update_iter = + std::find_if(_updated.begin(), _updated.end(), match); + if (update_iter == _updated.end()) { + _updated.push_back(m); + } else { + *update_iter = m; } } } - void erase(TKey m) { - if (_has_key(m)) { - _erased.insert(m); - } + } + void erase(TKey m) { + if (_has_key(m)) { + _erased.insert(m); } - void flush() { - _publish(&_added, &_updated, &_erased); - _added.clear(); - _updated.clear(); - _erased.clear(); - } - const std::map& state_data() const{ - return _state_data; - } - private: - bool _has_key(TKey k) const{ - return _keep_state ? _state_data.find(k) != _state_data.end() : - _state.find(k) != _state.end(); + } + void flush() { + _publish(&_added, &_updated, &_erased); + _added.clear(); + _updated.clear(); + _erased.clear(); + } + const std::map &state_data() const { return _state_data; } - } + private: + bool _has_key(TKey k) const { + return _keep_state ? _state_data.find(k) != _state_data.end() + : _state.find(k) != _state.end(); + } }; -}}//namespace \ No newline at end of file +} // namespace api +} // namespace bts \ No newline at end of file diff --git a/src/lib/api/public/Update.h b/src/lib/api/public/Update.h index 3d18c5d6d..c13a0341d 100644 --- a/src/lib/api/public/Update.h +++ b/src/lib/api/public/Update.h @@ -1,112 +1,113 @@ #pragma once #include "RawUpdate.h" -#include #include -#include +#include #include +#include namespace bts { namespace api { - template - class Change { - T _old, _new; - public: - Change(const T& old_value, const T& new_value) : _old(old_value), _new(new_value) { } - const T& previous() const { return _old; } - const T& current() const { return _new; } - }; +template class Change { + T _old, _new; - template - struct Update { - Update(std::vector& all, std::vector& added, std::vector> changed, std::vector& removed) : - _all_items(std::move(all)), - _added_items(std::move(added)), + public: + Change(const T &old_value, const T &new_value) + : _old(old_value), _new(new_value) {} + const T &previous() const { return _old; } + const T ¤t() const { return _new; } +}; + +template struct Update { + Update( + 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)) - {} + _removed_items(std::move(removed)) {} - Update(const Update& other) : _all_items(other._all_items), - _added_items(other._added_items), - _changed_items(other._changed_items), - _removed_items(other._removed_items) - {} - - Update(Update&& other) : - _all_items(std::move(other._all_items)), + Update(const Update &other) + : _all_items(other._all_items), _added_items(other._added_items), + _changed_items(other._changed_items), + _removed_items(other._removed_items) {} + + Update(Update &&other) + : _all_items(std::move(other._all_items)), _added_items(std::move(other._added_items)), _changed_items(std::move(other._changed_items)), - _removed_items(std::move(other._removed_items)) - {} + _removed_items(std::move(other._removed_items)) {} - TKey key(const T& t) const { return ServiceType::key(t); } - const std::vector& all() const { return _all_items; } - const std::vector& added() const { return _added_items; } - const std::vector>& changed() const { return _changed_items; } - const std::vector& removed() const { return _removed_items; } + TKey key(const T &t) const { return ServiceType::key(t); } + const std::vector &all() const { return _all_items; } + const std::vector &added() const { return _added_items; } + const std::vector> &changed() const { return _changed_items; } + const std::vector &removed() const { return _removed_items; } - private: - std::vector _all_items; - std::vector _added_items; - std::vector> _changed_items; - std::vector _removed_items; + private: + std::vector _all_items; + std::vector _added_items; + std::vector> _changed_items; + std::vector _removed_items; +}; + +template +std::function>( + const rxcpp::observable> &)> +reconstitute() { + return [](const rxcpp::observable> &input) { + auto state = std::make_shared>(); + return input.map([state](RawUpdate &raw) { + if (raw.is_reset) { + std::vector removed; + removed.reserve(state->size()); + for (auto &t : *state) { + removed.push_back(std::move(t.second)); + } + state->clear(); + std::vector all, added; + std::vector> changed; + return Update(all, added, changed, removed); + } else { + // + // Remove + std::vector removed; + removed.reserve(raw.removed_keys.size()); + for (int key : raw.removed_keys) { + auto iter = state->find(key); + if (iter != state->end()) { + removed.push_back(iter->second); + state->erase(iter); + } + } + // + // Add + for (size_t x = 0; x < raw.added_keys.size(); ++x) { + (*state)[raw.added_keys[x]] = raw.added_items[x]; + } + // + // Change + std::vector> changed; + changed.reserve(raw.changed_keys.size()); + for (size_t x = 0; x < raw.changed_keys.size(); ++x) { + changed.push_back(Change{ + (*state)[raw.changed_keys[x]], raw.changed_items[x]}); + (*state)[raw.changed_keys[x]] = raw.changed_items[x]; + } + // + // All + std::vector all; + all.reserve(state->size()); + for (const auto &item : *state) { + all.push_back(item.second); + } + + return Update( + all, raw.added_items, changed, removed); + } + }); }; +} - template - std::function>(const rxcpp::observable>&)> reconstitute() { - return [](const rxcpp::observable>& input) { - auto state = std::make_shared>(); - return input.map([state](RawUpdate& raw) { - if (raw.is_reset) { - std::vector removed; - removed.reserve(state->size()); - for (auto& t : *state) { - removed.push_back(std::move(t.second)); - } - state->clear(); - std::vector all, added; - std::vector> changed; - return Update(all, added, changed, removed); - } - else { - // - // Remove - std::vector removed; - removed.reserve(raw.removed_keys.size()); - for (int key : raw.removed_keys) { - auto iter = state->find(key); - if (iter != state->end()) { - removed.push_back(iter->second); - state->erase(iter); - } - } - // - // Add - for (size_t x = 0; x < raw.added_keys.size(); ++x) { - (*state)[raw.added_keys[x]] = raw.added_items[x]; - } - // - // Change - std::vector> changed; - changed.reserve(raw.changed_keys.size()); - for (size_t x = 0; x < raw.changed_keys.size(); ++x) { - changed.push_back(Change{(*state)[raw.changed_keys[x]], raw.changed_items[x]}); - (*state)[raw.changed_keys[x]] = raw.changed_items[x]; - } - // - // All - std::vector all; - all.reserve(state->size()); - for (const auto& item : *state) { - all.push_back(item.second); - } - - return Update(all, raw.added_items, changed, removed); - } - }); - }; - } - - -}}//namespace +} // namespace api +} // namespace bts diff --git a/src/lib/api/service_helpers/AdminServiceUtils.cpp b/src/lib/api/service_helpers/AdminServiceUtils.cpp index 77eee1497..10bac8f3a 100644 --- a/src/lib/api/service_helpers/AdminServiceUtils.cpp +++ b/src/lib/api/service_helpers/AdminServiceUtils.cpp @@ -1,54 +1,52 @@ -#include "lib/api/services/AdminService.server.pb.h" #include "lib/api/service_helpers/AdminServiceUtils.h" -#include "lib/md/get_symbols.h" +#include "lib/api/services/AdminService.server.pb.h" +#include "lib/config/config.h" #include "lib/config/protos/cme_reference_data.pb.h" #include "lib/config/protos/jetfix.pb.h" -#include "lib/config/config.h" #include "lib/config/protos/system.pb.h" +#include "lib/md/get_symbols.h" -#include #include #include +#include -namespace bts{ -namespace admin{ +namespace bts { +namespace admin { using namespace bts::api::admin; using namespace bts::api::orderman; //////////////////////////////////////////// // connection accessors //////////////////// -//////////////////////////////////////////// -uint32_t AdminServiceUtils::find_max_connection_id (const AdminData& data){ +//////////////////////////////////////////// +uint32_t AdminServiceUtils::find_max_connection_id(const AdminData &data) { uint32_t rv = 0; - for(const auto &conn : data.connections()) + for (const auto &conn : data.connections()) if (conn.id() > rv) rv = conn.id(); return rv; } -const ExchangeConnection* AdminServiceUtils::find_connection( - const AdminData& data, - const std::string& connection_name){ - for(const auto& connection : data.connections()) - if(connection.name()==connection_name) +const ExchangeConnection *AdminServiceUtils::find_connection( + const AdminData &data, const std::string &connection_name) { + for (const auto &connection : data.connections()) + if (connection.name() == connection_name) return &connection; return nullptr; } -bool AdminServiceUtils::has_exchange(const ExchangeConnection& conn, - api::Venue exchange){ +bool AdminServiceUtils::has_exchange( + const ExchangeConnection &conn, api::Venue exchange) { bool rv = false; - switch(exchange) - { + switch (exchange) { case api::Venue::VENUE_GLBX: rv = conn.has_cme_connection() && - (conn.cme_connection().has_cgw_connection() || + (conn.cme_connection().has_cgw_connection() || conn.cme_connection().has_msgw_connection()); break; case api::Venue::VENUE_UNSET: case api::Venue::VENUE_SIM: case api::Venue::VENUE_SIMICE: rv = conn.has_sim_connection(); - break; + break; case api::Venue::VENUE_ICE: rv = conn.has_ice_connection(); break; @@ -62,89 +60,93 @@ bool AdminServiceUtils::has_exchange(const ExchangeConnection& conn, } return rv; } -const ExchangeConnection* AdminServiceUtils::find_default_account_connection( - const AdminData& data, - const BTSAccount& account, - bts::api::Venue exchange){ - //todo:get from parent accounts if not overridden - if(account.has_connections()) - for (const std::string& conn_name : account.connections().exchange_connection_names()){ - const ExchangeConnection* conn = find_connection(data, conn_name); - if (conn!=nullptr && has_exchange(*conn, exchange)) +const ExchangeConnection *AdminServiceUtils::find_default_account_connection( + const AdminData &data, const BTSAccount &account, + bts::api::Venue exchange) { + // todo:get from parent accounts if not overridden + if (account.has_connections()) + for (const std::string &conn_name : + account.connections().exchange_connection_names()) { + const ExchangeConnection *conn = find_connection(data, conn_name); + if (conn != nullptr && has_exchange(*conn, exchange)) return conn; } return nullptr; } -const ExchangeConnection* AdminServiceUtils::resolve_cme_connection( - const AdminData& data, - const BTSAccount& account, - const bts::api::Security& sec){ - if(account.has_connections()) - for (const std::string& conn_name : account.connections().exchange_connection_names()){ - const ExchangeConnection* conn = find_connection(data, conn_name); - if (conn!=nullptr && conn->has_cme_connection()) +const ExchangeConnection *AdminServiceUtils::resolve_cme_connection( + const AdminData &data, const BTSAccount &account, + const bts::api::Security &sec) { + if (account.has_connections()) + for (const std::string &conn_name : + account.connections().exchange_connection_names()) { + const ExchangeConnection *conn = find_connection(data, conn_name); + if (conn != nullptr && conn->has_cme_connection()) if (conn->cme_connection().has_cgw_connection() || - (sec.has_glbx() && conn->cme_connection().has_msgw_connection() && - conn->cme_connection().msgw_connection().market_segment_id() == sec.glbx().market_segment_id())) + (sec.has_glbx() && + conn->cme_connection().has_msgw_connection() && + conn->cme_connection().msgw_connection().market_segment_id() == + sec.glbx().market_segment_id())) return conn; } - return nullptr; + return nullptr; } -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&) -{ - if(account.has_connections()) - { - for (const std::string& conn_name : account.connections().exchange_connection_names()) - { - const bts::api::admin::ExchangeConnection* conn = find_connection(data, conn_name); - if (conn!=nullptr && conn->has_ice_connection()) - return conn; +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 &) { + if (account.has_connections()) { + for (const std::string &conn_name : + account.connections().exchange_connection_names()) { + const bts::api::admin::ExchangeConnection *conn = + find_connection(data, conn_name); + if (conn != nullptr && conn->has_ice_connection()) + return conn; } } - return nullptr; + return nullptr; } -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& ){ - if(account.has_connections()) - for (const std::string& conn_name : account.connections().exchange_connection_names()){ - const bts::api::admin::ExchangeConnection* conn = find_connection(data, conn_name); - if (conn!=nullptr && conn->has_sim_connection()) - return conn; +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 &) { + if (account.has_connections()) + for (const std::string &conn_name : + account.connections().exchange_connection_names()) { + const bts::api::admin::ExchangeConnection *conn = + find_connection(data, conn_name); + if (conn != nullptr && conn->has_sim_connection()) + return conn; } - return nullptr; + return nullptr; } -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::ExchangeConnection* rv = nullptr; - switch(sec.exchange()){ +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::ExchangeConnection *rv = nullptr; + switch (sec.exchange()) { case api::Venue::VENUE_GLBX: { auto deployment_type = - boost::to_lower_copy(config::get().type()); + boost::to_lower_copy(config::get().type()); rv = resolve_cme_connection(data, account, sec); - if (rv == nullptr && (deployment_type == "dev" || - deployment_type == "demo")) + if (rv == nullptr && + (deployment_type == "dev" || deployment_type == "demo")) rv = resolve_sim_connection(data, account, sec); break; } - case api::Venue::VENUE_ICE: - { + case api::Venue::VENUE_ICE: { rv = resolve_ice_connection(data, account, sec); - auto deployment_type = boost::to_lower_copy(config::get().type()); - if (rv == nullptr && (deployment_type == "dev" || deployment_type == "demo")) + auto deployment_type = + boost::to_lower_copy(config::get().type()); + if (rv == nullptr && + (deployment_type == "dev" || deployment_type == "demo")) rv = resolve_sim_connection(data, account, sec); break; - } + } case api::Venue::VENUE_UNSET: case api::Venue::VENUE_BTS: case api::Venue::VENUE_SIM: @@ -152,248 +154,242 @@ AdminServiceUtils::resolve_connection(const bts::api::admin::AdminData& data, rv = resolve_sim_connection(data, account, sec); break; case api::Venue::VENUE_CBOE: - case api::Venue::VENUE_CBOECFE: + case api::Venue::VENUE_CBOECFE: case api::Venue::Venue_INT_MIN_SENTINEL_DO_NOT_USE_: - case api::Venue::Venue_INT_MAX_SENTINEL_DO_NOT_USE_: + case api::Venue::Venue_INT_MAX_SENTINEL_DO_NOT_USE_: rv = nullptr; break; } return rv; -} +} //////////////////////////////////////////// // connection mutators ///////////////////// //////////////////////////////////////////// -bts::api::admin::ExchangeConnection* AdminServiceUtils::add_connection (bts::api::admin::AdminData& data, - const bts::api::admin::ExchangeConnection& new_connection){ +bts::api::admin::ExchangeConnection *AdminServiceUtils::add_connection( + bts::api::admin::AdminData &data, + const bts::api::admin::ExchangeConnection &new_connection) { auto new_connection_ptr = data.add_connections(); new_connection_ptr->CopyFrom(new_connection); return new_connection_ptr; } -void AdminServiceUtils::fill_connections_from_config(bts::api::admin::AdminData& admin_data){ +void AdminServiceUtils::fill_connections_from_config( + bts::api::admin::AdminData &admin_data) { admin_data.clear_connections(); auto &all_connections = config::get().connection(); - for (auto const &c : all_connections){ + for (auto const &c : all_connections) { bts::api::admin::ExchangeConnection connection; - uint32_t new_id = find_max_connection_id(admin_data)+1; + uint32_t new_id = find_max_connection_id(admin_data) + 1; connection.set_id(new_id); connection.set_name(c.name()); switch (c.platform()) { case config::JetFIX::Connection::GLBX: - if (c.cme_market_segment_id()==0) + if (c.cme_market_segment_id() == 0) connection.mutable_cme_connection()->mutable_cgw_connection(); else - connection.mutable_cme_connection()->mutable_msgw_connection()->set_market_segment_id(c.cme_market_segment_id()); - add_connection(admin_data,connection); + connection.mutable_cme_connection() + ->mutable_msgw_connection() + ->set_market_segment_id(c.cme_market_segment_id()); + add_connection(admin_data, connection); break; case config::JetFIX::Connection::CBOE: break; case config::JetFIX::Connection::SIM: case config::JetFIX::Connection::SIMICE: connection.mutable_sim_connection(); - add_connection(admin_data,connection); + add_connection(admin_data, connection); break; case config::JetFIX::Connection::ICE: - connection.mutable_ice_connection()->set_sender_compid(c.sender_compid()); - add_connection(admin_data,connection); + connection.mutable_ice_connection()->set_sender_compid( + c.sender_compid()); + add_connection(admin_data, connection); break; - } } - for(int i=0;iname()) + if (name == account_ptr->name()) return account_ptr; return nullptr; } -std::map -AdminServiceUtils::get_clearing_account_map(const AdminData& data){ - std::map rv; - auto all_accounts = accounts(data,true); - for (BTSAccount const* a : all_accounts){ - // only for CME, ICE, GLBX +std::map +AdminServiceUtils::get_clearing_account_map(const AdminData &data) { + std::map rv; + auto all_accounts = accounts(data, true); + for (BTSAccount const *a : all_accounts) { + // only for CME, ICE, GLBX AdminServiceOperationResult res; // cme { - auto cme_clr_acc = find_account_exchange_account(data, *a, - api::Venue::VENUE_GLBX, - res); - if(res.is_success()) + auto cme_clr_acc = find_account_exchange_account( + data, *a, api::Venue::VENUE_GLBX, res); + if (res.is_success()) rv[cme_clr_acc] = a->id(); } // ice { - auto ice_clr_acc = find_account_exchange_account(data, *a, - api::Venue::VENUE_ICE, - res); - if(res.is_success()) + auto ice_clr_acc = find_account_exchange_account( + data, *a, api::Venue::VENUE_ICE, res); + if (res.is_success()) rv[ice_clr_acc] = a->id(); } // sim { - auto sim_clr_acc = find_account_exchange_account(data, *a, - api::Venue::VENUE_SIM, - res); - if(res.is_success()) + auto sim_clr_acc = find_account_exchange_account( + data, *a, api::Venue::VENUE_SIM, res); + if (res.is_success()) rv[sim_clr_acc] = a->id(); } } return rv; } -const BTSAccount* AdminServiceUtils::find_account (const AdminData& data, - const std::string& name, - bool include_deleted){ +const BTSAccount *AdminServiceUtils::find_account( + const AdminData &data, const std::string &name, bool include_deleted) { auto account_ptrs = accounts(data, include_deleted); for (auto account_ptr : account_ptrs) - if(name==account_ptr->name()) + if (name == account_ptr->name()) return account_ptr; return nullptr; } -BTSAccount const* AdminServiceUtils::find_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){ +BTSAccount const *AdminServiceUtils::find_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) { AdminServiceOperationResult res; - // returns the first account that matches - std::string s = find_account_exchange_account (data, *a, exchange, res); + // returns the first account that matches + std::string s = find_account_exchange_account(data, *a, exchange, res); if (res.is_success() && s == clearing_account) return a; } return nullptr; } -BTSAccount* AdminServiceUtils::find_account (AdminData& data, - uint32_t id, - bool include_deleted){ +BTSAccount *AdminServiceUtils::find_account( + AdminData &data, uint32_t id, bool include_deleted) { auto account_ptrs = accounts_mutable(data, include_deleted); for (auto account_ptr : account_ptrs) - if(id==account_ptr->id()) + if (id == account_ptr->id()) return account_ptr; return nullptr; } -const BTSAccount* AdminServiceUtils::find_account (const AdminData& data, - uint32_t id, - bool include_deleted){ +const BTSAccount *AdminServiceUtils::find_account( + const AdminData &data, uint32_t id, bool include_deleted) { auto account_ptrs = accounts(data, include_deleted); for (auto account_ptr : account_ptrs) - if(id==account_ptr->id()) + if (id == account_ptr->id()) return account_ptr; return nullptr; } -std::vector AdminServiceUtils::accounts ( - const AdminData& data, - bool include_deleted){ - std::vector rv; - for (const auto& account : data.accounts()) +std::vector +AdminServiceUtils::accounts(const AdminData &data, bool include_deleted) { + std::vector rv; + for (const auto &account : data.accounts()) if (account.is_present() || include_deleted) rv.push_back(&account); return rv; } -std::vector AdminServiceUtils::accounts_mutable (bts::api::admin::AdminData& data, - bool include_deleted){ - std::vector rv; - for(int i=0; i AdminServiceUtils::accounts_mutable( + bts::api::admin::AdminData &data, bool include_deleted) { + std::vector rv; + for (int i = 0; i < data.accounts_size(); i++) { + bts::api::admin::BTSAccount *account_ptr = data.mutable_accounts(i); if (account_ptr->is_present() || include_deleted) rv.push_back(account_ptr); - } + } return rv; } -uint32_t AdminServiceUtils::find_max_acct_id (const bts::api::admin::AdminData& data){ +uint32_t +AdminServiceUtils::find_max_acct_id(const bts::api::admin::AdminData &data) { uint32_t rv = 0; - for(const auto &acct : data.accounts()) + for (const auto &acct : data.accounts()) if (acct.id() > rv) rv = acct.id(); return rv; } -const CMEAccountData* AdminServiceUtils::get_account_cme_data( - const BTSAccount& account, - const AdminData& data){ - if (account.has_exchange_account_data() && +const CMEAccountData *AdminServiceUtils::get_account_cme_data( + const BTSAccount &account, const AdminData &data) { + if (account.has_exchange_account_data() && account.exchange_account_data().has_cme_account_data()) return &(account.exchange_account_data().cme_account_data()); - else if (has_id(account.parent_account_id())){ - const BTSAccount* parent_account = - find_account(data, account.parent_account_id()); + else if (has_id(account.parent_account_id())) { + const BTSAccount *parent_account = + find_account(data, account.parent_account_id()); if (parent_account != nullptr) - return get_account_cme_data (*parent_account, data); + return get_account_cme_data(*parent_account, data); } return nullptr; } -const ICEAccountData* AdminServiceUtils::get_account_ice_data( - const BTSAccount& account, - const AdminData& data){ - if (account.has_exchange_account_data() && +const ICEAccountData *AdminServiceUtils::get_account_ice_data( + const BTSAccount &account, const AdminData &data) { + if (account.has_exchange_account_data() && account.exchange_account_data().has_ice_account_data()) return &(account.exchange_account_data().ice_account_data()); - else if (has_id(account.parent_account_id())){ - const BTSAccount* parent_account = - find_account(data, account.parent_account_id()); + else if (has_id(account.parent_account_id())) { + const BTSAccount *parent_account = + find_account(data, account.parent_account_id()); if (parent_account != nullptr) - return get_account_ice_data (*parent_account, data); + return get_account_ice_data(*parent_account, data); } return nullptr; } -const bts::api::admin::SIMAccountData* AdminServiceUtils::get_account_sim_data(const bts::api::admin::BTSAccount& account, - const bts::api::admin::AdminData& data){ - if (account.has_exchange_account_data() && account.exchange_account_data().has_sim_account_data()) +const bts::api::admin::SIMAccountData *AdminServiceUtils::get_account_sim_data( + const bts::api::admin::BTSAccount &account, + const bts::api::admin::AdminData &data) { + if (account.has_exchange_account_data() && + account.exchange_account_data().has_sim_account_data()) return &(account.exchange_account_data().sim_account_data()); - else if (has_id(account.parent_account_id())){ - const bts::api::admin::BTSAccount* parent_account = find_account(data, account.parent_account_id()); + else if (has_id(account.parent_account_id())) { + const bts::api::admin::BTSAccount *parent_account = + find_account(data, account.parent_account_id()); if (parent_account != nullptr) - return get_account_sim_data (*parent_account, data); + return get_account_sim_data(*parent_account, data); } return nullptr; } -bool AdminServiceUtils::account_has_connection(const BTSAccount& account, - const std::string& connection_name){ - if(account.has_connections()){ - for(int i=0; iclearing_account(); break; } - case api::Venue::VENUE_ICE: - { + case api::Venue::VENUE_ICE: { auto ice_account_data = get_account_ice_data(account, data); if (ice_account_data != nullptr) rv = ice_account_data->clearing_account(); - break; + break; } - case api::Venue::VENUE_SIM: - case api::Venue::VENUE_SIMICE: - { + case api::Venue::VENUE_SIM: + case api::Venue::VENUE_SIMICE: { auto sim_account_data = get_account_sim_data(account, data); if (sim_account_data != nullptr) rv = sim_account_data->clearing_account(); @@ -402,9 +398,9 @@ std::string AdminServiceUtils::find_account_exchange_account ( case api::Venue::VENUE_UNSET: case api::Venue::VENUE_BTS: case api::Venue::VENUE_CBOE: - case api::Venue::VENUE_CBOECFE: + case api::Venue::VENUE_CBOECFE: case api::Venue::Venue_INT_MIN_SENTINEL_DO_NOT_USE_: - case api::Venue::Venue_INT_MAX_SENTINEL_DO_NOT_USE_: + case api::Venue::Venue_INT_MAX_SENTINEL_DO_NOT_USE_: out_result.set_is_success(false); out_result.set_error_text("Exchange not supported"); break; @@ -412,116 +408,121 @@ std::string AdminServiceUtils::find_account_exchange_account ( return rv; } -std::map AdminServiceUtils::accounts_map(const bts::api::admin::AdminData& admin_data){ - std::map rv; +std::map +AdminServiceUtils::accounts_map(const bts::api::admin::AdminData &admin_data) { + std::map rv; auto account_ptrs = accounts(admin_data, false); - for(const bts::api::admin::BTSAccount* account_ptr : account_ptrs) - rv.insert(std::pair(account_ptr->id(),account_ptr->is_active())); + for (const bts::api::admin::BTSAccount *account_ptr : account_ptrs) + rv.insert(std::pair( + account_ptr->id(), account_ptr->is_active())); return rv; } -void AdminServiceUtils::validate_account_update (const bts::api::admin::AdminData& admin_data, - const bts::api::admin::BTSAccount& updated_account, - bts::api::admin::AdminServiceOperationResult& result){ +void AdminServiceUtils::validate_account_update( + const bts::api::admin::AdminData &admin_data, + const bts::api::admin::BTSAccount &updated_account, + bts::api::admin::AdminServiceOperationResult &result) { result.set_is_success(true); // validate id - if(find_account(admin_data, updated_account.id()) == nullptr){ + if (find_account(admin_data, updated_account.id()) == nullptr) { result.set_is_success(false); result.set_error_text("Could not find account id"); return; } // validate that name change doesnt collide auto account_ptrs = accounts(admin_data, false); - for (const bts::api::admin::BTSAccount* account_ptr : account_ptrs) - if (account_ptr->id() != updated_account.id() && account_ptr->name() == updated_account.name()){ + for (const bts::api::admin::BTSAccount *account_ptr : account_ptrs) + if (account_ptr->id() != updated_account.id() && + account_ptr->name() == updated_account.name()) { result.set_is_success(false); result.set_error_text("Account by this name already exists"); return; } // validate account exchange changes - validate_account_exchange_data (updated_account, result); + validate_account_exchange_data(updated_account, result); } -void AdminServiceUtils::validate_account_exchange_data ( - const bts::api::admin::BTSAccount& account, - bts::api::admin::AdminServiceOperationResult& result){ +void AdminServiceUtils::validate_account_exchange_data( + const bts::api::admin::BTSAccount &account, + bts::api::admin::AdminServiceOperationResult &result) { result.set_is_success(true); - if (account.has_exchange_account_data()){ - if (account.exchange_account_data().has_cme_account_data()){ - const bts::api::admin::CMEAccountData& cme_account_data = - account.exchange_account_data().cme_account_data(); - if (cme_account_data.clearing_account().size() > 12){ + if (account.has_exchange_account_data()) { + if (account.exchange_account_data().has_cme_account_data()) { + const bts::api::admin::CMEAccountData &cme_account_data = + account.exchange_account_data().cme_account_data(); + if (cme_account_data.clearing_account().size() > 12) { result.set_is_success(false); result.set_error_text("CME account can not be more " "12 characters long"); } - } + } } } -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, - bts::api::admin::AdminServiceOperationResult& out_result){ +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, + bts::api::admin::AdminServiceOperationResult &out_result) { bts::api::orderman::RoutingRecord rv; - const bts::api::admin::BTSAccount* account_ptr = find_account(data, account_name); - if (account_ptr == nullptr){ + const bts::api::admin::BTSAccount *account_ptr = + find_account(data, account_name); + if (account_ptr == nullptr) { out_result.set_is_success(false); out_result.set_error_text("Could not find account"); return rv; } - const bts::api::admin::BTSUser* user_ptr = find_user(data, user_name); - if (user_ptr == nullptr){ + const bts::api::admin::BTSUser *user_ptr = find_user(data, user_name); + if (user_ptr == nullptr) { out_result.set_is_success(false); out_result.set_error_text("Could not find user"); return rv; } - return get_routing_record(data, account_ptr->id(), user_ptr->id(), sec, out_result); + return 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, - bts::api::admin::AdminServiceOperationResult& 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, + bts::api::admin::AdminServiceOperationResult &out_result) { bts::api::orderman::RoutingRecord rv; out_result.set_is_success(true); - const bts::api::admin::BTSAccount* account_ptr = find_account(data,account_id); - if (account_ptr == nullptr){ + const bts::api::admin::BTSAccount *account_ptr = + find_account(data, account_id); + if (account_ptr == nullptr) { out_result.set_is_success(false); out_result.set_error_text("Could not find account"); return rv; } - const bts::api::admin::BTSUser* user_ptr = find_user(data, user_id); - if (user_ptr == nullptr){ + const bts::api::admin::BTSUser *user_ptr = find_user(data, user_id); + if (user_ptr == nullptr) { out_result.set_is_success(false); out_result.set_error_text("Could not find user"); return rv; } - const bts::api::admin::ExchangeConnection* conn_ptr = //find_default_account_connection(data, *account_ptr, sec.exchange()); - resolve_connection(data,*account_ptr,sec); - if(conn_ptr == nullptr){ + const bts::api::admin::ExchangeConnection + *conn_ptr = // find_default_account_connection(data, *account_ptr, + // sec.exchange()); + resolve_connection(data, *account_ptr, sec); + if (conn_ptr == nullptr) { out_result.set_is_success(false); out_result.set_error_text("Could not find connection"); return rv; } switch (sec.exchange()) { - case api::Venue::VENUE_ICE: - { - const bts::api::admin::ICEUserData* ice_user_data = get_user_ice_data(*user_ptr, data); - if(ice_user_data==nullptr) - { - out_result.set_is_success(false); - out_result.set_error_text("Could not find ICE data for user"); - return rv; - } - const bts::api::admin::ICEAccountData* ice_account_data = get_account_ice_data(*account_ptr, data); - if(ice_account_data==nullptr) - { + case api::Venue::VENUE_ICE: { + const bts::api::admin::ICEUserData *ice_user_data = + get_user_ice_data(*user_ptr, data); + if (ice_user_data == nullptr) { + out_result.set_is_success(false); + out_result.set_error_text("Could not find ICE data for user"); + return rv; + } + const bts::api::admin::ICEAccountData *ice_account_data = + get_account_ice_data(*account_ptr, data); + if (ice_account_data == nullptr) { out_result.set_is_success(false); out_result.set_error_text("Could not find ICE data for account"); return rv; - } + } // check for data corectness - if (ice_user_data->operator_id().length() == 0) - { + if (ice_user_data->operator_id().length() == 0) { out_result.set_is_success(false); out_result.set_error_text("Operator ID is not set"); return rv; @@ -530,120 +531,132 @@ bts::api::orderman::RoutingRecord AdminServiceUtils::get_routing_record(const bt rv.set_session(conn_ptr->name()); rv.set_sender_compid(conn_ptr->ice_connection().sender_compid()); rv.set_account(ice_account_data->clearing_account()); - rv.set_operator_id(ice_user_data->operator_id()); + rv.set_operator_id(ice_user_data->operator_id()); rv.set_cti_code(ice_account_data->cti()); rv.set_customer_or_firm(ice_account_data->origin()); rv.set_clearing_firm(ice_account_data->clearing_firm()); - rv.set_customer_account_ref_id(ice_account_data->customer_account_ref_id()); + rv.set_customer_account_ref_id( + ice_account_data->customer_account_ref_id()); rv.set_account_code(ice_account_data->account_code()); rv.set_company_id(std::to_string(ice_user_data->company_id())); rv.set_authorized_trader(ice_user_data->authorized_trader()); - rv.set_authorized_group(ice_user_data->authorized_group()); + rv.set_authorized_group(ice_user_data->authorized_group()); rv.set_cust_order_handing_inst(ice_user_data->cust_order_handing_inst()); - - return rv; + + return rv; } case bts::api::Venue::VENUE_GLBX: { - const bts::api::admin::CMEUserData* cme_user_data = get_user_cme_data(*user_ptr, data); - if(cme_user_data==nullptr){ - out_result.set_is_success(false); - out_result.set_error_text("Could not find CME data for user");//CME or globex ? - return rv; - } - const bts::api::admin::CMEAccountData* cme_account_data = get_account_cme_data(*account_ptr, data); - if(cme_account_data==nullptr){ - out_result.set_is_success(false); - out_result.set_error_text("Could not find CME data for account"); - return rv; - } - // check for data corectness - if (cme_user_data->operator_id().length() == 0){ - out_result.set_is_success(false); - out_result.set_error_text("Operator ID is not set"); - return rv; - } - if (cme_user_data->location().length() == 0){ - out_result.set_is_success(false); - out_result.set_error_text("Location is not set"); - return rv; - } - if (cme_account_data->clearing_account().length() == 0){ - out_result.set_is_success(false); - out_result.set_error_text("Clearing Account is not set"); - return rv; - } - if (cme_account_data->cti()==bts::api::orderman::CTICode::CTI_CODE_UNDEFINED){ - out_result.set_is_success(false); - out_result.set_error_text("CTI Code is not set"); - return rv; - } - rv.set_session(conn_ptr->name()); - rv.set_operator_id(cme_user_data->operator_id()); - rv.set_location(cme_user_data->location()); + const bts::api::admin::CMEUserData *cme_user_data = + get_user_cme_data(*user_ptr, data); + if (cme_user_data == nullptr) { + out_result.set_is_success(false); + out_result.set_error_text( + "Could not find CME data for user"); // CME or globex ? + return rv; + } + const bts::api::admin::CMEAccountData *cme_account_data = + get_account_cme_data(*account_ptr, data); + if (cme_account_data == nullptr) { + out_result.set_is_success(false); + out_result.set_error_text("Could not find CME data for account"); + return rv; + } + // check for data corectness + if (cme_user_data->operator_id().length() == 0) { + out_result.set_is_success(false); + out_result.set_error_text("Operator ID is not set"); + return rv; + } + if (cme_user_data->location().length() == 0) { + out_result.set_is_success(false); + out_result.set_error_text("Location is not set"); + return rv; + } + if (cme_account_data->clearing_account().length() == 0) { + out_result.set_is_success(false); + out_result.set_error_text("Clearing Account is not set"); + return rv; + } + if (cme_account_data->cti() == + bts::api::orderman::CTICode::CTI_CODE_UNDEFINED) { + out_result.set_is_success(false); + out_result.set_error_text("CTI Code is not set"); + return rv; + } + rv.set_session(conn_ptr->name()); + rv.set_operator_id(cme_user_data->operator_id()); + rv.set_location(cme_user_data->location()); - rv.set_smp_id(cme_user_data->smp_id()); + rv.set_smp_id(cme_user_data->smp_id()); - if (cme_user_data->smp_instruction()== "O") - rv.set_smp_instruction(api::orderman::SelfMatchPreventionInstruction::SELF_MATCH_PREVENTION_INSTRUCTION_CANCEL_RESTING); - else if (cme_user_data->smp_instruction()== "N") - rv.set_smp_instruction(api::orderman::SelfMatchPreventionInstruction::SELF_MATCH_PREVENTION_INSTRUCTION_CANCEL_AGRESSING); - else - rv.set_smp_instruction(api::orderman::SelfMatchPreventionInstruction::SELF_MATCH_PREVENTION_INSTRUCTION_UNDEFINED); + if (cme_user_data->smp_instruction() == "O") + rv.set_smp_instruction( + api::orderman::SelfMatchPreventionInstruction:: + SELF_MATCH_PREVENTION_INSTRUCTION_CANCEL_RESTING); + else if (cme_user_data->smp_instruction() == "N") + rv.set_smp_instruction( + api::orderman::SelfMatchPreventionInstruction:: + SELF_MATCH_PREVENTION_INSTRUCTION_CANCEL_AGRESSING); + else + rv.set_smp_instruction( + api::orderman::SelfMatchPreventionInstruction:: + SELF_MATCH_PREVENTION_INSTRUCTION_UNDEFINED); - rv.set_account(cme_account_data->clearing_account()); - rv.set_cti_code(cme_account_data->cti()); - rv.set_customer_or_firm(cme_account_data->origin()); - return rv; + rv.set_account(cme_account_data->clearing_account()); + rv.set_cti_code(cme_account_data->cti()); + rv.set_customer_or_firm(cme_account_data->origin()); + return rv; } - case api::Venue::VENUE_SIM: - case api::Venue::VENUE_SIMICE: - { - const bts::api::admin::SIMUserData* sim_user_data = get_user_sim_data(*user_ptr, data); - if(sim_user_data==nullptr){ - out_result.set_is_success(false); - out_result.set_error_text("Could not find SIM data for user"); - return rv; - } - const bts::api::admin::SIMAccountData* sim_account_data = get_account_sim_data(*account_ptr, data); - if(sim_account_data==nullptr){ - out_result.set_is_success(false); - out_result.set_error_text("Could not find SIM data for account"); - return rv; - } - // check for data corectness - if (sim_user_data->operator_id().length() == 0){ - out_result.set_is_success(false); - out_result.set_error_text("Operator ID is not set"); - return rv; - } - if (sim_user_data->location().length() == 0){ - out_result.set_is_success(false); - out_result.set_error_text("Location is not set"); - return rv; - } - if (sim_account_data->clearing_account().length() == 0){ - out_result.set_is_success(false); - out_result.set_error_text("Clearing Account is not set"); - return rv; - } - if (sim_account_data->cti()==bts::api::orderman::CTICode::CTI_CODE_UNDEFINED){ - out_result.set_is_success(false); - out_result.set_error_text("CTI Code is not set"); - return rv; - } - rv.set_session(conn_ptr->name()); - rv.set_operator_id(sim_user_data->operator_id()); - rv.set_location(sim_user_data->location()); - rv.set_account(sim_account_data->clearing_account()); - rv.set_cti_code(sim_account_data->cti()); - rv.set_customer_or_firm(sim_account_data->origin()); - return rv; - } - break; + case api::Venue::VENUE_SIM: + case api::Venue::VENUE_SIMICE: { + const bts::api::admin::SIMUserData *sim_user_data = + get_user_sim_data(*user_ptr, data); + if (sim_user_data == nullptr) { + out_result.set_is_success(false); + out_result.set_error_text("Could not find SIM data for user"); + return rv; + } + const bts::api::admin::SIMAccountData *sim_account_data = + get_account_sim_data(*account_ptr, data); + if (sim_account_data == nullptr) { + out_result.set_is_success(false); + out_result.set_error_text("Could not find SIM data for account"); + return rv; + } + // check for data corectness + if (sim_user_data->operator_id().length() == 0) { + out_result.set_is_success(false); + out_result.set_error_text("Operator ID is not set"); + return rv; + } + if (sim_user_data->location().length() == 0) { + out_result.set_is_success(false); + out_result.set_error_text("Location is not set"); + return rv; + } + if (sim_account_data->clearing_account().length() == 0) { + out_result.set_is_success(false); + out_result.set_error_text("Clearing Account is not set"); + return rv; + } + if (sim_account_data->cti() == + bts::api::orderman::CTICode::CTI_CODE_UNDEFINED) { + out_result.set_is_success(false); + out_result.set_error_text("CTI Code is not set"); + return rv; + } + rv.set_session(conn_ptr->name()); + rv.set_operator_id(sim_user_data->operator_id()); + rv.set_location(sim_user_data->location()); + rv.set_account(sim_account_data->clearing_account()); + rv.set_cti_code(sim_account_data->cti()); + rv.set_customer_or_firm(sim_account_data->origin()); + return rv; + } break; case api::Venue::VENUE_UNSET: case api::Venue::VENUE_BTS: case api::Venue::VENUE_CBOE: - case api::Venue::VENUE_CBOECFE: + case api::Venue::VENUE_CBOECFE: case api::Venue::Venue_INT_MIN_SENTINEL_DO_NOT_USE_: case api::Venue::Venue_INT_MAX_SENTINEL_DO_NOT_USE_: out_result.set_is_success(false); @@ -656,90 +669,101 @@ bts::api::orderman::RoutingRecord AdminServiceUtils::get_routing_record(const bt //////////////////////////////////////////// // 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::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) { result.set_is_success(true); // the error conditions are checked first and returned immediatly // i. account with the name already exists // ii. parent account is set and does not exist - if (find_account(data, account_name, true) != nullptr){ + if (find_account(data, account_name, true) != nullptr) { result.set_is_success(false); result.set_error_text("Account by this name already exists"); return nullptr; } - if (has_id(parent_account_id)){ - if (find_account(data, parent_account_id) == nullptr){ + if (has_id(parent_account_id)) { + if (find_account(data, parent_account_id) == nullptr) { result.set_is_success(false); - result.set_error_text("Parent group does not exist"); + result.set_error_text("Parent group does not exist"); return nullptr; - } + } } - uint32_t new_id = find_max_acct_id(data)+1; + uint32_t new_id = find_max_acct_id(data) + 1; result.set_new_id(new_id); - bts::api::admin::BTSAccount* new_account_ptr = data.add_accounts(); + bts::api::admin::BTSAccount *new_account_ptr = data.add_accounts(); new_account_ptr->set_is_present(true); new_account_ptr->set_id(new_id); new_account_ptr->set_parent_account_id(parent_account_id); new_account_ptr->set_name(account_name); new_account_ptr->set_description(description); new_account_ptr->set_is_active(is_active); - new_account_ptr->mutable_risk_limit_enforcement()->set_ignore_spread_position_limits(true); + new_account_ptr->mutable_risk_limit_enforcement() + ->set_ignore_spread_position_limits(true); return new_account_ptr; } -void AdminServiceUtils::update_account(bts::api::admin::AdminData& admin_data, - const bts::api::admin::BTSAccount& updated_account, - bts::api::admin::AdminServiceOperationResult& result){ - validate_account_update (admin_data, updated_account, result); - if (result.is_success()){ - bts::api::admin::BTSAccount* account_ptr = find_account(admin_data, updated_account.id()); +void AdminServiceUtils::update_account( + bts::api::admin::AdminData &admin_data, + const bts::api::admin::BTSAccount &updated_account, + bts::api::admin::AdminServiceOperationResult &result) { + validate_account_update(admin_data, updated_account, result); + if (result.is_success()) { + bts::api::admin::BTSAccount *account_ptr = + find_account(admin_data, updated_account.id()); account_ptr->CopyFrom(updated_account); } } -void AdminServiceUtils::delete_account (bts::api::admin::AdminData& admin_data, - const bts::api::admin::IDAPIArgument& id, - bts::api::admin::AdminServiceOperationResult& result){ +void AdminServiceUtils::delete_account( + bts::api::admin::AdminData &admin_data, + const bts::api::admin::IDAPIArgument &id, + bts::api::admin::AdminServiceOperationResult &result) { result.set_is_success(true); - api::admin::BTSAccount* account_ptr = AdminServiceUtils::find_account(admin_data, id.id()); - if (account_ptr != nullptr) - { + api::admin::BTSAccount *account_ptr = + AdminServiceUtils::find_account(admin_data, id.id()); + if (account_ptr != nullptr) { std::string deleted_name; int deleted_idx = 0; - do{ + do { deleted_idx++; - deleted_name = deleted_idx == 1 ? fmt::format("DELETED_{}", account_ptr->name()) : - fmt::format("DELETED_{}_{}", deleted_idx, account_ptr->name()); - } - while(AdminServiceUtils::find_account(admin_data, deleted_name, true) != nullptr); + deleted_name = + deleted_idx == 1 + ? fmt::format("DELETED_{}", account_ptr->name()) + : fmt::format( + "DELETED_{}_{}", deleted_idx, account_ptr->name()); + } while (AdminServiceUtils::find_account( + admin_data, deleted_name, true) != nullptr); account_ptr->set_is_present(false); account_ptr->set_name(deleted_name); - } - else{ + } else { result.set_is_success(false); result.set_error_text("Could not find account"); } } -void AdminServiceUtils::set_account_exchange_data(bts::api::admin::BTSAccount* account, - const bts::api::admin::ExchangeAccountData& exchange_data){ - account->mutable_exchange_account_data()->CopyFrom(exchange_data); +void AdminServiceUtils::set_account_exchange_data( + bts::api::admin::BTSAccount *account, + const bts::api::admin::ExchangeAccountData &exchange_data) { + account->mutable_exchange_account_data()->CopyFrom(exchange_data); } -void AdminServiceUtils::sync_account_connections(const bts::api::admin::AdminData& data, - bts::api::admin::BTSAccount& account){ - if(account.has_connections()){ +void AdminServiceUtils::sync_account_connections( + const bts::api::admin::AdminData &data, + bts::api::admin::BTSAccount &account) { + if (account.has_connections()) { std::map all_conn_names; - for(int i=0; i< data.connections_size(); i++) - all_conn_names[data.connections(i).name()]=true; + for (int i = 0; i < data.connections_size(); i++) + all_conn_names[data.connections(i).name()] = true; std::vector cleaned_connections; - for(int i=0; imutable_exchange_connection_names()->Clear(); - for(auto it=cleaned_connections.begin(); it!= cleaned_connections.end(); it++) + account.mutable_connections() + ->mutable_exchange_connection_names() + ->Clear(); + for (auto it = cleaned_connections.begin(); + it != cleaned_connections.end(); it++) account.mutable_connections()->add_exchange_connection_names(*it); } } @@ -747,82 +771,96 @@ void AdminServiceUtils::sync_account_connections(const bts::api::admin::AdminDat // group accessors ///////////////////////// //////////////////////////////////////////// -bts::api::admin::BTSUserGroup* AdminServiceUtils::find_group (bts::api::admin::AdminData& data, - uint32_t id){ - for(int i=0; iid()) - return group; - } - return nullptr; -} -const bts::api::admin::BTSUserGroup* const AdminServiceUtils::find_group (const bts::api::admin::AdminData& data, - uint32_t id){ - for(const bts::api::admin::BTSUserGroup& group : data.user_groups()) - if(id == group.id()) - return &group; - return nullptr; -} -bts::api::admin::BTSUserGroup* AdminServiceUtils::find_group (bts::api::admin::AdminData& data, - const std::string& group_name){ - for(int i=0; iname()) +bts::api::admin::BTSUserGroup * +AdminServiceUtils::find_group(bts::api::admin::AdminData &data, uint32_t id) { + for (int i = 0; i < data.user_groups_size(); i++) { + bts::api::admin::BTSUserGroup *group = data.mutable_user_groups(i); + if (id == group->id()) return group; } return nullptr; } -uint32_t AdminServiceUtils::find_max_group_id (const bts::api::admin::AdminData& data){ +const bts::api::admin::BTSUserGroup *const AdminServiceUtils::find_group( + const bts::api::admin::AdminData &data, uint32_t id) { + for (const bts::api::admin::BTSUserGroup &group : data.user_groups()) + if (id == group.id()) + return &group; + return nullptr; +} +bts::api::admin::BTSUserGroup *AdminServiceUtils::find_group( + bts::api::admin::AdminData &data, const std::string &group_name) { + for (int i = 0; i < data.user_groups_size(); i++) { + bts::api::admin::BTSUserGroup *group = data.mutable_user_groups(i); + if (group_name == group->name()) + return group; + } + return nullptr; +} +uint32_t +AdminServiceUtils::find_max_group_id(const bts::api::admin::AdminData &data) { uint32_t rv = 0; - for(const bts::api::admin::BTSUserGroup& group : data.user_groups()) + for (const bts::api::admin::BTSUserGroup &group : data.user_groups()) if (group.id() > rv) rv = group.id(); return rv; } -const bts::api::admin::CMEUserData* AdminServiceUtils::get_group_cme_data(const bts::api::admin::BTSUserGroup& group, - const bts::api::admin::AdminData& data){ - if (group.has_user_data() && group.user_data().has_exchange_user_data() && group.user_data().exchange_user_data().has_cme_data()) +const bts::api::admin::CMEUserData *AdminServiceUtils::get_group_cme_data( + const bts::api::admin::BTSUserGroup &group, + const bts::api::admin::AdminData &data) { + if (group.has_user_data() && group.user_data().has_exchange_user_data() && + group.user_data().exchange_user_data().has_cme_data()) return &(group.user_data().exchange_user_data().cme_data()); - else if (has_id(group.parent_group_id())){ - const bts::api::admin::BTSUserGroup* parent_group = find_group(data, group.parent_group_id()); + else if (has_id(group.parent_group_id())) { + const bts::api::admin::BTSUserGroup *parent_group = + find_group(data, group.parent_group_id()); if (parent_group != nullptr) return get_group_cme_data(*parent_group, data); } return nullptr; } -const bts::api::admin::ICEUserData* AdminServiceUtils::get_group_ice_data(const bts::api::admin::BTSUserGroup& group, - const bts::api::admin::AdminData& data){ - if (group.has_user_data() && group.user_data().has_exchange_user_data() && group.user_data().exchange_user_data().has_ice_data()) +const bts::api::admin::ICEUserData *AdminServiceUtils::get_group_ice_data( + const bts::api::admin::BTSUserGroup &group, + const bts::api::admin::AdminData &data) { + if (group.has_user_data() && group.user_data().has_exchange_user_data() && + group.user_data().exchange_user_data().has_ice_data()) return &(group.user_data().exchange_user_data().ice_data()); - else if (has_id(group.parent_group_id())){ - const bts::api::admin::BTSUserGroup* parent_group = find_group(data, group.parent_group_id()); + else if (has_id(group.parent_group_id())) { + const bts::api::admin::BTSUserGroup *parent_group = + find_group(data, group.parent_group_id()); if (parent_group != nullptr) return get_group_ice_data(*parent_group, data); } return nullptr; } -const bts::api::admin::SIMUserData* AdminServiceUtils::get_group_sim_data(const bts::api::admin::BTSUserGroup& group, - const bts::api::admin::AdminData& data){ - if (group.has_user_data() && group.user_data().has_exchange_user_data() && group.user_data().exchange_user_data().has_sim_data()) +const bts::api::admin::SIMUserData *AdminServiceUtils::get_group_sim_data( + const bts::api::admin::BTSUserGroup &group, + const bts::api::admin::AdminData &data) { + if (group.has_user_data() && group.user_data().has_exchange_user_data() && + group.user_data().exchange_user_data().has_sim_data()) return &(group.user_data().exchange_user_data().sim_data()); - else if (has_id(group.parent_group_id())){ - const bts::api::admin::BTSUserGroup* parent_group = find_group(data, group.parent_group_id()); + else if (has_id(group.parent_group_id())) { + const bts::api::admin::BTSUserGroup *parent_group = + find_group(data, group.parent_group_id()); if (parent_group != nullptr) return get_group_sim_data(*parent_group, data); } return nullptr; } -const bts::api::admin::UserAccountPermissions* const AdminServiceUtils::get_group_user_permissions (const bts::api::admin::AdminData& admin_data, - uint32_t group_id){ - const bts::api::admin::BTSUserGroup* const group = find_group(admin_data, group_id); - if(group != nullptr){ - if (group->has_user_data() && group->user_data().has_account_permissions()) +const bts::api::admin::UserAccountPermissions *const +AdminServiceUtils::get_group_user_permissions( + const bts::api::admin::AdminData &admin_data, uint32_t group_id) { + const bts::api::admin::BTSUserGroup *const group = + find_group(admin_data, group_id); + if (group != nullptr) { + if (group->has_user_data() && + group->user_data().has_account_permissions()) return &group->user_data().account_permissions(); if (has_id(group->parent_group_id())) - return get_group_user_permissions(admin_data, group->parent_group_id()); + return get_group_user_permissions( + admin_data, group->parent_group_id()); } return nullptr; } @@ -830,158 +868,167 @@ const bts::api::admin::UserAccountPermissions* const AdminServiceUtils::get_grou //////////////////////////////////////////// // group mutators ////////////////////////// //////////////////////////////////////////// -bts::api::admin::BTSUserGroup* AdminServiceUtils::create_group(bts::api::admin::AdminData& data, - uint32_t parent_group_id, - const std::string& group_name, - bts::api::admin::AdminServiceOperationResult& result){ +bts::api::admin::BTSUserGroup *AdminServiceUtils::create_group( + 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 // i. account with the name already exists // ii. parent account is set and does not exist - result.set_is_success(true); - if (find_group (data, group_name) != nullptr){ + result.set_is_success(true); + if (find_group(data, group_name) != nullptr) { result.set_is_success(false); result.set_error_text("Group by this name already exists"); return nullptr; } - if (has_id(parent_group_id)){ - if(find_group(data, parent_group_id) == nullptr){ + if (has_id(parent_group_id)) { + if (find_group(data, parent_group_id) == nullptr) { result.set_is_success(false); - result.set_error_text("Parent group does not exist"); - return nullptr; + result.set_error_text("Parent group does not exist"); + return nullptr; } } - uint32_t new_id = find_max_group_id(data)+1; - bts::api::admin::BTSUserGroup* new_group_ptr = data.add_user_groups(); + uint32_t new_id = find_max_group_id(data) + 1; + bts::api::admin::BTSUserGroup *new_group_ptr = data.add_user_groups(); new_group_ptr->set_id(new_id); new_group_ptr->set_parent_group_id(parent_group_id); new_group_ptr->set_name(group_name); - return new_group_ptr; + return new_group_ptr; } //////////////////////////////////////////// // user accessors ////////////////////////// //////////////////////////////////////////// -bts::api::admin::BTSUser* AdminServiceUtils::find_user (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){ - if(user_name==user_ptr->name()) +bts::api::admin::BTSUser *AdminServiceUtils::find_user( + 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) { + if (user_name == user_ptr->name()) return user_ptr; } return nullptr; } -const bts::api::admin::BTSUser* AdminServiceUtils::find_user (const bts::api::admin::AdminData& data, const std::string& user_name, - bool include_deleted){ - auto user_ptrs = users(data,include_deleted); +const bts::api::admin::BTSUser *AdminServiceUtils::find_user( + 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) - if(user_name==user_ptr->name()) + if (user_name == user_ptr->name()) return user_ptr; return nullptr; } -bts::api::admin::BTSUser* AdminServiceUtils::find_user (bts::api::admin::AdminData& data, uint32_t id, - bool include_deleted){ - auto user_ptrs = users_mutable(data,include_deleted); - for(auto user_ptr : user_ptrs){ - if(id==user_ptr->id()) +bts::api::admin::BTSUser *AdminServiceUtils::find_user( + bts::api::admin::AdminData &data, uint32_t id, bool include_deleted) { + auto user_ptrs = users_mutable(data, include_deleted); + for (auto user_ptr : user_ptrs) { + if (id == user_ptr->id()) return user_ptr; } return nullptr; } -const bts::api::admin::BTSUser* const AdminServiceUtils::find_user (const bts::api::admin::AdminData& data,uint32_t id, - bool include_deleted){ - auto user_ptrs = users(data,include_deleted); +const bts::api::admin::BTSUser *const AdminServiceUtils::find_user( + const bts::api::admin::AdminData &data, uint32_t id, bool include_deleted) { + auto user_ptrs = users(data, include_deleted); for (auto user_ptr : user_ptrs) - if(id==user_ptr->id()) + if (id == user_ptr->id()) return user_ptr; return nullptr; } -std::vector AdminServiceUtils::users (const bts::api::admin::AdminData& data, - bool include_deleted){ - std::vector rv; - for (const bts::api::admin::BTSUser& user : data.users()) +std::vector AdminServiceUtils::users( + const bts::api::admin::AdminData &data, bool include_deleted) { + std::vector rv; + for (const bts::api::admin::BTSUser &user : data.users()) if (user.is_present() || include_deleted) rv.push_back(&user); return rv; } -std::vector AdminServiceUtils::users_mutable (bts::api::admin::AdminData& data, - bool include_deleted){ - std::vector rv; - for(int i=0; i AdminServiceUtils::users_mutable( + bts::api::admin::AdminData &data, bool include_deleted) { + std::vector rv; + for (int i = 0; i < data.users_size(); i++) { auto user_ptr = data.mutable_users(i); if (user_ptr->is_present() || include_deleted) rv.push_back(user_ptr); } return rv; } -uint32_t AdminServiceUtils::find_max_user_id (const bts::api::admin::AdminData& data){ +uint32_t +AdminServiceUtils::find_max_user_id(const bts::api::admin::AdminData &data) { uint32_t rv = 0; - auto user_ptrs = users(data,true); - for(auto user_ptr : user_ptrs) + auto user_ptrs = users(data, true); + for (auto user_ptr : user_ptrs) if (user_ptr->id() > rv) rv = user_ptr->id(); return rv; } -const bts::api::admin::CMEUserData* AdminServiceUtils::get_user_cme_data(const bts::api::admin::BTSUser& user, - const bts::api::admin::AdminData& data){ - if (user.has_user_data() && user.user_data().has_exchange_user_data() && user.user_data().exchange_user_data().has_cme_data()) +const bts::api::admin::CMEUserData *AdminServiceUtils::get_user_cme_data( + const bts::api::admin::BTSUser &user, + const bts::api::admin::AdminData &data) { + if (user.has_user_data() && user.user_data().has_exchange_user_data() && + user.user_data().exchange_user_data().has_cme_data()) return &(user.user_data().exchange_user_data().cme_data()); - else{ - const bts::api::admin::BTSUserGroup* parent_group = find_group(data, user.parent_group_id()); - if (parent_group != nullptr) - return get_group_cme_data(*parent_group, data); + else { + const bts::api::admin::BTSUserGroup *parent_group = + find_group(data, user.parent_group_id()); + if (parent_group != nullptr) + return get_group_cme_data(*parent_group, data); } return nullptr; } -const bts::api::admin::ICEUserData* AdminServiceUtils::get_user_ice_data(const bts::api::admin::BTSUser& user, - const bts::api::admin::AdminData& data){ - if (user.has_user_data() && user.user_data().has_exchange_user_data() && user.user_data().exchange_user_data().has_ice_data()) +const bts::api::admin::ICEUserData *AdminServiceUtils::get_user_ice_data( + const bts::api::admin::BTSUser &user, + const bts::api::admin::AdminData &data) { + if (user.has_user_data() && user.user_data().has_exchange_user_data() && + user.user_data().exchange_user_data().has_ice_data()) return &(user.user_data().exchange_user_data().ice_data()); - else{ - const bts::api::admin::BTSUserGroup* parent_group = find_group(data, user.parent_group_id()); - if (parent_group != nullptr) - return get_group_ice_data(*parent_group, data); + else { + const bts::api::admin::BTSUserGroup *parent_group = + find_group(data, user.parent_group_id()); + if (parent_group != nullptr) + return get_group_ice_data(*parent_group, data); } return nullptr; } -const bts::api::admin::SIMUserData* AdminServiceUtils::get_user_sim_data(const bts::api::admin::BTSUser& user, - const bts::api::admin::AdminData& data){ - if (user.has_user_data() && user.user_data().has_exchange_user_data() && user.user_data().exchange_user_data().has_sim_data()) +const bts::api::admin::SIMUserData *AdminServiceUtils::get_user_sim_data( + const bts::api::admin::BTSUser &user, + const bts::api::admin::AdminData &data) { + if (user.has_user_data() && user.user_data().has_exchange_user_data() && + user.user_data().exchange_user_data().has_sim_data()) return &(user.user_data().exchange_user_data().sim_data()); - else{ - const bts::api::admin::BTSUserGroup* parent_group = find_group(data, user.parent_group_id()); - if (parent_group != nullptr) - return get_group_sim_data(*parent_group, data); + else { + const bts::api::admin::BTSUserGroup *parent_group = + find_group(data, user.parent_group_id()); + if (parent_group != nullptr) + return get_group_sim_data(*parent_group, data); } return nullptr; } - // finds the "exchange user" (ex: "operator_id" at CME or "authorized_trader" - // 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, - bts::api::admin::AdminServiceOperationResult& out_result){ +// finds the "exchange user" (ex: "operator_id" at CME or "authorized_trader" +// 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, + bts::api::admin::AdminServiceOperationResult &out_result) { out_result.set_is_success(true); std::string rv = ""; - switch(exchange) - { + switch (exchange) { case api::Venue::VENUE_GLBX: { auto cme_user_data = get_user_cme_data(user, data); if (cme_user_data != nullptr) rv = cme_user_data->operator_id(); break; } - case api::Venue::VENUE_ICE: - { + case api::Venue::VENUE_ICE: { auto ice_user_data = get_user_ice_data(user, data); if (ice_user_data != nullptr) rv = ice_user_data->operator_id(); - break; + break; } - case api::Venue::VENUE_SIM: - case api::Venue::VENUE_SIMICE: - { + case api::Venue::VENUE_SIM: + case api::Venue::VENUE_SIMICE: { auto sim_user_data = get_user_sim_data(user, data); if (sim_user_data != nullptr) rv = sim_user_data->operator_id(); @@ -991,107 +1038,107 @@ std::string AdminServiceUtils::find_user_exchange_id (const bts::api::admin::Adm case api::Venue::VENUE_UNSET: case api::Venue::VENUE_BTS: case api::Venue::VENUE_CBOE: - case api::Venue::VENUE_CBOECFE: + case api::Venue::VENUE_CBOECFE: case api::Venue::Venue_INT_MIN_SENTINEL_DO_NOT_USE_: - case api::Venue::Venue_INT_MAX_SENTINEL_DO_NOT_USE_: - out_result.set_is_success(false); out_result.set_error_text("Exchange not supported"); + case api::Venue::Venue_INT_MAX_SENTINEL_DO_NOT_USE_: + out_result.set_is_success(false); + out_result.set_error_text("Exchange not supported"); break; } return rv; } -std::string AdminServiceUtils::find_user_company_id (const bts::api::admin::AdminData& data, - const bts::api::admin::BTSUser& user, - api::Venue exchange, - bts::api::admin::AdminServiceOperationResult& out_result) -{ +std::string AdminServiceUtils::find_user_company_id( + const bts::api::admin::AdminData &data, + const bts::api::admin::BTSUser &user, api::Venue exchange, + bts::api::admin::AdminServiceOperationResult &out_result) { out_result.set_is_success(true); std::string rv = ""; - switch(exchange) - { - case api::Venue::VENUE_ICE: - { + switch (exchange) { + case api::Venue::VENUE_ICE: { auto ice_user_data = get_user_ice_data(user, data); if (ice_user_data != nullptr) rv = std::to_string(ice_user_data->company_id()); - break; + break; } - case api::Venue::VENUE_SIM: + case api::Venue::VENUE_SIM: case api::Venue::VENUE_SIMICE: case api::Venue::VENUE_GLBX: case api::Venue::VENUE_UNSET: case api::Venue::VENUE_BTS: case api::Venue::VENUE_CBOE: - case api::Venue::VENUE_CBOECFE: + case api::Venue::VENUE_CBOECFE: case api::Venue::Venue_INT_MIN_SENTINEL_DO_NOT_USE_: - case api::Venue::Venue_INT_MAX_SENTINEL_DO_NOT_USE_: - out_result.set_is_success(false); out_result.set_error_text("Exchange not supported"); + case api::Venue::Venue_INT_MAX_SENTINEL_DO_NOT_USE_: + out_result.set_is_success(false); + out_result.set_error_text("Exchange not supported"); break; } return rv; } -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, - api::Venue exchange){ +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, + api::Venue exchange) { AdminServiceOperationResult find_account_result, find_user_result; // i. uses the exchange and exchange_user to reverse lookup the user(s) - auto user_ptrs = users(admin_data, false); - std::vector matching_users; - for (BTSUser const* u : user_ptrs){ - auto exchange_u = find_user_exchange_id(admin_data, *u, - exchange, find_user_result); - if (find_user_result.is_success() && boost::algorithm::iequals ( - exchange_u, - exchange_user)) - matching_users.push_back(u); - } - // 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 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) - { - auto exchange_u = find_user_company_id(admin_data, *u, exchange, find_user_result); - if (find_user_result.is_success() && boost::algorithm::iequals ( exchange_u, exchange_user)) + auto user_ptrs = users(admin_data, false); + std::vector matching_users; + for (BTSUser const *u : user_ptrs) { + auto exchange_u = + find_user_exchange_id(admin_data, *u, exchange, find_user_result); + if (find_user_result.is_success() && + boost::algorithm::iequals(exchange_u, exchange_user)) matching_users.push_back(u); - } - // ii. uses the exchange, connection and exchange_account to reverse lookup the account(s) + } + // 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 + // 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) { + auto exchange_u = + find_user_company_id(admin_data, *u, exchange, find_user_result); + if (find_user_result.is_success() && + boost::algorithm::iequals(exchange_u, exchange_user)) + matching_users.push_back(u); + } + // ii. uses the exchange, connection and exchange_account to reverse lookup + // the account(s) auto account_ptrs = accounts(admin_data, false); - std::vector matching_accounts; - for (BTSAccount const* a :account_ptrs) - if (account_has_connection(*a, connection)){ - auto exchange_a = find_account_exchange_account(admin_data, *a, - exchange, - find_account_result); - if (find_account_result.is_success() && boost::algorithm::iequals ( - exchange_a, - exchange_account)) + std::vector matching_accounts; + for (BTSAccount const *a : account_ptrs) + if (account_has_connection(*a, connection)) { + auto exchange_a = find_account_exchange_account( + admin_data, *a, exchange, find_account_result); + if (find_account_result.is_success() && + boost::algorithm::iequals(exchange_a, exchange_account)) matching_accounts.push_back(a); } - // iii. finds the first account from ii that the user from i is authorized to trade - for (BTSUser const* u : matching_users){ - std::vector user_auth_accounts; - find_user_trading_accounts (admin_data, u->id(), user_auth_accounts); - for (BTSAccount const* i : user_auth_accounts) - for (BTSAccount const* j : matching_accounts) - if(i->id() == j->id()) - return std::pair(i,u); + // iii. finds the first account from ii that the user from i is authorized to + // trade + for (BTSUser const *u : matching_users) { + std::vector user_auth_accounts; + find_user_trading_accounts(admin_data, u->id(), user_auth_accounts); + for (BTSAccount const *i : user_auth_accounts) + for (BTSAccount const *j : matching_accounts) + if (i->id() == j->id()) + return std::pair(i, u); } - return std::pair(nullptr, nullptr); + return std::pair(nullptr, nullptr); } - // for a given user finds the account permissions (if permissions are // derived from the group, it traverses the group hierarcy to find the // correct permissions. -const bts::api::admin::UserAccountPermissions* AdminServiceUtils::get_user_permissions (const bts::api::admin::AdminData& admin_data, - uint32_t user_id){ - const bts::api::admin::BTSUser* const user = find_user(admin_data, user_id); - if(user != nullptr){ +const bts::api::admin::UserAccountPermissions * +AdminServiceUtils::get_user_permissions( + const bts::api::admin::AdminData &admin_data, uint32_t user_id) { + const bts::api::admin::BTSUser *const user = find_user(admin_data, user_id); + if (user != nullptr) { if (user->has_user_data() && user->user_data().has_account_permissions()) return &user->user_data().account_permissions(); else @@ -1101,135 +1148,140 @@ const bts::api::admin::UserAccountPermissions* AdminServiceUtils::get_user_permi } // 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, - std::vector& associated_accounts){ - const bts::api::admin::UserAccountPermissions* user_perm_ptr = get_user_permissions (admin_data, user_id); +void AdminServiceUtils::find_user_trading_accounts( + 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); if (user_perm_ptr != nullptr) - for(auto it=user_perm_ptr->account_permissions().begin(); it!=user_perm_ptr->account_permissions().end(); it++) - if (it->second.has_trading_permission() && it->second.trading_permission().has_permissions()){ - const api::admin::BTSAccount* account_ptr = find_account(admin_data, it->first); - if (account_ptr != nullptr) - associated_accounts.push_back(account_ptr); + for (auto it = user_perm_ptr->account_permissions().begin(); + it != user_perm_ptr->account_permissions().end(); it++) + if (it->second.has_trading_permission() && + it->second.trading_permission().has_permissions()) { + const api::admin::BTSAccount *account_ptr = + find_account(admin_data, it->first); + if (account_ptr != nullptr) + associated_accounts.push_back(account_ptr); } } // 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, - 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()); - if (user_perm_ptr) - { - const auto& permission_unit = user_perm_ptr->account_permissions().find(account_id); - if(permission_unit != user_perm_ptr->account_permissions().end() && permission_unit->second.has_trading_permission() && - permission_unit->second.trading_permission().has_permissions()) - { +void AdminServiceUtils::find_users_for_trading_account( + 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()); + if (user_perm_ptr) { + const auto &permission_unit = + user_perm_ptr->account_permissions().find(account_id); + if (permission_unit != user_perm_ptr->account_permissions().end() && + permission_unit->second.has_trading_permission() && + permission_unit->second.trading_permission().has_permissions()) { associated_users.push_back(u); } - } + } } } - -void AdminServiceUtils::validate_user_update (const bts::api::admin::AdminData& admin_data, - const bts::api::admin::BTSUser& updated_user, - bts::api::admin::AdminServiceOperationResult& result){ +void AdminServiceUtils::validate_user_update( + const bts::api::admin::AdminData &admin_data, + const bts::api::admin::BTSUser &updated_user, + bts::api::admin::AdminServiceOperationResult &result) { result.set_is_success(true); // validate id - if(find_user(admin_data, updated_user.id()) == nullptr){ + if (find_user(admin_data, updated_user.id()) == nullptr) { result.set_is_success(false); result.set_error_text("Could not find user id"); return; } // validate that name change doesnt collide - auto user_ptrs = users(admin_data,true); + auto user_ptrs = users(admin_data, true); for (auto user_ptr : user_ptrs) - if (user_ptr->id() != updated_user.id() && user_ptr->name() == updated_user.name()){ + if (user_ptr->id() != updated_user.id() && + user_ptr->name() == updated_user.name()) { result.set_is_success(false); result.set_error_text("User by this name already exists"); return; - } - validate_user_exchange_data (updated_user, result); + } + validate_user_exchange_data(updated_user, result); } -void AdminServiceUtils::validate_user_exchange_data (const bts::api::admin::BTSUser& user, - bts::api::admin::AdminServiceOperationResult& result){ +void AdminServiceUtils::validate_user_exchange_data( + const bts::api::admin::BTSUser &user, + bts::api::admin::AdminServiceOperationResult &result) { result.set_is_success(true); // this is not right (should navigate to the group) - if (user.has_user_data() && user.user_data().has_exchange_user_data() && user.user_data().exchange_user_data().has_cme_data()){ - const api::admin::CMEUserData& cme_user_data = user.user_data().exchange_user_data().cme_data(); - if (cme_user_data.operator_id().size() > 18){ + if (user.has_user_data() && user.user_data().has_exchange_user_data() && + user.user_data().exchange_user_data().has_cme_data()) { + const api::admin::CMEUserData &cme_user_data = + user.user_data().exchange_user_data().cme_data(); + if (cme_user_data.operator_id().size() > 18) { result.set_is_success(false); - result.set_error_text("CME operator id can not be more 12 characters long"); + result.set_error_text( + "CME operator id can not be more 12 characters long"); } } } -void AdminServiceUtils::get_md_entitlement_report(const AdminData& admin_data, - std::vector& entitlements){ - for (const auto& user : admin_data.users()) - { - const CMEUserData* cme_data=AdminServiceUtils::get_user_cme_data(user, admin_data); - if(cme_data!=nullptr) - { - for (const auto& cme_mic_data : cme_data->md_permissions()) - { - MDEntitlementReportUnit rv=get_cme_md_entitlement_unit(user, cme_mic_data); +void AdminServiceUtils::get_md_entitlement_report( + const AdminData &admin_data, + std::vector &entitlements) { + for (const auto &user : admin_data.users()) { + const CMEUserData *cme_data = + AdminServiceUtils::get_user_cme_data(user, admin_data); + if (cme_data != nullptr) { + for (const auto &cme_mic_data : cme_data->md_permissions()) { + MDEntitlementReportUnit rv = + get_cme_md_entitlement_unit(user, cme_mic_data); entitlements.push_back(rv); } } - const ICEUserData* ice_data=AdminServiceUtils::get_user_ice_data(user, admin_data); - if(ice_data!=nullptr) - { - for (const auto& ice_mic_data : ice_data->md_permissions()) - { - MDEntitlementReportUnit rv=get_ice_md_entitlement_unit(user, ice_mic_data); + const ICEUserData *ice_data = + AdminServiceUtils::get_user_ice_data(user, admin_data); + if (ice_data != nullptr) { + for (const auto &ice_mic_data : ice_data->md_permissions()) { + MDEntitlementReportUnit rv = + get_ice_md_entitlement_unit(user, ice_mic_data); entitlements.push_back(rv); } - } - } + } + } } MDEntitlementReportUnit AdminServiceUtils::get_cme_md_entitlement_unit( - const BTSUser& user, - const CMEMicData& cme_mic_data){ + const BTSUser &user, const CMEMicData &cme_mic_data) { MDEntitlementReportUnit rv; rv.set_user(user.name()); rv.set_user_id(user.id()); rv.set_exchange("GLBX"); - switch(cme_mic_data.mic()) - { - case api::CMEMics::CME: - rv.set_mic("CME"); - break; - case api::CMEMics::NYMEX: - rv.set_mic("NYMEX"); - break; - case api::CMEMics::CBT: - rv.set_mic("CBT"); - break; - case api::CMEMics::COMEX: - rv.set_mic("COMEX"); - break; - case api::CMEMics::MGE: - rv.set_mic("MGE"); - break; - case api::CMEMics::DME: - rv.set_mic("DME"); - break; - case api::CMEMics::NYMSW: - rv.set_mic("NYMSW"); - break; - case api::CMEMics::FXS: - rv.set_mic("FXS"); - break; - case api::CMEMics::UNSET: - case api::CMEMics::CMEMics_INT_MIN_SENTINEL_DO_NOT_USE_: - case api::CMEMics::CMEMics_INT_MAX_SENTINEL_DO_NOT_USE_: - rv.set_mic(""); - break; + switch (cme_mic_data.mic()) { + case api::CMEMics::CME: + rv.set_mic("CME"); + break; + case api::CMEMics::NYMEX: + rv.set_mic("NYMEX"); + break; + case api::CMEMics::CBT: + rv.set_mic("CBT"); + break; + case api::CMEMics::COMEX: + rv.set_mic("COMEX"); + break; + case api::CMEMics::MGE: + rv.set_mic("MGE"); + break; + case api::CMEMics::DME: + rv.set_mic("DME"); + break; + case api::CMEMics::NYMSW: + rv.set_mic("NYMSW"); + break; + case api::CMEMics::FXS: + rv.set_mic("FXS"); + break; + case api::CMEMics::UNSET: + case api::CMEMics::CMEMics_INT_MIN_SENTINEL_DO_NOT_USE_: + case api::CMEMics::CMEMics_INT_MAX_SENTINEL_DO_NOT_USE_: + rv.set_mic(""); + break; } rv.set_enabled(cme_mic_data.enabled()); std::ostringstream key; @@ -1238,13 +1290,12 @@ MDEntitlementReportUnit AdminServiceUtils::get_cme_md_entitlement_unit( return rv; } MDEntitlementReportUnit AdminServiceUtils::get_ice_md_entitlement_unit( - const BTSUser& user, - const ICEMicData& ice_mic_data){ + const BTSUser &user, const ICEMicData &ice_mic_data) { MDEntitlementReportUnit rv; rv.set_user(user.name()); rv.set_user_id(user.id()); - rv.set_exchange( bts::api::Venue_Name(bts::api::Venue::VENUE_ICE) ); - rv.set_mic( bts::api::ICEMics_Name( ice_mic_data.mic()) ); + rv.set_exchange(bts::api::Venue_Name(bts::api::Venue::VENUE_ICE)); + rv.set_mic(bts::api::ICEMics_Name(ice_mic_data.mic())); rv.set_enabled(ice_mic_data.enabled()); std::ostringstream key; @@ -1253,20 +1304,20 @@ MDEntitlementReportUnit AdminServiceUtils::get_ice_md_entitlement_unit( return rv; } -void AdminServiceUtils::get_user_symbol_permissions(const AdminData& data, - const BTSUser& user, - std::vector& rv){ +void AdminServiceUtils::get_user_symbol_permissions( + const AdminData &data, const BTSUser &user, + std::vector &rv) { std::map mic_perm_map; auto exchange = api::Venue::VENUE_GLBX; - const CMEUserData* cme_data=get_user_cme_data(user,data); - if(cme_data!=nullptr) - for(const auto& mic_data : cme_data->md_permissions()) - if(mic_data.enabled()) - mic_perm_map[mic_data.mic()]=true; - const auto& cme_symb_mics = config::get().cme_mic(); - for(auto it=cme_symb_mics.begin();it!=cme_symb_mics.end();it++){ - const std::string& symbol=it->first; - api::CMEMics mic=it->second; + const CMEUserData *cme_data = get_user_cme_data(user, data); + if (cme_data != nullptr) + for (const auto &mic_data : cme_data->md_permissions()) + if (mic_data.enabled()) + mic_perm_map[mic_data.mic()] = true; + const auto &cme_symb_mics = config::get().cme_mic(); + for (auto it = cme_symb_mics.begin(); it != cme_symb_mics.end(); it++) { + const std::string &symbol = it->first; + api::CMEMics mic = it->second; UserSymbolMDPermissionUnit u; std::ostringstream key; key << exchange << user.name() << symbol; @@ -1274,133 +1325,143 @@ void AdminServiceUtils::get_user_symbol_permissions(const AdminData& data, u.set_user_id(user.id()); u.set_exchange(exchange); u.set_symbol(symbol); - u.set_enabled(mic_perm_map.find(mic)!=mic_perm_map.end()); - rv.push_back(u); + u.set_enabled(mic_perm_map.find(mic) != mic_perm_map.end()); + rv.push_back(u); } } //////////////////////////////////////////// // 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, - const bts::api::admin::LicenseData& license_data, - const bts::api::admin::LicenseEntitlements& license_entitlements, - bts::api::admin::AdminServiceCreateEntityResult& result){ +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, + const bts::api::admin::LicenseData &license_data, + const bts::api::admin::LicenseEntitlements &license_entitlements, + bts::api::admin::AdminServiceCreateEntityResult &result) { result.set_is_success(true); // the error conditions are checked first and returned immediatly // i. user with the name already exists // ii. parent group does not exist - if (find_user (data, name, true) != nullptr){ - result.set_is_success(false); - result.set_error_text("User by this name already exists"); - return nullptr; + if (find_user(data, name, true) != nullptr) { + result.set_is_success(false); + result.set_error_text("User by this name already exists"); + return nullptr; } - if (find_group(data, parent_group_id) == nullptr){ - result.set_is_success(false); - result.set_error_text("Parent group does not exist"); - return nullptr; + if (find_group(data, parent_group_id) == nullptr) { + result.set_is_success(false); + result.set_error_text("Parent group does not exist"); + return nullptr; } - uint32_t new_id = AdminServiceUtils::find_max_user_id(data)+1; - bts::api::admin::BTSUser* new_user_ptr = data.add_users(); + uint32_t new_id = AdminServiceUtils::find_max_user_id(data) + 1; + bts::api::admin::BTSUser *new_user_ptr = data.add_users(); new_user_ptr->set_is_present(true); new_user_ptr->set_id(new_id); new_user_ptr->set_parent_group_id(parent_group_id); new_user_ptr->set_name(name); - new_user_ptr->set_password (password); - new_user_ptr->set_full_name (full_name); - new_user_ptr->set_company (company); + new_user_ptr->set_password(password); + new_user_ptr->set_full_name(full_name); + new_user_ptr->set_company(company); new_user_ptr->set_is_active(is_active); new_user_ptr->mutable_license_data()->CopyFrom(license_data); new_user_ptr->mutable_license_entitlements()->CopyFrom(license_entitlements); - result.set_new_id(new_id); + result.set_new_id(new_id); return new_user_ptr; } -void AdminServiceUtils::set_user_exchange_data(bts::api::admin::BTSUser* user, - const bts::api::admin::ExchangeUserData& exchange_user_data){ +void AdminServiceUtils::set_user_exchange_data( + bts::api::admin::BTSUser *user, + const bts::api::admin::ExchangeUserData &exchange_user_data) { if (!user->has_user_data()) user->mutable_user_data(); if (!user->user_data().has_exchange_user_data()) - user->mutable_user_data()->mutable_exchange_user_data()->CopyFrom(exchange_user_data); + user->mutable_user_data()->mutable_exchange_user_data()->CopyFrom( + exchange_user_data); } -// void AdminServiceUtils::set_user_md_entitlement_data(bts::api::admin::BTSUser* user, -// const bts::api::admin::ExchangeUserMarketDataEntitlementData& exchange_user_md_entitelemnt_data){ +// void +// AdminServiceUtils::set_user_md_entitlement_data(bts::api::admin::BTSUser* +// user, +// const +// bts::api::admin::ExchangeUserMarketDataEntitlementData& +// exchange_user_md_entitelemnt_data){ // if (!user->has_user_data()) // user->mutable_user_data(); // if (!user->user_data().has_exchange_md_entitlement_data()) // user->mutable_user_data()->mutable_exchange_md_entitlement_data()->CopyFrom(exchange_user_md_entitelemnt_data); // } -void AdminServiceUtils::clear_user_accounts (bts::api::admin::BTSUser* user){ - if(user->has_user_data() && user->user_data().has_account_permissions()) +void AdminServiceUtils::clear_user_accounts(bts::api::admin::BTSUser *user) { + if (user->has_user_data() && user->user_data().has_account_permissions()) user->mutable_user_data()->clear_account_permissions(); } -void AdminServiceUtils::set_user_accounts (bts::api::admin::BTSUser* user, const bts::api::admin::UserAccountPermissions& user_account_permissions){ - if(!user->has_user_data()) +void AdminServiceUtils::set_user_accounts( + bts::api::admin::BTSUser *user, + const bts::api::admin::UserAccountPermissions &user_account_permissions) { + if (!user->has_user_data()) user->mutable_user_data(); - user->mutable_user_data()->mutable_account_permissions()->CopyFrom(user_account_permissions); + user->mutable_user_data()->mutable_account_permissions()->CopyFrom( + user_account_permissions); } -bts::api::admin::BTSUser* AdminServiceUtils::update_user(bts::api::admin::AdminData& admin_data, - const bts::api::admin::BTSUser& updated_user, - bts::api::admin::AdminServiceOperationResult& result){ +bts::api::admin::BTSUser *AdminServiceUtils::update_user( + bts::api::admin::AdminData &admin_data, + const bts::api::admin::BTSUser &updated_user, + bts::api::admin::AdminServiceOperationResult &result) { validate_user_update(admin_data, updated_user, result); - if (result.is_success()){ - bts::api::admin::BTSUser* user_ptr = find_user(admin_data, updated_user.id()); + if (result.is_success()) { + bts::api::admin::BTSUser *user_ptr = + find_user(admin_data, updated_user.id()); user_ptr->CopyFrom(updated_user); return user_ptr; - } - else + } else return nullptr; } -void AdminServiceUtils::delete_user (bts::api::admin::AdminData& admin_data, - const bts::api::admin::IDAPIArgument& id, - bts::api::admin::AdminServiceOperationResult& result){ +void AdminServiceUtils::delete_user( + bts::api::admin::AdminData &admin_data, + const bts::api::admin::IDAPIArgument &id, + bts::api::admin::AdminServiceOperationResult &result) { result.set_is_success(true); - api::admin::BTSUser* user_ptr = AdminServiceUtils::find_user(admin_data, id.id()); - if (user_ptr != nullptr) - { + api::admin::BTSUser *user_ptr = + AdminServiceUtils::find_user(admin_data, id.id()); + if (user_ptr != nullptr) { std::string deleted_name; int deleted_idx = 0; - do{ + do { // keep going until the modified name is not found, - // otherwise keep "incrementing" the modified name + // otherwise keep "incrementing" the modified name deleted_idx++; - deleted_name = deleted_idx == 1 ? fmt::format("DELETED_{}", user_ptr->name()) : - fmt::format("DELETED_{}_{}", deleted_idx, user_ptr->name()); - } - while(AdminServiceUtils::find_user(admin_data, deleted_name, true) != nullptr); + deleted_name = + deleted_idx == 1 + ? fmt::format("DELETED_{}", user_ptr->name()) + : fmt::format("DELETED_{}_{}", deleted_idx, user_ptr->name()); + } while (AdminServiceUtils::find_user(admin_data, deleted_name, true) != + nullptr); user_ptr->set_is_present(false); user_ptr->set_name(deleted_name); - } - else{ + } else { result.set_is_success(false); result.set_error_text("Could not find user"); } } //////////////////////////////////////////// -//risk limits ////////////////////////////// +// risk limits ////////////////////////////// //////////////////////////////////////////// -bool AdminServiceUtils::_sort_security_scopes (const bts::api::admin::SecurityScope& a, - const bts::api::admin::SecurityScope& b){ +bool AdminServiceUtils::_sort_security_scopes( + const bts::api::admin::SecurityScope &a, + const bts::api::admin::SecurityScope &b) { // for both the sec and product scope sorting, the more // qualified arg is sent to the top (vs wildcard). the // order of qualification is sec_id, symbol, type, exchange. // if both a and b are equally qualified, it is a - // a dont-care case (in terms of sec/prod res) and + // a dont-care case (in terms of sec/prod res) and // ascending orderring is used - if (has_id(a.security_id())){ + if (has_id(a.security_id())) { if (has_id(b.security_id())) return a.security_id() < b.security_id(); else return true; } if (has_id(b.security_id())) - return false; + return false; // symbol - if (is_symbol_set(a.security_symbol())){ + if (is_symbol_set(a.security_symbol())) { if (is_symbol_set(b.security_symbol())) return a.security_symbol() < b.security_symbol(); else @@ -1413,10 +1474,11 @@ bool AdminServiceUtils::_sort_security_scopes (const bts::api::admin::SecuritySc return a.security_type() < b.security_type(); return a.exchange() < b.exchange(); } -bool AdminServiceUtils::_sort_product_scopes (const bts::api::admin::ProductScope& a, - const bts::api::admin::ProductScope& b){ +bool AdminServiceUtils::_sort_product_scopes( + const bts::api::admin::ProductScope &a, + const bts::api::admin::ProductScope &b) { // symbol - if (is_symbol_set(a.security_symbol())){ + if (is_symbol_set(a.security_symbol())) { if (is_symbol_set(b.security_symbol())) return a.security_symbol() < b.security_symbol(); else @@ -1429,99 +1491,110 @@ bool AdminServiceUtils::_sort_product_scopes (const bts::api::admin::ProductScop return a.security_type() < b.security_type(); return a.exchange() < b.exchange(); } -void AdminServiceUtils::sort_limits (bts::api::admin::BTSAccount& account){ - std::sort (account.mutable_security_position_limits()->begin(), - account.mutable_security_position_limits()->end(), - [](const bts::api::admin::AccountSecurityPositionLimitUnit& a, const bts::api::admin::AccountSecurityPositionLimitUnit& b){ - return _sort_security_scopes(a.security(), b.security()); - }); - std::sort (account.mutable_product_position_limits()->begin(), - account.mutable_product_position_limits()->end(), - [](const bts::api::admin::AccountProductPositionLimitUnit& a, const bts::api::admin::AccountProductPositionLimitUnit& b){ - return _sort_product_scopes(a.product(), b.product()); - }); +void AdminServiceUtils::sort_limits(bts::api::admin::BTSAccount &account) { + std::sort( + account.mutable_security_position_limits()->begin(), + account.mutable_security_position_limits()->end(), + [](const bts::api::admin::AccountSecurityPositionLimitUnit &a, + const bts::api::admin::AccountSecurityPositionLimitUnit &b) { + return _sort_security_scopes(a.security(), b.security()); + }); + std::sort( + account.mutable_product_position_limits()->begin(), + account.mutable_product_position_limits()->end(), + [](const bts::api::admin::AccountProductPositionLimitUnit &a, + const bts::api::admin::AccountProductPositionLimitUnit &b) { + return _sort_product_scopes(a.product(), b.product()); + }); if (account.has_security_clip_limits()) - std::sort (account.mutable_security_clip_limits()->mutable_limit()->begin(), - account.mutable_security_clip_limits()->mutable_limit()->end(), - [](const bts::api::admin::AccountSecurityClipLimitUnit& a, const bts::api::admin::AccountSecurityClipLimitUnit& b){ - return _sort_security_scopes(a.security(), b.security()); - }); + std::sort( + account.mutable_security_clip_limits()->mutable_limit()->begin(), + account.mutable_security_clip_limits()->mutable_limit()->end(), + [](const bts::api::admin::AccountSecurityClipLimitUnit &a, + const bts::api::admin::AccountSecurityClipLimitUnit &b) { + return _sort_security_scopes(a.security(), b.security()); + }); } -bts::api::admin::AdminData AdminServiceUtils::sort_limits (const bts::api::admin::AdminData& admin_data){ +bts::api::admin::AdminData +AdminServiceUtils::sort_limits(const bts::api::admin::AdminData &admin_data) { bts::api::admin::AdminData rv; - rv.CopyFrom(admin_data); - for(int i=0; i symbols; - md::get_system_md_symbols(venue, sec_type,&symbols); + md::get_system_md_symbols(venue, sec_type, &symbols); for (auto const &s : symbols) { auto acct_a_prod_limit = to_account->add_product_position_limits(); @@ -1544,13 +1618,15 @@ void add_product_position_limits(bts::api::admin::BTSAccount* to_account, api::V } } -void add_security_clip_sizes_to_account(bts::api::admin::BTSAccount* to_account, api::Venue venue, api::SecurityType sec_type,uint32_t limit) -{ +void add_security_clip_sizes_to_account( + 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); + md::get_system_md_symbols(venue, sec_type, &symbols); for (auto const &s : symbols) { - auto acct_a_clip_size = to_account->mutable_security_clip_limits()->add_limit(); + auto acct_a_clip_size = + to_account->mutable_security_clip_limits()->add_limit(); acct_a_clip_size->mutable_security()->set_exchange(s.exchange()); acct_a_clip_size->mutable_security()->set_security_type(s.type()); acct_a_clip_size->mutable_security()->set_security_symbol(s.symbol()); @@ -1558,224 +1634,345 @@ void add_security_clip_sizes_to_account(bts::api::admin::BTSAccount* to_account, } } -void add_security_position_limits (bts::api::admin::BTSAccount* to_account, api::Venue venue, api::SecurityType sec_type) -{ +void add_security_position_limits( + 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); acct_a1_sec_limit->mutable_security()->set_security_type(sec_type); acct_a1_sec_limit->mutable_security()->set_security_symbol("*"); - acct_a1_sec_limit->set_long_position_limit (10000); - acct_a1_sec_limit->set_short_position_limit (10000); + acct_a1_sec_limit->set_long_position_limit(10000); + acct_a1_sec_limit->set_short_position_limit(10000); } -void AdminServiceUtils::bootstrap_data (bts::api::admin::AdminData& data){ +void AdminServiceUtils::bootstrap_data(bts::api::admin::AdminData &data) { data.set_id(1); bts::api::admin::AdminServiceOperationResult result; bts::api::admin::AdminServiceCreateAccountResult account_result; bts::api::admin::AdminServiceCreateEntityResult user_result; // adding accounts - auto parent_account = create_account(data, 0, std::string("ACC A"), std::string("description"), true, account_result); - auto account_1 = create_account(data, parent_account->id(), std::string("ACC A1"), std::string("description"), true, account_result); account_1->set_is_active(true); - auto account_2 = create_account(data, parent_account->id(), std::string("ACC A2"), std::string("description"), true, account_result); account_2->set_is_active(true); - auto account_3 = create_account(data, parent_account->id(), std::string("ACC A3"), std::string("description"), true, account_result); account_3->set_is_active(true); - auto account_4 = create_account(data, parent_account->id(), std::string("BLUETST"), std::string("description"), true, account_result); account_4->set_is_active(true); - create_account(data, parent_account->id(), std::string("ACC A4"), std::string("description"), true, account_result); + auto parent_account = create_account( + data, 0, std::string("ACC A"), std::string("description"), true, + account_result); + auto account_1 = create_account( + data, parent_account->id(), std::string("ACC A1"), + std::string("description"), true, account_result); + account_1->set_is_active(true); + auto account_2 = create_account( + data, parent_account->id(), std::string("ACC A2"), + std::string("description"), true, account_result); + account_2->set_is_active(true); + auto account_3 = create_account( + data, parent_account->id(), std::string("ACC A3"), + std::string("description"), true, account_result); + account_3->set_is_active(true); + auto account_4 = create_account( + data, parent_account->id(), std::string("BLUETST"), + std::string("description"), true, account_result); + account_4->set_is_active(true); + create_account( + data, parent_account->id(), std::string("ACC A4"), + std::string("description"), true, account_result); // add group auto def_group = create_group(data, 0, std::string("default"), result); // adding users to the group bts::api::admin::LicenseData license_data; - bts::api::admin::LicenseEntitlements license_entitlements; std::string empty(""); - auto user_1 = create_user(data, def_group->id(), std::string("bts"), std::string(""), empty, empty, false, license_data, license_entitlements, user_result); user_1->set_is_active(true); - auto user_2 = create_user(data, def_group->id(), std::string("bts_2"), std::string("bts_2"), empty, empty, false, license_data, license_entitlements, user_result); user_2->set_is_active(true); - auto user_3 = create_user(data, def_group->id(), std::string("bts_3"), std::string("bts_3"), empty, empty, false, license_data, license_entitlements, user_result); user_3->set_is_active(true); - //associate users - bts::api::admin::UserAccountPermissionUnit permission_unit; + bts::api::admin::LicenseEntitlements license_entitlements; + std::string empty(""); + auto user_1 = create_user( + data, def_group->id(), std::string("bts"), std::string(""), empty, empty, + false, license_data, license_entitlements, user_result); + user_1->set_is_active(true); + auto user_2 = create_user( + data, def_group->id(), std::string("bts_2"), std::string("bts_2"), empty, + empty, false, license_data, license_entitlements, user_result); + user_2->set_is_active(true); + auto user_3 = create_user( + data, def_group->id(), std::string("bts_3"), std::string("bts_3"), empty, + empty, false, license_data, license_entitlements, user_result); + user_3->set_is_active(true); + // associate users + bts::api::admin::UserAccountPermissionUnit permission_unit; permission_unit.mutable_trading_permission()->set_has_permissions(true); permission_unit.mutable_admin_permission()->set_has_permissions(true); bts::api::admin::UserAccountPermissions account_permissions; - account_permissions.mutable_account_permissions()->insert(google::protobuf::MapPair(parent_account->id(), permission_unit)); - account_permissions.mutable_account_permissions()->insert(google::protobuf::MapPair(account_1->id(), permission_unit)); - account_permissions.mutable_account_permissions()->insert(google::protobuf::MapPair(account_2->id(), permission_unit)); - account_permissions.mutable_account_permissions()->insert(google::protobuf::MapPair(account_3->id(), permission_unit)); - account_permissions.mutable_account_permissions()->insert(google::protobuf::MapPair(account_4->id(), permission_unit)); + account_permissions.mutable_account_permissions()->insert( + google::protobuf::MapPair< + uint32_t, bts::api::admin::UserAccountPermissionUnit>( + parent_account->id(), permission_unit)); + account_permissions.mutable_account_permissions()->insert( + google::protobuf::MapPair< + uint32_t, bts::api::admin::UserAccountPermissionUnit>( + account_1->id(), permission_unit)); + account_permissions.mutable_account_permissions()->insert( + google::protobuf::MapPair< + uint32_t, bts::api::admin::UserAccountPermissionUnit>( + account_2->id(), permission_unit)); + account_permissions.mutable_account_permissions()->insert( + google::protobuf::MapPair< + uint32_t, bts::api::admin::UserAccountPermissionUnit>( + account_3->id(), permission_unit)); + account_permissions.mutable_account_permissions()->insert( + google::protobuf::MapPair< + uint32_t, bts::api::admin::UserAccountPermissionUnit>( + account_4->id(), permission_unit)); set_user_accounts(user_1, account_permissions); set_user_accounts(user_2, account_permissions); set_user_accounts(user_3, account_permissions); -// add cme and sim account data + // add cme and sim account data bts::api::admin::ExchangeAccountData exchange_account_data; - exchange_account_data.mutable_cme_account_data()->set_cti(bts::api::orderman::CTICode::CTI_CODE_CTI_CODE1); - exchange_account_data.mutable_cme_account_data()->set_origin(bts::api::orderman::CustomerOrFirm::CUSTOMER_OR_FIRM_FIRM); - exchange_account_data.mutable_cme_account_data()->set_clearing_account(parent_account->name()); - - exchange_account_data.mutable_ice_account_data()->set_cti(bts::api::orderman::CTICode::CTI_CODE_UNDEFINED); - exchange_account_data.mutable_ice_account_data()->set_origin(bts::api::orderman::CustomerOrFirm::CUSTOMER_OR_FIRM_FIRM); - exchange_account_data.mutable_ice_account_data()->set_clearing_account(parent_account->name()); + exchange_account_data.mutable_cme_account_data()->set_cti( + bts::api::orderman::CTICode::CTI_CODE_CTI_CODE1); + exchange_account_data.mutable_cme_account_data()->set_origin( + bts::api::orderman::CustomerOrFirm::CUSTOMER_OR_FIRM_FIRM); + exchange_account_data.mutable_cme_account_data()->set_clearing_account( + parent_account->name()); + + exchange_account_data.mutable_ice_account_data()->set_cti( + bts::api::orderman::CTICode::CTI_CODE_UNDEFINED); + exchange_account_data.mutable_ice_account_data()->set_origin( + bts::api::orderman::CustomerOrFirm::CUSTOMER_OR_FIRM_FIRM); + exchange_account_data.mutable_ice_account_data()->set_clearing_account( + parent_account->name()); exchange_account_data.mutable_ice_account_data()->set_clearing_firm("649"); - - exchange_account_data.mutable_sim_account_data()->set_cti(bts::api::orderman::CTICode::CTI_CODE_CTI_CODE1); - exchange_account_data.mutable_sim_account_data()->set_origin(bts::api::orderman::CustomerOrFirm::CUSTOMER_OR_FIRM_FIRM); - exchange_account_data.mutable_sim_account_data()->set_clearing_account(parent_account->name()); + + exchange_account_data.mutable_sim_account_data()->set_cti( + bts::api::orderman::CTICode::CTI_CODE_CTI_CODE1); + exchange_account_data.mutable_sim_account_data()->set_origin( + bts::api::orderman::CustomerOrFirm::CUSTOMER_OR_FIRM_FIRM); + exchange_account_data.mutable_sim_account_data()->set_clearing_account( + parent_account->name()); set_account_exchange_data(parent_account, exchange_account_data); - - exchange_account_data.mutable_cme_account_data()->set_clearing_account(account_1->name()); - exchange_account_data.mutable_ice_account_data()->set_clearing_account(account_1->name()); - exchange_account_data.mutable_sim_account_data()->set_clearing_account(account_1->name()); + exchange_account_data.mutable_cme_account_data()->set_clearing_account( + account_1->name()); + exchange_account_data.mutable_ice_account_data()->set_clearing_account( + account_1->name()); + exchange_account_data.mutable_sim_account_data()->set_clearing_account( + account_1->name()); set_account_exchange_data(account_1, exchange_account_data); - exchange_account_data.mutable_cme_account_data()->set_clearing_account(account_2->name()); - exchange_account_data.mutable_ice_account_data()->set_clearing_account(account_2->name()); - exchange_account_data.mutable_sim_account_data()->set_clearing_account(account_2->name()); + exchange_account_data.mutable_cme_account_data()->set_clearing_account( + account_2->name()); + exchange_account_data.mutable_ice_account_data()->set_clearing_account( + account_2->name()); + exchange_account_data.mutable_sim_account_data()->set_clearing_account( + account_2->name()); set_account_exchange_data(account_2, exchange_account_data); - - exchange_account_data.mutable_cme_account_data()->set_clearing_account(account_3->name()); - exchange_account_data.mutable_ice_account_data()->set_clearing_account(account_3->name()); - exchange_account_data.mutable_sim_account_data()->set_clearing_account(account_3->name()); + + exchange_account_data.mutable_cme_account_data()->set_clearing_account( + account_3->name()); + exchange_account_data.mutable_ice_account_data()->set_clearing_account( + account_3->name()); + exchange_account_data.mutable_sim_account_data()->set_clearing_account( + account_3->name()); set_account_exchange_data(account_3, exchange_account_data); - exchange_account_data.mutable_ice_account_data()->set_clearing_account(account_4->name()); + exchange_account_data.mutable_ice_account_data()->set_clearing_account( + account_4->name()); set_account_exchange_data(account_4, exchange_account_data); - // add cme and sim user data bts::api::admin::ExchangeUserData exchange_user_data; - exchange_user_data.mutable_cme_data()->set_operator_id("op_id_" + user_1->name()); + exchange_user_data.mutable_cme_data()->set_operator_id( + "op_id_" + user_1->name()); exchange_user_data.mutable_cme_data()->set_location("us,nc"); - - exchange_user_data.mutable_ice_data()->set_operator_id("op_id_" + user_1->name()); + + exchange_user_data.mutable_ice_data()->set_operator_id( + "op_id_" + user_1->name()); exchange_user_data.mutable_ice_data()->set_company_id(51251); exchange_user_data.mutable_ice_data()->set_authorized_trader("bluetrd-fx"); exchange_user_data.mutable_ice_data()->set_authorized_group("Group"); exchange_user_data.mutable_ice_data()->set_password("Starts123"); - exchange_user_data.mutable_ice_data()->set_mifid_direct_electronic_access(-1); + exchange_user_data.mutable_ice_data()->set_mifid_direct_electronic_access( + -1); exchange_user_data.mutable_ice_data()->set_mifid_trading_capacity(-1); exchange_user_data.mutable_ice_data()->set_mifid_liquidity_provision(-1); - exchange_user_data.mutable_ice_data()->set_mifid_commodity_deriv_indicator(-1); + exchange_user_data.mutable_ice_data()->set_mifid_commodity_deriv_indicator( + -1); exchange_user_data.mutable_ice_data()->set_mifid_investment_decision(-1); exchange_user_data.mutable_ice_data()->set_mifid_execution_decision(-1); exchange_user_data.mutable_ice_data()->set_mifid_client_id_code(-1); exchange_user_data.mutable_ice_data()->set_mifid_id(1); - - exchange_user_data.mutable_sim_data()->set_operator_id("op_id_" + user_1->name()); + + exchange_user_data.mutable_sim_data()->set_operator_id( + "op_id_" + user_1->name()); exchange_user_data.mutable_sim_data()->set_location("us,nc"); set_user_exchange_data(user_1, exchange_user_data); - exchange_user_data.mutable_cme_data()->set_operator_id("op_id_" + user_2->name()); + exchange_user_data.mutable_cme_data()->set_operator_id( + "op_id_" + user_2->name()); exchange_user_data.mutable_cme_data()->set_location("us,nc"); - - exchange_user_data.mutable_ice_data()->set_operator_id("op_id_" + user_2->name()); + + exchange_user_data.mutable_ice_data()->set_operator_id( + "op_id_" + user_2->name()); exchange_user_data.mutable_ice_data()->set_company_id(51251); exchange_user_data.mutable_ice_data()->set_authorized_trader("bluetrd-fx"); exchange_user_data.mutable_ice_data()->set_authorized_group("Group"); exchange_user_data.mutable_ice_data()->set_password("Starts123"); - exchange_user_data.mutable_ice_data()->set_mifid_direct_electronic_access(-1); + exchange_user_data.mutable_ice_data()->set_mifid_direct_electronic_access( + -1); exchange_user_data.mutable_ice_data()->set_mifid_trading_capacity(-1); exchange_user_data.mutable_ice_data()->set_mifid_liquidity_provision(-1); - exchange_user_data.mutable_ice_data()->set_mifid_commodity_deriv_indicator(-1); + exchange_user_data.mutable_ice_data()->set_mifid_commodity_deriv_indicator( + -1); exchange_user_data.mutable_ice_data()->set_mifid_investment_decision(-1); exchange_user_data.mutable_ice_data()->set_mifid_execution_decision(-1); exchange_user_data.mutable_ice_data()->set_mifid_client_id_code(-1); exchange_user_data.mutable_ice_data()->set_mifid_id(1); - - - exchange_user_data.mutable_sim_data()->set_operator_id("op_id_" + user_2->name()); + + exchange_user_data.mutable_sim_data()->set_operator_id( + "op_id_" + user_2->name()); exchange_user_data.mutable_sim_data()->set_location("us,nc"); set_user_exchange_data(user_2, exchange_user_data); - exchange_user_data.mutable_cme_data()->set_operator_id("op_id_" + user_3->name()); + exchange_user_data.mutable_cme_data()->set_operator_id( + "op_id_" + user_3->name()); exchange_user_data.mutable_cme_data()->set_location("us,nc"); - - exchange_user_data.mutable_ice_data()->set_operator_id("op_id_" + user_3->name()); + + exchange_user_data.mutable_ice_data()->set_operator_id( + "op_id_" + user_3->name()); exchange_user_data.mutable_ice_data()->set_company_id(51251); exchange_user_data.mutable_ice_data()->set_authorized_trader("bluetrd-fx"); exchange_user_data.mutable_ice_data()->set_authorized_group("Group"); exchange_user_data.mutable_ice_data()->set_password("Starts123"); - exchange_user_data.mutable_ice_data()->set_mifid_direct_electronic_access(-1); + exchange_user_data.mutable_ice_data()->set_mifid_direct_electronic_access( + -1); exchange_user_data.mutable_ice_data()->set_mifid_trading_capacity(-1); exchange_user_data.mutable_ice_data()->set_mifid_liquidity_provision(-1); - exchange_user_data.mutable_ice_data()->set_mifid_commodity_deriv_indicator(-1); + exchange_user_data.mutable_ice_data()->set_mifid_commodity_deriv_indicator( + -1); exchange_user_data.mutable_ice_data()->set_mifid_investment_decision(-1); exchange_user_data.mutable_ice_data()->set_mifid_execution_decision(-1); exchange_user_data.mutable_ice_data()->set_mifid_client_id_code(-1); exchange_user_data.mutable_ice_data()->set_mifid_id(1); - - - exchange_user_data.mutable_sim_data()->set_operator_id("op_id_" + user_3->name()); + + exchange_user_data.mutable_sim_data()->set_operator_id( + "op_id_" + user_3->name()); exchange_user_data.mutable_sim_data()->set_location("us,nc"); set_user_exchange_data(user_3, exchange_user_data); // associate all connections to all accounts - for(int i=0; imutable_connections()->add_exchange_connection_names(conn_name); + for (int j = 0; j < data.accounts_size(); j++) + data.mutable_accounts(j) + ->mutable_connections() + ->add_exchange_connection_names(conn_name); } // add prod limit for ACC A - add_product_position_limits(parent_account, api::Venue::VENUE_GLBX, api::SecurityType::SECURITYTYPE_FUTURE,50000); - add_product_position_limits(parent_account, api::Venue::VENUE_GLBX, api::SecurityType::SECURITYTYPE_SPREAD,50000); - add_product_position_limits(parent_account, api::Venue::VENUE_SIM, api::SecurityType::SECURITYTYPE_FUTURE,50000); - add_product_position_limits(parent_account, api::Venue::VENUE_SIM, api::SecurityType::SECURITYTYPE_SPREAD,50000); + add_product_position_limits( + parent_account, api::Venue::VENUE_GLBX, + api::SecurityType::SECURITYTYPE_FUTURE, 50000); + add_product_position_limits( + parent_account, api::Venue::VENUE_GLBX, + api::SecurityType::SECURITYTYPE_SPREAD, 50000); + add_product_position_limits( + parent_account, api::Venue::VENUE_SIM, + api::SecurityType::SECURITYTYPE_FUTURE, 50000); + add_product_position_limits( + parent_account, api::Venue::VENUE_SIM, + api::SecurityType::SECURITYTYPE_SPREAD, 50000); // security clip sizes for ACC A - add_security_clip_sizes_to_account(parent_account, api::Venue::VENUE_GLBX, api::SecurityType::SECURITYTYPE_FUTURE,50); - add_security_clip_sizes_to_account(parent_account, api::Venue::VENUE_GLBX, api::SecurityType::SECURITYTYPE_SPREAD,50); - add_security_clip_sizes_to_account(parent_account, api::Venue::VENUE_SIM, api::SecurityType::SECURITYTYPE_FUTURE,50); - add_security_clip_sizes_to_account(parent_account, api::Venue::VENUE_SIM, api::SecurityType::SECURITYTYPE_SPREAD,50); + add_security_clip_sizes_to_account( + parent_account, api::Venue::VENUE_GLBX, + api::SecurityType::SECURITYTYPE_FUTURE, 50); + add_security_clip_sizes_to_account( + parent_account, api::Venue::VENUE_GLBX, + api::SecurityType::SECURITYTYPE_SPREAD, 50); + add_security_clip_sizes_to_account( + parent_account, api::Venue::VENUE_SIM, + api::SecurityType::SECURITYTYPE_FUTURE, 50); + add_security_clip_sizes_to_account( + parent_account, api::Venue::VENUE_SIM, + api::SecurityType::SECURITYTYPE_SPREAD, 50); // add sec limit for ACC A1 // cme - add_security_position_limits(account_1, api::Venue::VENUE_GLBX, api::SecurityType::SECURITYTYPE_FUTURE); - add_security_position_limits(account_1, api::Venue::VENUE_GLBX, api::SecurityType::SECURITYTYPE_SPREAD); - add_security_position_limits(account_1, api::Venue::VENUE_SIM, api::SecurityType::SECURITYTYPE_FUTURE); - add_security_position_limits(account_1, api::Venue::VENUE_SIM, api::SecurityType::SECURITYTYPE_SPREAD); + add_security_position_limits( + account_1, api::Venue::VENUE_GLBX, + api::SecurityType::SECURITYTYPE_FUTURE); + add_security_position_limits( + account_1, api::Venue::VENUE_GLBX, + api::SecurityType::SECURITYTYPE_SPREAD); + add_security_position_limits( + account_1, api::Venue::VENUE_SIM, + api::SecurityType::SECURITYTYPE_FUTURE); + add_security_position_limits( + account_1, api::Venue::VENUE_SIM, + api::SecurityType::SECURITYTYPE_SPREAD); // add prod limit for ACC A1 - add_product_position_limits(account_1, api::Venue::VENUE_GLBX, api::SecurityType::SECURITYTYPE_FUTURE,100000); - add_product_position_limits(account_1, api::Venue::VENUE_GLBX, api::SecurityType::SECURITYTYPE_SPREAD,100000); - add_product_position_limits(account_1, api::Venue::VENUE_SIM, api::SecurityType::SECURITYTYPE_FUTURE,100000); - add_product_position_limits(account_1, api::Venue::VENUE_SIM, api::SecurityType::SECURITYTYPE_SPREAD,100000); + add_product_position_limits( + account_1, api::Venue::VENUE_GLBX, + api::SecurityType::SECURITYTYPE_FUTURE, 100000); + add_product_position_limits( + account_1, api::Venue::VENUE_GLBX, + api::SecurityType::SECURITYTYPE_SPREAD, 100000); + add_product_position_limits( + account_1, api::Venue::VENUE_SIM, api::SecurityType::SECURITYTYPE_FUTURE, + 100000); + add_product_position_limits( + account_1, api::Venue::VENUE_SIM, api::SecurityType::SECURITYTYPE_SPREAD, + 100000); // security clip sizes for ACC A1 - add_security_clip_sizes_to_account(account_1, api::Venue::VENUE_GLBX, api::SecurityType::SECURITYTYPE_FUTURE,100); - add_security_clip_sizes_to_account(account_1, api::Venue::VENUE_GLBX, api::SecurityType::SECURITYTYPE_SPREAD,100); - add_security_clip_sizes_to_account(account_1, api::Venue::VENUE_SIM, api::SecurityType::SECURITYTYPE_FUTURE,100); - add_security_clip_sizes_to_account(account_1, api::Venue::VENUE_SIM, api::SecurityType::SECURITYTYPE_SPREAD,100); + add_security_clip_sizes_to_account( + account_1, api::Venue::VENUE_GLBX, + api::SecurityType::SECURITYTYPE_FUTURE, 100); + add_security_clip_sizes_to_account( + account_1, api::Venue::VENUE_GLBX, + api::SecurityType::SECURITYTYPE_SPREAD, 100); + add_security_clip_sizes_to_account( + account_1, api::Venue::VENUE_SIM, api::SecurityType::SECURITYTYPE_FUTURE, + 100); + add_security_clip_sizes_to_account( + account_1, api::Venue::VENUE_SIM, api::SecurityType::SECURITYTYPE_SPREAD, + 100); - //ICE limits - add_product_position_limits(account_4, api::Venue::VENUE_ICE, api::SecurityType::SECURITYTYPE_FUTURE,50000); - add_product_position_limits(account_4, api::Venue::VENUE_ICE, api::SecurityType::SECURITYTYPE_SPREAD,50000); - add_security_clip_sizes_to_account(account_4, api::Venue::VENUE_ICE, api::SecurityType::SECURITYTYPE_FUTURE,50); - add_security_clip_sizes_to_account(account_4, api::Venue::VENUE_ICE, api::SecurityType::SECURITYTYPE_SPREAD,50); - + // ICE limits + add_product_position_limits( + account_4, api::Venue::VENUE_ICE, api::SecurityType::SECURITYTYPE_FUTURE, + 50000); + add_product_position_limits( + account_4, api::Venue::VENUE_ICE, api::SecurityType::SECURITYTYPE_SPREAD, + 50000); + add_security_clip_sizes_to_account( + account_4, api::Venue::VENUE_ICE, api::SecurityType::SECURITYTYPE_FUTURE, + 50); + add_security_clip_sizes_to_account( + account_4, api::Venue::VENUE_ICE, api::SecurityType::SECURITYTYPE_SPREAD, + 50); } -bool AdminServiceUtils::has_id (uint32_t id){return id>0;} -bool AdminServiceUtils::is_symbol_set (const std::string& symbol){ - return symbol !="*"; +bool AdminServiceUtils::has_id(uint32_t id) { return id > 0; } +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, - double mult){ - if(s.has_spread()) - for (const auto& leg : s.spread().legs()){ - auto effective_leg_mult = mult * - (leg.side() == api::Side::SIDE_BUY ? 1.0 : -1.0) * - std::abs(leg.quantity()); + const api::Security &s, std::map &out_map, + double mult) { + if (s.has_spread()) + for (const auto &leg : s.spread().legs()) { + auto effective_leg_mult = + mult * (leg.side() == api::Side::SIDE_BUY ? 1.0 : -1.0) * + std::abs(leg.quantity()); get_spread_prod_qty(leg.security(), out_map, effective_leg_mult); } else out_map[s.symbol()] = mult + out_map[s.symbol()]; } -bool AdminServiceUtils::residual_pos_spread(const api::Security& s){ - if(!s.has_spread()) +bool AdminServiceUtils::residual_pos_spread(const api::Security &s) { + if (!s.has_spread()) return false; - std::map prod_qty_map; - get_spread_prod_qty(s,prod_qty_map,1.0); - for(const auto& kv : prod_qty_map) - if(std::abs(kv.second) > 0.0000001) + std::map prod_qty_map; + get_spread_prod_qty(s, prod_qty_map, 1.0); + for (const auto &kv : prod_qty_map) + if (std::abs(kv.second) > 0.0000001) return true; return false; } -}} +} // namespace admin +} // namespace bts diff --git a/src/lib/api/service_helpers/AdminServiceUtils.h b/src/lib/api/service_helpers/AdminServiceUtils.h index 6e39faeb8..517b4aa7c 100644 --- a/src/lib/api/service_helpers/AdminServiceUtils.h +++ b/src/lib/api/service_helpers/AdminServiceUtils.h @@ -1,348 +1,317 @@ #pragma once -#include #include "lib/api/services/AdminService.server.pb.h" #include "lib/api/services/OrderService.server.pb.h" #include "lib/domain_model/Security.h" +#include -namespace bts{ -namespace admin{ +namespace bts { +namespace admin { using namespace bts::api::admin; using namespace bts::api::orderman; -class AdminServiceUtils{ -public: +class AdminServiceUtils { + public: //////////////////////////////////////////// // connection accessors //////////////////// //////////////////////////////////////////// // finds the max id out of all the existing connections // (todo: deleted connections) - static uint32_t find_max_connection_id (const AdminData& data); + static uint32_t find_max_connection_id(const AdminData &data); // finds a connection by name and returns a mutable pointer to it - static const ExchangeConnection* find_connection(const AdminData& data, - const std::string& connection_name); + static const ExchangeConnection * + find_connection(const AdminData &data, const std::string &connection_name); // finds the presence of an exchange in a connection - static bool has_exchange(const ExchangeConnection& conn, - bts::api::Venue exchange); + static bool + has_exchange(const ExchangeConnection &conn, bts::api::Venue exchange); // finds the default connections for an exchange // in a given account - static const ExchangeConnection* find_default_account_connection( - const AdminData& data, - const BTSAccount& account, - bts::api::Venue exchange); - static const ExchangeConnection* resolve_cme_connection( - const AdminData& data, - const BTSAccount& account, - const api::Security& sec); - static const ExchangeConnection* resolve_ice_connection( - const AdminData& data, - const BTSAccount& account, - const api::Security& sec); - static const ExchangeConnection* resolve_sim_connection( - const AdminData& data, - const BTSAccount& account, - const api::Security& sec); - static const ExchangeConnection* resolve_connection( - const AdminData& data, - const BTSAccount& account, - const bts::api::Security& sec); + static const ExchangeConnection *find_default_account_connection( + const AdminData &data, const BTSAccount &account, + bts::api::Venue exchange); + static const ExchangeConnection *resolve_cme_connection( + const AdminData &data, const BTSAccount &account, + const api::Security &sec); + static const ExchangeConnection *resolve_ice_connection( + const AdminData &data, const BTSAccount &account, + const api::Security &sec); + static const ExchangeConnection *resolve_sim_connection( + const AdminData &data, const BTSAccount &account, + const api::Security &sec); + static const ExchangeConnection *resolve_connection( + const AdminData &data, const BTSAccount &account, + const bts::api::Security &sec); //////////////////////////////////////////// // connection mutators ///////////////////// //////////////////////////////////////////// // adds a new connection (does not check for name uniqueness) - static ExchangeConnection* add_connection(AdminData& data, - const ExchangeConnection& new_connection); + static ExchangeConnection * + add_connection(AdminData &data, const ExchangeConnection &new_connection); // reads the connections from config and fills in the // admin data (with names only) - static void fill_connections_from_config(AdminData& admin_data); + static void fill_connections_from_config(AdminData &admin_data); //////////////////////////////////////////// // account accessors /////////////////////// //////////////////////////////////////////// // 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, - bool include_deleted=false); - static std::map get_clearing_account_map(const AdminData&); - + static BTSAccount *find_account( + 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, - bts::api::Venue); + static BTSAccount const *find_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, - bool include_deleted=false); + static const BTSAccount *find_account( + 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 - static BTSAccount* find_account (AdminData& data, - uint32_t id, - bool include_deleted=false); + static BTSAccount * + find_account(AdminData &data, uint32_t id, bool include_deleted = false); // like above but returns a const pointer - static const BTSAccount* find_account (const AdminData& data, - uint32_t id, - bool include_deleted=false); + static const BTSAccount *find_account( + const AdminData &data, uint32_t id, bool include_deleted = false); // this function is an indirection layer for account access // so deletions are dealt in a more deliberate manner - static std::vector accounts (const AdminData& data, - bool include_deleted); - static std::vector accounts_mutable (AdminData& data, - bool include_deleted); - // finds the max id amongts all the existing accounts - static uint32_t find_max_acct_id (const AdminData& data); + static std::vector + accounts(const AdminData &data, bool include_deleted); + static std::vector + accounts_mutable(AdminData &data, bool include_deleted); + // finds the max id amongts all the existing accounts + static uint32_t find_max_acct_id(const AdminData &data); // gets the account data for cme (and goes up the hierarchy // if needed) - static const CMEAccountData* get_account_cme_data(const BTSAccount& account, - const AdminData& data); - static const ICEAccountData* get_account_ice_data(const BTSAccount& account, - const AdminData& data); - static const SIMAccountData* get_account_sim_data(const BTSAccount& account, - const AdminData& data); - // returns true if an account has a connection - bool static account_has_connection(const BTSAccount& account, - const std::string& connection_name); + static const CMEAccountData * + get_account_cme_data(const BTSAccount &account, const AdminData &data); + static const ICEAccountData * + get_account_ice_data(const BTSAccount &account, const AdminData &data); + static const SIMAccountData * + get_account_sim_data(const BTSAccount &account, const AdminData &data); + // returns true if an account has a connection + bool static account_has_connection( + const BTSAccount &account, const std::string &connection_name); // 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, - AdminServiceOperationResult& out_result); + static std::string find_account_exchange_account( + 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); + 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, - AdminServiceOperationResult& result); + static void validate_account_update( + 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 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, - 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, 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); //////////////////////////////////////////// // 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); + 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); // writes over the account data completely - static void update_account(AdminData& data, - const BTSAccount& updated_account, - AdminServiceOperationResult& result); - static void delete_account (AdminData& admin_data, - const IDAPIArgument& id, - AdminServiceOperationResult& result); - static void set_account_exchange_data(BTSAccount* account, - const ExchangeAccountData& exchange_data); + static void update_account( + AdminData &data, const BTSAccount &updated_account, + AdminServiceOperationResult &result); + static void delete_account( + AdminData &admin_data, const IDAPIArgument &id, + AdminServiceOperationResult &result); + static void set_account_exchange_data( + BTSAccount *account, const ExchangeAccountData &exchange_data); // this is not a generally useful function but since // connection are in config, this cleans up the account's // connections and syncs it with the list in AdminData - static void sync_account_connections(const AdminData& data, - BTSAccount& account); + static void + sync_account_connections(const AdminData &data, BTSAccount &account); //////////////////////////////////////////// // group accessors ///////////////////////// //////////////////////////////////////////// // given an id, finds the mutable pointer to a group - static BTSUserGroup* find_group (AdminData& data, uint32_t id); + static BTSUserGroup *find_group(AdminData &data, uint32_t id); // given an id, finds the const pointer to a group - static const BTSUserGroup* const find_group (const AdminData& data, - uint32_t id); + static const BTSUserGroup *const + find_group(const AdminData &data, uint32_t id); // given a name, finds the mutable pointer to a group - static BTSUserGroup* find_group (AdminData& data, - const std::string& group_name); + static BTSUserGroup * + find_group(AdminData &data, const std::string &group_name); // finds the max id out of all the groups - static uint32_t find_max_group_id (const AdminData& data); - // travels up the group tree until it finds a populated cme data - static const CMEUserData* get_group_cme_data(const BTSUserGroup& group, - const AdminData& data); - static const ICEUserData* get_group_ice_data(const BTSUserGroup& group, - const AdminData& data); - static const SIMUserData* get_group_sim_data(const BTSUserGroup& group, - const AdminData& data); - static const UserAccountPermissions* const get_group_user_permissions ( - const bts::api::admin::AdminData& admin_data, - uint32_t group_id); + static uint32_t find_max_group_id(const AdminData &data); + // travels up the group tree until it finds a populated cme data + static const CMEUserData * + get_group_cme_data(const BTSUserGroup &group, const AdminData &data); + static const ICEUserData * + get_group_ice_data(const BTSUserGroup &group, const AdminData &data); + static const SIMUserData * + get_group_sim_data(const BTSUserGroup &group, const AdminData &data); + static const UserAccountPermissions *const get_group_user_permissions( + const bts::api::admin::AdminData &admin_data, uint32_t group_id); //////////////////////////////////////////// // group mutators/ ///////////////////////// //////////////////////////////////////////// - static BTSUserGroup* create_group(AdminData& data, - uint32_t parent_group_id, - const std::string& group_name, - AdminServiceOperationResult& result); + static BTSUserGroup *create_group( + 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, - bool include_deleted=false); - static const BTSUser* find_user (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); - static const BTSUser* const find_user (const AdminData& data, - uint32_t id, - bool include_deleted=false); - static std::vector users (const AdminData& data, - bool include_deleted); - static std::vector users_mutable (AdminData& data, - bool include_deleted); - static uint32_t find_max_user_id (const AdminData& data); - static const CMEUserData* get_user_cme_data(const BTSUser& user, - const AdminData& data); - static const ICEUserData* get_user_ice_data(const BTSUser& user, - const AdminData& data); - static const SIMUserData* get_user_sim_data(const BTSUser& user, - const AdminData& data); - // finds the "exchange user" (ex: "operator_id" at CME or "authorized_trader" + static BTSUser *find_user( + AdminData &data, const std::string &user_name, + bool include_deleted = false); + static const BTSUser *find_user( + 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); + static const BTSUser *const + find_user(const AdminData &data, uint32_t id, bool include_deleted = false); + static std::vector + users(const AdminData &data, bool include_deleted); + static std::vector + users_mutable(AdminData &data, bool include_deleted); + static uint32_t find_max_user_id(const AdminData &data); + static const CMEUserData * + get_user_cme_data(const BTSUser &user, const AdminData &data); + static const ICEUserData * + get_user_ice_data(const BTSUser &user, const AdminData &data); + static const SIMUserData * + get_user_sim_data(const BTSUser &user, const AdminData &data); + // 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, - AdminServiceOperationResult& out_result); + static std::string find_user_exchange_id( + 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, - 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, - api::Venue exchange); + // 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, + 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, + 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 // correct permissions. - static const UserAccountPermissions* get_user_permissions ( - const AdminData& admin_data, - uint32_t user_id); + static const UserAccountPermissions * + get_user_permissions(const AdminData &admin_data, uint32_t user_id); // 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, - std::vector& associated_accounts); + static void find_user_trading_accounts( + 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, - std::vector& associated_users); - // validates that changes in user data satisfy all the + static void find_users_for_trading_account( + 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, - AdminServiceOperationResult& result); + static void validate_user_update( + const AdminData &admin_data, const BTSUser &updated_user, + AdminServiceOperationResult &result); // vaidates the exchange part of user data updates - static void validate_user_exchange_data ( - const BTSUser& updated_user, - AdminServiceOperationResult& out_result); - static void get_md_entitlement_report(const AdminData& admin_data, - std::vector& entitlements); + static void validate_user_exchange_data( + const BTSUser &updated_user, AdminServiceOperationResult &out_result); + static void get_md_entitlement_report( + const AdminData &admin_data, + std::vector &entitlements); // Gets a reporting unit out of CMEMicData static MDEntitlementReportUnit get_cme_md_entitlement_unit( - const BTSUser& user, - const CMEMicData& cme_mic_data); + const BTSUser &user, const CMEMicData &cme_mic_data); static MDEntitlementReportUnit get_ice_md_entitlement_unit( - const BTSUser& user, - const ICEMicData& ice_mic_data); + const BTSUser &user, const ICEMicData &ice_mic_data); static void get_user_symbol_permissions( - const AdminData& data, - const BTSUser& user, - std::vector& res); + 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, - const LicenseData& license_data, - const LicenseEntitlements& license_entitlements, - AdminServiceCreateEntityResult& result); - static BTSUser* update_user(AdminData& admin_data, - const BTSUser& updated_user, - AdminServiceOperationResult& result); - static void delete_user (AdminData& admin_data, - const IDAPIArgument& id, - AdminServiceOperationResult& result); + 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, + const LicenseData &license_data, + const LicenseEntitlements &license_entitlements, + AdminServiceCreateEntityResult &result); + static BTSUser *update_user( + AdminData &admin_data, const BTSUser &updated_user, + AdminServiceOperationResult &result); + static void delete_user( + AdminData &admin_data, const IDAPIArgument &id, + AdminServiceOperationResult &result); static void set_user_exchange_data( - BTSUser* user, - const ExchangeUserData& exchange_user_data); - static void clear_user_accounts (BTSUser* user); - static void set_user_accounts (BTSUser* user, - const UserAccountPermissions& user_account_permissions); + BTSUser *user, const ExchangeUserData &exchange_user_data); + static void clear_user_accounts(BTSUser *user); + static void set_user_accounts( + BTSUser *user, const UserAccountPermissions &user_account_permissions); //////////////////////////////////////////// - //risk limits ////////////////////////////// + // risk limits ////////////////////////////// //////////////////////////////////////////// // sorting function used by sort_limits to // sort SecurityScope's - static bool _sort_security_scopes (const SecurityScope& a, - const SecurityScope& b); + static bool + _sort_security_scopes(const SecurityScope &a, const SecurityScope &b); // sorting function used by sort_limits to - // sort ProductScope's - static bool _sort_product_scopes (const ProductScope& a, - const ProductScope&); + // sort ProductScope's + static bool + _sort_product_scopes(const ProductScope &a, const ProductScope &); // this sorts the rules such that the most // specific ones are at the top. this makes it // easier to match rules with securities/products - static void sort_limits (BTSAccount& account); + static void sort_limits(BTSAccount &account); // creates a copy of AdminData with sorted rules - static AdminData sort_limits (const AdminData& admin_data); + static AdminData sort_limits(const AdminData &admin_data); // find the clip size for a security, account static const uint32_t find_account_security_clip_size( - const BTSAccount& account, - const api::Security& security); + const BTSAccount &account, const api::Security &security); // find the position limit for an account, security - static const AccountSecurityPositionLimitUnit* - find_account_security_position_limit(const BTSAccount& account, - const api::Security& security); + static const AccountSecurityPositionLimitUnit * + find_account_security_position_limit( + const BTSAccount &account, const api::Security &security); // find the position limit for an account, product - static const AccountProductPositionLimitUnit* - find_account_product_position_limit(const BTSAccount& account, - const api::Product& product); - static bool match_security_scope (const SecurityScope& scope, - const api::Security& security); - static bool match_product_scope (const ProductScope& scope, - const api::Product& product); - static bool match_product(const api::Security& security, - const api::Product& product); - static bool _match_limit_rule_symbol (const std::string& symbol, - const std::string& limit_symbol); - static api::SecurityType security_type(const api::Security& security); + static const AccountProductPositionLimitUnit * + find_account_product_position_limit( + const BTSAccount &account, const api::Product &product); + static bool match_security_scope( + const SecurityScope &scope, const api::Security &security); + static bool + match_product_scope(const ProductScope &scope, const api::Product &product); + static bool + match_product(const api::Security &security, const api::Product &product); + static bool _match_limit_rule_symbol( + const std::string &symbol, const std::string &limit_symbol); + static api::SecurityType security_type(const api::Security &security); //////////////////////////////////////////// // misc//////// //////////////////////////// //////////////////////////////////////////// - static bool has_id (uint32_t id); - 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, - double mult=1.0); + static bool has_id(uint32_t id); + 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, + double mult = 1.0); // returns true if this spread effects the position of any outrights - static bool residual_pos_spread(const api::Security& s); + static bool residual_pos_spread(const api::Security &s); }; -}} +} // namespace admin +} // namespace bts diff --git a/src/lib/api/service_helpers/AlgoServiceUtils.cpp b/src/lib/api/service_helpers/AlgoServiceUtils.cpp index 354843a70..7b2b7c577 100644 --- a/src/lib/api/service_helpers/AlgoServiceUtils.cpp +++ b/src/lib/api/service_helpers/AlgoServiceUtils.cpp @@ -3,17 +3,17 @@ //#include "lib/api/services/OrderService.server.pb.h" //#include // -//namespace bts { -//namespace orderman { +// namespace bts { +// namespace orderman { // -//using namespace bts::api::orderman; -//using namespace std; +// using namespace bts::api::orderman; +// using namespace std; // -//bool match_algo_tree(const CustomOrderDefinition &, +// bool match_algo_tree(const CustomOrderDefinition &, // const CustomOrderDefinition &) { // return true; //} -//string template_key(const AlgoTemplate &t) { +// string template_key(const AlgoTemplate &t) { // string rv; // if (t.has_composite_algo_params()) // rv = t.name() + "_" + t.composite_algo_params().name(); diff --git a/src/lib/api/service_helpers/AlgoServiceUtils.h b/src/lib/api/service_helpers/AlgoServiceUtils.h index 436bde66e..0b05b1a8e 100644 --- a/src/lib/api/service_helpers/AlgoServiceUtils.h +++ b/src/lib/api/service_helpers/AlgoServiceUtils.h @@ -3,13 +3,13 @@ //#include //#include // -//namespace bts{ -//namespace api {namespace orderman{class CustomOrderDefinition;}} -//namespace api {namespace orderman {class AlgoTemplate;}} -//namespace api {namespace orderman{class CompositeAlgoRecord;}} -//namespace orderman{ +// namespace bts{ +// namespace api {namespace orderman{class CustomOrderDefinition;}} +// namespace api {namespace orderman {class AlgoTemplate;}} +// namespace api {namespace orderman{class CompositeAlgoRecord;}} +// namespace orderman{ // -//bool match_algo_tree (const bts::api::orderman::CustomOrderDefinition& l, +// bool match_algo_tree (const bts::api::orderman::CustomOrderDefinition& l, // const bts::api::orderman::CustomOrderDefinition& r); -//std::string template_key(const bts::api::orderman::AlgoTemplate&); +// std::string template_key(const bts::api::orderman::AlgoTemplate&); //}} diff --git a/src/lib/api/service_helpers/PositionUtilities.cpp b/src/lib/api/service_helpers/PositionUtilities.cpp index 863f426f5..2ddea0908 100644 --- a/src/lib/api/service_helpers/PositionUtilities.cpp +++ b/src/lib/api/service_helpers/PositionUtilities.cpp @@ -1,130 +1,99 @@ #include "PositionUtilities.h" -#include "lib/api/services/PositionService.server.pb.h" -#include "lib/api/services/OrderService.pb.h" #include "lib/api/services/OrderService.client.pb.h" +#include "lib/api/services/OrderService.pb.h" +#include "lib/api/services/PositionService.server.pb.h" #include "lib/logging/logging.h" namespace bts { -namespace position{ +namespace position { 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){ - if(fill_q<0){ - LOG(OrderMan,Error,"avg_price_qty " - "fill_id:{} fill_q:{} is_add:{}", - fill_id, fill_q, is_add); - fill_q=0; +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) { + if (fill_q < 0) { + LOG(OrderMan, Error, + "avg_price_qty " + "fill_id:{} fill_q:{} is_add:{}", + fill_id, fill_q, is_add); + fill_q = 0; } - if(is_add){ - tot_qty=base_q+fill_q; - avg_price = (base_p*base_q+fill_p*fill_q)/tot_qty; - } - else{ - if(fill_q>=base_q){ - tot_qty=0; - avg_price=0; - if(fill_q>base_q) - LOG(OrderMan,Error,"avg_price_qty " - "fill_id:{} base_qty:{} fill_qty:{}", - fill_id, base_q, fill_q); - } - else{ - tot_qty=base_q-fill_q; - avg_price = (base_p*base_q-fill_p*fill_q)/tot_qty; + if (is_add) { + tot_qty = base_q + fill_q; + avg_price = (base_p * base_q + fill_p * fill_q) / tot_qty; + } else { + if (fill_q >= base_q) { + tot_qty = 0; + avg_price = 0; + if (fill_q > base_q) + LOG(OrderMan, Error, + "avg_price_qty " + "fill_id:{} base_qty:{} fill_qty:{}", + fill_id, base_q, fill_q); + } else { + tot_qty = base_q - fill_q; + avg_price = (base_p * base_q - fill_p * fill_q) / tot_qty; } } } -void PositionUtilities::apply_fill (PositionEntry& pos, - api::Side side, - double price, - double qty, - const std::string& fill_id, - bool is_add){ +void PositionUtilities::apply_fill( + 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(pos.long_avg_price(), - pos.long_pos(), - price, - qty, - is_add, - fill_id, - tot_avg_price, - tot_qty); + if (side == api::Side::SIDE_BUY) { + avg_price_qty( + pos.long_avg_price(), pos.long_pos(), price, qty, is_add, fill_id, + tot_avg_price, tot_qty); pos.set_long_avg_price(tot_avg_price); pos.set_long_pos(tot_qty); - } - else{ - avg_price_qty(pos.short_avg_price(), - pos.short_pos(), - price, - qty, - is_add, - fill_id, - tot_avg_price, - tot_qty); + } else { + avg_price_qty( + pos.short_avg_price(), pos.short_pos(), price, qty, is_add, fill_id, + tot_avg_price, tot_qty); pos.set_short_avg_price(tot_avg_price); pos.set_short_pos(tot_qty); } } -void PositionUtilities::apply_fill (PositionEntry& pos, - const Fill& f, - bool is_add){ +void PositionUtilities::apply_fill( + PositionEntry &pos, const Fill &f, bool is_add) { // strip legs are not applied to positions - if(f.fill_kind() == Fill::FILL_KIND_STRIP_LEG || - f.fill_kind() == Fill::FILL_KIND_SOD_STRIP_LEG) + if (f.fill_kind() == Fill::FILL_KIND_STRIP_LEG || + f.fill_kind() == Fill::FILL_KIND_SOD_STRIP_LEG) return; - PositionUtilities::apply_fill(pos, - f.side(), - f.last_price(), - f.last_shares(), - f.fill_key(), - is_add); + PositionUtilities::apply_fill( + pos, f.side(), f.last_price(), f.last_shares(), f.fill_key(), is_add); } -void PositionUtilities::apply_manual_fill ( - PositionEntry& pos, - const ManualFill& mf, - bool is_add){ - PositionUtilities::apply_fill(pos, - mf.side(), - mf.price(), - mf.quantity(), - "", - is_add); +void PositionUtilities::apply_manual_fill( + PositionEntry &pos, const ManualFill &mf, bool is_add) { + PositionUtilities::apply_fill( + pos, mf.side(), mf.price(), mf.quantity(), "", is_add); } -void PositionUtilities::total_position(const PositionUnit& p, - uint32_t& total_long, - uint32_t& total_short){ - total_long = p.sod().long_pos() + p.day().long_pos() + +void PositionUtilities::total_position( + const PositionUnit &p, uint32_t &total_long, uint32_t &total_short) { + total_long = p.sod().long_pos() + p.day().long_pos() + p.admin_day().long_pos() + p.admin_sod().long_pos(); - total_short = p.sod().short_pos() + p.day().short_pos() + - p.admin_day().short_pos() + p.admin_sod().short_pos(); + total_short = p.sod().short_pos() + p.day().short_pos() + + p.admin_day().short_pos() + p.admin_sod().short_pos(); } -PositionEntry PositionUtilities::add_positions ( - const std::vector& v){ +PositionEntry +PositionUtilities::add_positions(const std::vector &v) { double long_pos = 0, long_price = 0, short_pos = 0, short_price = 0; - for (auto ptr : v){ - const auto& p = *ptr; + for (auto ptr : v) { + const auto &p = *ptr; long_pos += p.long_pos(); - long_price += p.long_pos()*p.long_avg_price(); + long_price += p.long_pos() * p.long_avg_price(); short_pos += p.short_pos(); - short_price += p.short_pos()*p.short_avg_price(); + short_price += p.short_pos() * p.short_avg_price(); } - long_price = long_pos > 0 ? long_price/long_pos : 0.0; - short_price = short_pos > 0 ? short_price/short_pos : 0.0; + long_price = long_pos > 0 ? long_price / long_pos : 0.0; + short_price = short_pos > 0 ? short_price / short_pos : 0.0; bts::api::position::PositionEntry rv; rv.set_long_pos(long_pos); rv.set_long_avg_price(long_price); @@ -135,8 +104,8 @@ PositionEntry PositionUtilities::add_positions ( // copies from the new PositionEntry fields // to the doubles (this is a temporary function) -void PositionUtilities::backwards_compat(PositionUnit& p){ - std::vector v; +void PositionUtilities::backwards_compat(PositionUnit &p) { + std::vector v; // day v.push_back(&p.day()); v.push_back(&p.admin_day()); @@ -157,13 +126,11 @@ void PositionUtilities::backwards_compat(PositionUnit& p){ p.set_sod_short_avg_price(sod.short_avg_price()); } -double PositionUtilities::compute_pnl_entry (const PositionEntry& p, - double cpp, - double md){ - return std::abs(p.long_pos()) * cpp * - (md - p.long_avg_price()) + - std::abs(p.short_pos()) * cpp * - (p.short_avg_price() - md); +double PositionUtilities::compute_pnl_entry( + const PositionEntry &p, double cpp, double md) { + return std::abs(p.long_pos()) * cpp * (md - p.long_avg_price()) + + std::abs(p.short_pos()) * cpp * (p.short_avg_price() - md); } -}} \ No newline at end of file +} // namespace position +} // namespace bts \ No newline at end of file diff --git a/src/lib/api/service_helpers/PositionUtilities.h b/src/lib/api/service_helpers/PositionUtilities.h index 1ceab634e..04de7406a 100644 --- a/src/lib/api/service_helpers/PositionUtilities.h +++ b/src/lib/api/service_helpers/PositionUtilities.h @@ -1,54 +1,46 @@ #pragma once -#include "lib/api/services/PositionService.server.pb.h" -#include "lib/api/services/OrderService.pb.h" #include "lib/api/services/OrderService.client.pb.h" +#include "lib/api/services/OrderService.pb.h" +#include "lib/api/services/PositionService.server.pb.h" #include "lib/logging/logging.h" namespace bts { -namespace position{ +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); +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, - const bts::api::orderman::Fill& fill, - bool is_add); + static void apply_fill( + bts::api::position::PositionEntry &pos, api::Side side, double price, + double qty, const std::string &fill_id, bool is_add); - static void apply_manual_fill (bts::api::position::PositionEntry& pos, - const bts::api::position::ManualFill& mf, - 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); // subsumes p2 into p1 - static void total_position(const bts::api::position::PositionUnit& p, - uint32_t& total_long, - uint32_t& total_short); + static void total_position( + const bts::api::position::PositionUnit &p, uint32_t &total_long, + uint32_t &total_short); + + static bts::api::position::PositionEntry add_positions( + const std::vector &v); - static bts::api::position::PositionEntry add_positions ( - const std::vector& v); - // copies from the new PositionEntry fields // to the doubles (this is a temporary function) - static void backwards_compat(bts::api::position::PositionUnit& p); + static void backwards_compat(bts::api::position::PositionUnit &p); - static double compute_pnl_entry (const api::position::PositionEntry& p, - double cpp, - double md); + static double compute_pnl_entry( + const api::position::PositionEntry &p, double cpp, double md); }; -}} \ No newline at end of file +} // namespace position +} // namespace bts \ No newline at end of file diff --git a/src/lib/api/test/ApiTests.cpp b/src/lib/api/test/ApiTests.cpp index 8779490ab..723edd1ff 100644 --- a/src/lib/api/test/ApiTests.cpp +++ b/src/lib/api/test/ApiTests.cpp @@ -1,12 +1,12 @@ -#include "../public/ServiceContext.h" #include "../public/ApiUtils.h" -#include "lib/utils/bts_export.h" +#include "../public/ServiceContext.h" #include "HelloServiceServer.h" +#include "lib/utils/bts_export.h" #include "lib/api/services/ApiUnitTestService.server.pb.h" -#include #include +#include using namespace std; @@ -14,42 +14,46 @@ namespace bts { namespace api { namespace test { - struct ApiTestServiceServer: ApiTestServiceBase { - ServiceContext& _ctx; - unique_ptr _hello; - unique_ptr _shout; +struct ApiTestServiceServer : ApiTestServiceBase { + ServiceContext &_ctx; + unique_ptr _hello; + unique_ptr _shout; - ApiTestServiceServer(ServiceContext& ctx) : - ApiTestServiceBase(ctx, "cpp"), - _ctx(ctx), - _hello(), - _shout() - {} - // Inherited via ApiTestServiceBase - virtual void test_empty_reply(const EmptyRequest&, const std::function& reply) override { - UnitTestResult result; - reply(result); - } + ApiTestServiceServer(ServiceContext &ctx) + : ApiTestServiceBase(ctx, "cpp"), _ctx(ctx), _hello(), _shout() {} + // Inherited via ApiTestServiceBase + virtual void test_empty_reply( + const EmptyRequest &, + const std::function &reply) override { + UnitTestResult result; + reply(result); + } - virtual void run_hello_service(const EmptyRequest&, const std::function& reply) override { - _hello.reset(new HelloServiceServer(_ctx)); - reply(UnitTestResult()); - } - virtual void stop_hello_service(const EmptyRequest&, const std::function& reply) override { - _hello.reset(); - reply(UnitTestResult()); - } - virtual void run_shout_service(const EmptyRequest&, const std::function& reply) override { - _shout.reset(new ShoutServiceServer(_ctx)); - reply(UnitTestResult()); - } - virtual void stop_shout_service(const EmptyRequest&, const std::function& reply) override { - _shout.reset(); - reply(UnitTestResult()); - } - - - }; + virtual void run_hello_service( + const EmptyRequest &, + const std::function &reply) override { + _hello.reset(new HelloServiceServer(_ctx)); + reply(UnitTestResult()); + } + virtual void stop_hello_service( + const EmptyRequest &, + const std::function &reply) override { + _hello.reset(); + reply(UnitTestResult()); + } + virtual void run_shout_service( + const EmptyRequest &, + const std::function &reply) override { + _shout.reset(new ShoutServiceServer(_ctx)); + reply(UnitTestResult()); + } + virtual void stop_shout_service( + const EmptyRequest &, + const std::function &reply) override { + _shout.reset(); + reply(UnitTestResult()); + } +}; struct ApiTestBundle { ApiTestBundle() : ctx(), server() {} @@ -57,15 +61,19 @@ struct ApiTestBundle { unique_ptr server; }; -extern "C" BTS_EXPORT ApiTestBundle* apitest_start_apitest_service(bts::qbus::Quickbus* bus) { - ApiTestBundle* pbundle = new ApiTestBundle(); +extern "C" BTS_EXPORT ApiTestBundle * +apitest_start_apitest_service(bts::qbus::Quickbus *bus) { + ApiTestBundle *pbundle = new ApiTestBundle(); pbundle->ctx.reset(new ServiceContext(bus)); pbundle->server.reset(new ApiTestServiceServer(*pbundle->ctx)); return pbundle; } -extern "C" BTS_EXPORT void apitest_stop_apitest_service(ApiTestBundle* server) { - if (server != nullptr) delete server; +extern "C" BTS_EXPORT void apitest_stop_apitest_service(ApiTestBundle *server) { + if (server != nullptr) + delete server; } -}}}//namespace +} // namespace test +} // namespace api +} // namespace bts diff --git a/src/lib/api/test/HelloServiceServer.cpp b/src/lib/api/test/HelloServiceServer.cpp index 539fdd1cb..12efe3a01 100644 --- a/src/lib/api/test/HelloServiceServer.cpp +++ b/src/lib/api/test/HelloServiceServer.cpp @@ -6,14 +6,12 @@ namespace bts { namespace api { namespace test { -HelloServiceServer::HelloServiceServer(bts::api::ServiceContext & context) : - HelloServiceBase(context), - _id(0), - _shouter(context.locate()), - _gpub(make_greetings_publisher()) -{ } +HelloServiceServer::HelloServiceServer(bts::api::ServiceContext &context) + : HelloServiceBase(context), _id(0), + _shouter(context.locate()), + _gpub(make_greetings_publisher()) {} -void HelloServiceServer::publish(const std::string& msg, int* to_remove) { +void HelloServiceServer::publish(const std::string &msg, int *to_remove) { std::vector added; HelloLog row; char id[128]; @@ -29,14 +27,18 @@ void HelloServiceServer::publish(const std::string& msg, int* to_remove) { _gpub(&added, nullptr, &removed); } -void HelloServiceServer::say_hello(const HelloRequest & request, const std::function& reply) { +void HelloServiceServer::say_hello( + const HelloRequest &request, + const std::function &reply) { HelloResponse response; response.set_message("hello " + request.name()); publish(response.message()); reply(response); } -void HelloServiceServer::yell_hello(const HelloRequest & request, const std::function& reply) { +void HelloServiceServer::yell_hello( + const HelloRequest &request, + const std::function &reply) { HelloResponse response; ShoutRequest sr; @@ -50,17 +52,18 @@ void HelloServiceServer::yell_hello(const HelloRequest & request, const std::fun reply(hr); } }); - } -ShoutServiceServer::ShoutServiceServer(bts::api::ServiceContext & context) : - ShoutServiceBase(context) -{ } -void test::ShoutServiceServer::upper(const ShoutRequest & request, const std::function& on_result) { +ShoutServiceServer::ShoutServiceServer(bts::api::ServiceContext &context) + : ShoutServiceBase(context) {} +void test::ShoutServiceServer::upper( + const ShoutRequest &request, + const std::function &on_result) { ShoutResponse response; - response.set_msg( - boost::to_upper_copy(request.msg())); + response.set_msg(boost::to_upper_copy(request.msg())); on_result(response); } -}}}//namespace +} // namespace test +} // namespace api +} // namespace bts diff --git a/src/lib/api/test/HelloServiceServer.h b/src/lib/api/test/HelloServiceServer.h index 2aae38a07..d9f4f9c6e 100644 --- a/src/lib/api/test/HelloServiceServer.h +++ b/src/lib/api/test/HelloServiceServer.h @@ -1,39 +1,44 @@ #pragma once -#include "lib/utils/bts_no_copy.h" #include "lib/utils/bts_export.h" +#include "lib/utils/bts_no_copy.h" -#include "lib/api/services/HelloService.server.pb.h" #include "lib/api/services/HelloService.client.pb.h" +#include "lib/api/services/HelloService.server.pb.h" namespace bts { namespace api { namespace test { -struct BTS_EXPORT HelloServiceServer : public HelloServiceBase -{ -public: - HelloServiceServer(bts::api::ServiceContext& context); +struct BTS_EXPORT HelloServiceServer : public HelloServiceBase { + public: + HelloServiceServer(bts::api::ServiceContext &context); -private: + private: BTS_NO_COPY(HelloServiceServer); int _id; ShoutService _shouter; GreetingsPublisher _gpub; - void publish(const std::string& msg, int * to_remove=nullptr); + void publish(const std::string &msg, int *to_remove = nullptr); // Inherited via HelloServiceBase - virtual void say_hello(const HelloRequest & request, const std::function& on_result) override; - virtual void yell_hello(const HelloRequest & request, const std::function& on_result) override; + virtual void say_hello( + const HelloRequest &request, + const std::function &on_result) override; + virtual void yell_hello( + const HelloRequest &request, + const std::function &on_result) override; }; -struct BTS_EXPORT ShoutServiceServer : public ShoutServiceBase -{ - ShoutServiceServer(bts::api::ServiceContext& context); +struct BTS_EXPORT ShoutServiceServer : public ShoutServiceBase { + ShoutServiceServer(bts::api::ServiceContext &context); // Inherited via ShoutServiceBase - virtual void upper(const ShoutRequest & request, const std::function& on_result) override; + virtual void upper( + const ShoutRequest &request, + const std::function &on_result) override; }; -}}}//namespace - +} // namespace test +} // namespace api +} // namespace bts diff --git a/src/lib/config/ConfigCheck.cpp b/src/lib/config/ConfigCheck.cpp index a15be7d1e..ed8210a1f 100644 --- a/src/lib/config/ConfigCheck.cpp +++ b/src/lib/config/ConfigCheck.cpp @@ -1,34 +1,35 @@ -#include "config.h" #include "ConfigCheck.h" -#include "lib/utils/bts_export.h" +#include "config.h" #include "lib/utils/TimeStamp.h" +#include "lib/utils/bts_export.h" -#include +#include #include #include +#include #include #include -#include namespace proto = google::protobuf; namespace bts { namespace config { namespace interop { - std::string get_macro_string(const char* name); -} } } +std::string get_macro_string(const char *name); +} +} // namespace config +} // namespace bts using namespace bts; -void fill_in_defaults(google::protobuf::Message* msg) { - const proto::Descriptor* d = msg->GetDescriptor(); - const proto::Reflection* r = msg->GetReflection(); +void fill_in_defaults(google::protobuf::Message *msg) { + const proto::Descriptor *d = msg->GetDescriptor(); + const proto::Reflection *r = msg->GetReflection(); for (int x = 0; x < d->field_count(); ++x) { - auto* fd = d->field(x); + auto *fd = d->field(x); auto type = fd->cpp_type(); if (!fd->is_repeated()) { if (type == proto::FieldDescriptor::CPPTYPE_MESSAGE) { fill_in_defaults(r->MutableMessage(msg, fd)); - } - else if (fd->has_default_value() && !r->HasField(*msg, fd)) { + } else if (fd->has_default_value() && !r->HasField(*msg, fd)) { switch (type) { case proto::FieldDescriptor::CPPTYPE_INT32: r->SetInt32(msg, fd, fd->default_value_int32()); @@ -65,8 +66,8 @@ void fill_in_defaults(google::protobuf::Message* msg) { } } -extern "C" BTS_EXPORT void configcheck(int argc, const char** argv) { - std::vector args(argv, argv+argc); +extern "C" BTS_EXPORT void configcheck(int argc, const char **argv) { + std::vector args(argv, argv + argc); char buffer[4096] = {0}; utils::TimeStamp start = utils::TimeStamp::now(); bool success = config::initialize_nothrow(buffer, sizeof(buffer)); @@ -81,27 +82,23 @@ extern "C" BTS_EXPORT void configcheck(int argc, const char** argv) { } std::cout << "Load time> " << std::floor(time * 1000) << " ms" << std::endl; - for (size_t x = 0; x < args.size(); x++) - { + for (size_t x = 0; x < args.size(); x++) { std::string key = args[x]; if (key[0] == '$') { // macro std::string result = config::interop::get_macro_string(key.c_str()); std::cout << key << ": " << result; - } - else { - const google::protobuf::Message* message = config::interop::get_named(key.c_str()); - if (message) - { - google::protobuf::Message* mut = message->New(); + } else { + const google::protobuf::Message *message = + config::interop::get_named(key.c_str()); + if (message) { + google::protobuf::Message *mut = message->New(); mut->CopyFrom(*message); if (args.size() > 1) std::cout << key << ":" << std::endl; fill_in_defaults(mut); mut->PrintDebugString(); - } - else - { + } else { std::cout << "Cannot find a config key by the name: " << key; } } diff --git a/src/lib/config/ConfigCheck.h b/src/lib/config/ConfigCheck.h index b79431a0b..4356a314d 100644 --- a/src/lib/config/ConfigCheck.h +++ b/src/lib/config/ConfigCheck.h @@ -1,3 +1,3 @@ #pragma once #include "lib/utils/bts_export.h" -extern "C" BTS_EXPORT void configcheck(int argc, const char** argv); \ No newline at end of file +extern "C" BTS_EXPORT void configcheck(int argc, const char **argv); \ No newline at end of file diff --git a/src/lib/config/ConfigDownloader.cpp b/src/lib/config/ConfigDownloader.cpp old mode 100755 new mode 100644 index da23232eb..eda20ac9a --- a/src/lib/config/ConfigDownloader.cpp +++ b/src/lib/config/ConfigDownloader.cpp @@ -2,9 +2,9 @@ #include "ConfigDownloader.h" -#include #include #include +#include #include "lib/utils/bts_assert.h" @@ -14,40 +14,34 @@ namespace bts { namespace config { namespace internal { -ConfigDownloader::ConfigDownloader() : - _curl(NULL) -{ +ConfigDownloader::ConfigDownloader() : _curl(NULL) { curl_global_init(CURL_GLOBAL_DEFAULT); _curl = curl_easy_init(); bts_assert(_curl); } -ConfigDownloader::~ConfigDownloader() -{ - curl_easy_cleanup(_curl); -} +ConfigDownloader::~ConfigDownloader() { curl_easy_cleanup(_curl); } -size_t curl_write(char* buffer, size_t size, size_t count, void* stream) { - stringstream* out = static_cast(stream); +size_t curl_write(char *buffer, size_t size, size_t count, void *stream) { + stringstream *out = static_cast(stream); bts_assert(out); size_t bytes = size * count; out->write(buffer, bytes); return count; } -bool is_http(const string& url) { - return url.substr(0,7) == "http://"; -} +bool is_http(const string &url) { return url.substr(0, 7) == "http://"; } -int no_linger(void*, curl_socket_t socket, curlsocktype) { +int no_linger(void *, curl_socket_t socket, curlsocktype) { linger l; l.l_onoff = 1; l.l_linger = 0; - setsockopt(socket, SOL_SOCKET, SO_LINGER, (char*)&l, sizeof(l)); + setsockopt(socket, SOL_SOCKET, SO_LINGER, (char *)&l, sizeof(l)); return CURL_SOCKOPT_OK; } -ConfigDownloader::Result ConfigDownloader::get(const string& url, stringstream& out_stream) { +ConfigDownloader::Result +ConfigDownloader::get(const string &url, stringstream &out_stream) { curl_easy_setopt(_curl, CURLOPT_URL, url.c_str()); curl_easy_setopt(_curl, CURLOPT_WRITEFUNCTION, curl_write); curl_easy_setopt(_curl, CURLOPT_WRITEDATA, &out_stream); @@ -55,30 +49,28 @@ ConfigDownloader::Result ConfigDownloader::get(const string& url, stringstream& curl_easy_setopt(_curl, CURLOPT_FAILONERROR, 1); curl_easy_setopt(_curl, CURLOPT_CONNECTTIMEOUT, 6); curl_easy_setopt(_curl, CURLOPT_SOCKOPTFUNCTION, no_linger); - + CURLcode res = curl_easy_perform(_curl); long http_code = 0; CURLcode r2 = curl_easy_getinfo(_curl, CURLINFO_RESPONSE_CODE, &http_code); bts_assert(r2 == CURLE_OK); - + bool used_http = is_http(url); if (res == CURLE_OK && (http_code == 200 || !used_http)) { return SUCCESS; - } else - if (res == CURLE_OPERATION_TIMEDOUT - || res == CURLE_COULDNT_RESOLVE_HOST - || res == CURLE_COULDNT_RESOLVE_PROXY - || res == CURLE_COULDNT_CONNECT - || res == CURLE_REMOTE_ACCESS_DENIED - || res == CURLE_FTP_CANT_GET_HOST - ) { - // Cannot rely on logging before config is initialized - // LOG(Error, Config) << "Permanent failure loading '" << url << "' - CURL error: " << curl_easy_strerror(res); + } else if ( + res == CURLE_OPERATION_TIMEDOUT || res == CURLE_COULDNT_RESOLVE_HOST || + res == CURLE_COULDNT_RESOLVE_PROXY || res == CURLE_COULDNT_CONNECT || + res == CURLE_REMOTE_ACCESS_DENIED || res == CURLE_FTP_CANT_GET_HOST) { + // Cannot rely on logging before config is initialized + // LOG(Error, Config) << "Permanent failure loading '" << url << "' - CURL + // error: " << curl_easy_strerror(res); return PERMANENT_FAILURE; } return FAILURE; } -}}}//namespace - +} // namespace internal +} // namespace config +} // namespace bts diff --git a/src/lib/config/ConfigDownloader.h b/src/lib/config/ConfigDownloader.h old mode 100755 new mode 100644 index d86a0c777..3ae8c6d5e --- a/src/lib/config/ConfigDownloader.h +++ b/src/lib/config/ConfigDownloader.h @@ -8,25 +8,20 @@ namespace bts { namespace config { namespace internal { - -class ConfigDownloader -{ -public: +class ConfigDownloader { + public: ConfigDownloader(); ~ConfigDownloader(); - enum Result { - FAILURE, - SUCCESS, - PERMANENT_FAILURE - }; + enum Result { FAILURE, SUCCESS, PERMANENT_FAILURE }; - Result get(const std::string& url, std::stringstream& out_stream); + Result get(const std::string &url, std::stringstream &out_stream); -private: + private: BTS_NO_COPY(ConfigDownloader); - CURL* _curl; + CURL *_curl; }; -}}}//namespace - +} // namespace internal +} // namespace config +} // namespace bts diff --git a/src/lib/config/ConfigErrorCollector.cpp b/src/lib/config/ConfigErrorCollector.cpp old mode 100755 new mode 100644 index 77a98dbbd..5222b5151 --- a/src/lib/config/ConfigErrorCollector.cpp +++ b/src/lib/config/ConfigErrorCollector.cpp @@ -7,67 +7,61 @@ namespace bts { namespace config { namespace internal { -ConfigErrorCollector::ConfigErrorCollector(IConfigLog& log, const char* file): - _log(log), - _file(file), - _errors() -{ -} +ConfigErrorCollector::ConfigErrorCollector(IConfigLog &log, const char *file) + : _log(log), _file(file), _errors() {} -inline std::string format(const std::string& file, int line, int column, const std::string& message) -{ +inline std::string format( + const std::string &file, int line, int column, const std::string &message) { std::stringstream buffer; - buffer << file.c_str() << ":" << line+1 << ":" << column+1 << ": error: " << message; + buffer << file.c_str() << ":" << line + 1 << ":" << column + 1 + << ": error: " << message; return buffer.str(); } -void ConfigErrorCollector::AddError(int line, int column, const std::string& message) -{ +void ConfigErrorCollector::AddError( + int line, int column, const std::string &message) { _errors.push_back(format(_file, line, column, message)); } -void ConfigErrorCollector::AddWarning(int line, int column, const std::string& message) -{ +void ConfigErrorCollector::AddWarning( + int line, int column, const std::string &message) { // Note: A better solution is to note the optmized out files in // generate_all_config_proto and filter those out. if (os::is_windows() || - (_file.find("expiration_display_offset.conf") == std::string::npos && - _file.find("toggles.conf") == std::string::npos)) { + (_file.find("expiration_display_offset.conf") == std::string::npos && + _file.find("toggles.conf") == std::string::npos)) { _log.warning(format(_file, line, column, message)); } } // For debugging purposes void ConfigErrorCollector::AddError( - const std::string& , // File name in which the error occurred. - const std::string& , // Full name of the erroneous element. - const proto::Message* , // Descriptor of the erroneous element. - ErrorLocation , // One of the location constants, above. - const std::string& // Human-readable error message. - ) -{ + const std::string &, // File name in which the error occurred. + const std::string &, // Full name of the erroneous element. + const proto::Message *, // Descriptor of the erroneous element. + ErrorLocation, // One of the location constants, above. + const std::string & // Human-readable error message. +) { //_log.warning(format(filename, 0, 0, message)); } // For debugging purposes void ConfigErrorCollector::AddWarning( - const std::string& , // File name in which the error occurred. - const std::string& , // Full name of the erroneous element. - const proto::Message* , // Descriptor of the erroneous element. - ErrorLocation , // One of the location constants, above. - const std::string& // Human-readable error message. - ) -{ + const std::string &, // File name in which the error occurred. + const std::string &, // Full name of the erroneous element. + const proto::Message *, // Descriptor of the erroneous element. + ErrorLocation, // One of the location constants, above. + const std::string & // Human-readable error message. +) { //_log.warning(format(filename, 0, 0, message)); } -std::string ConfigErrorCollector::ToString() -{ - if (_errors.size() == 0) return ""; +std::string ConfigErrorCollector::ToString() { + if (_errors.size() == 0) + return ""; std::string error = _errors.front(); - for (size_t x = 1; x < _errors.size(); x++) - { + for (size_t x = 1; x < _errors.size(); x++) { error += '\n'; error += _errors[x]; } @@ -75,5 +69,6 @@ std::string ConfigErrorCollector::ToString() return error; } -}}}//namespace - +} // namespace internal +} // namespace config +} // namespace bts diff --git a/src/lib/config/ConfigErrorCollector.h b/src/lib/config/ConfigErrorCollector.h old mode 100755 new mode 100644 index c4113e14f..433d246d2 --- a/src/lib/config/ConfigErrorCollector.h +++ b/src/lib/config/ConfigErrorCollector.h @@ -2,10 +2,10 @@ #include "ConfigLog.h" -#include -#include -#include #include +#include +#include +#include namespace proto = google::protobuf; @@ -13,41 +13,40 @@ namespace bts { namespace config { namespace internal { -class ConfigErrorCollector : - public proto::io::ErrorCollector, - public proto::DescriptorPool::ErrorCollector -{ -public: - ConfigErrorCollector(IConfigLog& log, const char* file); +class ConfigErrorCollector : public proto::io::ErrorCollector, + public proto::DescriptorPool::ErrorCollector { + public: + ConfigErrorCollector(IConfigLog &log, const char *file); - void AddError(int line, int column, const std::string& message) override; - void AddWarning(int line, int column, const std::string& message) override; + void AddError(int line, int column, const std::string &message) override; + void AddWarning(int line, int column, const std::string &message) override; - void AddError( - const std::string& filename, // File name in which the error occurred. - const std::string& element_name, // Full name of the erroneous element. - const proto::Message* descriptor, // Descriptor of the erroneous element. - ErrorLocation location, // One of the location constants, above. - const std::string& message // Human-readable error message. - ) override; + void AddError( + const std::string &filename, // File name in which the error occurred. + const std::string &element_name, // Full name of the erroneous element. + const proto::Message *descriptor, // Descriptor of the erroneous element. + ErrorLocation location, // One of the location constants, above. + const std::string &message // Human-readable error message. + ) override; - void AddWarning( - const std::string& filename, // File name in which the error occurred. - const std::string& element_name, // Full name of the erroneous element. - const proto::Message* descriptor, // Descriptor of the erroneous element. - ErrorLocation location, // One of the location constants, above. - const std::string& message // Human-readable error message. - ) override; + void AddWarning( + const std::string &filename, // File name in which the error occurred. + const std::string &element_name, // Full name of the erroneous element. + const proto::Message *descriptor, // Descriptor of the erroneous element. + ErrorLocation location, // One of the location constants, above. + const std::string &message // Human-readable error message. + ) override; - std::string ToString(); + std::string ToString(); -private: + private: BTS_NO_COPY(ConfigErrorCollector); - IConfigLog& _log; + IConfigLog &_log; std::string _file; std::vector _errors; }; -}}}//namespace - +} // namespace internal +} // namespace config +} // namespace bts diff --git a/src/lib/config/ConfigLog.cpp b/src/lib/config/ConfigLog.cpp old mode 100755 new mode 100644 index 267e4fa11..2dfd7495b --- a/src/lib/config/ConfigLog.cpp +++ b/src/lib/config/ConfigLog.cpp @@ -8,84 +8,67 @@ namespace internal { struct ConfigLog::PImpl { PImpl() - : - print_errors(true), - logger_hub("config_logger"), - logger(logger_hub.make_logger()) - { - } + : print_errors(true), logger_hub("config_logger"), + logger(logger_hub.make_logger()) {} bool print_errors; log::LoggerHub logger_hub; log::Logger &logger; }; -ConfigLog::ConfigLog() : - me (new PImpl()) -{ +ConfigLog::ConfigLog() : me(new PImpl()) { log::LoggingConfig cfg; - cfg.level_names = { {Diag,"Diag"},{Info,"Info"}, - {Warn,"Warn"},{Error,"Error"}, - {Fatal,"Fatal"},{Sys,"Sys"} }; - cfg.subsystem_names = { {log::Gen,"Gen"},{log::Log,"Log"} }; - + cfg.level_names = {{Diag, "Diag"}, {Info, "Info"}, {Warn, "Warn"}, + {Error, "Error"}, {Fatal, "Fatal"}, {Sys, "Sys"}}; + cfg.subsystem_names = {{log::Gen, "Gen"}, {log::Log, "Log"}}; + cfg.logger_initial_queue_size = 10; log::Filter f; for (auto &l : f) l = Warn; - + cfg.deployment_type = "Config"; f[log::Cfg.ordinal] = Warn; - cfg.sinks["console"] = std::make_pair (log::console_sink(cfg),f); + cfg.sinks["console"] = std::make_pair(log::console_sink(cfg), f); f[log::Cfg.ordinal] = Info; - cfg.sinks["syslog"] = std::make_pair (log::syslog_sink(cfg),f); + cfg.sinks["syslog"] = std::make_pair(log::syslog_sink(cfg), f); me->logger_hub.config(cfg); - + start(); } -void ConfigLog::start() -{ - me->logger_hub.start(); -} +void ConfigLog::start() { me->logger_hub.start(); } -ConfigLog::~ConfigLog() -{ - me->logger.mark_inactive(); -} +ConfigLog::~ConfigLog() { me->logger.mark_inactive(); } -bool ConfigLog::print_errors() const {return me->print_errors;} -void ConfigLog::set_print_errors(bool value) {me->print_errors = value;} +bool ConfigLog::print_errors() const { return me->print_errors; } +void ConfigLog::set_print_errors(bool value) { me->print_errors = value; } -void ConfigLog::info(const std::string& msg) -{ +void ConfigLog::info(const std::string &msg) { if (me->print_errors) - me->logger.enqueue(log::log_ts(),log::Cfg,Info,__FILE__,__LINE__,"{0}",msg); + me->logger.enqueue( + log::log_ts(), log::Cfg, Info, __FILE__, __LINE__, "{0}", msg); } -void ConfigLog::error(const std::string& msg) -{ +void ConfigLog::error(const std::string &msg) { if (me->print_errors) - me->logger.enqueue(log::log_ts(),log::Cfg,Error,__FILE__,__LINE__,"{0}",msg); + me->logger.enqueue( + log::log_ts(), log::Cfg, Error, __FILE__, __LINE__, "{0}", msg); } -void ConfigLog::warning(const std::string& msg) -{ +void ConfigLog::warning(const std::string &msg) { if (me->print_errors) - me->logger.enqueue(log::log_ts(),log::Cfg,Warn,__FILE__,__LINE__,"{0}",msg); + me->logger.enqueue( + log::log_ts(), log::Cfg, Warn, __FILE__, __LINE__, "{0}", msg); } // // Log Aggregator -LogAggregator::LogAggregator(IConfigLog& log) : - _log(log), - _buffer() -{ -} +LogAggregator::LogAggregator(IConfigLog &log) : _log(log), _buffer() {} -void LogAggregator::info(const std::string& msg) { +void LogAggregator::info(const std::string &msg) { _buffer << msg; #ifdef _WIN32 _buffer << std::endl; @@ -94,11 +77,9 @@ void LogAggregator::info(const std::string& msg) { #endif } -void LogAggregator::error(const std::string& msg) { - _log.error(msg); -} +void LogAggregator::error(const std::string &msg) { _log.error(msg); } -void LogAggregator::warning(const std::string& msg) { +void LogAggregator::warning(const std::string &msg) { _log.warning(msg); _buffer << "> Warning: " << msg << std::endl; #ifdef _WIN32 @@ -110,6 +91,6 @@ void LogAggregator::warning(const std::string& msg) { std::string LogAggregator::text() { return _buffer.str(); } - -}}}//namespace - +} // namespace internal +} // namespace config +} // namespace bts diff --git a/src/lib/config/ConfigLog.h b/src/lib/config/ConfigLog.h old mode 100755 new mode 100644 index 463643a47..eeebc37e3 --- a/src/lib/config/ConfigLog.h +++ b/src/lib/config/ConfigLog.h @@ -2,39 +2,37 @@ #include "lib/utils/bts_no_copy.h" -#include -#include #include +#include +#include namespace bts { namespace config { namespace internal { -class IConfigLog -{ -public: - virtual void info(const std::string& msg) = 0; - virtual void error(const std::string& msg) = 0; - virtual void warning(const std::string& msg) = 0; - virtual ~IConfigLog() { } +class IConfigLog { + public: + virtual void info(const std::string &msg) = 0; + virtual void error(const std::string &msg) = 0; + virtual void warning(const std::string &msg) = 0; + virtual ~IConfigLog() {} }; // A back door though the logging system // To allow config diagnostic logging -class ConfigLog : public IConfigLog -{ -public: +class ConfigLog : public IConfigLog { + public: ConfigLog(); ~ConfigLog(); - void info(const std::string& msg); - void error(const std::string& msg); - void warning(const std::string& msg); - - bool print_errors() const ; - void set_print_errors(bool value) ; + void info(const std::string &msg); + void error(const std::string &msg); + void warning(const std::string &msg); -private: + bool print_errors() const; + void set_print_errors(bool value); + + private: void start(); struct PImpl; std::unique_ptr me; @@ -42,32 +40,32 @@ private: // Log aggregator aggregates Info and warning messages into one string // but passes error message through to the log immediately -class LogAggregator : public IConfigLog -{ -public: - LogAggregator(IConfigLog& real_log); - void info(const std::string&); - void error(const std::string&); - void warning(const std::string&); +class LogAggregator : public IConfigLog { + public: + LogAggregator(IConfigLog &real_log); + void info(const std::string &); + void error(const std::string &); + void warning(const std::string &); std::string text(); -private: - IConfigLog& _log; + private: + IConfigLog &_log; std::ostringstream _buffer; }; -class ErrorsOnlyLog : public IConfigLog -{ -public: - ErrorsOnlyLog(IConfigLog& log) : _log(log) {} +class ErrorsOnlyLog : public IConfigLog { + public: + ErrorsOnlyLog(IConfigLog &log) : _log(log) {} ~ErrorsOnlyLog() {} - void info(const std::string&) {} - void error(const std::string& msg) { _log.error(msg); } - void warning(const std::string& msg) { _log.error(msg); } -private: - IConfigLog& _log; + void info(const std::string &) {} + void error(const std::string &msg) { _log.error(msg); } + void warning(const std::string &msg) { _log.error(msg); } + + private: + IConfigLog &_log; }; -}}}//namespace - +} // namespace internal +} // namespace config +} // namespace bts diff --git a/src/lib/config/ConfigPropertyEvaluator.cpp b/src/lib/config/ConfigPropertyEvaluator.cpp old mode 100755 new mode 100644 index d7ac2b1c0..ad442cfc8 --- a/src/lib/config/ConfigPropertyEvaluator.cpp +++ b/src/lib/config/ConfigPropertyEvaluator.cpp @@ -1,9 +1,9 @@ #include "ConfigPropertyEvaluator.h" -#include "lib/utils/windows_wrapper.h" -#include "lib/utils/bts_assert.h" -#include "lib/expression/ExpressionEvaluator.h" #include "ConfigurationState.h" +#include "lib/expression/ExpressionEvaluator.h" +#include "lib/utils/bts_assert.h" +#include "lib/utils/windows_wrapper.h" #include #include @@ -17,51 +17,50 @@ using namespace boost; using expression::Value; namespace proto = google::protobuf; -class ConfigListRuleEvaluatorShim : public expression::IPropertyEvaluator -{ - expression::IPropertyEvaluator& _eval; -public: - ConfigListRuleEvaluatorShim(expression::IPropertyEvaluator& eval) : _eval(eval) { } +class ConfigListRuleEvaluatorShim : public expression::IPropertyEvaluator { + expression::IPropertyEvaluator &_eval; + + public: + ConfigListRuleEvaluatorShim(expression::IPropertyEvaluator &eval) + : _eval(eval) {} virtual ~ConfigListRuleEvaluatorShim() {} - virtual bool get_value(const std::string& property, Value* out_value) { return _eval.get_value(property, out_value); } + virtual bool get_value(const std::string &property, Value *out_value) { + return _eval.get_value(property, out_value); + } }; - -ConfigPropertyEvaluator::ConfigPropertyEvaluator(ConfigurationState& config) - : _config(config), _rule_engine() -{ - std::shared_ptr ptr(new ConfigListRuleEvaluatorShim(*this)); +ConfigPropertyEvaluator::ConfigPropertyEvaluator(ConfigurationState &config) + : _config(config), _rule_engine() { + std::shared_ptr ptr( + new ConfigListRuleEvaluatorShim(*this)); _rule_engine.reset(new expression::ExpressionEvaluator(ptr)); } -ConfigPropertyEvaluator::~ConfigPropertyEvaluator() -{ -} +ConfigPropertyEvaluator::~ConfigPropertyEvaluator() {} -void get_field_scalar(const proto::Message& message, const proto::FieldDescriptor* field_desc, - Value& out_value) -{ - const proto::Reflection* mirror = message.GetReflection(); +void get_field_scalar( + const proto::Message &message, const proto::FieldDescriptor *field_desc, + Value &out_value) { + const proto::Reflection *mirror = message.GetReflection(); - switch(field_desc->cpp_type()) - { + switch (field_desc->cpp_type()) { case proto::FieldDescriptor::CPPTYPE_INT32: - out_value = Value((double) mirror->GetInt32(message, field_desc)); + out_value = Value((double)mirror->GetInt32(message, field_desc)); break; case proto::FieldDescriptor::CPPTYPE_INT64: - out_value = Value((double) mirror->GetInt64(message, field_desc)); + out_value = Value((double)mirror->GetInt64(message, field_desc)); break; case proto::FieldDescriptor::CPPTYPE_UINT32: - out_value = Value((double) mirror->GetUInt32(message, field_desc)); + out_value = Value((double)mirror->GetUInt32(message, field_desc)); break; case proto::FieldDescriptor::CPPTYPE_UINT64: - out_value = Value((double) mirror->GetUInt64(message, field_desc)); + out_value = Value((double)mirror->GetUInt64(message, field_desc)); break; case proto::FieldDescriptor::CPPTYPE_DOUBLE: out_value = Value(mirror->GetDouble(message, field_desc)); break; case proto::FieldDescriptor::CPPTYPE_FLOAT: - out_value = Value((double) mirror->GetFloat(message, field_desc)); + out_value = Value((double)mirror->GetFloat(message, field_desc)); break; case proto::FieldDescriptor::CPPTYPE_BOOL: out_value = Value(mirror->GetBool(message, field_desc)); @@ -73,88 +72,80 @@ void get_field_scalar(const proto::Message& message, const proto::FieldDescripto out_value = Value(mirror->GetEnum(message, field_desc)->name()); break; case proto::FieldDescriptor::CPPTYPE_MESSAGE: - out_value = Value((void*)&mirror->GetMessage(message, field_desc)); + out_value = Value((void *)&mirror->GetMessage(message, field_desc)); break; default: throw std::invalid_argument("Unsupported field type in Config rule"); } } -void get_field_vector(const proto::Message& message, const proto::FieldDescriptor* field_desc, Value& out_value) -{ - const proto::Reflection* mirror = message.GetReflection(); +void get_field_vector( + 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); std::vector values; - switch(field_desc->cpp_type()) - { + switch (field_desc->cpp_type()) { case proto::FieldDescriptor::CPPTYPE_INT32: - for(size_t index = 0; index < field_size; index++) - { - values.push_back( - Value((double) mirror->GetRepeatedInt32(message, field_desc, index))); + for (size_t index = 0; index < field_size; index++) { + values.push_back(Value( + (double)mirror->GetRepeatedInt32(message, field_desc, index))); } break; case proto::FieldDescriptor::CPPTYPE_INT64: - for(size_t index = 0; index < field_size; index++) - { - values.push_back( - Value((double) mirror->GetRepeatedInt64(message, field_desc, index))); + for (size_t index = 0; index < field_size; index++) { + values.push_back(Value( + (double)mirror->GetRepeatedInt64(message, field_desc, index))); } break; case proto::FieldDescriptor::CPPTYPE_UINT32: - for(size_t index = 0; index < field_size; index++) - { - values.push_back( - Value((double) mirror->GetRepeatedUInt32(message, field_desc, index))); + for (size_t index = 0; index < field_size; index++) { + values.push_back(Value( + (double)mirror->GetRepeatedUInt32(message, field_desc, index))); } break; case proto::FieldDescriptor::CPPTYPE_UINT64: - for(size_t index = 0; index < field_size; index++) - { - values.push_back( - Value((double) mirror->GetRepeatedUInt64(message, field_desc, index))); + for (size_t index = 0; index < field_size; index++) { + values.push_back(Value( + (double)mirror->GetRepeatedUInt64(message, field_desc, index))); } break; case proto::FieldDescriptor::CPPTYPE_DOUBLE: - for(size_t index = 0; index < field_size; index++) - { - values.push_back( - Value((double) mirror->GetRepeatedDouble(message, field_desc, index))); + for (size_t index = 0; index < field_size; index++) { + values.push_back(Value( + (double)mirror->GetRepeatedDouble(message, field_desc, index))); } break; case proto::FieldDescriptor::CPPTYPE_FLOAT: - for(size_t index = 0; index < field_size; index++) - { - values.push_back( - Value((double) mirror->GetRepeatedFloat(message, field_desc, index))); + for (size_t index = 0; index < field_size; index++) { + values.push_back(Value( + (double)mirror->GetRepeatedFloat(message, field_desc, index))); } break; case proto::FieldDescriptor::CPPTYPE_BOOL: - for(size_t index = 0; index < field_size; index++) - { + for (size_t index = 0; index < field_size; index++) { values.push_back( - Value(mirror->GetRepeatedBool(message, field_desc, index))); + Value(mirror->GetRepeatedBool(message, field_desc, index))); } break; case proto::FieldDescriptor::CPPTYPE_STRING: - for(size_t index = 0; index < field_size; index++) - { + for (size_t index = 0; index < field_size; index++) { values.push_back( - Value(mirror->GetRepeatedString(message, field_desc, index))); + Value(mirror->GetRepeatedString(message, field_desc, index))); } break; case proto::FieldDescriptor::CPPTYPE_ENUM: for (size_t index = 0; index < field_size; index++) { - values.push_back( - Value(mirror->GetRepeatedEnum(message, field_desc, index)->name())); + values.push_back(Value( + mirror->GetRepeatedEnum(message, field_desc, index)->name())); } break; case proto::FieldDescriptor::CPPTYPE_MESSAGE: for (size_t index = 0; index < field_size; index++) { - values.push_back( - Value((void*)&mirror->GetRepeatedMessage(message, field_desc, index))); + values.push_back(Value( + (void *)&mirror->GetRepeatedMessage(message, field_desc, index))); } break; default: @@ -164,23 +155,26 @@ void get_field_vector(const proto::Message& message, const proto::FieldDescripto out_value = Value(values); } -const proto::Message* lookup_key(std::shared_ptr evaluator, - const proto::Message* message, const proto::FieldDescriptor* field, const std::string& search_key) { +const proto::Message *lookup_key( + std::shared_ptr evaluator, + const proto::Message *message, const proto::FieldDescriptor *field, + const std::string &search_key) { bts_assert(message); bts_assert(field); bts_assert(!search_key.empty()); bts_assert(field->is_repeated()); bts_assert(field->type() == proto::FieldDescriptor::TYPE_MESSAGE); - const proto::Reflection* mirror = message->GetReflection(); + const proto::Reflection *mirror = message->GetReflection(); int size = mirror->FieldSize(*message, field); - const proto::FieldDescriptor* key_field = NULL; - const proto::FieldDescriptor* rule_field = NULL; - const proto::Reflection* key_reflection = NULL; + const proto::FieldDescriptor *key_field = NULL; + const proto::FieldDescriptor *rule_field = NULL; + const proto::Reflection *key_reflection = NULL; for (int x = 0; x < size; x++) { // Iterate through the field instances - const proto::Message& cur = mirror->GetRepeatedMessage(*message, field, x); + const proto::Message &cur = + mirror->GetRepeatedMessage(*message, field, x); if (x == 0) { // Grab the reflection and field descriptor for the repeated type key_reflection = cur.GetReflection(); @@ -204,14 +198,12 @@ const proto::Message* lookup_key(std::shared_ptrGetStringReference(cur, key_field, &key); - if (key == search_key) - { - if(rule_field != NULL) - { + if (key == search_key) { + if (rule_field != NULL) { std::string rule; rule = key_reflection->GetStringReference(cur, rule_field, &rule); - if(rule != "" && !evaluator->eval(rule)) - return cur.New(); + if (rule != "" && !evaluator->eval(rule)) + return cur.New(); } return &cur; } @@ -220,77 +212,74 @@ const proto::Message* lookup_key(std::shared_ptr > tokens(property, char_separator(".[]")); // Note: Split arbitrarily on [], enforcing matching brackets is done in the parser - tokenizer >::iterator iter = tokens.begin (), end = tokens.end (); + tokenizer> tokens( + property, + char_separator(".[]")); // Note: Split arbitrarily on [], enforcing + // matching brackets is done in the parser + tokenizer>::iterator iter = tokens.begin(), + end = tokens.end(); // The first token is the key name - const proto::Message* key = _config.try_get_message_or_default(*iter); - if (!key) return false; + const proto::Message *key = _config.try_get_message_or_default(*iter); + if (!key) + return false; // 2) Drill down using reflection to find the named property - do - { + do { ++iter; if (iter == end) { // We're asking for a complete Message - *out_value = Value((void*)key); + *out_value = Value((void *)key); return true; } - const proto::Descriptor* message_desc = key->GetDescriptor(); + const proto::Descriptor *message_desc = key->GetDescriptor(); std::string field_name = *iter; - const proto::FieldDescriptor* field_desc = message_desc->FindFieldByName(field_name); - - if (field_desc) - { - if (field_desc->is_repeated()) - { + const proto::FieldDescriptor *field_desc = + message_desc->FindFieldByName(field_name); + + if (field_desc) { + if (field_desc->is_repeated()) { ++iter; - if (field_desc->type() == proto::FieldDescriptor::TYPE_MESSAGE && iter != end) - { + if (field_desc->type() == proto::FieldDescriptor::TYPE_MESSAGE && + iter != end) { // Treat the next token as a key into the list key = lookup_key(_rule_engine, key, field_desc, *iter); - if (key == NULL) return false; - } - else - { + if (key == NULL) + return false; + } else { get_field_vector(*key, field_desc, *out_value); return (iter == end); } - } - else - { - if (field_desc->type() != proto::FieldDescriptor::TYPE_MESSAGE) - { + } else { + if (field_desc->type() != proto::FieldDescriptor::TYPE_MESSAGE) { get_field_scalar(*key, field_desc, *out_value); return (++iter == tokens.end()); - } - else - { + } else { // continue iterating - const proto::Reflection* mirror = key->GetReflection(); + const proto::Reflection *mirror = key->GetReflection(); key = &mirror->GetMessage(*key, field_desc); } } - } - else { + } else { break; } - } while(key && iter != end); + } while (key && iter != end); return false; } -}}}//namespace +} // namespace internal +} // namespace config +} // namespace bts diff --git a/src/lib/config/ConfigPropertyEvaluator.h b/src/lib/config/ConfigPropertyEvaluator.h old mode 100755 new mode 100644 index 6583479f1..23b7d2d1c --- a/src/lib/config/ConfigPropertyEvaluator.h +++ b/src/lib/config/ConfigPropertyEvaluator.h @@ -1,31 +1,35 @@ #ifndef CONFIGPROPERTYEVALUATOR_H_ #define CONFIGPROPERTYEVALUATOR_H_ -#include "lib/utils/bts_no_copy.h" -#include "lib/expression/Value.h" #include "lib/expression/IPropertyEvaluator.h" +#include "lib/expression/Value.h" +#include "lib/utils/bts_no_copy.h" namespace bts { -namespace expression { class ExpressionEvaluator;} +namespace expression { +class ExpressionEvaluator; +} namespace config { namespace internal { class ConfigurationState; -class ConfigPropertyEvaluator : public expression::IPropertyEvaluator -{ -public: - ConfigPropertyEvaluator(ConfigurationState& config); +class ConfigPropertyEvaluator : public expression::IPropertyEvaluator { + public: + ConfigPropertyEvaluator(ConfigurationState &config); ~ConfigPropertyEvaluator(); - bool get_value(const std::string& property, expression::Value* out_value) override; + bool get_value( + const std::string &property, expression::Value *out_value) override; -private: + private: BTS_NO_COPY(ConfigPropertyEvaluator); - ConfigurationState& _config; + ConfigurationState &_config; std::shared_ptr _rule_engine; }; -}}}//namespace +} // namespace internal +} // namespace config +} // namespace bts #endif diff --git a/src/lib/config/ConfigValueQueue.cpp b/src/lib/config/ConfigValueQueue.cpp old mode 100755 new mode 100644 index 2d65a5ee8..85c138275 --- a/src/lib/config/ConfigValueQueue.cpp +++ b/src/lib/config/ConfigValueQueue.cpp @@ -2,10 +2,10 @@ #include "ConfigValueQueue.h" #include "ConfigurationException.h" -#include "lib/utils/proto_helper.h" -#include -#include #include "config.h" +#include "lib/utils/proto_helper.h" +#include +#include namespace bts { namespace config { @@ -16,45 +16,36 @@ using namespace bts::expression; using namespace bts::util::proto; using std::vector; -ConfigValueQueue::ConfigValueQueue(IPropertyEvaluator& evaluator) : - _eval(evaluator), - _vals(), - _current_file() -{ -} +ConfigValueQueue::ConfigValueQueue(IPropertyEvaluator &evaluator) + : _eval(evaluator), _vals(), _current_file() {} -ConfigValueQueue::~ConfigValueQueue() -{ -} +ConfigValueQueue::~ConfigValueQueue() {} -void ConfigValueQueue::clear() { - _vals.clear(); -} +void ConfigValueQueue::clear() { _vals.clear(); } void ConfigValueQueue::process() { try { process_fields(); - } catch(...) { + } catch (...) { clear(); throw; } } -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, - const proto::Message* root) { +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, + const proto::Message *root) { bts_assert(msg); bts_assert(reflection); bts_assert(field); bts_assert(!source.empty()); - //bts_assert(!destination.empty()); - //bts_assert_d(root != nullptr); - DeferredValue dv = {msg, reflection, field, index, line, col, _current_file, source, destination, root}; + // bts_assert(!destination.empty()); + // bts_assert_d(root != nullptr); + DeferredValue dv = {msg, reflection, field, index, line, + col, _current_file, source, destination, root}; _vals.push_back(dv); } @@ -66,7 +57,7 @@ void ConfigValueQueue::process_fields() { temp.clear(); len = _vals.size(); for (size_t x = 0; x < len; ++x) { - DeferredValue& dv = _vals[x]; + DeferredValue &dv = _vals[x]; if (can_process(dv.sourceval)) { process_field(dv); } else { @@ -75,28 +66,31 @@ void ConfigValueQueue::process_fields() { } _vals = temp; // Continue as long as progress is being made - } while(_vals.size() > 0 && _vals.size() < len); + } while (_vals.size() > 0 && _vals.size() < len); // Error condition if (!_vals.empty()) { std::ostringstream msg; - msg << "Unable to processes config value references. " << _vals.size() << " errors detected.\n\n"; + msg << "Unable to processes config value references. " << _vals.size() + << " errors detected.\n\n"; for (iter = _vals.begin(); iter != _vals.end(); iter++) { - msg << "Cannot write " << iter->sourceval << " due to circular reference. "; - msg << iter->filename << ":" << iter->line << "," << iter->col << std::endl; + msg << "Cannot write " << iter->sourceval + << " due to circular reference. "; + msg << iter->filename << ":" << iter->line << "," << iter->col + << std::endl; } std::string error = msg.str(); throw new RecursiveReferenceException(error.c_str()); } } -bool ConfigValueQueue::can_process(const std::string& source) { +bool ConfigValueQueue::can_process(const std::string &source) { // Determine if source has a pending write size_t len = _vals.size(); - for(size_t x = 0; x < len; ++x) { + for (size_t x = 0; x < len; ++x) { // If there is a destination assignment underneath the source path // Then we cannot copy the value yet - const string& dest = _vals[x].dest_key; + const string &dest = _vals[x].dest_key; if (dest.compare(0, source.size(), source) == 0) { if (dest.size() <= source.size() || dest[source.size()] == '.') { return false; @@ -107,61 +101,60 @@ bool ConfigValueQueue::can_process(const std::string& source) { return true; } -bool is_relevant(const proto::Message* message) { +bool is_relevant(const proto::Message *message) { if (message) { - const proto::Descriptor* desc = message->GetDescriptor(); + const proto::Descriptor *desc = message->GetDescriptor(); bts_assert_d(desc); - const proto::Message& result = config::get_message(desc); + const proto::Message &result = config::get_message(desc); return &result == message; } return true; } -void ConfigValueQueue::process_field(const DeferredValue& dv) { +void ConfigValueQueue::process_field(const DeferredValue &dv) { Value val; if (_eval.get_value(dv.sourceval, &val)) { assign_value_to_field(dv.message, dv.reflection, dv.field, val, dv.index); } else { if (is_relevant(dv.root_message)) { std::string message = "Error retrieving value for " + dv.sourceval; - throw SelfReferenceException(message.c_str(), dv.filename.c_str(), dv.line, dv.col); + throw SelfReferenceException( + message.c_str(), dv.filename.c_str(), dv.line, dv.col); } } } 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); + vector v = boost::get>(value); if (field->is_repeated()) { for (vector::iterator i = v.begin(); i != v.end(); ++i) { int size = reflection->FieldSize(*message, field); - add(message, reflection, field, (TProto)boost::get(*i)); + add( + message, reflection, field, (TProto)boost::get(*i)); if (index != size) { - for (int i = index; i < size; ++i) { - reflection->SwapElements(message, field, i, size); - } + for (int i = index; i < size; ++i) { + reflection->SwapElements(message, field, i, size); + } } index++; } bump_indexes(message, field, v.size()); - } - else if (field->type() == proto::FieldDescriptor::Type::TYPE_STRING) { + } else if (field->type() == proto::FieldDescriptor::Type::TYPE_STRING) { reflection->SetString(message, field, value_to_string(value)); - } - else if (field->type() == proto::FieldDescriptor::Type::TYPE_BOOL) { + } else if (field->type() == proto::FieldDescriptor::Type::TYPE_BOOL) { reflection->SetBool(message, field, value_to_bool(value)); - } - else { - string error = "Invalid type conversion in assignment to " + message->GetTypeName() + "." + field->name(); + } else { + string error = "Invalid type conversion in assignment to " + + message->GetTypeName() + "." + field->name(); throw ConfigurationException(error.c_str()); } } else { - set_field(message, reflection, field, (TProto)boost::get(value), index); + set_field( + message, reflection, field, (TProto)boost::get(value), index); if (field->is_repeated()) { bump_indexes(message, field, 1); } @@ -170,12 +163,10 @@ 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); + vector v = boost::get>(value); bts_assert(field->is_repeated()); for (vector::iterator i = v.begin(); i != v.end(); ++i) { int size = reflection->FieldSize(*message, field); @@ -198,53 +189,62 @@ void ConfigValueQueue::lexical_assign( } } -void ConfigValueQueue::assign_value_to_field(proto::Message* message, - const proto::Reflection* reflection, - const proto::FieldDescriptor* field, - const Value& value, int index) throw() { +void ConfigValueQueue::assign_value_to_field( + 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 - // Note: ConfigPropertyEvaluator puts every numeric type in as double so the right hand side must be double - switch(field->type()) { + // Note: ConfigPropertyEvaluator puts every numeric type in as double so the + // right hand side must be double + switch (field->type()) { case FieldDescriptor::TYPE_DOUBLE: - assign(MY_ARGS); break; + assign(MY_ARGS); + break; case FieldDescriptor::TYPE_FLOAT: - assign(MY_ARGS); break; + assign(MY_ARGS); + break; case FieldDescriptor::TYPE_FIXED64: case FieldDescriptor::TYPE_INT64: - assign(MY_ARGS); break; + assign(MY_ARGS); + break; case FieldDescriptor::TYPE_UINT64: - assign(MY_ARGS); break; + assign(MY_ARGS); + break; case FieldDescriptor::TYPE_FIXED32: case FieldDescriptor::TYPE_INT32: if (value.which() == ValueType::string) { lexical_assign(MY_ARGS); - } - else { + } else { assign(MY_ARGS); } break; case FieldDescriptor::TYPE_UINT32: - assign(MY_ARGS); break; + assign(MY_ARGS); + break; case FieldDescriptor::TYPE_BOOL: - assign(MY_ARGS); break; + assign(MY_ARGS); + break; case FieldDescriptor::TYPE_STRING: - if (value.which() == ValueType::integer || value.which() == ValueType::real) { + if (value.which() == ValueType::integer || + value.which() == ValueType::real) { lexical_assign(MY_ARGS); - } - else { + } else { assign(MY_ARGS); } break; case FieldDescriptor::TYPE_MESSAGE: - assign(MY_ARGS); break; + assign(MY_ARGS); + break; case FieldDescriptor::TYPE_ENUM: { if (value.which() == ValueType::list) { - vector v = boost::get >(value); - for (vector::iterator iter = v.begin(); iter != v.end(); iter++) { + vector v = boost::get>(value); + for (vector::iterator iter = v.begin(); iter != v.end(); + iter++) { int size = reflection->FieldSize(*message, field); - const EnumDescriptor* enum_type = field->enum_type(); - const EnumValueDescriptor* enum_value = enum_type->FindValueByName(boost::get(value)); + const EnumDescriptor *enum_type = field->enum_type(); + const EnumValueDescriptor *enum_value = + enum_type->FindValueByName(boost::get(value)); reflection->AddEnum(message, field, enum_value); if (index != size) { for (int i = index; i < size; ++i) { @@ -254,10 +254,10 @@ void ConfigValueQueue::assign_value_to_field(proto::Message* message, index++; } bump_indexes(message, field, v.size()); - } - else { - const EnumDescriptor* enum_type = field->enum_type(); - const EnumValueDescriptor* enum_value = enum_type->FindValueByName(boost::get(value)); + } else { + const EnumDescriptor *enum_type = field->enum_type(); + const EnumValueDescriptor *enum_value = + enum_type->FindValueByName(boost::get(value)); set_field(message, reflection, field, enum_value, index); if (field->is_repeated()) { bump_indexes(message, field, 1); @@ -278,18 +278,17 @@ void ConfigValueQueue::assign_value_to_field(proto::Message* message, #undef MY_ARGS } -void ConfigValueQueue::bump_indexes(proto::Message* message, - const proto::FieldDescriptor* field, - int count) -{ +void ConfigValueQueue::bump_indexes( + proto::Message *message, const proto::FieldDescriptor *field, int count) { std::vector::iterator iter = _vals.begin(); - for (;iter != _vals.end(); iter++) { - DeferredValue& dv = *iter; + for (; iter != _vals.end(); iter++) { + DeferredValue &dv = *iter; if (dv.message == message && dv.field == field) { dv.index += count; } } } -}}}//namespace - +} // namespace internal +} // namespace config +} // namespace bts diff --git a/src/lib/config/ConfigValueQueue.h b/src/lib/config/ConfigValueQueue.h old mode 100755 new mode 100644 index 963ca7029..1ccc1688d --- a/src/lib/config/ConfigValueQueue.h +++ b/src/lib/config/ConfigValueQueue.h @@ -1,8 +1,8 @@ #pragma once -#include "lib/utils/bts_no_copy.h" -#include "lib/expression/Value.h" #include "lib/expression/IPropertyEvaluator.h" +#include "lib/expression/Value.h" +#include "lib/utils/bts_no_copy.h" #include "text_format/text_format.h" #include @@ -13,31 +13,29 @@ namespace config { namespace internal { namespace proto = ::google::protobuf; - #ifdef __GNUC__ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Weffc++" #endif struct DeferredValue { - proto::Message* message; - const proto::Reflection* reflection; - const proto::FieldDescriptor* field; + proto::Message *message; + const proto::Reflection *reflection; + const proto::FieldDescriptor *field; int index; int line; int col; std::string filename; std::string sourceval; std::string dest_key; - const proto::Message* root_message; + const proto::Message *root_message; }; #ifdef __GNUC__ #pragma GCC diagnostic pop #endif -class ConfigValueQueue : public google::protobuf::IDeferValueLookup -{ -public: - ConfigValueQueue(expression::IPropertyEvaluator& evaluator); +class ConfigValueQueue : public google::protobuf::IDeferValueLookup { + public: + ConfigValueQueue(expression::IPropertyEvaluator &evaluator); ~ConfigValueQueue(); // Process the queue of deferred values @@ -45,57 +43,53 @@ public: void clear(); // 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, const proto::Message* root) override; + 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, + const proto::Message *root) override; - void set_filename(const std::string& filename) { _current_file = filename; } + void set_filename(const std::string &filename) { _current_file = filename; } -private: // fields - expression::IPropertyEvaluator& _eval; + private: // fields + expression::IPropertyEvaluator &_eval; std::vector _vals; std::string _current_file; BTS_NO_COPY(ConfigValueQueue); -private: //methods + private: // methods void process_fields(); - bool can_process(const std::string& key_name); - void process_field(const DeferredValue&); + bool can_process(const std::string &key_name); + 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, int insert_index=0) throw(); - void bump_indexes(proto::Message* message, - const proto::FieldDescriptor* field, - int count); + void assign_value_to_field( + 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, int& index); + 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, int& index); + 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, int& index) { - assign(message, reflection, field, value, index); + proto::Message *message, const proto::Reflection *reflection, + const proto::FieldDescriptor *field, const expression::Value &value, + int &index) { + assign(message, reflection, field, value, index); } }; -}}}//namespace - +} // namespace internal +} // namespace config +} // namespace bts diff --git a/src/lib/config/ConfigurationException.cpp b/src/lib/config/ConfigurationException.cpp old mode 100755 new mode 100644 index 500b5d197..a3aa29cb3 --- a/src/lib/config/ConfigurationException.cpp +++ b/src/lib/config/ConfigurationException.cpp @@ -3,35 +3,30 @@ namespace bts { namespace config { - // - // ConfigurationException - // - ConfigurationException::ConfigurationException(const char* what) - : std::logic_error(""), _what(what) - { - } +// +// ConfigurationException +// +ConfigurationException::ConfigurationException(const char *what) + : std::logic_error(""), _what(what) {} - ConfigurationException::ConfigurationException(const std::string& what) - : std::logic_error(""), _what(what) - { - } - - ConfigurationException::ConfigurationException(const ConfigurationException& other) - : std::logic_error(""), _what(other._what) - { - } +ConfigurationException::ConfigurationException(const std::string &what) + : std::logic_error(""), _what(what) {} - ConfigurationException& ConfigurationException::operator=(const ConfigurationException& other) - { - _what = other._what; - return *this; - } +ConfigurationException::ConfigurationException( + const ConfigurationException &other) + : std::logic_error(""), _what(other._what) {} - const char* ConfigurationException::what() const throw() - { - return _what.c_str(); - } +ConfigurationException & +ConfigurationException::operator=(const ConfigurationException &other) { + _what = other._what; + return *this; +} - ConfigurationException::~ConfigurationException() throw() {} +const char *ConfigurationException::what() const throw() { + return _what.c_str(); +} -}}//namespace +ConfigurationException::~ConfigurationException() throw() {} + +} // namespace config +} // namespace bts diff --git a/src/lib/config/ConfigurationException.h b/src/lib/config/ConfigurationException.h old mode 100755 new mode 100644 index 908bee68a..d5477ffe8 --- a/src/lib/config/ConfigurationException.h +++ b/src/lib/config/ConfigurationException.h @@ -1,53 +1,46 @@ #ifndef BADCONFIGURATIONEXCEPTION_H_ #define BADCONFIGURATIONEXCEPTION_H_ -#include -#include -#include #include "lib/utils/bts_export.h" +#include +#include +#include namespace bts { namespace config { -class ConfigurationException : public std::logic_error -{ -public: - ConfigurationException(const char* what); - ConfigurationException(const std::string& what); - ConfigurationException(const ConfigurationException& other); - ConfigurationException& operator=(const ConfigurationException& other); +class ConfigurationException : public std::logic_error { + public: + ConfigurationException(const char *what); + ConfigurationException(const std::string &what); + ConfigurationException(const ConfigurationException &other); + ConfigurationException &operator=(const ConfigurationException &other); virtual ~ConfigurationException() throw(); - BTS_EXPORT const char* what() const throw() override; + BTS_EXPORT const char *what() const throw() override; -protected: + protected: std::string _what; }; -class InvalidDescriptorException : public ConfigurationException -{ -public: - InvalidDescriptorException(const char* what) - : ConfigurationException(what) - { +class InvalidDescriptorException : public ConfigurationException { + public: + InvalidDescriptorException(const char *what) : ConfigurationException(what) { _what += " was not compiled into config."; } }; -class InvalidKeyException : public ConfigurationException -{ -public: - InvalidKeyException(const char* what) - : ConfigurationException(what) - { +class InvalidKeyException : public ConfigurationException { + public: + InvalidKeyException(const char *what) : ConfigurationException(what) { _what += " is not a valid config type."; } }; -class SelfReferenceException : public ConfigurationException -{ -public: - SelfReferenceException(const char* what, const char* file, int line, int col) : ConfigurationException(what) { +class SelfReferenceException : public ConfigurationException { + public: + SelfReferenceException(const char *what, const char *file, int line, int col) + : ConfigurationException(what) { std::ostringstream out; out << what; out << " Location: " << file << ":" << line << "," << col; @@ -55,21 +48,20 @@ public: } }; -class RecursiveReferenceException : public ConfigurationException -{ -public: - RecursiveReferenceException(const char* what) : ConfigurationException(what) { } +class RecursiveReferenceException : public ConfigurationException { + public: + RecursiveReferenceException(const char *what) + : ConfigurationException(what) {} }; -class ServerUnreachableException : public ConfigurationException -{ -public: - ServerUnreachableException(const char* what) : ConfigurationException(what) - { +class ServerUnreachableException : public ConfigurationException { + public: + ServerUnreachableException(const char *what) : ConfigurationException(what) { _what = "Unable to reach server "; _what += what; } }; -}} +} // namespace config +} // namespace bts #endif diff --git a/src/lib/config/ConfigurationState.cpp b/src/lib/config/ConfigurationState.cpp old mode 100755 new mode 100644 index 0678fbd61..728aa1037 --- a/src/lib/config/ConfigurationState.cpp +++ b/src/lib/config/ConfigurationState.cpp @@ -1,29 +1,28 @@ #include "lib/os/os.h" -#include "ConfigurationState.h" -#include "ConfigurationException.h" -#include "ConfigPropertyEvaluator.h" #include "ConfigErrorCollector.h" -#include "PreprocessInputStream.h" +#include "ConfigPropertyEvaluator.h" #include "ConfigValueQueue.h" -#include "lib/os/os.h" -#include "lib/utils/bts_assert.h" -#include "lib/utils/is_unittest_environment.h" -#include "lib/utils/bts_array_size.h" -#include "lib/utils/defer.h" +#include "ConfigurationException.h" +#include "ConfigurationState.h" +#include "PreprocessInputStream.h" #include "config.h" +#include "lib/os/os.h" +#include "lib/utils/bts_array_size.h" +#include "lib/utils/bts_assert.h" +#include "lib/utils/defer.h" +#include "lib/utils/is_unittest_environment.h" #include "lib/config/protos/system.pb.h" #include // iequals #include -#include #include -#include +#include #include #include - +#include #define URDL_HEADER_ONLY 1 #define URDL_DISALE_SSL 1 @@ -33,66 +32,52 @@ #include #include #else -#include -#include -#include #include +#include +#include +#include #endif -#include "lib/config_proto_files.h" #include "lib/config_defaults.h" +#include "lib/config_proto_files.h" -using namespace std; +using namespace std; namespace bts { namespace config { namespace internal { -const char* MESSAGE_STRING_RULE = "rule"; -const char* MESSAGE_STRING_VALUE = "value"; -const char* MESSAGE_STRING_INCLUDE = "include"; -const char* MESSAGE_STRING_INCLUDE_BACKUP = "fallback"; -const char* MESSAGE_STRING_MACRO_TYPE = "MacroType"; -const char* MESSAGE_STRING_MACRO = "macro"; +const char *MESSAGE_STRING_RULE = "rule"; +const char *MESSAGE_STRING_VALUE = "value"; +const char *MESSAGE_STRING_INCLUDE = "include"; +const char *MESSAGE_STRING_INCLUDE_BACKUP = "fallback"; +const char *MESSAGE_STRING_MACRO_TYPE = "MacroType"; +const char *MESSAGE_STRING_MACRO = "macro"; -const char* CONFIG_SERVER_ENV_VAR = "BTSConfig"; +const char *CONFIG_SERVER_ENV_VAR = "BTSConfig"; -inline tuple hostname(const std::string& path); +inline tuple hostname(const std::string &path); -ConfigurationState::ConfigurationState(void) : - _is_initialized(false), - _initialization_mutex(), - _dynamic_pool(), - _prototype_factory(), - _prototype(nullptr), - _config_chain(), - _defaults(), - _properties(new ConfigPropertyEvaluator(*this)), - _rule_engine(_properties), - _macros(), - _deferred_queue(new ConfigValueQueue(*_properties.get())), - _host(), - _port(80) -{ -} +ConfigurationState::ConfigurationState(void) + : _is_initialized(false), _initialization_mutex(), _dynamic_pool(), + _prototype_factory(), _prototype(nullptr), _config_chain(), _defaults(), + _properties(new ConfigPropertyEvaluator(*this)), + _rule_engine(_properties), _macros(), + _deferred_queue(new ConfigValueQueue(*_properties.get())), _host(), + _port(80) {} -ConfigurationState::~ConfigurationState(void) -{ -} +ConfigurationState::~ConfigurationState(void) {} -std::string get_command_argument(const char* key) -{ +std::string get_command_argument(const char *key) { std::vector cmd_line = os::get_command_line(); - std::vector::iterator begin = cmd_line.begin(), end = cmd_line.end(); - for (; begin != end; begin++) - { - if (boost::iequals(*begin, key)) - { + std::vector::iterator begin = cmd_line.begin(), + end = cmd_line.end(); + for (; begin != end; begin++) { + if (boost::iequals(*begin, key)) { begin++; if (begin == end) { break; - } - else { + } else { os::setenv(CONFIG_SERVER_ENV_VAR, begin->c_str()); return *begin; } @@ -101,38 +86,42 @@ std::string get_command_argument(const char* key) return ""; } -string ConfigurationState::settings_path() -{ +string ConfigurationState::settings_path() { // Look for the -ConfigServer option on the command line std::string cmd_arg = get_command_argument("-ConfigServer"); - if (!cmd_arg.empty()) return cmd_arg; + if (!cmd_arg.empty()) + return cmd_arg; // Then the BTSCONFIG environment variable - const char* env_server = getenv(CONFIG_SERVER_ENV_VAR); - if (env_server) return env_server; + const char *env_server = getenv(CONFIG_SERVER_ENV_VAR); + if (env_server) + return env_server; // then look in sparkdata return os::sparkdata_path("conf"); } -void ConfigurationState::initialize_defaults(IConfigLog& log) -{ +void ConfigurationState::initialize_defaults(IConfigLog &log) { std::lock_guard lock(_initialization_mutex); - if (_is_initialized) return; + if (_is_initialized) + return; generate_all_config_proto(log); - + std::shared_ptr new_message(_prototype->New()); ErrorsOnlyLog elog(log); std::string defaults; - for (const char* str : config_static_defaults) { + for (const char *str : config_static_defaults) { defaults += str; defaults += "\n"; } - proto::io::ArrayInputStream input_stream(defaults.c_str(), (int)defaults.length()); - parse_stream("static_defaults.conf", input_stream, *new_message.get(), elog, *_deferred_queue.get()); + proto::io::ArrayInputStream input_stream( + defaults.c_str(), (int)defaults.length()); + parse_stream( + "static_defaults.conf", input_stream, *new_message.get(), elog, + *_deferred_queue.get()); _defaults = new_message; // do not process 'include' for static defaults @@ -140,8 +129,7 @@ void ConfigurationState::initialize_defaults(IConfigLog& log) _is_initialized = true; } -void ConfigurationState::initialize_builtins() -{ +void ConfigurationState::initialize_builtins() { System sys; sys.set_host_name(os::host_name()); @@ -158,9 +146,10 @@ void ConfigurationState::initialize_builtins() sys.set_config_host(_host); sys.set_config_port(_port); if (!_host.empty()) { - hostent* host_entry = gethostbyname(_host.c_str()); - bts_assert_msg(host_entry != NULL, "Unable to resolve host name " + _host); - in_addr* address = (in_addr*) host_entry->h_addr_list[0]; + hostent *host_entry = gethostbyname(_host.c_str()); + bts_assert_msg( + host_entry != NULL, "Unable to resolve host name " + _host); + in_addr *address = (in_addr *)host_entry->h_addr_list[0]; string ip_address = inet_ntoa(*address); sys.set_config_ip(ip_address); } @@ -168,7 +157,8 @@ void ConfigurationState::initialize_builtins() sys.set_is_remote_app(GetSystemMetrics(SM_REMOTESESSION) == 1); // Screen dpi, Assumes screen dpi is uniform in x and y - // Computes 2 different ratios depending - one will be right depending on whether the process calls SetDPIAware() + // Computes 2 different ratios depending - one will be right depending on + // whether the process calls SetDPIAware() HDC screen = GetDC(0); int log_pixels_x = GetDeviceCaps(screen, LOGPIXELSX); auto ratio2 = log_pixels_x / 96.0; @@ -180,29 +170,27 @@ void ConfigurationState::initialize_builtins() ReleaseDC(0, screen); #endif - + std::vector args = os::get_command_line(); - for (std::vector::iterator iter = args.begin(); iter != args.end(); iter++) - { + for (std::vector::iterator iter = args.begin(); + iter != args.end(); iter++) { sys.add_cmd_args(*iter); } // Version string std::string app_version_file = os::get_install_path() + "/spark.version"; - if (boost::filesystem::exists(app_version_file)) - { + if (boost::filesystem::exists(app_version_file)) { std::ifstream input(app_version_file.c_str(), std::ifstream::in); - if (!input.fail()) - { + if (!input.fail()) { // Read the last line of the file std::string version; - while(!input.eof()) - { + while (!input.eof()) { std::string temp; std::getline(input, temp); - if (!temp.empty()) version = temp; + if (!temp.empty()) + version = temp; } - + sys.set_version(version); input.close(); } @@ -212,13 +200,18 @@ void ConfigurationState::initialize_builtins() // // Add the System value to the defaults - const proto::FieldDescriptor* field_desc = _defaults->GetDescriptor()->FindFieldByName("System"); - const proto::Descriptor* message_desc = field_desc->message_type(); - + const proto::FieldDescriptor *field_desc = + _defaults->GetDescriptor()->FindFieldByName("System"); + const proto::Descriptor *message_desc = field_desc->message_type(); + // Create a meta message - proto::Message* new_message = _defaults->GetReflection()->AddMessage(_defaults.get(), field_desc); - const proto::FieldDescriptor* value_desc = message_desc->FindFieldByName("value"); - new_message->GetReflection()->MutableMessage(new_message, value_desc)->CopyFrom(sys); + proto::Message *new_message = + _defaults->GetReflection()->AddMessage(_defaults.get(), field_desc); + const proto::FieldDescriptor *value_desc = + message_desc->FindFieldByName("value"); + new_message->GetReflection() + ->MutableMessage(new_message, value_desc) + ->CopyFrom(sys); initialize_introspection(); } @@ -229,15 +222,16 @@ void ConfigurationState::initialize_introspection() { ConfigIntrospection ci; proto::DescriptorPool::generated_pool(); for (size_t x = 0; x < BTS_ARRAYSIZE(config_proto_files); x++) { - std::string proto_path = "core/bts_core/config/"; + std::string proto_path = "core/bts_core/config/"; proto_path += config_proto_files[x]; - const proto::FileDescriptor* file_desc = proto::DescriptorPool::generated_pool()->FindFileByName(proto_path); + const proto::FileDescriptor *file_desc = + proto::DescriptorPool::generated_pool()->FindFileByName(proto_path); if (file_desc != nullptr) { - ConfigIntrospection::ConfigProto* config_proto = ci.add_config(); + ConfigIntrospection::ConfigProto *config_proto = ci.add_config(); bts_assert(config_proto); config_proto->set_name(file_desc->name()); - for (int y=0; y < file_desc->message_type_count(); y++) { - const proto::Descriptor* message_desc = file_desc->message_type(y); + for (int y = 0; y < file_desc->message_type_count(); y++) { + const proto::Descriptor *message_desc = file_desc->message_type(y); if (message_desc != nullptr) { config_proto->add_type(message_desc->full_name()); } @@ -245,55 +239,60 @@ void ConfigurationState::initialize_introspection() { } } - // Add to defaults - const proto::FieldDescriptor* field_desc = _defaults->GetDescriptor()->FindFieldByName("ConfigIntrospection"); - const proto::Descriptor* message_desc = field_desc->message_type(); - proto::Message* new_message = _defaults->GetReflection()->AddMessage(_defaults.get(), field_desc); - const proto::FieldDescriptor* value_desc = message_desc->FindFieldByName("value"); - new_message->GetReflection()->MutableMessage(new_message, value_desc)->CopyFrom(ci); + const proto::FieldDescriptor *field_desc = + _defaults->GetDescriptor()->FindFieldByName("ConfigIntrospection"); + const proto::Descriptor *message_desc = field_desc->message_type(); + proto::Message *new_message = + _defaults->GetReflection()->AddMessage(_defaults.get(), field_desc); + const proto::FieldDescriptor *value_desc = + message_desc->FindFieldByName("value"); + new_message->GetReflection() + ->MutableMessage(new_message, value_desc) + ->CopyFrom(ci); } -void ConfigurationState::initialize_macros() -{ - std::vector > :: iterator iter; - for (iter = _config_chain.begin(); iter != _config_chain.end(); ++iter) - { - const proto::Message* message = (*iter).get(); +void ConfigurationState::initialize_macros() { + std::vector>::iterator iter; + for (iter = _config_chain.begin(); iter != _config_chain.end(); ++iter) { + const proto::Message *message = (*iter).get(); add_macro(message); } add_macro(_defaults.get()); } -void ConfigurationState::add_macro(const proto::Message* message) -{ +void ConfigurationState::add_macro(const proto::Message *message) { bts_assert(message); - const proto::FieldDescriptor* field_desc = message->GetDescriptor()->FindFieldByName(MESSAGE_STRING_MACRO); - if (field_desc) - { + const proto::FieldDescriptor *field_desc = + message->GetDescriptor()->FindFieldByName(MESSAGE_STRING_MACRO); + if (field_desc) { int size = message->GetReflection()->FieldSize(*message, field_desc); - for (int index = 0; index < size; index++) - { + for (int index = 0; index < size; index++) { // read "name" and "expression" fields - const proto::Message& meta_message = message->GetReflection()->GetRepeatedMessage(*message, field_desc, index); - const proto::FieldDescriptor* name_desc = meta_message.GetDescriptor()->FindFieldByName("name"); - const std::string name = '$' + meta_message.GetReflection()->GetString(meta_message, name_desc); + const proto::Message &meta_message = + message->GetReflection()->GetRepeatedMessage( + *message, field_desc, index); + const proto::FieldDescriptor *name_desc = + meta_message.GetDescriptor()->FindFieldByName("name"); + const std::string name = '$' + meta_message.GetReflection()->GetString( + meta_message, name_desc); - const proto::FieldDescriptor* exp_desc = meta_message.GetDescriptor()->FindFieldByName("expression"); - const std::string expression = meta_message.GetReflection()->GetString(meta_message, exp_desc); - - if (_macros.find(name) == _macros.end()) - { + const proto::FieldDescriptor *exp_desc = + meta_message.GetDescriptor()->FindFieldByName("expression"); + const std::string expression = + meta_message.GetReflection()->GetString(meta_message, exp_desc); + + if (_macros.find(name) == _macros.end()) { // eval expression to Value - //expression::Value result = _rule_engine.eval_to_value(expression); + // expression::Value result = + // _rule_engine.eval_to_value(expression); _macros[name] = expression; } } } } -expression::Value ConfigurationState::get_macro(const std::string& name) -{ +expression::Value ConfigurationState::get_macro(const std::string &name) { map::iterator iter = _macros.find(name); if (iter == _macros.end()) { std::string error = std::string("Macro '") + name + "' is undefined"; @@ -302,26 +301,33 @@ expression::Value ConfigurationState::get_macro(const std::string& name) return _rule_engine.eval_to_value(iter->second); } -std::string ConfigurationState::get_macro_string(const std::string& name) { +std::string ConfigurationState::get_macro_string(const std::string &name) { try { expression::Value result = get_macro(name); return expression::value_to_string(result); + } catch (const ConfigurationException &e) { + return e.what(); } - catch (const ConfigurationException& e) { return e.what(); } } -void check_rule(proto::Message* message, expression::ExpressionEvaluator& rule_engine) { - const proto::Reflection* reflection = message->GetReflection(); - const proto::Descriptor* descriptor = message->GetDescriptor(); +void check_rule( + proto::Message *message, expression::ExpressionEvaluator &rule_engine) { + const proto::Reflection *reflection = message->GetReflection(); + const proto::Descriptor *descriptor = message->GetDescriptor(); for (int findex = 0; findex < descriptor->field_count(); ++findex) { - const proto::FieldDescriptor* field = descriptor->field(findex); + const proto::FieldDescriptor *field = descriptor->field(findex); if (field->is_repeated()) { int field_size = reflection->FieldSize(*message, field); for (int index = 0; index < field_size; ++index) { - const proto::Message& field_message = reflection->GetRepeatedMessage(*message, field, index); - const proto::FieldDescriptor* rule_descriptor = field_message.GetDescriptor()->FindFieldByName(MESSAGE_STRING_RULE); + const proto::Message &field_message = + reflection->GetRepeatedMessage(*message, field, index); + const proto::FieldDescriptor *rule_descriptor = + field_message.GetDescriptor()->FindFieldByName( + MESSAGE_STRING_RULE); if (rule_descriptor) { // Macros don't have rules - const std::string rule = field_message.GetReflection()->GetString(field_message, rule_descriptor); + const std::string rule = + field_message.GetReflection()->GetString( + field_message, rule_descriptor); rule_engine.eval(rule); } } @@ -331,19 +337,18 @@ void check_rule(proto::Message* message, expression::ExpressionEvaluator& rule_e void ConfigurationState::check_rules() { initialize(); - std::vector > :: iterator iter; - for (iter = _config_chain.begin(); iter != _config_chain.end(); ++iter) - { - proto::Message* message = (*iter).get(); + std::vector>::iterator iter; + for (iter = _config_chain.begin(); iter != _config_chain.end(); ++iter) { + proto::Message *message = (*iter).get(); check_rule(message, _rule_engine); } check_rule(_defaults.get(), _rule_engine); } -void ConfigurationState::initialize_settings() -{ +void ConfigurationState::initialize_settings() { std::lock_guard lock(_initialization_mutex); - if (_is_initialized) return; + if (_is_initialized) + return; ConfigLog log; initialize_defaults(log); @@ -351,16 +356,12 @@ void ConfigurationState::initialize_settings() std::string settings = settings_path(); std::string fallback = get_command_argument("-ConfigFallback"); - DEFER(// Do this even if load() fails - initialize_builtins(); - initialize_macros(); - _deferred_queue->process(); - ); + DEFER( // Do this even if load() fails + initialize_builtins(); initialize_macros(); _deferred_queue->process();); load(settings, fallback, log); } -void ConfigurationState::reset() -{ +void ConfigurationState::reset() { std::lock_guard lock(_initialization_mutex); _config_chain.clear(); @@ -375,30 +376,34 @@ void ConfigurationState::reset() _port = 80; } -int ConfigurationState::load(const std::string& url, const std::string& fallback_url, IConfigLog& log) -{ +int ConfigurationState::load( + const std::string &url, const std::string &fallback_url, IConfigLog &log) { std::shared_ptr new_message(_prototype->New()); bool loaded = false; try { - loaded = load_message(url, *new_message.get(), log, *_deferred_queue.get()); - } - catch(ServerUnreachableException&) { + loaded = + load_message(url, *new_message.get(), log, *_deferred_queue.get()); + } catch (ServerUnreachableException &) { if (fallback_url.empty()) { throw; } } - if (!loaded && !fallback_url.empty()) - { + if (!loaded && !fallback_url.empty()) { std::string message = "Failed to load: " + url + " using fallback."; log.warning(message); - loaded = load_message(fallback_url, *new_message.get(), log, *_deferred_queue.get()); - if (_host.empty() || _host == "localhost") { tie(_host, _port) = hostname(fallback_url); } + loaded = load_message( + fallback_url, *new_message.get(), log, *_deferred_queue.get()); + if (_host.empty() || _host == "localhost") { + tie(_host, _port) = hostname(fallback_url); + } } - if (_host.empty() || _host == "localhost") { tie(_host, _port) = hostname(url); } - if (!loaded) return 0; - + if (_host.empty() || _host == "localhost") { + tie(_host, _port) = hostname(url); + } + if (!loaded) + return 0; std::string include = get_include(*new_message.get()); std::string fallback = get_fallback(*new_message.get()); @@ -407,23 +412,25 @@ int ConfigurationState::load(const std::string& url, const std::string& fallback _config_chain.push_back(new_message); // Recursively load includes - if (!include.empty()) - { + if (!include.empty()) { return 1 + load(include, fallback, log); } return 1; } -int ConfigurationState::load_string(const std::string& values, bool print_errors) -{ +int ConfigurationState::load_string( + const std::string &values, bool print_errors) { ConfigLog log; log.set_print_errors(print_errors); initialize_defaults(log); std::shared_ptr new_message(_prototype->New()); - proto::io::ArrayInputStream input_stream(values.c_str(), (int)values.length()); - parse_stream("test string", input_stream, *new_message.get(), log, *_deferred_queue.get()); + proto::io::ArrayInputStream input_stream( + values.c_str(), (int)values.length()); + parse_stream( + "test string", input_stream, *new_message.get(), log, + *_deferred_queue.get()); std::string include = get_include(*new_message.get()); std::string fallback = get_fallback(*new_message.get()); @@ -431,8 +438,7 @@ int ConfigurationState::load_string(const std::string& values, bool print_errors _config_chain.push_back(new_message); int count = 0; - if (!include.empty()) - { + if (!include.empty()) { count += load(include, fallback, log); } @@ -446,15 +452,16 @@ int ConfigurationState::load_string(const std::string& values, bool print_errors return 1 + count; } -void ConfigurationState::add_metadata_field(proto::FileDescriptorProto* file_dp, proto::DescriptorProto* message_dp, const proto::Descriptor* base_field, int index) -{ +void ConfigurationState::add_metadata_field( + 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(); + proto::DescriptorProto *meta_message = file_dp->add_message_type(); std::string meta_name = base_field->name() + "meta"; meta_message->set_name(meta_name); - + // Add 'rule' - proto::FieldDescriptorProto* rule_field = meta_message->add_field(); + proto::FieldDescriptorProto *rule_field = meta_message->add_field(); rule_field->set_name(MESSAGE_STRING_RULE); rule_field->set_number(1); rule_field->set_type(proto::FieldDescriptorProto_Type_TYPE_STRING); @@ -462,14 +469,14 @@ void ConfigurationState::add_metadata_field(proto::FileDescriptorProto* file_dp, rule_field->set_default_value("true"); // Add 'value' - proto::FieldDescriptorProto* value_field = meta_message->add_field(); + proto::FieldDescriptorProto *value_field = meta_message->add_field(); value_field->set_name(MESSAGE_STRING_VALUE); value_field->set_number(2); value_field->set_type_name(base_field->full_name()); value_field->set_label(proto::FieldDescriptorProto_Label_LABEL_REQUIRED); - + // Now add a field to message_dp of that type - proto::FieldDescriptorProto* field_desc = message_dp->add_field(); + proto::FieldDescriptorProto *field_desc = message_dp->add_field(); field_desc->set_name(base_field->name()); field_desc->set_number(index); field_desc->set_type_name(meta_name); @@ -477,47 +484,48 @@ void ConfigurationState::add_metadata_field(proto::FileDescriptorProto* file_dp, } // Construct a new Message that describes the save file format -// This can then be used with google::protobuf::TextFormat to load and save files -void ConfigurationState::generate_all_config_proto(IConfigLog& log) -{ - const char* bts_config_classname = "__BTSConfig"; +// This can then be used with google::protobuf::TextFormat to load and save +// files +void ConfigurationState::generate_all_config_proto(IConfigLog &log) { + const char *bts_config_classname = "__BTSConfig"; int field_number = 0; proto::FileDescriptorProto bts_config_dp; bts_config_dp.set_name("config.proto"); - proto::DescriptorProto* config_message = bts_config_dp.add_message_type(); + proto::DescriptorProto *config_message = bts_config_dp.add_message_type(); config_message->set_name(bts_config_classname); // Add the 'include' field - proto::FieldDescriptorProto* include_field = config_message->add_field(); + proto::FieldDescriptorProto *include_field = config_message->add_field(); include_field->set_name(MESSAGE_STRING_INCLUDE); include_field->set_number(++field_number); include_field->set_type(proto::FieldDescriptorProto_Type_TYPE_STRING); include_field->set_label(proto::FieldDescriptorProto_Label_LABEL_OPTIONAL); // Add the 'fallback' field - proto::FieldDescriptorProto* backup_field = config_message->add_field(); + proto::FieldDescriptorProto *backup_field = config_message->add_field(); backup_field->set_name(MESSAGE_STRING_INCLUDE_BACKUP); backup_field->set_number(++field_number); backup_field->set_type(proto::FieldDescriptorProto_Type_TYPE_STRING); backup_field->set_label(proto::FieldDescriptorProto_Label_LABEL_OPTIONAL); // Add 'macro' message type - proto::DescriptorProto* macro_message = bts_config_dp.add_message_type(); + proto::DescriptorProto *macro_message = bts_config_dp.add_message_type(); macro_message->set_name(MESSAGE_STRING_MACRO_TYPE); - proto::FieldDescriptorProto* name_field = macro_message->add_field(); + proto::FieldDescriptorProto *name_field = macro_message->add_field(); name_field->set_name("name"); name_field->set_number(1); name_field->set_type(proto::FieldDescriptorProto_Type_TYPE_STRING); name_field->set_label(proto::FieldDescriptorProto_Label_LABEL_REQUIRED); - proto::FieldDescriptorProto* expression_field = macro_message->add_field(); + proto::FieldDescriptorProto *expression_field = macro_message->add_field(); expression_field->set_name("expression"); expression_field->set_number(2); expression_field->set_type(proto::FieldDescriptorProto_Type_TYPE_STRING); - expression_field->set_label(proto::FieldDescriptorProto_Label_LABEL_REQUIRED); + expression_field->set_label( + proto::FieldDescriptorProto_Label_LABEL_REQUIRED); // add 'macro' message field - proto::FieldDescriptorProto* macro_field = config_message->add_field(); + proto::FieldDescriptorProto *macro_field = config_message->add_field(); macro_field->set_name(MESSAGE_STRING_MACRO); macro_field->set_number(++field_number); macro_field->set_type(proto::FieldDescriptorProto_Type_TYPE_MESSAGE); @@ -526,169 +534,176 @@ void ConfigurationState::generate_all_config_proto(IConfigLog& log) // add a meta type and field for each generated message proto::DescriptorPool::generated_pool(); - for (size_t x = 0; x < BTS_ARRAYSIZE(config_proto_files); x++) - { - std::string proto_path = "lib/config/protos/"; + for (size_t x = 0; x < BTS_ARRAYSIZE(config_proto_files); x++) { + std::string proto_path = "lib/config/protos/"; proto_path += config_proto_files[x]; - const proto::FileDescriptor* file_desc = proto::DescriptorPool::generated_pool()->FindFileByName(proto_path); - if (file_desc != nullptr) - { + const proto::FileDescriptor *file_desc = + proto::DescriptorPool::generated_pool()->FindFileByName(proto_path); + if (file_desc != nullptr) { bts_config_dp.add_dependency(file_desc->name()); - for (int y=0; y < file_desc->message_type_count(); y++) - { - const proto::Descriptor* message_desc = file_desc->message_type(y); - add_metadata_field(&bts_config_dp, config_message, message_desc, ++field_number); + for (int y = 0; y < file_desc->message_type_count(); y++) { + const proto::Descriptor *message_desc = file_desc->message_type(y); + add_metadata_field( + &bts_config_dp, config_message, message_desc, ++field_number); } - } - else - { - #ifdef WIN32 + } else { +#ifdef WIN32 // on linux the linker might throw away config protos that // are not used in sparkd. On windows we build a dll so that // should not happen throw InvalidDescriptorException(config_proto_files[x]); - #endif +#endif } } - + // Generate a proper FileDesctiptor from the FileDescriptorProto // The newly created descriptors live in the pool - _dynamic_pool.reset(new proto::DescriptorPool(proto::DescriptorPool::generated_pool())); + _dynamic_pool.reset( + new proto::DescriptorPool(proto::DescriptorPool::generated_pool())); ConfigErrorCollector errors(log, ""); - const proto::FileDescriptor* file_desc = _dynamic_pool->BuildFileCollectingErrors(bts_config_dp, &errors); + const proto::FileDescriptor *file_desc = + _dynamic_pool->BuildFileCollectingErrors(bts_config_dp, &errors); if (!file_desc) { std::string error_message = errors.ToString(); if (!error_message.empty()) { bts_assert_msg(file_desc, error_message); } else { - bts_assert_msg(false, "Config: error building parser message. No errors logged by protobuf library.\n This could mean you have defined 2 config keys with the same name. Unfortunately that's all I know."); + bts_assert_msg( + false, + "Config: error building parser message. No errors logged by " + "protobuf library.\n This could mean you have defined 2 config " + "keys with the same name. Unfortunately that's all I know."); } } - const proto::Descriptor* bts_config_desc = file_desc->FindMessageTypeByName(bts_config_classname); - + const proto::Descriptor *bts_config_desc = + file_desc->FindMessageTypeByName(bts_config_classname); + _prototype_factory.reset(new proto::DynamicMessageFactory()); _prototype_factory->SetDelegateToGeneratedFactory(true); _prototype = _prototype_factory->GetPrototype(bts_config_desc); } -bool is_valid_key_descriptor(const proto::Descriptor* property_desc) -{ +bool is_valid_key_descriptor(const proto::Descriptor *property_desc) { std::string file_name = property_desc->file()->name(); size_t file_name_start = file_name.find_last_of('/') + 1; file_name = file_name.substr(file_name_start); - for (size_t x = 0; x < BTS_ARRAYSIZE(config_proto_files); x++) - { + for (size_t x = 0; x < BTS_ARRAYSIZE(config_proto_files); x++) { std::string proto_name = config_proto_files[x]; - if (boost::iequals(file_name, proto_name)) - { + if (boost::iequals(file_name, proto_name)) { return true; } } return false; } -const proto::Message* ConfigurationState::try_get_message(const std::string& property_name) -{ +const proto::Message * +ConfigurationState::try_get_message(const std::string &property_name) { initialize_settings(); - const proto::Message* message; + const proto::Message *message; // Iterate through the loaded files - std::vector > :: iterator iter; - for (iter = _config_chain.begin(); iter != _config_chain.end(); ++iter) - { + std::vector>::iterator iter; + for (iter = _config_chain.begin(); iter != _config_chain.end(); ++iter) { message = try_get_value(property_name, **iter); - if (message) - { + if (message) { return message; } } // Fall back to defaults message = try_get_value(property_name, *_defaults.get()); - if (message) - { + if (message) { return message; } return nullptr; } -const proto::Message* ConfigurationState::try_get_message_or_default(const std::string& property_name) { +const proto::Message *ConfigurationState::try_get_message_or_default( + const std::string &property_name) { const auto pmsg = try_get_message(property_name); if (pmsg) { return pmsg; } // If we can't find a value we should return a default instance - const auto* descriptor = get_descriptor_by_name(property_name); + const auto *descriptor = get_descriptor_by_name(property_name); if (descriptor) { - return proto::MessageFactory::generated_factory()->GetPrototype(descriptor); + return proto::MessageFactory::generated_factory()->GetPrototype( + descriptor); } return nullptr; } -const proto::Message& ConfigurationState::get_message(const proto::Descriptor* property_desc) -{ - if (!is_valid_key_descriptor(property_desc)) - { +const proto::Message & +ConfigurationState::get_message(const proto::Descriptor *property_desc) { + if (!is_valid_key_descriptor(property_desc)) { throw InvalidKeyException(property_desc->name().c_str()); } - - const proto::Message* message = try_get_message(property_desc->name()); - if (!message) - { + + const proto::Message *message = try_get_message(property_desc->name()); + if (!message) { // Get the message prototype - will only have compiled in defaults - message = proto::MessageFactory::generated_factory()->GetPrototype(property_desc); + message = proto::MessageFactory::generated_factory()->GetPrototype( + property_desc); } return *message; } -const proto::Message* ConfigurationState::try_get_value(const std::string& field_name, const proto::Message& message) const -{ +const proto::Message *ConfigurationState::try_get_value( + const std::string &field_name, const proto::Message &message) const { // 1) Get the metadata descriptor - const proto::Descriptor* message_desc = message.GetDescriptor(); - const proto::FieldDescriptor* meta_desc = message_desc->FindFieldByName(field_name); - if (meta_desc) - { + const proto::Descriptor *message_desc = message.GetDescriptor(); + const proto::FieldDescriptor *meta_desc = + message_desc->FindFieldByName(field_name); + if (meta_desc) { // 2) Get the repeated metadata int meta_size = message.GetReflection()->FieldSize(message, meta_desc); - for (int index = 0; index < meta_size; index++) - { + for (int index = 0; index < meta_size; index++) { // 3) Iterate over repeated field and check rule - const proto::Message& meta_message = message.GetReflection()->GetRepeatedMessage(message, meta_desc, index); - const proto::FieldDescriptor* rule_desc = meta_message.GetDescriptor()->FindFieldByName(MESSAGE_STRING_RULE); - const std::string rule = meta_message.GetReflection()->GetString(meta_message, rule_desc); + const proto::Message &meta_message = + message.GetReflection()->GetRepeatedMessage( + message, meta_desc, index); + const proto::FieldDescriptor *rule_desc = + meta_message.GetDescriptor()->FindFieldByName(MESSAGE_STRING_RULE); + const std::string rule = + meta_message.GetReflection()->GetString(meta_message, rule_desc); - if (_rule_engine.eval(rule)) - { - // 4) return value - const proto::FieldDescriptor* value_desc = meta_message.GetDescriptor()->FindFieldByName(MESSAGE_STRING_VALUE); - const proto::Message& message_value = meta_message.GetReflection()->GetMessage(meta_message, value_desc, proto::MessageFactory::generated_factory()); - return &message_value; - } - else - { + if (_rule_engine.eval(rule)) { + // 4) return value + const proto::FieldDescriptor *value_desc = + meta_message.GetDescriptor()->FindFieldByName( + MESSAGE_STRING_VALUE); + const proto::Message &message_value = + meta_message.GetReflection()->GetMessage( + meta_message, value_desc, + proto::MessageFactory::generated_factory()); + return &message_value; + } else { // TODO: Consider a rule result cache // pro: faster lookups after first parse - // con: right now config is read only and perfectly parallel after load + // con: right now config is read only and perfectly parallel after + // load } } } return nullptr; } -const google::protobuf::Descriptor* ConfigurationState::get_descriptor_by_name(const std::string& name) { - const proto::Message* pmsg = _defaults.get(); +const google::protobuf::Descriptor * +ConfigurationState::get_descriptor_by_name(const std::string &name) { + const proto::Message *pmsg = _defaults.get(); if (pmsg) { // Get the metadata descriptor (Meta = rule+value fields) - const proto::Descriptor* desc = pmsg->GetDescriptor(); - const proto::FieldDescriptor* meta_desc = desc->FindFieldByName(name); + const proto::Descriptor *desc = pmsg->GetDescriptor(); + const proto::FieldDescriptor *meta_desc = desc->FindFieldByName(name); if (meta_desc) { // Find the "value" field descriptor - const proto::Descriptor* pmsg_desc = meta_desc->message_type(); - const proto::FieldDescriptor* value_desc = pmsg_desc->FindFieldByName(MESSAGE_STRING_VALUE); + const proto::Descriptor *pmsg_desc = meta_desc->message_type(); + const proto::FieldDescriptor *value_desc = + pmsg_desc->FindFieldByName(MESSAGE_STRING_VALUE); if (value_desc) { // return it's type return value_desc->message_type(); @@ -698,48 +713,39 @@ const google::protobuf::Descriptor* ConfigurationState::get_descriptor_by_name(c return nullptr; } -PathType::type get_path_type(std::string path) -{ - if (path.find("://") != std::string::npos) - { +PathType::type get_path_type(std::string path) { + if (path.find("://") != std::string::npos) { return PathType::directory; - //const char last_char = path.at(path.length()-1); - //return last_char == '/' ? PathType::directory : PathType::file; - } - else - { - if (boost::filesystem::is_directory(path)) - { + // const char last_char = path.at(path.length()-1); + // return last_char == '/' ? PathType::directory : PathType::file; + } else { + if (boost::filesystem::is_directory(path)) { return PathType::directory; - } - else if (boost::filesystem::exists(path)) - { + } else if (boost::filesystem::exists(path)) { return PathType::file; - } - else - { + } else { return PathType::not_found; } } } -urdl::url url_from_string(std::string& path, bool required) -{ +urdl::url url_from_string(std::string &path, bool required) { boost::system::error_code ec; - // attempt to parse the path as a URL - if that fails assume it is an absolute file path and append file:/// + // attempt to parse the path as a URL - if that fails assume it is an + // absolute file path and append file:/// urdl::url url = urdl::url::from_string(path, ec); - if (ec) - { + if (ec) { std::string file_prefix = "file:///"; std::string abs_path = boost::filesystem::absolute(path).string(); - url = urdl::url::from_string(file_prefix + os::normalize_path(abs_path), ec); + url = urdl::url::from_string( + file_prefix + os::normalize_path(abs_path), ec); } bts_assert_msg(!required || !ec, ec.message().c_str()); return url; } -inline tuple hostname(const std::string& path) { +inline tuple hostname(const std::string &path) { boost::system::error_code ec; string host; uint32_t port = 80; @@ -761,24 +767,26 @@ inline tuple hostname(const std::string& path) { } // If we are still empty return "localhost" - if (host.empty()) host = "localhost"; + if (host.empty()) + host = "localhost"; return std::make_tuple(host, port); } // Loads a single message file or directory -bool load_message(std::string url, proto::Message& out_message, IConfigLog& log, ConfigValueQueue& lookup) -{ +bool load_message( + std::string url, proto::Message &out_message, IConfigLog &log, + ConfigValueQueue &lookup) { ConfigDownloader downloader; bool result = false; - switch(get_path_type(url)) - { + switch (get_path_type(url)) { case PathType::directory: result = load_directory(url, downloader, out_message, log, lookup) > 0; break; case PathType::file: - result = load_file(url, downloader, out_message, log, lookup) == ConfigDownloader::SUCCESS; + result = load_file(url, downloader, out_message, log, lookup) == + ConfigDownloader::SUCCESS; break; default: std::ostringstream error; @@ -792,55 +800,64 @@ bool load_message(std::string url, proto::Message& out_message, IConfigLog& log, return result; } -int load_directory(std::string url, ConfigDownloader& downloader, proto::Message& out_message, IConfigLog& log, ConfigValueQueue& lookup) -{ +int load_directory( + std::string url, ConfigDownloader &downloader, proto::Message &out_message, + IConfigLog &log, ConfigValueQueue &lookup) { LogAggregator aggregate_log(log); aggregate_log.info("URL: " + url); - const char last_char = url.at(url.length()-1); + const char last_char = url.at(url.length() - 1); if (last_char != '/') { url = url + '/'; } - - // If a file called "all" exists in the config directory we can short circuit ~60 http requests - ConfigDownloader::Result all_result = load_file(url + ".all", downloader, out_message, aggregate_log, lookup, false); + + // If a file called "all" exists in the config directory we can short circuit + // ~60 http requests + ConfigDownloader::Result all_result = load_file( + url + ".all", downloader, out_message, aggregate_log, lookup, false); if (all_result == ConfigDownloader::SUCCESS) { log.info(aggregate_log.text()); return 1; } - + // load spark.conf int load_count = 0; - ConfigDownloader::Result result = load_file(url + "spark.conf", downloader, out_message, aggregate_log, lookup, false); - if (result == ConfigDownloader::SUCCESS) - { + ConfigDownloader::Result result = load_file( + url + "spark.conf", downloader, out_message, aggregate_log, lookup, + false); + if (result == ConfigDownloader::SUCCESS) { load_count++; - } - else if (result == ConfigDownloader::PERMANENT_FAILURE) { - // If the server is down it doesn't make sense to suffer though the timeouts for the other files + } else if (result == ConfigDownloader::PERMANENT_FAILURE) { + // If the server is down it doesn't make sense to suffer though the + // timeouts for the other files throw ServerUnreachableException(url.c_str()); } bool edge_has_include = !get_include(out_message).empty(); - for(const char* proto_file: config_proto_files) - { + for (const char *proto_file : config_proto_files) { std::string config_file(proto_file); - if (config_file == "system.proto") continue; - if (config_file == "edge.proto") continue; + if (config_file == "system.proto") + continue; + if (config_file == "edge.proto") + continue; const char proto_ext[] = ".proto"; const char conf_ext[] = ".conf"; size_t extension_pos = config_file.rfind(proto_ext); // path_to_config_proto/foo.proto => foo.conf - config_file.replace(extension_pos, sizeof(proto_ext), conf_ext, sizeof(conf_ext)); - boost::filesystem::path p (config_file); - config_file = p.filename ().string (); - if (load_file(url + config_file, downloader, out_message, aggregate_log, lookup, false)) - { + config_file.replace( + extension_pos, sizeof(proto_ext), conf_ext, sizeof(conf_ext)); + boost::filesystem::path p(config_file); + config_file = p.filename().string(); + if (load_file( + url + config_file, downloader, out_message, aggregate_log, lookup, + false)) { load_count++; if (!edge_has_include) { - bts_assert_msg(get_include(out_message).empty(), "Includes may only be specified in spark.conf"); + bts_assert_msg( + get_include(out_message).empty(), + "Includes may only be specified in spark.conf"); } // NOTE: This code allows any config key to go in any .conf file @@ -854,8 +871,9 @@ int load_directory(std::string url, ConfigDownloader& downloader, proto::Message return load_count; } -ConfigDownloader::Result load_file(std::string path, ConfigDownloader& downloader, proto::Message& out_message, IConfigLog& log, ConfigValueQueue& lookup, bool required) -{ +ConfigDownloader::Result load_file( + 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); @@ -872,8 +890,9 @@ ConfigDownloader::Result load_file(std::string path, ConfigDownloader& downloade return result; } -void parse_stream(const std::string& file, proto::io::ZeroCopyInputStream& input_stream, proto::Message& out_message, IConfigLog& log, ConfigValueQueue& lookup) -{ +void parse_stream( + 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); @@ -881,32 +900,31 @@ void parse_stream(const std::string& file, proto::io::ZeroCopyInputStream& input lookup.set_filename(file); parser.AllowPartialMessage(true); bool success = parser.Parse(&input_stream, &out_message); - if (!success) - { + if (!success) { std::string error_message = error_collector.ToString(); log.error(error_message); throw ConfigurationException(error_message); } } -std::string get_field(const proto::Message& message, const char* name) -{ - const proto::Descriptor* message_descriptor = message.GetDescriptor(); - const proto::FieldDescriptor* include_field = message_descriptor->FindFieldByName(name); - const std::string include = message.GetReflection()->GetString(message, include_field); +std::string get_field(const proto::Message &message, const char *name) { + const proto::Descriptor *message_descriptor = message.GetDescriptor(); + const proto::FieldDescriptor *include_field = + message_descriptor->FindFieldByName(name); + const std::string include = + message.GetReflection()->GetString(message, include_field); return include; } -std::string get_include(const proto::Message& message) -{ +std::string get_include(const proto::Message &message) { return get_field(message, MESSAGE_STRING_INCLUDE); } -std::string get_fallback(const proto::Message& message) -{ +std::string get_fallback(const proto::Message &message) { return get_field(message, MESSAGE_STRING_INCLUDE_BACKUP); } -}}}//end namespaces - +} // namespace internal +} // namespace config +} // namespace bts diff --git a/src/lib/config/ConfigurationState.h b/src/lib/config/ConfigurationState.h old mode 100755 new mode 100644 index 440c16e14..b5527017c --- a/src/lib/config/ConfigurationState.h +++ b/src/lib/config/ConfigurationState.h @@ -1,39 +1,39 @@ #ifndef CONFIGURATIONSTATE_H_ #define CONFIGURATIONSTATE_H_ -#include "ConfigurationException.h" +#include "ConfigDownloader.h" #include "ConfigLog.h" +#include "ConfigurationException.h" #include "lib/expression/ExpressionEvaluator.h" #include "lib/expression/Value.h" -#include "ConfigDownloader.h" -#include #include "text_format/text_format.h" -#include +#include #include +#include #include -#include #include +#include #include #include - namespace google { - namespace protobuf { - class Message; - class DescriptorPool; - class DynamicMessageFactory; - class Descriptor; - class FileDescriptorProto; - class DescriptorProto; - } -} +namespace protobuf { +class Message; +class DescriptorPool; +class DynamicMessageFactory; +class Descriptor; +class FileDescriptorProto; +class DescriptorProto; +} // namespace protobuf +} // namespace google namespace bts { namespace config { - class System; -}} +class System; +} +} // namespace bts namespace proto = google::protobuf; @@ -41,81 +41,95 @@ namespace bts { namespace config { namespace internal { - class ConfigPropertyEvaluator; - class ConfigValueQueue; +class ConfigPropertyEvaluator; +class ConfigValueQueue; - class ConfigurationState - { - public: - ConfigurationState(void); - ~ConfigurationState(void); +class ConfigurationState { + public: + ConfigurationState(void); + ~ConfigurationState(void); - void initialize_defaults(IConfigLog& log); - void initialize_settings(); - - int load(const std::string& url, const std::string& fallback, IConfigLog&); - int load_string(const std::string& values, bool print_errors=false); - void reset(); + void initialize_defaults(IConfigLog &log); + void initialize_settings(); - const proto::Message& get_message(const proto::Descriptor* property_desc); - const proto::Message* try_get_message(const std::string& property_name); - const proto::Message* try_get_message_or_default(const std::string& property_name); - - bool is_initialized() { return _is_initialized; } + int load(const std::string &url, const std::string &fallback, IConfigLog &); + int load_string(const std::string &values, bool print_errors = false); + void reset(); - expression::Value get_macro(const std::string& name); - std::string get_macro_string(const std::string& name); + const proto::Message &get_message(const proto::Descriptor *property_desc); + const proto::Message *try_get_message(const std::string &property_name); + const proto::Message * + try_get_message_or_default(const std::string &property_name); - void check_rules(); + bool is_initialized() { return _is_initialized; } - const google::protobuf::Descriptor* get_descriptor_by_name(const std::string& name); + expression::Value get_macro(const std::string &name); + std::string get_macro_string(const std::string &name); - private: - BTS_NO_COPY(ConfigurationState); + void check_rules(); - void initialize_builtins(); - void initialize_introspection(); - 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); - void generate_all_config_proto(IConfigLog&); - const proto::Message* try_get_value(const std::string& field_name, const proto::Message& message) const; + const google::protobuf::Descriptor * + get_descriptor_by_name(const std::string &name); - std::string settings_path(); + private: + BTS_NO_COPY(ConfigurationState); - bool _is_initialized; - std::recursive_mutex _initialization_mutex; - - boost::scoped_ptr _dynamic_pool; - boost::scoped_ptr _prototype_factory; - const proto::Message* _prototype; // owned by prototype_factory - std::vector > _config_chain; - std::shared_ptr _defaults; + void initialize_builtins(); + void initialize_introspection(); + 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); + void generate_all_config_proto(IConfigLog &); + const proto::Message *try_get_value( + const std::string &field_name, const proto::Message &message) const; - std::shared_ptr _properties; - expression::ExpressionEvaluator _rule_engine; - std::map _macros; - std::shared_ptr _deferred_queue; + std::string settings_path(); - // ConfigLog _log; - std::string _host; - uint32_t _port; - }; + bool _is_initialized; + std::recursive_mutex _initialization_mutex; - std::string get_include(const proto::Message& messages); - std::string get_fallback(const proto::Message& message); - - struct PathType { - enum type { not_found, file, directory }; - }; - PathType::type get_path_type(std::string path); + boost::scoped_ptr _dynamic_pool; + boost::scoped_ptr _prototype_factory; + const proto::Message *_prototype; // owned by prototype_factory + std::vector> _config_chain; + std::shared_ptr _defaults; - // 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&, ConfigValueQueue&); - int load_directory(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); - void parse_stream(const std::string& file, proto::io::ZeroCopyInputStream& stream, proto::Message& out_message, IConfigLog&, ConfigValueQueue& lookup); + std::shared_ptr _properties; + expression::ExpressionEvaluator _rule_engine; + std::map _macros; + std::shared_ptr _deferred_queue; -}}} + // ConfigLog _log; + std::string _host; + uint32_t _port; +}; + +std::string get_include(const proto::Message &messages); +std::string get_fallback(const proto::Message &message); + +struct PathType { + enum type { not_found, file, directory }; +}; +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 &, + ConfigValueQueue &); +int load_directory( + 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); +void parse_stream( + const std::string &file, proto::io::ZeroCopyInputStream &stream, + proto::Message &out_message, IConfigLog &, ConfigValueQueue &lookup); + +} // namespace internal +} // namespace config +} // namespace bts #endif diff --git a/src/lib/config/PreprocessInputStream.cpp b/src/lib/config/PreprocessInputStream.cpp old mode 100755 new mode 100644 index fbaa5508d..54787278c --- a/src/lib/config/PreprocessInputStream.cpp +++ b/src/lib/config/PreprocessInputStream.cpp @@ -1,22 +1,23 @@ #include "PreprocessInputStream.h" -#include #include +#include using namespace std; namespace bts { namespace config { -void replace_all(string& line, const string& before, const string& after) { +void replace_all(string &line, const string &before, const string &after) { string::const_iterator end = line.end(); string::const_iterator current = line.begin(); - string::const_iterator next = search(current, end, before.begin(), before.end()); + string::const_iterator next = + search(current, end, before.begin(), before.end()); if (next != end) { std::string result; - while(next != end) { + while (next != end) { result.append(current, next); result.append(after); current = next + before.size(); @@ -27,44 +28,39 @@ void replace_all(string& line, const string& before, const string& after) { } } -PreprocessInputStream::PreprocessInputStream(std::istream& input, map replacements) : - _buffer(), - _stream() -{ +PreprocessInputStream::PreprocessInputStream( + std::istream &input, map replacements) + : _buffer(), _stream() { char temp[4096]; - while(input.read(temp, sizeof(temp))) { + while (input.read(temp, sizeof(temp))) { _buffer.append(temp, sizeof(temp)); } _buffer.append(temp, input.gcount()); - for (map::iterator iter = replacements.begin(); iter != replacements.end(); iter++) { - const string& key = iter->first; - const string& value = iter->second; + for (map::iterator iter = replacements.begin(); + iter != replacements.end(); iter++) { + const string &key = iter->first; + const string &value = iter->second; replace_all(_buffer, key, value); } - _stream.reset(new proto::io::ArrayInputStream(_buffer.c_str(), _buffer.size())); + _stream.reset( + new proto::io::ArrayInputStream(_buffer.c_str(), _buffer.size())); } -PreprocessInputStream::~PreprocessInputStream() -{ -} +PreprocessInputStream::~PreprocessInputStream() {} -bool PreprocessInputStream::Next(const void** data, int* size) { +bool PreprocessInputStream::Next(const void **data, int *size) { return _stream->Next(data, size); } -void PreprocessInputStream::BackUp(int count) { - _stream->BackUp(count); -} +void PreprocessInputStream::BackUp(int count) { _stream->BackUp(count); } -bool PreprocessInputStream::Skip(int count) { - return _stream->Skip(count); -} +bool PreprocessInputStream::Skip(int count) { return _stream->Skip(count); } proto::int64 PreprocessInputStream::ByteCount() const { return _stream->ByteCount(); } -}}//namespace - +} // namespace config +} // namespace bts diff --git a/src/lib/config/PreprocessInputStream.h b/src/lib/config/PreprocessInputStream.h old mode 100755 new mode 100644 index aad2829e0..4115f3f3f --- a/src/lib/config/PreprocessInputStream.h +++ b/src/lib/config/PreprocessInputStream.h @@ -1,34 +1,34 @@ #pragma once -#include -#include #include "lib/utils/bts_no_copy.h" +#include +#include #include -#include #include +#include namespace bts { namespace config { namespace proto = google::protobuf; -class PreprocessInputStream : public proto::io::ZeroCopyInputStream -{ -public: - PreprocessInputStream(std::istream& input, std::map replacements); +class PreprocessInputStream : public proto::io::ZeroCopyInputStream { + public: + PreprocessInputStream( + std::istream &input, std::map replacements); ~PreprocessInputStream(); - bool Next(const void** data, int* size) override; + bool Next(const void **data, int *size) override; void BackUp(int count) override; bool Skip(int count) override; proto::int64 ByteCount() const override; -private: + private: std::string _buffer; boost::scoped_ptr _stream; BTS_NO_COPY(PreprocessInputStream); }; -}}//namespace - +} // namespace config +} // namespace bts diff --git a/src/lib/config/config.cpp b/src/lib/config/config.cpp old mode 100755 new mode 100644 index 38455c881..afb413310 --- a/src/lib/config/config.cpp +++ b/src/lib/config/config.cpp @@ -6,9 +6,9 @@ #include "ConfigurationState.h" #include -#include -#include #include +#include +#include //#include @@ -23,22 +23,14 @@ internal::ConfigurationState config_state; // Public API ////////////////////////////////////////// -extern "C" BTS_EXPORT void initialize() -{ - config_state.initialize_settings(); -} +extern "C" BTS_EXPORT void initialize() { config_state.initialize_settings(); } -extern "C" BTS_EXPORT bool initialize_nothrow(char* error_message, size_t len) -{ - try - { +extern "C" BTS_EXPORT bool initialize_nothrow(char *error_message, size_t len) { + try { initialize(); - } - catch(std::exception& e) - { + } catch (std::exception &e) { std::string msg = e.what(); - if (msg.size() < len) - { + if (msg.size() < len) { os::strncpy(error_message, msg.c_str(), len); } return false; @@ -46,9 +38,9 @@ extern "C" BTS_EXPORT bool initialize_nothrow(char* error_message, size_t len) return true; } -//extern "C" -const proto::Message& get_message(const google::protobuf::Descriptor* descriptor) -{ +// extern "C" +const proto::Message & +get_message(const google::protobuf::Descriptor *descriptor) { return config_state.get_message(descriptor); } @@ -58,59 +50,55 @@ namespace interop { // Functions used for interop to other languages ///////////////////////////////////////////////// - std::string getbuffer_serialized_buffer; -extern "C" BTS_EXPORT const char* get_buffer(const char* key_name, int& out_length) -{ - google::protobuf::DescriptorPool const* pool = google::protobuf::DescriptorPool::generated_pool(); - const proto::Descriptor* message_desc = pool->FindMessageTypeByName(key_name); +extern "C" BTS_EXPORT const char * +get_buffer(const char *key_name, int &out_length) { + google::protobuf::DescriptorPool const *pool = + google::protobuf::DescriptorPool::generated_pool(); + const proto::Descriptor *message_desc = + pool->FindMessageTypeByName(key_name); - const proto::Message& message = get_message(message_desc); + const proto::Message &message = get_message(message_desc); getbuffer_serialized_buffer.clear(); message.SerializePartialToString(&getbuffer_serialized_buffer); - + out_length = getbuffer_serialized_buffer.size(); return getbuffer_serialized_buffer.c_str(); } -extern "C" BTS_EXPORT const proto::Message* get_named(const char* key_name) -{ +extern "C" BTS_EXPORT const proto::Message *get_named(const char *key_name) { return config_state.try_get_message_or_default(key_name); } -BTS_EXPORT std::string get_macro_string(const char* name) { return config_state.get_macro_string(name); } - +BTS_EXPORT std::string get_macro_string(const char *name) { + return config_state.get_macro_string(name); } +} // namespace interop + namespace internal { ////////////////////////////////////////// // Functions used in testing ////////////////////////////////////////// -extern "C" BTS_EXPORT void initialize_for_test(const char* config) { +extern "C" BTS_EXPORT void initialize_for_test(const char *config) { initialize_for_test(std::string(config), false); } -void initialize_for_test(const std::string& values, bool print_errors) -{ +void initialize_for_test(const std::string &values, bool print_errors) { config_state.reset(); config_state.load_string(values, print_errors); } -extern "C" BTS_EXPORT void reset() -{ - config_state.reset(); -} +extern "C" BTS_EXPORT void reset() { config_state.reset(); } -extern "C" BTS_EXPORT bool check_rules(char* error_msg, size_t len) { +extern "C" BTS_EXPORT bool check_rules(char *error_msg, size_t len) { try { config_state.check_rules(); - } - catch(std::exception& e) { + } catch (std::exception &e) { std::string msg = e.what(); - if (msg.size() < len) - { + if (msg.size() < len) { os::strncpy(error_msg, msg.c_str(), len); } return false; @@ -118,5 +106,7 @@ extern "C" BTS_EXPORT bool check_rules(char* error_msg, size_t len) { return true; } -}}} // end namespaces +} // namespace internal +} // namespace config +} // namespace bts #endif diff --git a/src/lib/config/config.h b/src/lib/config/config.h old mode 100755 new mode 100644 index 46f388312..279cc3bbd --- a/src/lib/config/config.h +++ b/src/lib/config/config.h @@ -7,65 +7,67 @@ #include namespace google { - namespace protobuf { - class Descriptor; - class Message; - } -} +namespace protobuf { +class Descriptor; +class Message; +} // namespace protobuf +} // namespace google // Config -// This API is intentionally kept flat and C-style to make interop from other languages simpler. +// This API is intentionally kept flat and C-style to make interop from other +// languages simpler. namespace bts { namespace config { - // Load and initialize config. - // This will be automatically called on the first key request but since loading config - // can result in network requests this function is available for applications that want to - // manage pauses in execution. - // Ex: initialize() on a background thread so that config::get() is fast on a UI thread - extern "C" BTS_EXPORT void initialize(); +// Load and initialize config. +// This will be automatically called on the first key request but since loading +// config can result in network requests this function is available for +// applications that want to manage pauses in execution. Ex: initialize() on a +// background thread so that config::get() is fast on a UI thread +extern "C" BTS_EXPORT void initialize(); - // Calls initialize() but catches any thrown exception and copies it to the provided buffer - extern "C" BTS_EXPORT bool initialize_nothrow(char* error_msg, size_t length); +// Calls initialize() but catches any thrown exception and copies it to the +// provided buffer +extern "C" BTS_EXPORT bool initialize_nothrow(char *error_msg, size_t length); - // Gets a raw message pointer from config for the given descriptor - //extern "C" - BTS_EXPORT const google::protobuf::Message& get_message(const google::protobuf::Descriptor* descriptor); +// Gets a raw message pointer from config for the given descriptor +// extern "C" +BTS_EXPORT const google::protobuf::Message & +get_message(const google::protobuf::Descriptor *descriptor); - template - const T& get() - { - const google::protobuf::Descriptor* descriptor = T::descriptor(); - const google::protobuf::Message& message = get_message(descriptor); - const T& retval = utils::checked_cast(message); - return retval; - } +template const T &get() { + const google::protobuf::Descriptor *descriptor = T::descriptor(); + const google::protobuf::Message &message = get_message(descriptor); + const T &retval = utils::checked_cast(message); + return retval; +} - namespace interop - { - // Returns a serialized protocol buffer of the given type - // The memory that this is serialized to may be re-used so you - // should imediately deserialize and copy the data. - extern "C" BTS_EXPORT const char* get_buffer(const char* key_name, int& out_length); +namespace interop { +// Returns a serialized protocol buffer of the given type +// The memory that this is serialized to may be re-used so you +// should imediately deserialize and copy the data. +extern "C" BTS_EXPORT const char * +get_buffer(const char *key_name, int &out_length); - extern "C" BTS_EXPORT const google::protobuf::Message* get_named(const char* key_name); - } +extern "C" BTS_EXPORT const google::protobuf::Message * +get_named(const char *key_name); +} // namespace interop - namespace internal - { - // Initialize configuration state from a string instead of from the filesystem. defaults.conf will still be loaded. - // Calling this a second time clears all values from previous initialization - extern "C" BTS_EXPORT void initialize_for_test(const char* config); - void initialize_for_test(const std::string& configuration, bool print_errors=true); - - // Releases all resources and returns config to factory defaults - extern "C" BTS_EXPORT void reset(); - - extern "C" BTS_EXPORT bool check_rules(char* error_msg, size_t length); - } -}} +namespace internal { +// Initialize configuration state from a string instead of from the filesystem. +// defaults.conf will still be loaded. Calling this a second time clears all +// values from previous initialization +extern "C" BTS_EXPORT void initialize_for_test(const char *config); +void initialize_for_test( + const std::string &configuration, bool print_errors = true); +// Releases all resources and returns config to factory defaults +extern "C" BTS_EXPORT void reset(); +extern "C" BTS_EXPORT bool check_rules(char *error_msg, size_t length); +} // namespace internal +} // namespace config +} // namespace bts #endif diff --git a/src/lib/config/tests/HTTPServer.cpp b/src/lib/config/tests/HTTPServer.cpp old mode 100755 new mode 100644 index 72f18ebdf..210569a96 --- a/src/lib/config/tests/HTTPServer.cpp +++ b/src/lib/config/tests/HTTPServer.cpp @@ -9,33 +9,27 @@ namespace config { namespace internal { HTTPServer::HTTPServer() - : _io_service(), - _acceptor(_io_service, tcp::endpoint(boost::asio::ip::address_v4::loopback(), 0)), - _cur_socket(), - _request_response_pairs(), - _thread(), - _done(false) -{ - -} + : _io_service(), + _acceptor( + _io_service, + tcp::endpoint(boost::asio::ip::address_v4::loopback(), 0)), + _cur_socket(), _request_response_pairs(), _thread(), _done(false) {} -unsigned int HTTPServer::port() const -{ +unsigned int HTTPServer::port() const { return _acceptor.local_endpoint().port(); } -void HTTPServer::add_response(const std::string& path, const std::string& response, const std::string& content) -{ +void HTTPServer::add_response( + const std::string &path, const std::string &response, + const std::string &content) { _request_response_pairs[path] = response + content; } -void HTTPServer::start() -{ +void HTTPServer::start() { _thread.reset(new boost::thread(boost::bind(&HTTPServer::worker, this))); } -void HTTPServer::stop() -{ +void HTTPServer::stop() { _done = true; _io_service.stop(); @@ -45,55 +39,52 @@ void HTTPServer::stop() } } - -void HTTPServer::worker() -{ +void HTTPServer::worker() { start_accept(); - + _io_service.run(); } -void HTTPServer::start_accept() -{ +void HTTPServer::start_accept() { _cur_socket.reset(new boost::asio::ip::tcp::socket(_io_service)); - _acceptor.async_accept(*_cur_socket.get(), boost::bind(&HTTPServer::handle_accept, this, _cur_socket.get(), boost::asio::placeholders::error)); + _acceptor.async_accept( + *_cur_socket.get(), + boost::bind( + &HTTPServer::handle_accept, this, _cur_socket.get(), + boost::asio::placeholders::error)); } -void HTTPServer::handle_accept(boost::asio::ip::tcp::socket* socket, const boost::system::error_code& error) -{ - if (!error) - { +void HTTPServer::handle_accept( + boost::asio::ip::tcp::socket *socket, + const boost::system::error_code &error) { + if (!error) { handle_connect(socket); } start_accept(); } -void HTTPServer::handle_connect(boost::asio::ip::tcp::socket* socket) -{ +void HTTPServer::handle_connect(boost::asio::ip::tcp::socket *socket) { boost::asio::streambuf buffer; size_t size = boost::asio::read_until(*socket, buffer, "\r\n\r\n"); std::string request(size, 0); buffer.sgetn(&request[0], size); - + size_t start = request.find("GET ") + 4; size_t end = request.find(" HTTP/1.1\r\n"); size_t url_args = request.find("?"); if (url_args != std::string::npos) end = std::min(end, url_args); - std::string request_path = request.substr(start, end-start); + std::string request_path = request.substr(start, end - start); - std::map::iterator request_match = - _request_response_pairs.find(request_path); - - if (request_match == _request_response_pairs.end()) - { + std::map::iterator request_match = + _request_response_pairs.find(request_path); + + if (request_match == _request_response_pairs.end()) { std::string response = "HTTP/1.0 404 NOT FOUND\r\n" "Content-Type: text/plain\r\n\r\n" "not found\r\n"; boost::asio::write(*socket, boost::asio::buffer(response)); - } - else - { + } else { boost::asio::write(*socket, boost::asio::buffer(request_match->second)); } @@ -102,4 +93,6 @@ void HTTPServer::handle_connect(boost::asio::ip::tcp::socket* socket) socket->close(ec); } -}}} +} // namespace internal +} // namespace config +} // namespace bts diff --git a/src/lib/config/tests/HTTPServer.h b/src/lib/config/tests/HTTPServer.h old mode 100755 new mode 100644 index a52aae5d3..971fb9999 --- a/src/lib/config/tests/HTTPServer.h +++ b/src/lib/config/tests/HTTPServer.h @@ -17,28 +17,30 @@ #include #include -#include #include +#include namespace bts { namespace config { namespace internal { -class HTTPServer -{ -public: +class HTTPServer { + public: HTTPServer(); unsigned int port() const; void start(); - void add_response(const std::string& path, const std::string& response, const std::string& content); + void add_response( + const std::string &path, const std::string &response, + const std::string &content); void stop(); -private: + private: void worker(); void start_accept(); - void handle_accept(boost::asio::ip::tcp::socket*, const boost::system::error_code& error); - void handle_connect(boost::asio::ip::tcp::socket*); + void handle_accept( + boost::asio::ip::tcp::socket *, const boost::system::error_code &error); + void handle_connect(boost::asio::ip::tcp::socket *); boost::asio::io_service _io_service; boost::asio::ip::tcp::acceptor _acceptor; @@ -46,8 +48,9 @@ private: std::map _request_response_pairs; boost::scoped_ptr _thread; bool _done; - }; -}}} // end namespace +} // namespace internal +} // namespace config +} // namespace bts #endif diff --git a/src/lib/config/tests/config_ref_tests.cpp b/src/lib/config/tests/config_ref_tests.cpp old mode 100755 new mode 100644 index cbc24635e..f5338122e --- a/src/lib/config/tests/config_ref_tests.cpp +++ b/src/lib/config/tests/config_ref_tests.cpp @@ -1,12 +1,12 @@ -#include "lib/utils/TempFile.h" #include "lib/utils/TempDir.h" +#include "lib/utils/TempFile.h" -#include "../config.h" -#include "../ConfigurationState.h" #include "../ConfigurationException.h" -#include "lib/expression/ParserExceptions.h" -#include "lib/config/protos/testkeys.pb.h" +#include "../ConfigurationState.h" +#include "../config.h" #include "lib/config/invalid/invalid.pb.h" +#include "lib/config/protos/testkeys.pb.h" +#include "lib/expression/ParserExceptions.h" #include "HTTPServer.h" #include "catch/catch.hpp" @@ -21,48 +21,42 @@ using bts::config::test::Foo; using bts::config::test::FooGroup; using bts::config::test::FooList; - namespace bts { int config_ref_tests = 0; -TEST_CASE ("Configuration Reference Tests", "[config]") { +TEST_CASE("Configuration Reference Tests", "[config]") { - SECTION("basic_value") - { - initialize_for_test( - "TestSite {" - " value {" - " name: 'ref value'" - " }" - "}" - "Foo { \n" - " value {\n" - " name: @TestSite.name" - " }\n" - "}\n" - ); - - const Foo& foo = get(); + SECTION("basic_value") { + initialize_for_test("TestSite {" + " value {" + " name: 'ref value'" + " }" + "}" + "Foo { \n" + " value {\n" + " name: @TestSite.name" + " }\n" + "}\n"); + + const Foo &foo = get(); REQUIRE(foo.name() == "ref value"); } SECTION("scalar_to_repeat") { - initialize_for_test( - "TestSite {" - " value {" - " name: 'a@example.com' " - " }" - "}" - "Foo { \n" - " value {\n" - " email: \"before@example.com\" \n" - " email: @TestSite.name \n" - " email: \"after@example.com\" \n" - " }\n" - "}\n" - ); + initialize_for_test("TestSite {" + " value {" + " name: 'a@example.com' " + " }" + "}" + "Foo { \n" + " value {\n" + " email: \"before@example.com\" \n" + " email: @TestSite.name \n" + " email: \"after@example.com\" \n" + " }\n" + "}\n"); + + const Foo &foo = get(); - const Foo& foo = get(); - REQUIRE(foo.email_size() == 3); REQUIRE(foo.email(0) == "before@example.com"); REQUIRE(foo.email(1) == "a@example.com"); @@ -70,30 +64,28 @@ TEST_CASE ("Configuration Reference Tests", "[config]") { } SECTION("repeat_to_repeat ") { - initialize_for_test( - "StringTable {" - " value {" - " entries: 'a@example.com' " - " entries: 'b@example.com' " - " }" - "}" - "TestSite {" - " value {" - " name: 'c@example.com' " - " }" - "}" - "Foo { \n" - " value {\n" - " email: \"before@example.com\" \n" - " email: @StringTable.entries \n" - " email: @TestSite.name \n" - " email: \"after@example.com\" \n" - " }\n" - "}\n" - ); + initialize_for_test("StringTable {" + " value {" + " entries: 'a@example.com' " + " entries: 'b@example.com' " + " }" + "}" + "TestSite {" + " value {" + " name: 'c@example.com' " + " }" + "}" + "Foo { \n" + " value {\n" + " email: \"before@example.com\" \n" + " email: @StringTable.entries \n" + " email: @TestSite.name \n" + " email: \"after@example.com\" \n" + " }\n" + "}\n"); + + const Foo &foo = get(); - const Foo& foo = get(); - REQUIRE(foo.email_size() == 5); REQUIRE(foo.email(0) == "before@example.com"); REQUIRE(foo.email(1) == "a@example.com"); @@ -103,91 +95,83 @@ TEST_CASE ("Configuration Reference Tests", "[config]") { } SECTION("message_value") { - initialize_for_test( - "Foo { \n" - " rule: 'false'" - " value {\n" - " name: \"bad\"\n" - " }\n" - "}\n" - "Foo { \n" - " value {\n" - " name: \"good\"\n" - " }\n" - "}\n" - "FooGroup {" - " value { " - " group: @Foo.name " - " foo: @Foo " - " }" - "}" - ); + initialize_for_test("Foo { \n" + " rule: 'false'" + " value {\n" + " name: \"bad\"\n" + " }\n" + "}\n" + "Foo { \n" + " value {\n" + " name: \"good\"\n" + " }\n" + "}\n" + "FooGroup {" + " value { " + " group: @Foo.name " + " foo: @Foo " + " }" + "}"); - const FooGroup& g = get(); + const FooGroup &g = get(); REQUIRE(g.group() == "good"); REQUIRE(g.foo().name() == "good"); } SECTION("nested_message_value") { - initialize_for_test( - "NamedFoo { \n" - " value {\n" - " key: 'good foo' " - " foo { " - " name: \"good\"\n" - " }" - " }\n" - "}\n" - "FooGroup {" - " value { " - " group: @NamedFoo.key " - " foo: @NamedFoo.foo " - " }" - "}" - ); + initialize_for_test("NamedFoo { \n" + " value {\n" + " key: 'good foo' " + " foo { " + " name: \"good\"\n" + " }" + " }\n" + "}\n" + "FooGroup {" + " value { " + " group: @NamedFoo.key " + " foo: @NamedFoo.foo " + " }" + "}"); - const FooGroup& g = get(); + const FooGroup &g = get(); REQUIRE(g.group() == "good foo"); REQUIRE(g.foo().name() == "good"); } SECTION("macro_value") { - initialize_for_test( - "macro {" - " name: 'macro1' " - " expression: \"'m1'\" " - "}" - "Foo { \n" - " value {\n" - " name: $macro1" - " }\n" - "}\n" - ); - - const Foo& foo = get(); + initialize_for_test("macro {" + " name: 'macro1' " + " expression: \"'m1'\" " + "}" + "Foo { \n" + " value {\n" + " name: $macro1" + " }\n" + "}\n"); + + const Foo &foo = get(); REQUIRE(foo.name() == "m1"); } SECTION("enum_value") { - initialize_for_test( - "ConsoleColor {" - " value {" - " color: Blue " - " }" - "}" - "ConsoleColors {" - " value {" - " color: @ConsoleColor.color" - " colors: Green" - " colors: @ConsoleColor.color" - " colors: DarkRed" - " colors: @ConsoleColor.color" - " }" - "}" - ); + initialize_for_test("ConsoleColor {" + " value {" + " color: Blue " + " }" + "}" + "ConsoleColors {" + " value {" + " color: @ConsoleColor.color" + " colors: Green" + " colors: @ConsoleColor.color" + " colors: DarkRed" + " colors: @ConsoleColor.color" + " }" + "}"); - const test::ConsoleColor& c1 = get(); - const test::ConsoleColors& c2 = get(); + const test::ConsoleColor &c1 = get(); + const test::ConsoleColors &c2 = get(); REQUIRE(c2.color() == c1.color()); REQUIRE(c2.colors_size() == 4); REQUIRE(c2.colors(0) == test::ConsoleColor::Green); @@ -197,99 +181,94 @@ TEST_CASE ("Configuration Reference Tests", "[config]") { } SECTION("named_key") { - initialize_for_test( - "Foo { \n" - " value {\n" - " name: @FooList.item[foo2].foo.name " - " }\n" - "}\n" - "FooList { \n" - " value {\n" - " item { " - " key: 'foo1' " - " foo { " - " name: 'foo1' " - " }" - " }" - " item { " - " key: 'foo2' " - " foo { " - " name: 'foo2' " - " }" - " }" - " item { " - " key: 'foo3' " - " foo { " - " name: 'foo3' " - " }" - " }" - " }\n" - "}\n" - ); - + initialize_for_test("Foo { \n" + " value {\n" + " name: @FooList.item[foo2].foo.name " + " }\n" + "}\n" + "FooList { \n" + " value {\n" + " item { " + " key: 'foo1' " + " foo { " + " name: 'foo1' " + " }" + " }" + " item { " + " key: 'foo2' " + " foo { " + " name: 'foo2' " + " }" + " }" + " item { " + " key: 'foo3' " + " foo { " + " name: 'foo3' " + " }" + " }" + " }\n" + "}\n"); + REQUIRE(get().name() == "foo2"); } SECTION("named_key_rule") { - initialize_for_test( - "Foo { \n" - " value {\n" - " name: @FooList.item[foo2].foo.name " - " }\n" - "}\n" - "FooList { \n" - " value {\n" - " item { " - " key: 'foo1' " - " foo { " - " name: 'foo1' " - " }" - " }" - " item { " - " key: 'foo2' " - " rule: '1=0' " - " foo { " - " name: 'foo2' " - " }" - " }" - " item { " - " key: 'foo3' " - " foo { " - " name: 'foo3' " - " }" - " }" - " }\n" - "}\n" - ); - - //NOTE that a false rule will still create a message with defaults, so the list contains the same number of elements + initialize_for_test("Foo { \n" + " value {\n" + " name: @FooList.item[foo2].foo.name " + " }\n" + "}\n" + "FooList { \n" + " value {\n" + " item { " + " key: 'foo1' " + " foo { " + " name: 'foo1' " + " }" + " }" + " item { " + " key: 'foo2' " + " rule: '1=0' " + " foo { " + " name: 'foo2' " + " }" + " }" + " item { " + " key: 'foo3' " + " foo { " + " name: 'foo3' " + " }" + " }" + " }\n" + "}\n"); + + // NOTE that a false rule will still create a message with defaults, so + // the list contains the same number of elements REQUIRE(get().name() == "Blue Foo"); REQUIRE(get().item_size() == 3); } SECTION("named_key2") { - initialize_for_test( - "Foo { \n" - " value: @FooList.foo[foo2] " - "}\n" - "FooList { \n" - " value {\n" - " foo { " - " name: 'foo1' " - " id: 1 " - " }" - " foo { " - " name: 'foo2' " - " id: 2 " - " }" - " foo { " - " name: 'foo3' " - " id: 3 " - " }" - " }\n" - "}\n" - ); - + initialize_for_test("Foo { \n" + " value: @FooList.foo[foo2] " + "}\n" + "FooList { \n" + " value {\n" + " foo { " + " name: 'foo1' " + " id: 1 " + " }" + " foo { " + " name: 'foo2' " + " id: 2 " + " }" + " foo { " + " name: 'foo3' " + " id: 3 " + " }" + " }\n" + "}\n"); + REQUIRE(get().name() == "foo2"); REQUIRE(get().id() == 2); } @@ -298,105 +277,101 @@ TEST_CASE ("Configuration Reference Tests", "[config]") { bool error = false; try { initialize_for_test( - "Foo { \n" - " value: @FooList[foo2] " // FooList doesn't have a key or a property named foo2 - "}\n" - "FooList { \n" - " value {\n" - " foo { " - " name: 'foo1' " - " id: 1 " - " }" - " foo { " - " name: 'foo2' " - " id: 2 " - " }" - " foo { " - " name: 'foo3' " - " id: 3 " - " }" - " }\n" - "}\n" - ); - } - catch(...) { + "Foo { \n" + " value: @FooList[foo2] " // FooList doesn't have a key or a + // property named foo2 + "}\n" + "FooList { \n" + " value {\n" + " foo { " + " name: 'foo1' " + " id: 1 " + " }" + " foo { " + " name: 'foo2' " + " id: 2 " + " }" + " foo { " + " name: 'foo3' " + " id: 3 " + " }" + " }\n" + "}\n"); + } catch (...) { error = true; } REQUIRE(error); } SECTION("named_struture") { - initialize_for_test( - "FooGroup { \n" - " value {\n" - " foo: @FooList.item[foo3].foo " - " }\n" - "}\n" - "FooList { \n" - " value {\n" - " item { " - " key: 'foo1' " - " foo { " - " name: 'foo1' " - " id: 1 " - " }" - " }" - " item { " - " key: 'foo2' " - " foo { " - " name: 'foo2' " - " id: 2 " - " }" - " }" - " item { " - " key: 'foo3' " - " foo { " - " name: 'foo3' " - " id: 3 " - " }" - " }" - " }\n" - "}\n" - ); + initialize_for_test("FooGroup { \n" + " value {\n" + " foo: @FooList.item[foo3].foo " + " }\n" + "}\n" + "FooList { \n" + " value {\n" + " item { " + " key: 'foo1' " + " foo { " + " name: 'foo1' " + " id: 1 " + " }" + " }" + " item { " + " key: 'foo2' " + " foo { " + " name: 'foo2' " + " id: 2 " + " }" + " }" + " item { " + " key: 'foo3' " + " foo { " + " name: 'foo3' " + " id: 3 " + " }" + " }" + " }\n" + "}\n"); REQUIRE(get().foo().name() == "foo3"); REQUIRE(get().foo().id() == 3); } SECTION("named_structure_rule") { - initialize_for_test( - "FooGroup { \n" - " value {\n" - " foo: @FooList.item[foo3].foo " - " }\n" - "}\n" - "FooList { \n" - " value {\n" - " item { " - " key: 'foo1' " - " foo { " - " name: 'foo1' " - " id: 1 " - " }" - " }" - " item { " - " key: 'foo2' " - " foo { " - " name: 'foo2' " - " id: 2 " - " }" - " }" - " item { " - " key: 'foo3' " - " rule: 'false'" - " foo { " - " name: 'foo3' " - " id: 3 " - " }" - " }" - " }\n" - "}\n" - ); - //NOTE that a false rule will still create a message with defaults, so the list contains the same number of elements + initialize_for_test("FooGroup { \n" + " value {\n" + " foo: @FooList.item[foo3].foo " + " }\n" + "}\n" + "FooList { \n" + " value {\n" + " item { " + " key: 'foo1' " + " foo { " + " name: 'foo1' " + " id: 1 " + " }" + " }" + " item { " + " key: 'foo2' " + " foo { " + " name: 'foo2' " + " id: 2 " + " }" + " }" + " item { " + " key: 'foo3' " + " rule: 'false'" + " foo { " + " name: 'foo3' " + " id: 3 " + " }" + " }" + " }\n" + "}\n"); + // NOTE that a false rule will still create a message with defaults, so + // the list contains the same number of elements REQUIRE(get().foo().name() == "Blue Foo"); REQUIRE(get().foo().id() == 1234); REQUIRE(get().item_size() == 3); @@ -404,70 +379,68 @@ TEST_CASE ("Configuration Reference Tests", "[config]") { SECTION("named_value_rule") { initialize_for_test( - "FooList { \n" - " value {\n" - " item { " - " key: 'foo1' " - " foo { " - " name: 'foo1' " - " id: 1 " - " }" - " }" - " item { " - " key: 'foo2' " - " foo { " - " name: 'foo2' " - " id: 2 " - " }" - " }" - " item { " - " key: 'foo3' " - " foo { " - " name: 'foo3' " - " id: 3 " - " }" - " }" - " }\n" - "}\n" - "Foo { \n" - // Adding [] to BooleanGrammer.h is very difficult because boost::spirit is crap - // also it risks making list syntax [1,2,3] ambiguous so this is a workaround syntax - " rule: 'FooList.item.foo1.foo.id = 2' " - " value {\n" - " name: 'bad' " - " }\n" - "}\n" - "Foo { \n" - " rule: 'FooList.item.foo2.foo.id = 2' " - " value {\n" - " name: 'good' " - " }\n" - "}\n" - ); + "FooList { \n" + " value {\n" + " item { " + " key: 'foo1' " + " foo { " + " name: 'foo1' " + " id: 1 " + " }" + " }" + " item { " + " key: 'foo2' " + " foo { " + " name: 'foo2' " + " id: 2 " + " }" + " }" + " item { " + " key: 'foo3' " + " foo { " + " name: 'foo3' " + " id: 3 " + " }" + " }" + " }\n" + "}\n" + "Foo { \n" + // Adding [] to BooleanGrammer.h is very difficult because + // boost::spirit is crap also it risks making list syntax [1,2,3] + // ambiguous so this is a workaround syntax + " rule: 'FooList.item.foo1.foo.id = 2' " + " value {\n" + " name: 'bad' " + " }\n" + "}\n" + "Foo { \n" + " rule: 'FooList.item.foo2.foo.id = 2' " + " value {\n" + " name: 'good' " + " }\n" + "}\n"); - const Foo& foo = get(); + const Foo &foo = get(); REQUIRE(foo.name() == "good"); } SECTION("recursive_reference_good") { - initialize_for_test( - "TestSite { \n" - " value {\n" - " name: \"good\"\n" - " }\n" - "}\n" - "Foo { \n" - " value {\n" - " name: @TestSite.name " - " }\n" - "}\n" - "FooGroup {" - " value { " - " group: @Foo.name " - " foo: @Foo " - " }" - "}" - ); + initialize_for_test("TestSite { \n" + " value {\n" + " name: \"good\"\n" + " }\n" + "}\n" + "Foo { \n" + " value {\n" + " name: @TestSite.name " + " }\n" + "}\n" + "FooGroup {" + " value { " + " group: @Foo.name " + " foo: @Foo " + " }" + "}"); REQUIRE(get().group() == "good"); REQUIRE(get().foo().name() == "good"); @@ -477,52 +450,47 @@ TEST_CASE ("Configuration Reference Tests", "[config]") { bool error = false; try { - initialize_for_test( - "TestSite { \n" - " value {\n" - " name: @Foo.name " - " }\n" - "}\n" - "Foo { \n" - " value {\n" - " name: @TestSite.name " - " }\n" - "}\n" - "FooGroup {" - " value { " - " group: @Foo.name " - " foo: @Foo " - " }" - "}" - ); - - - } catch(...) { + initialize_for_test("TestSite { \n" + " value {\n" + " name: @Foo.name " + " }\n" + "}\n" + "Foo { \n" + " value {\n" + " name: @TestSite.name " + " }\n" + "}\n" + "FooGroup {" + " value { " + " group: @Foo.name " + " foo: @Foo " + " }" + "}"); + + } catch (...) { error = true; } REQUIRE(error); } SECTION("recursive_order_independent") { - initialize_for_test( - "FooGroup {" - " value { " - " group: @Foo.name " - " foo: @Foo " - " }" - "}" - "TestSite { \n" - " value {\n" - " name: \"good\"\n" - " }\n" - "}\n" - "Foo { \n" - " value {\n" - " name: @TestSite.name " - " }\n" - "}\n" - ); - + initialize_for_test("FooGroup {" + " value { " + " group: @Foo.name " + " foo: @Foo " + " }" + "}" + "TestSite { \n" + " value {\n" + " name: \"good\"\n" + " }\n" + "}\n" + "Foo { \n" + " value {\n" + " name: @TestSite.name " + " }\n" + "}\n"); + // In this test we mighe expect @Foo.name or @Foo to be evaluated first // But Foo is incomplete until @TestSite.name is evaluated. REQUIRE(get().group() == "good"); @@ -532,13 +500,12 @@ TEST_CASE ("Configuration Reference Tests", "[config]") { SECTION("loop_test") { bool error = false; try { - initialize_for_test( - "Foo { \n" - " value {\n" - " name: @Foo.name " - " }\n" - "}\n"); - } catch(...) { + initialize_for_test("Foo { \n" + " value {\n" + " name: @Foo.name " + " }\n" + "}\n"); + } catch (...) { error = true; } REQUIRE(error); @@ -546,115 +513,109 @@ TEST_CASE ("Configuration Reference Tests", "[config]") { SECTION("merge_test") { // Config used to go through a merge step for each file in a directory. - // This would invalidate the memory held by the deferred value queue and cause - // crashes and instability. This is to verify that we don't regress the new behavior. + // This would invalidate the memory held by the deferred value queue and + // cause crashes and instability. This is to verify that we don't regress + // the new behavior. HTTPServer server; std::string port = boost::lexical_cast(server.port()); std::string config_url = "http://localhost:" + port + "/"; - std::string response = - "HTTP/1.0 200 OK\r\n" - "Content-Type: text/plain\r\n\r\n"; + std::string response = "HTTP/1.0 200 OK\r\n" + "Content-Type: text/plain\r\n\r\n"; - server.add_response("/spark.conf", response, - "Foo {\n" - " value: {\n" - " name: \"included_value\"\n" - " id: 4096\n" - " }}\n" - "TestSite {" - " value { " - " name: @FooGroup.group" // reference to testkeys.conf - " }" - "}" - ); - server.add_response("/testkeys.conf", response, - "FooGroup {\n" - " value {\n" - " group: \"http_group\"\n" - " foo {\n" - " name: @Foo.name " // reference to spark.conf - " id: 80\n" - "}}}\n" - ); + server.add_response( + "/spark.conf", response, + "Foo {\n" + " value: {\n" + " name: \"included_value\"\n" + " id: 4096\n" + " }}\n" + "TestSite {" + " value { " + " name: @FooGroup.group" // reference to testkeys.conf + " }" + "}"); + server.add_response( + "/testkeys.conf", response, + "FooGroup {\n" + " value {\n" + " group: \"http_group\"\n" + " foo {\n" + " name: @Foo.name " // reference to spark.conf + " id: 80\n" + "}}}\n"); server.start(); initialize_for_test("include: \"" + config_url + "\""); server.stop(); - const FooGroup& group = get(); - const test::TestSite& site = get(); + const FooGroup &group = get(); + const test::TestSite &site = get(); REQUIRE(group.foo().name() == "included_value"); REQUIRE(site.name() == "http_group"); } SECTION("test_conversion") { - initialize_for_test( - "Foo {\n" - " value: {\n" - " name: @RuleRef.a_int \n" - " id: @RuleRef.a_string " - " }}\n" - "Foo {\n" - " rule: 'false' " - " value: {\n" - " name: @RuleRef.a_string \n" - " id: @RuleRef.a_int " - " }}\n" - "RuleRef { " - " value { " - " a_string: '42' " - " a_int: 99 " - " }" - "}" - ); + initialize_for_test("Foo {\n" + " value: {\n" + " name: @RuleRef.a_int \n" + " id: @RuleRef.a_string " + " }}\n" + "Foo {\n" + " rule: 'false' " + " value: {\n" + " name: @RuleRef.a_string \n" + " id: @RuleRef.a_int " + " }}\n" + "RuleRef { " + " value { " + " a_string: '42' " + " a_int: 99 " + " }" + "}"); - const Foo& foo = get(); + const Foo &foo = get(); REQUIRE(foo.name() == "99"); REQUIRE(foo.id() == 42); } SECTION("test_int") { - initialize_for_test( - "Foo {\n" - " value: {\n" - " id: @RuleRef.a_int " - " }}\n" - "RuleRef { " - " value { " - " a_string: 'good' " - " a_int: 99 " - " }" - "}" - ); + initialize_for_test("Foo {\n" + " value: {\n" + " id: @RuleRef.a_int " + " }}\n" + "RuleRef { " + " value { " + " a_string: 'good' " + " a_int: 99 " + " }" + "}"); - const Foo& foo = get(); + const Foo &foo = get(); REQUIRE(foo.id() == 99); } SECTION("test_repeated_to_repeated") { - initialize_for_test( - "FooList {\n" - " value: {\n" - " foo {\n" - " name: 'good1' \n" - " }\n" - " foo {\n" - " name: 'good2' \n" - " }\n" - " }}\n" - "RuleRef { " - " value { " - " foox { " - " name: 'original' " - " }" - " foox: @FooList.foo " - " }" - "}" - ); + initialize_for_test("FooList {\n" + " value: {\n" + " foo {\n" + " name: 'good1' \n" + " }\n" + " foo {\n" + " name: 'good2' \n" + " }\n" + " }}\n" + "RuleRef { " + " value { " + " foox { " + " name: 'original' " + " }" + " foox: @FooList.foo " + " }" + "}"); - const test::RuleRef& result = get(); + const test::RuleRef &result = get(); REQUIRE(result.foox_size() == 3); REQUIRE(result.foox(0).name() == "original"); @@ -663,43 +624,41 @@ TEST_CASE ("Configuration Reference Tests", "[config]") { } SECTION("test_repeated_after_key_rule") { - initialize_for_test( - "StringTable { \n" - " value { \n" - " entries: 'a' \n" - " entries: 'b' \n" - " } \n" - "} \n" - "FooList {\n" - " value: {\n" - " item {\n" - " key: 'one' \n" - " rule: \" 'a' in StringTable.entries\" \n" - " foox { \n" - " name: 'good1' \n" - " }\n" - " foox { \n" - " name: 'good2' \n" - " }\n" - " }\n" - " item {\n" - " key: 'two' \n" - " foox { \n" - " name: 'bad1' \n" - " }\n" - " }\n" - " }}\n" - "RuleRef { " - " value { " - " foox { " - " name: 'original' " - " }" - " foox: @FooList.item[one].foox " - " }" - "}" - ); + initialize_for_test("StringTable { \n" + " value { \n" + " entries: 'a' \n" + " entries: 'b' \n" + " } \n" + "} \n" + "FooList {\n" + " value: {\n" + " item {\n" + " key: 'one' \n" + " rule: \" 'a' in StringTable.entries\" \n" + " foox { \n" + " name: 'good1' \n" + " }\n" + " foox { \n" + " name: 'good2' \n" + " }\n" + " }\n" + " item {\n" + " key: 'two' \n" + " foox { \n" + " name: 'bad1' \n" + " }\n" + " }\n" + " }}\n" + "RuleRef { " + " value { " + " foox { " + " name: 'original' " + " }" + " foox: @FooList.item[one].foox " + " }" + "}"); - const test::RuleRef& result = get(); + const test::RuleRef &result = get(); REQUIRE(result.foox_size() == 3); REQUIRE(result.foox(0).name() == "original"); REQUIRE(result.foox(1).name() == "good1"); @@ -707,49 +666,48 @@ TEST_CASE ("Configuration Reference Tests", "[config]") { } SECTION("test_repeated_after_key_rule2") { - //This test fails on purpose to illustrate the frailty of the rule evaluation feature in 'keyed' list keys - initialize_for_test( - "TestSite {" - " value {" - " name: 'a' " - " }" - "}" - "StringTable {" - " value {" - " entries: @TestSite.name " - " entries: 'b' " - " }" - "}" - "FooList {\n" - " value: {\n" - " item {\n" - " key: 'one' \n" - " rule: \"'a' in StringTable.entries\" \n" - " foox { \n" - " name: 'good1' \n" - " }\n" - " foox { \n" - " name: 'good2' \n" - " }\n" - " }\n" - " item {\n" - " key: 'two' \n" - " foox { \n" - " name: 'bad1' \n" - " }\n" - " }\n" - " }}\n" - "RuleRef { " - " value { " - " foox { " - " name: 'original' " - " }" - " foox: @FooList.item[one].foox " - " }" - "}" - ); + // This test fails on purpose to illustrate the frailty of the rule + // evaluation feature in 'keyed' list keys + initialize_for_test("TestSite {" + " value {" + " name: 'a' " + " }" + "}" + "StringTable {" + " value {" + " entries: @TestSite.name " + " entries: 'b' " + " }" + "}" + "FooList {\n" + " value: {\n" + " item {\n" + " key: 'one' \n" + " rule: \"'a' in StringTable.entries\" \n" + " foox { \n" + " name: 'good1' \n" + " }\n" + " foox { \n" + " name: 'good2' \n" + " }\n" + " }\n" + " item {\n" + " key: 'two' \n" + " foox { \n" + " name: 'bad1' \n" + " }\n" + " }\n" + " }}\n" + "RuleRef { " + " value { " + " foox { " + " name: 'original' " + " }" + " foox: @FooList.item[one].foox " + " }" + "}"); - const test::RuleRef& result = get(); + const test::RuleRef &result = get(); REQUIRE(result.foox_size() == 3); REQUIRE(result.foox(0).name() == "original"); REQUIRE(result.foox(1).name() == "good1"); @@ -757,57 +715,57 @@ TEST_CASE ("Configuration Reference Tests", "[config]") { } SECTION("test_repeated_after_key_rule3") { - //This test fails on purpose to illustrate the frailty of the rule evaluation feature in 'keyed' list keys - initialize_for_test( - "RuleRef { " - " value { " - " foox { " - " name: 'original' " - " }" - " foox: @FooList.item[one].foox " - " }" - "}" - "TestSite {" - " value {" - " name: 'a' " - " }" - "}" - "StringTable {" - " value {" - " entries: @TestSite.name " - " entries: 'b' " - " }" - "}" - "FooList {\n" - " value: {\n" - " item {\n" - " key: 'one' \n" - " rule: \"'a' in StringTable.entries\" \n" - " foox { \n" - " name: 'good1' \n" - " }\n" - " foox { \n" - " name: 'good2' \n" - " }\n" - " }\n" - " item {\n" - " key: 'two' \n" - " foox { \n" - " name: 'bad1' \n" - " }\n" - " }\n" - " }}\n" + // This test fails on purpose to illustrate the frailty of the rule + // evaluation feature in 'keyed' list keys + initialize_for_test("RuleRef { " + " value { " + " foox { " + " name: 'original' " + " }" + " foox: @FooList.item[one].foox " + " }" + "}" + "TestSite {" + " value {" + " name: 'a' " + " }" + "}" + "StringTable {" + " value {" + " entries: @TestSite.name " + " entries: 'b' " + " }" + "}" + "FooList {\n" + " value: {\n" + " item {\n" + " key: 'one' \n" + " rule: \"'a' in StringTable.entries\" \n" + " foox { \n" + " name: 'good1' \n" + " }\n" + " foox { \n" + " name: 'good2' \n" + " }\n" + " }\n" + " item {\n" + " key: 'two' \n" + " foox { \n" + " name: 'bad1' \n" + " }\n" + " }\n" + " }}\n" - ); + ); - const test::RuleRef& result = get(); - //the order matters here, but seems to be deterministic + const test::RuleRef &result = get(); + // the order matters here, but seems to be deterministic REQUIRE(result.foox_size() == 1); } // SECTION("test_repeated_after_key_rule_should_fail") { - // //This test fails on purpose to illustrate the frailty of the rule evaluation feature in 'keyed' list keys - // initialize_for_test( + // //This test fails on purpose to illustrate the frailty of the rule + // evaluation feature in 'keyed' list keys initialize_for_test( // "RuleRef { " // " value { " // " foox { " @@ -855,75 +813,73 @@ TEST_CASE ("Configuration Reference Tests", "[config]") { // } SECTION("test_irrelevant_lookup") { - // If a key references another key which is not present it should only be an error if the resulting key will ever be used. + // If a key references another key which is not present it should only be + // an error if the resulting key will ever be used. initialize_for_test( - "FooList {\n" - " value: {\n" - " item {\n" - " key: 'one' \n" - " foox { \n" - " name: 'good1' \n" - " }\n" - " foox { \n" - " name: 'good2' \n" - " }\n" - " }\n" - " item {\n" - " key: 'two' \n" - " foox { \n" - " name: 'bad1' \n" - " }\n" - " }\n" - " }}\n" - "RuleRef { " - " rule: 'false' " - " value { " - " foox { " - " name: 'never used' " - " }" - " foox: @FooList.item[XXXXX].foox " // Invalid lookup - " }" - "}" - "RuleRef { " - " value { " - " foox { " - " name: 'original' " - " }" - " foox: @FooList.item[one].foox " - " }" - "}" - ); - const test::RuleRef& result = get(); + "FooList {\n" + " value: {\n" + " item {\n" + " key: 'one' \n" + " foox { \n" + " name: 'good1' \n" + " }\n" + " foox { \n" + " name: 'good2' \n" + " }\n" + " }\n" + " item {\n" + " key: 'two' \n" + " foox { \n" + " name: 'bad1' \n" + " }\n" + " }\n" + " }}\n" + "RuleRef { " + " rule: 'false' " + " value { " + " foox { " + " name: 'never used' " + " }" + " foox: @FooList.item[XXXXX].foox " // Invalid lookup + " }" + "}" + "RuleRef { " + " value { " + " foox { " + " name: 'original' " + " }" + " foox: @FooList.item[one].foox " + " }" + "}"); + const test::RuleRef &result = get(); REQUIRE(result.foox_size() == 3); } SECTION("macro_definition_order_test_hard") { // The $is_crusible test hard version - // $macro1 tests Value2.x with rule about $macro2 before $macro2 is defined - // Value2.x is an @reference of a 4th location - initialize_for_test( - "TestSite {" - " value { name: 'cme_1u7_cert' }" - "}" - "Foo {" - " rule: '$is_crucible'" - " value { name: @TestSite.name }" - "}" - "" - "Foo {" - " value { name: '' }" - "}" - "" - "macro {" - " name: 'o2_cme_enabled'" - " expression: \"Foo.name != ''\" " - "}" - "" - "macro {" - " name: 'is_crucible'" - " expression: 'true'" - "}" - ); + // $macro1 tests Value2.x with rule about $macro2 before $macro2 is + // defined Value2.x is an @reference of a 4th location + initialize_for_test("TestSite {" + " value { name: 'cme_1u7_cert' }" + "}" + "Foo {" + " rule: '$is_crucible'" + " value { name: @TestSite.name }" + "}" + "" + "Foo {" + " value { name: '' }" + "}" + "" + "macro {" + " name: 'o2_cme_enabled'" + " expression: \"Foo.name != ''\" " + "}" + "" + "macro {" + " name: 'is_crucible'" + " expression: 'true'" + "}"); REQUIRE(get().name() == "cme_1u7_cert"); } @@ -931,4 +887,4 @@ TEST_CASE ("Configuration Reference Tests", "[config]") { reset(); } -} +} // namespace bts diff --git a/src/lib/config/tests/config_tests.cpp b/src/lib/config/tests/config_tests.cpp old mode 100755 new mode 100644 index 18b37512e..7e8867909 --- a/src/lib/config/tests/config_tests.cpp +++ b/src/lib/config/tests/config_tests.cpp @@ -1,8 +1,8 @@ #include "lib/utils/TempFile.h" -#include "../config.h" -#include "../ConfigurationState.h" #include "../ConfigurationException.h" +#include "../ConfigurationState.h" +#include "../config.h" #include "lib/expression/ParserExceptions.h" #include "lib/utils/bts_assert.h" #include "lib/utils/is_unittest_environment.h" @@ -19,9 +19,9 @@ #define URDL_HEADER_ONLY 1 #define URDL_DISALE_SSL 1 -#include -#include #include +#include +#include using namespace bts::config; using namespace bts::config::internal; @@ -31,124 +31,107 @@ using bts::config::test::Foo; using bts::config::test::FooGroup; using bts::config::test::StringTable; - - namespace bts { int config_tests = 0; -TEST_CASE("Configuration Tests","[config]") { +TEST_CASE("Configuration Tests", "[config]") { bts::utils::internal::force_unittest_environment(); - SECTION("basic_get_value_test") - { - initialize_for_test( - "Foo { \n" - " rule: \"true\"\n" - " value {\n" - " name: \"Name A\"\n" - " id: 65\n" - " email: \"test@example.com\"\n" - " }\n" - "}\n"); + SECTION("basic_get_value_test") { + initialize_for_test("Foo { \n" + " rule: \"true\"\n" + " value {\n" + " name: \"Name A\"\n" + " id: 65\n" + " email: \"test@example.com\"\n" + " }\n" + "}\n"); - const Foo& foo = get(); + const Foo &foo = get(); REQUIRE(foo.name() == "Name A"); REQUIRE(foo.id() == 65); REQUIRE(foo.email().Get(0) == "test@example.com"); } - SECTION("default_value_test") - { + SECTION("default_value_test") { initialize_for_test(""); // Only loads defaults.conf // Should load a Foo from testkeys.conf - const Foo& foo = get(); + const Foo &foo = get(); REQUIRE(foo.name() == "Blue Foo"); // from testkeys.proto - REQUIRE(foo.id() == 1234); // from testkeys.proto + REQUIRE(foo.id() == 1234); // from testkeys.proto REQUIRE(foo.email().size() > 0); - REQUIRE(foo.email().Get(0) == "default@example.com"); // from testkeys.conf + REQUIRE( + foo.email().Get(0) == "default@example.com"); // from testkeys.conf } - SECTION("default_include_test") - { + SECTION("default_include_test") { // test defaults.conf with an include } - SECTION("invalid_key_type_test") - { + SECTION("invalid_key_type_test") { // Load an initialize with no files - OK all values default - const Foo& foo = get(); // OK + const Foo &foo = get(); // OK REQUIRE(foo.name() == "Blue Foo"); bool error = false; - try - { + try { get(); // BAD - } - catch(...) - { + } catch (...) { error = true; } REQUIRE(error == true); } - SECTION("invalid_config_test2") - { + SECTION("invalid_config_test2") { utils::TempFile config_b; - *config_b.out() << - "Foo {\n" - " value { \n" - " name: \"bob\"\n" - " id: 7319 \n" - " }"; + *config_b.out() << "Foo {\n" + " value { \n" + " name: \"bob\"\n" + " id: 7319 \n" + " }"; bool error = false; - try - { + try { initialize_for_test("include: \"" + config_b.path() + "\"", false); - } - catch(const ConfigurationException& err) - { + } catch (const ConfigurationException &err) { std::string what = err.what(); bts_assert(what.find("Expected identifier.") != std::string::npos); error = true; } REQUIRE(error == true); - } // Tests that we can load using a File:/// url // Tests complex value load - SECTION("file_url_test") - { + SECTION("file_url_test") { utils::TempFile config_a; utils::TempFile config_b; - *config_a.out() << "include: \"" << config_b.path() << "\"" << std::endl << - "Foo { \n" - " rule: \"false\"\n" - " value {\n" - " name: \"Name A\"\n" - " id: 65\n" - " email: \"A@bluecg.com\"\n" - " }\n" - "}\n"; + *config_a.out() << "include: \"" << config_b.path() << "\"" << std::endl + << "Foo { \n" + " rule: \"false\"\n" + " value {\n" + " name: \"Name A\"\n" + " id: 65\n" + " email: \"A@bluecg.com\"\n" + " }\n" + "}\n"; - *config_b.out() << - "Foo {\n" - " rule: \"true\"\n" - " value {\n" - " name: \"Name B\"\n" - " id: 66 " - " email: \"A@bluecg.com\" \n" - " }}"; + *config_b.out() << "Foo {\n" + " rule: \"true\"\n" + " value {\n" + " name: \"Name B\"\n" + " id: 66 " + " email: \"A@bluecg.com\" \n" + " }}"; - - // Get key Foo without loading any config files - this will show the default value + // Get key Foo without loading any config files - this will show the + // default value Foo foo = bts::config::get(); REQUIRE(foo.name() == "Blue Foo"); @@ -163,23 +146,20 @@ TEST_CASE("Configuration Tests","[config]") { REQUIRE(foo.id() == 66); } - SECTION("http_test") - { + SECTION("http_test") { HTTPServer server; std::string port = boost::lexical_cast(server.port()); std::string path = "/spark.conf"; - std::string response = - "HTTP/1.0 200 OK\r\n" - "Content-Type: text/plain\r\n\r\n"; - std::string content = - "FooGroup {\n" - " rule: \"true\"\n" - " value {\n" - " group: \"http_group\"\n" - " foo {\n" - " name: \"http\"\n" - " id: 80\n" - "}}}\n"; + std::string response = "HTTP/1.0 200 OK\r\n" + "Content-Type: text/plain\r\n\r\n"; + std::string content = "FooGroup {\n" + " rule: \"true\"\n" + " value {\n" + " group: \"http_group\"\n" + " foo {\n" + " name: \"http\"\n" + " id: 80\n" + "}}}\n"; server.add_response(path, response, content); server.start(); @@ -190,7 +170,7 @@ TEST_CASE("Configuration Tests","[config]") { server.stop(); - const FooGroup& foogrp = get(); + const FooGroup &foogrp = get(); REQUIRE(foogrp.group() == "http_group"); REQUIRE(foogrp.foo().name() == "http"); @@ -198,41 +178,41 @@ TEST_CASE("Configuration Tests","[config]") { REQUIRE(get().config_host() == "127.0.0.1"); } - SECTION("http_folder_test") - { + SECTION("http_folder_test") { HTTPServer server; std::string port = boost::lexical_cast(server.port()); std::string config_url = "http://localhost:" + port + "/"; - std::string response = - "HTTP/1.0 200 OK\r\n" - "Content-Type: text/plain\r\n\r\n"; + std::string response = "HTTP/1.0 200 OK\r\n" + "Content-Type: text/plain\r\n\r\n"; - server.add_response("/spark.conf", response, "include: \"" + config_url + "other/\""); - server.add_response("/testkeys.conf", response, - "FooGroup {\n" - " rule: \"true\"\n" - " value {\n" - " group: \"http_group\"\n" - " foo {\n" - " name: \"http\"\n" - " id: 80\n" - "}}}\n"); - - server.add_response("/other/spark.conf", response, - "Foo {\n" - " rule: \"true\"\n" - " value: {\n" - " name: \"included_value\"\n" - " id: 4096\n" - " }}\n"); + server.add_response( + "/spark.conf", response, "include: \"" + config_url + "other/\""); + server.add_response( + "/testkeys.conf", response, + "FooGroup {\n" + " rule: \"true\"\n" + " value {\n" + " group: \"http_group\"\n" + " foo {\n" + " name: \"http\"\n" + " id: 80\n" + "}}}\n"); + server.add_response( + "/other/spark.conf", response, + "Foo {\n" + " rule: \"true\"\n" + " value: {\n" + " name: \"included_value\"\n" + " id: 4096\n" + " }}\n"); server.start(); initialize_for_test("include: \"" + config_url + "\""); server.stop(); - const FooGroup& foogrp = get(); + const FooGroup &foogrp = get(); REQUIRE(foogrp.group() == "http_group"); REQUIRE(foogrp.foo().name() == "http"); @@ -242,44 +222,39 @@ TEST_CASE("Configuration Tests","[config]") { REQUIRE(get().id() == 4096); } - - SECTION("test_rules") - { - initialize_for_test( - "StringTable {\n" - " value { \n" - " entries: [\"foo\", \"bar\", \"baz\"] \n" - " }\n" - " }\n" - "RuleRef { \n" - " # use this rule of StringTable has a cow \n" - " rule: \"'cow' in StringTable.entries\" \n" - " value { \n" - " a_string: \"AAA\"\n" - " a_int: -1\n" - " }\n" - "}\n" - "RuleRef { \n" - " rule: \"'baz' in StringTable.entries\" \n" - " value { \n" - " a_string: \"BBB\"\n" - " a_int: 99\n" - " }\n" - "}\n" - "Foo { \n" - " rule: \"RuleRef.a_int == 789\"\n" - " value {\n" - " name: \"A\"\n" - " }\n" - "}\n" - "Foo { \n" - " rule: \"RuleRef.a_string == 'BBB'\"\n" - " value {\n" - " name: \"B\"\n" - " }\n" - "}\n" - ); - + SECTION("test_rules") { + initialize_for_test("StringTable {\n" + " value { \n" + " entries: [\"foo\", \"bar\", \"baz\"] \n" + " }\n" + " }\n" + "RuleRef { \n" + " # use this rule of StringTable has a cow \n" + " rule: \"'cow' in StringTable.entries\" \n" + " value { \n" + " a_string: \"AAA\"\n" + " a_int: -1\n" + " }\n" + "}\n" + "RuleRef { \n" + " rule: \"'baz' in StringTable.entries\" \n" + " value { \n" + " a_string: \"BBB\"\n" + " a_int: 99\n" + " }\n" + "}\n" + "Foo { \n" + " rule: \"RuleRef.a_int == 789\"\n" + " value {\n" + " name: \"A\"\n" + " }\n" + "}\n" + "Foo { \n" + " rule: \"RuleRef.a_string == 'BBB'\"\n" + " value {\n" + " name: \"B\"\n" + " }\n" + "}\n"); // What should happen: // Foo A @@ -297,286 +272,262 @@ TEST_CASE("Configuration Tests","[config]") { // success a_string == 'BBB' // return Foo B - const Foo& foo = get(); + const Foo &foo = get(); REQUIRE(foo.name() == "B"); } + SECTION("test_recursive_rules") { + initialize_for_test("StringTable {\n" + " rule: \"Foo.name == 'foo'\"\n" + " value { \n" + " entries: [\"foo\", \"bar\", \"baz\"] \n" + " }\n" + " }\n" + "RuleRef { \n" + " rule: \"'foo' in StringTable.entries\" \n" + " value { \n" + " a_string: \"AAA\"\n" + " a_int: -1\n" + " }\n" + "}\n" + "Foo { \n" + " rule: \"RuleRef.a_string == 'BBB'\"\n" + " value {\n" + " name: \"foo\"\n" + " }\n" + "}\n"); - - SECTION("test_recursive_rules") - { - initialize_for_test( - "StringTable {\n" - " rule: \"Foo.name == 'foo'\"\n" - " value { \n" - " entries: [\"foo\", \"bar\", \"baz\"] \n" - " }\n" - " }\n" - "RuleRef { \n" - " rule: \"'foo' in StringTable.entries\" \n" - " value { \n" - " a_string: \"AAA\"\n" - " a_int: -1\n" - " }\n" - "}\n" - "Foo { \n" - " rule: \"RuleRef.a_string == 'BBB'\"\n" - " value {\n" - " name: \"foo\"\n" - " }\n" - "}\n" - ); - - // Foo cannot be queried because RuleRef's rule requests StringTable which requests RuleRef + // Foo cannot be queried because RuleRef's rule requests StringTable which + // requests RuleRef bool error = false; - try - { + try { get(); - } - catch(const expression::RecursivePropertyGetException&) - { + } catch (const expression::RecursivePropertyGetException &) { error = true; } REQUIRE(error); } - SECTION("test_nested_properties") - { - initialize_for_test( - "RuleRef { \n" - " value { \n" - " nested {\n" - " list_int: [7,8,9] \n" - " nested {\n" - " a_string: 'ABC' \n" - " }\n" - " }\n" - " }\n" - "}\n" - "Foo { \n" - " rule: \"RuleRef.nested.nested.a_string == 'ABC' and 9 in RuleRef.nested.list_int\"\n" - " value {\n" - " name: \"foo\"\n" - " }\n" - "}\n" - ); - + SECTION("test_nested_properties") { + initialize_for_test("RuleRef { \n" + " value { \n" + " nested {\n" + " list_int: [7,8,9] \n" + " nested {\n" + " a_string: 'ABC' \n" + " }\n" + " }\n" + " }\n" + "}\n" + "Foo { \n" + " rule: \"RuleRef.nested.nested.a_string == 'ABC' " + "and 9 in RuleRef.nested.list_int\"\n" + " value {\n" + " name: \"foo\"\n" + " }\n" + "}\n"); + REQUIRE(get().name() == "foo"); } - SECTION("built_in_properties_test") - { - initialize_for_test( - "Foo { \n" - " rule: \"System.unittest_environment == true \"\n" - " value {\n" - " name: \"unit tests\"\n" - " }\n" - "}\n" - ); + SECTION("built_in_properties_test") { + initialize_for_test("Foo { \n" + " rule: \"System.unittest_environment == true \"\n" + " value {\n" + " name: \"unit tests\"\n" + " }\n" + "}\n"); REQUIRE(get().name() == "unit tests"); } - SECTION("nonbreaking_space_test") - { + SECTION("nonbreaking_space_test") { bool parse_error = false; - try - { + try { initialize_for_test( - "Foo { " - " value {\xA0\xA0 " - " name: \"valid name\"" - " \xA0 }" - "} ", false); - } - catch(const bts::config::ConfigurationException) - { + "Foo { " + " value {\xA0\xA0 " + " name: \"valid name\"" + " \xA0 }" + "} ", + false); + } catch (const bts::config::ConfigurationException) { parse_error = true; } REQUIRE(parse_error); } - SECTION("macro_bool_test") - { - initialize_for_test( - "macro" - "{" - " name: \"bool\"" - " expression: \"'c' in ['a', 'b', 'c', 'd']\"" - "}" - "" - "Foo" - "{" - " rule: \"$bool\"" - " value {" - " name: 'good'" - " }" - "}" - "" - "Foo" - "{" - " value {" - " name: 'bad'" - " }" - "}" - ); + SECTION("macro_bool_test") { + initialize_for_test("macro" + "{" + " name: \"bool\"" + " expression: \"'c' in ['a', 'b', 'c', 'd']\"" + "}" + "" + "Foo" + "{" + " rule: \"$bool\"" + " value {" + " name: 'good'" + " }" + "}" + "" + "Foo" + "{" + " value {" + " name: 'bad'" + " }" + "}"); REQUIRE(config::get().name() == "good"); - } - SECTION("macro_list_test") - { - initialize_for_test( - "macro" - "{" - " name: \"list\"" - " expression: \"['a', 'b', 'c', 'd']\"" - "}" - "" - "Foo" - "{" - " rule: \"'a' in $list\"" - " value {" - " name: 'good'" - " }" - "}" - "" - "Foo" - "{" - " value {" - " name: 'bad'" - " }" - "}" - ); + SECTION("macro_list_test") { + initialize_for_test("macro" + "{" + " name: \"list\"" + " expression: \"['a', 'b', 'c', 'd']\"" + "}" + "" + "Foo" + "{" + " rule: \"'a' in $list\"" + " value {" + " name: 'good'" + " }" + "}" + "" + "Foo" + "{" + " value {" + " name: 'bad'" + " }" + "}"); REQUIRE(config::get().name() == "good"); } SECTION("fallback_test") { - //HTTPServer main; + // HTTPServer main; HTTPServer fallback; - //std::string main_url = "http://localhost:" + boost::lexical_cast(main.port()) + "/"; + // std::string main_url = "http://localhost:" + + // boost::lexical_cast(main.port()) + "/"; std::string main_url = "http://does_not_exist:12345/"; - //main.stop(); - std::string fallback_url = "http://127.0.0.1:" + boost::lexical_cast(fallback.port()) + "/"; - std::string response = - "HTTP/1.0 200 OK\r\n" - "Content-Type: text/plain\r\n\r\n"; + // main.stop(); + std::string fallback_url = + "http://127.0.0.1:" + + boost::lexical_cast(fallback.port()) + "/"; + std::string response = "HTTP/1.0 200 OK\r\n" + "Content-Type: text/plain\r\n\r\n"; - std::string content = - "FooGroup {\n" - " value {\n" - " group: \"http_group\"\n" - " foo {\n" - " name: \"http\"\n" - " id: 80\n" - "}}}\n"; + std::string content = "FooGroup {\n" + " value {\n" + " group: \"http_group\"\n" + " foo {\n" + " name: \"http\"\n" + " id: 80\n" + "}}}\n"; fallback.add_response("/spark.conf", response, content); - + fallback.start(); initialize_for_test( - "include: '" + main_url + "'\n" - "fallback: '" + fallback_url + "'\n",false - ); + "include: '" + main_url + + "'\n" + "fallback: '" + + fallback_url + "'\n", + false); fallback.stop(); - + REQUIRE(get().foo().name() == "http"); REQUIRE(get().foo().id() == 80); - } SECTION("macro_definition_order_test") { // The $is_crusible test - // o2_cme_enabled depends on Foo which has a rule which depends on is_crucible. - // Eager evaluation caused a bug which would cause loading o2_cme_enabled to set is_crucible false. Case 3993 - initialize_for_test( - "Foo {" - " rule: '$is_crucible'" - " value { name: 'cme_1u7_cert' }" - "}" - "" - "Foo {" - " value { name: '' }" - "}" - "" - "macro {" - " name: 'o2_cme_enabled'" - " expression: \"Foo.name != ''\" " - "}" - "" - "macro {" - " name: 'is_crucible'" - " expression: 'true'" - "}" - ); + // o2_cme_enabled depends on Foo which has a rule which depends on + // is_crucible. Eager evaluation caused a bug which would cause loading + // o2_cme_enabled to set is_crucible false. Case 3993 + initialize_for_test("Foo {" + " rule: '$is_crucible'" + " value { name: 'cme_1u7_cert' }" + "}" + "" + "Foo {" + " value { name: '' }" + "}" + "" + "macro {" + " name: 'o2_cme_enabled'" + " expression: \"Foo.name != ''\" " + "}" + "" + "macro {" + " name: 'is_crucible'" + " expression: 'true'" + "}"); REQUIRE(get().name() == "cme_1u7_cert"); } SECTION("repeated_value_order_preserved") { - initialize_for_test( - "Foo {" - " value { name: 'edge-eharding' id: 80 }" - "}" - "StringTable {" - " value {" - " entries: 'http://'" - " entries: @Foo.name" - " entries: ':'" - " entries: @Foo.id" - " entries: '/risk'" - " }" - "}"); + initialize_for_test("Foo {" + " value { name: 'edge-eharding' id: 80 }" + "}" + "StringTable {" + " value {" + " entries: 'http://'" + " entries: @Foo.name" + " entries: ':'" + " entries: @Foo.id" + " entries: '/risk'" + " }" + "}"); std::string result; - for (const auto& part : get().entries()) { + for (const auto &part : get().entries()) { result += part; } REQUIRE(result == "http://edge-eharding:80/risk"); } SECTION("string_concat_test") { - initialize_for_test( - "Ports {\n" - " value { \n" - " config_port: 80 \n" - " }\n" - "}\n" - "RuleRef { \n" - " value { \n" - " a_string: \"localhost\"\n" - " }\n" - "}\n" - "macro{\n" - " name: 'list'\n" - " expression: \"['http://', RuleRef.a_string, ':', Ports.config_port, '/risk']\"\n" - "}" - "StringTable {\n" - "value {\n" - " entries: 'http://'\n" - " entries: @RuleRef.a_string\n" - " entries: ':'\n" - " entries: @Ports.config_port\n" - " entries: '/risk'\n" - "}}\n" - "Foo { \n" - " value {\n" - " name: $list\n" - " url: @StringTable.entries \n" - " }\n" - "}" - ); + initialize_for_test("Ports {\n" + " value { \n" + " config_port: 80 \n" + " }\n" + "}\n" + "RuleRef { \n" + " value { \n" + " a_string: \"localhost\"\n" + " }\n" + "}\n" + "macro{\n" + " name: 'list'\n" + " expression: \"['http://', RuleRef.a_string, ':', " + "Ports.config_port, '/risk']\"\n" + "}" + "StringTable {\n" + "value {\n" + " entries: 'http://'\n" + " entries: @RuleRef.a_string\n" + " entries: ':'\n" + " entries: @Ports.config_port\n" + " entries: '/risk'\n" + "}}\n" + "Foo { \n" + " value {\n" + " name: $list\n" + " url: @StringTable.entries \n" + " }\n" + "}"); auto foo = config::get(); auto expected = "http://localhost:80/risk"; REQUIRE(foo.name() == expected); REQUIRE(foo.url() == expected); } - + reset(); } -} - +} // namespace bts diff --git a/src/lib/config/text_format/strutil.h b/src/lib/config/text_format/strutil.h index df28c94da..a3d11957f 100644 --- a/src/lib/config/text_format/strutil.h +++ b/src/lib/config/text_format/strutil.h @@ -33,16 +33,16 @@ #ifndef GOOGLE_PROTOBUF_STUBS_STRUTIL_H__ #define GOOGLE_PROTOBUF_STUBS_STRUTIL_H__ -#include -#include #include #include +#include +#include namespace google { namespace protobuf { #ifdef _MSC_VER -#define strtoll _strtoi64 +#define strtoll _strtoi64 #define strtoull _strtoui64 #elif defined(__DECCXX) && defined(__osf__) // HP C++ on Tru64 does not have strtoll, but strtol is already 64-bit. @@ -63,43 +63,36 @@ namespace protobuf { // ---------------------------------------------------------------------- inline bool ascii_isalnum(char c) { - return ('a' <= c && c <= 'z') || - ('A' <= c && c <= 'Z') || - ('0' <= c && c <= '9'); + return ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || + ('0' <= c && c <= '9'); } -inline bool ascii_isdigit(char c) { - return ('0' <= c && c <= '9'); -} +inline bool ascii_isdigit(char c) { return ('0' <= c && c <= '9'); } inline bool ascii_isspace(char c) { - return c == ' ' || c == '\t' || c == '\n' || c == '\v' || c == '\f' || - c == '\r'; + return c == ' ' || c == '\t' || c == '\n' || c == '\v' || c == '\f' || + c == '\r'; } -inline bool ascii_isupper(char c) { - return c >= 'A' && c <= 'Z'; -} +inline bool ascii_isupper(char c) { return c >= 'A' && c <= 'Z'; } -inline bool ascii_islower(char c) { - return c >= 'a' && c <= 'z'; -} +inline bool ascii_islower(char c) { return c >= 'a' && c <= 'z'; } inline char ascii_toupper(char c) { - return ascii_islower(c) ? c - ('a' - 'A') : c; + return ascii_islower(c) ? c - ('a' - 'A') : c; } inline char ascii_tolower(char c) { - return ascii_isupper(c) ? c + ('a' - 'A') : c; + return ascii_isupper(c) ? c + ('a' - 'A') : c; } inline int hex_digit_to_int(char c) { - /* Assume ASCII. */ - int x = static_cast(c); - if (x > '9') { - x += 9; - } - return x & 0xf; + /* Assume ASCII. */ + int x = static_cast(c); + if (x > '9') { + x += 9; + } + return x & 0xf; } // ---------------------------------------------------------------------- @@ -110,18 +103,17 @@ inline int hex_digit_to_int(char c) { // prefix string if the prefix matches, otherwise the original // string. // ---------------------------------------------------------------------- -inline bool HasPrefixString(const string& str, - const string& prefix) { - return str.size() >= prefix.size() && - str.compare(0, prefix.size(), prefix) == 0; +inline bool HasPrefixString(const string &str, const string &prefix) { + return str.size() >= prefix.size() && + str.compare(0, prefix.size(), prefix) == 0; } -inline string StripPrefixString(const string& str, const string& prefix) { - if (HasPrefixString(str, prefix)) { - return str.substr(prefix.size()); - } else { - return str; - } +inline string StripPrefixString(const string &str, const string &prefix) { + if (HasPrefixString(str, prefix)) { + return str.substr(prefix.size()); + } else { + return str; + } } // ---------------------------------------------------------------------- @@ -132,18 +124,17 @@ inline string StripPrefixString(const string& str, const string& prefix) { // suffix string if the suffix matches, otherwise the original // string. // ---------------------------------------------------------------------- -inline bool HasSuffixString(const string& str, - const string& suffix) { - return str.size() >= suffix.size() && - str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0; +inline bool HasSuffixString(const string &str, const string &suffix) { + return str.size() >= suffix.size() && + str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0; } -inline string StripSuffixString(const string& str, const string& suffix) { - if (HasSuffixString(str, suffix)) { - return str.substr(0, str.size() - suffix.size()); - } else { - return str; - } +inline string StripSuffixString(const string &str, const string &suffix) { + if (HasSuffixString(str, suffix)) { + return str.substr(0, str.size() - suffix.size()); + } else { + return str; + } } // ---------------------------------------------------------------------- @@ -155,13 +146,12 @@ inline string StripSuffixString(const string& str, const string& suffix) { // StripWhitespace // Removes whitespaces from both ends of the given string. // ---------------------------------------------------------------------- -LIBPROTOBUF_EXPORT void ReplaceCharacters(string* s, const char* remove, - char replacewith); -LIBPROTOBUF_EXPORT void StripString(string* s, const char* remove, - char replacewith); - -LIBPROTOBUF_EXPORT void StripWhitespace(string* s); +LIBPROTOBUF_EXPORT void +ReplaceCharacters(string *s, const char *remove, char replacewith); +LIBPROTOBUF_EXPORT void +StripString(string *s, const char *remove, char replacewith); +LIBPROTOBUF_EXPORT void StripWhitespace(string *s); // ---------------------------------------------------------------------- // LowerString() @@ -173,26 +163,28 @@ LIBPROTOBUF_EXPORT void StripWhitespace(string* s); // strings. // ---------------------------------------------------------------------- -inline void LowerString(string * s) { - string::iterator end = s->end(); - for (string::iterator i = s->begin(); i != end; ++i) { - // tolower() changes based on locale. We don't want this! - if ('A' <= *i && *i <= 'Z') *i += 'a' - 'A'; - } +inline void LowerString(string *s) { + string::iterator end = s->end(); + for (string::iterator i = s->begin(); i != end; ++i) { + // tolower() changes based on locale. We don't want this! + if ('A' <= *i && *i <= 'Z') + *i += 'a' - 'A'; + } } -inline void UpperString(string * s) { - string::iterator end = s->end(); - for (string::iterator i = s->begin(); i != end; ++i) { - // toupper() changes based on locale. We don't want this! - if ('a' <= *i && *i <= 'z') *i += 'A' - 'a'; - } +inline void UpperString(string *s) { + string::iterator end = s->end(); + for (string::iterator i = s->begin(); i != end; ++i) { + // toupper() changes based on locale. We don't want this! + if ('a' <= *i && *i <= 'z') + *i += 'A' - 'a'; + } } -inline string ToUpper(const string& s) { - string out = s; - UpperString(&out); - return out; +inline string ToUpper(const string &s) { + string out = s; + UpperString(&out); + return out; } // ---------------------------------------------------------------------- @@ -203,8 +195,9 @@ inline string ToUpper(const string& s) { // happened or not. // ---------------------------------------------------------------------- -LIBPROTOBUF_EXPORT string StringReplace(const string& s, const string& oldsub, - const string& newsub, bool replace_all); +LIBPROTOBUF_EXPORT string StringReplace( + const string &s, const string &oldsub, const string &newsub, + bool replace_all); // ---------------------------------------------------------------------- // SplitStringUsing() @@ -212,8 +205,8 @@ LIBPROTOBUF_EXPORT string StringReplace(const string& s, const string& oldsub, // to 'result'. If there are consecutive delimiters, this function skips // over all of them. // ---------------------------------------------------------------------- -LIBPROTOBUF_EXPORT void SplitStringUsing(const string& full, const char* delim, - vector* res); +LIBPROTOBUF_EXPORT void +SplitStringUsing(const string &full, const char *delim, vector *res); // Split a string using one or more byte delimiters, presented // as a nul-terminated c string. Append the components to 'result'. @@ -223,23 +216,22 @@ LIBPROTOBUF_EXPORT void SplitStringUsing(const string& full, const char* delim, // // If "full" is the empty string, yields an empty string as the only value. // ---------------------------------------------------------------------- -LIBPROTOBUF_EXPORT void SplitStringAllowEmpty(const string& full, - const char* delim, - vector* result); +LIBPROTOBUF_EXPORT void SplitStringAllowEmpty( + const string &full, const char *delim, vector *result); // ---------------------------------------------------------------------- // Split() // Split a string using a character delimiter. // ---------------------------------------------------------------------- -inline vector Split( - const string& full, const char* delim, bool skip_empty = true) { - vector result; - if (skip_empty) { - SplitStringUsing(full, delim, &result); - } else { - SplitStringAllowEmpty(full, delim, &result); - } - return result; +inline vector +Split(const string &full, const char *delim, bool skip_empty = true) { + vector result; + if (skip_empty) { + SplitStringUsing(full, delim, &result); + } else { + SplitStringAllowEmpty(full, delim, &result); + } + return result; } // ---------------------------------------------------------------------- @@ -250,14 +242,13 @@ inline vector Split( // another takes a pointer to the target string. In the latter case the // target string is cleared and overwritten. // ---------------------------------------------------------------------- -LIBPROTOBUF_EXPORT void JoinStrings(const vector& components, - const char* delim, string* result); +LIBPROTOBUF_EXPORT void JoinStrings( + const vector &components, const char *delim, string *result); -inline string JoinStrings(const vector& components, - const char* delim) { - string result; - JoinStrings(components, delim, &result); - return result; +inline string JoinStrings(const vector &components, const char *delim) { + string result; + JoinStrings(components, delim, &result); + return result; } // ---------------------------------------------------------------------- @@ -291,9 +282,9 @@ inline string JoinStrings(const vector& components, // processed. // ---------------------------------------------------------------------- -LIBPROTOBUF_EXPORT int UnescapeCEscapeSequences(const char* source, char* dest); -LIBPROTOBUF_EXPORT int UnescapeCEscapeSequences(const char* source, char* dest, - vector *errors); +LIBPROTOBUF_EXPORT int UnescapeCEscapeSequences(const char *source, char *dest); +LIBPROTOBUF_EXPORT int UnescapeCEscapeSequences( + const char *source, char *dest, vector *errors); // ---------------------------------------------------------------------- // UnescapeCEscapeString() @@ -310,10 +301,10 @@ LIBPROTOBUF_EXPORT int UnescapeCEscapeSequences(const char* source, char* dest, // the third call, the new string is returned. // ---------------------------------------------------------------------- -LIBPROTOBUF_EXPORT int UnescapeCEscapeString(const string& src, string* dest); -LIBPROTOBUF_EXPORT int UnescapeCEscapeString(const string& src, string* dest, - vector *errors); -LIBPROTOBUF_EXPORT string UnescapeCEscapeString(const string& src); +LIBPROTOBUF_EXPORT int UnescapeCEscapeString(const string &src, string *dest); +LIBPROTOBUF_EXPORT int +UnescapeCEscapeString(const string &src, string *dest, vector *errors); +LIBPROTOBUF_EXPORT string UnescapeCEscapeString(const string &src); // ---------------------------------------------------------------------- // CEscape() @@ -322,22 +313,22 @@ LIBPROTOBUF_EXPORT string UnescapeCEscapeString(const string& src); // // Escaped chars: \n, \r, \t, ", ', \, and !isprint(). // ---------------------------------------------------------------------- -LIBPROTOBUF_EXPORT string CEscape(const string& src); +LIBPROTOBUF_EXPORT string CEscape(const string &src); // ---------------------------------------------------------------------- // CEscapeAndAppend() // Escapes 'src' using C-style escape sequences, and appends the escaped // string to 'dest'. // ---------------------------------------------------------------------- -LIBPROTOBUF_EXPORT void CEscapeAndAppend(StringPiece src, string* dest); +LIBPROTOBUF_EXPORT void CEscapeAndAppend(StringPiece src, string *dest); namespace strings { // Like CEscape() but does not escape bytes with the upper bit set. -LIBPROTOBUF_EXPORT string Utf8SafeCEscape(const string& src); +LIBPROTOBUF_EXPORT string Utf8SafeCEscape(const string &src); // Like CEscape() but uses hex (\x) escapes instead of octals. -LIBPROTOBUF_EXPORT string CHexEscape(const string& src); -} // namespace strings +LIBPROTOBUF_EXPORT string CHexEscape(const string &src); +} // namespace strings // ---------------------------------------------------------------------- // strto32() @@ -349,37 +340,39 @@ LIBPROTOBUF_EXPORT string CHexEscape(const string& src); // platforms, so using these is safer, from the point of view of // overflow behavior, than using the standard libc functions. // ---------------------------------------------------------------------- -LIBPROTOBUF_EXPORT int32 strto32_adaptor(const char *nptr, char **endptr, - int base); -LIBPROTOBUF_EXPORT uint32 strtou32_adaptor(const char *nptr, char **endptr, - int base); +LIBPROTOBUF_EXPORT int32 +strto32_adaptor(const char *nptr, char **endptr, int base); +LIBPROTOBUF_EXPORT uint32 +strtou32_adaptor(const char *nptr, char **endptr, int base); inline int32 strto32(const char *nptr, char **endptr, int base) { - if (sizeof(int32) == sizeof(long)) - return strtol(nptr, endptr, base); - else - return strto32_adaptor(nptr, endptr, base); + if (sizeof(int32) == sizeof(long)) + return strtol(nptr, endptr, base); + else + return strto32_adaptor(nptr, endptr, base); } inline uint32 strtou32(const char *nptr, char **endptr, int base) { - if (sizeof(uint32) == sizeof(unsigned long)) - return strtoul(nptr, endptr, base); - else - return strtou32_adaptor(nptr, endptr, base); + if (sizeof(uint32) == sizeof(unsigned long)) + return strtoul(nptr, endptr, base); + else + return strtou32_adaptor(nptr, endptr, base); } // For now, long long is 64-bit on all the platforms we care about, so these // functions can simply pass the call to strto[u]ll. inline int64 strto64(const char *nptr, char **endptr, int base) { - GOOGLE_COMPILE_ASSERT(sizeof(int64) == sizeof(long long), - sizeof_int64_is_not_sizeof_long_long); - return strtoll(nptr, endptr, base); + GOOGLE_COMPILE_ASSERT( + sizeof(int64) == sizeof(long long), + sizeof_int64_is_not_sizeof_long_long); + return strtoll(nptr, endptr, base); } inline uint64 strtou64(const char *nptr, char **endptr, int base) { - GOOGLE_COMPILE_ASSERT(sizeof(uint64) == sizeof(unsigned long long), - sizeof_uint64_is_not_sizeof_long_long); - return strtoull(nptr, endptr, base); + GOOGLE_COMPILE_ASSERT( + sizeof(uint64) == sizeof(unsigned long long), + sizeof_uint64_is_not_sizeof_long_long); + return strtoull(nptr, endptr, base); } // ---------------------------------------------------------------------- @@ -391,51 +384,51 @@ inline uint64 strtou64(const char *nptr, char **endptr, int base) { // safe_strtof() // safe_strtod() // ---------------------------------------------------------------------- -LIBPROTOBUF_EXPORT bool safe_strtob(StringPiece str, bool* value); +LIBPROTOBUF_EXPORT bool safe_strtob(StringPiece str, bool *value); -LIBPROTOBUF_EXPORT bool safe_strto32(const string& str, int32* value); -LIBPROTOBUF_EXPORT bool safe_strtou32(const string& str, uint32* value); -inline bool safe_strto32(const char* str, int32* value) { - return safe_strto32(string(str), value); +LIBPROTOBUF_EXPORT bool safe_strto32(const string &str, int32 *value); +LIBPROTOBUF_EXPORT bool safe_strtou32(const string &str, uint32 *value); +inline bool safe_strto32(const char *str, int32 *value) { + return safe_strto32(string(str), value); } -inline bool safe_strto32(StringPiece str, int32* value) { - return safe_strto32(str.ToString(), value); +inline bool safe_strto32(StringPiece str, int32 *value) { + return safe_strto32(str.ToString(), value); } -inline bool safe_strtou32(const char* str, uint32* value) { - return safe_strtou32(string(str), value); +inline bool safe_strtou32(const char *str, uint32 *value) { + return safe_strtou32(string(str), value); } -inline bool safe_strtou32(StringPiece str, uint32* value) { - return safe_strtou32(str.ToString(), value); +inline bool safe_strtou32(StringPiece str, uint32 *value) { + return safe_strtou32(str.ToString(), value); } -LIBPROTOBUF_EXPORT bool safe_strto64(const string& str, int64* value); -LIBPROTOBUF_EXPORT bool safe_strtou64(const string& str, uint64* value); -inline bool safe_strto64(const char* str, int64* value) { - return safe_strto64(string(str), value); +LIBPROTOBUF_EXPORT bool safe_strto64(const string &str, int64 *value); +LIBPROTOBUF_EXPORT bool safe_strtou64(const string &str, uint64 *value); +inline bool safe_strto64(const char *str, int64 *value) { + return safe_strto64(string(str), value); } -inline bool safe_strto64(StringPiece str, int64* value) { - return safe_strto64(str.ToString(), value); +inline bool safe_strto64(StringPiece str, int64 *value) { + return safe_strto64(str.ToString(), value); } -inline bool safe_strtou64(const char* str, uint64* value) { - return safe_strtou64(string(str), value); +inline bool safe_strtou64(const char *str, uint64 *value) { + return safe_strtou64(string(str), value); } -inline bool safe_strtou64(StringPiece str, uint64* value) { - return safe_strtou64(str.ToString(), value); +inline bool safe_strtou64(StringPiece str, uint64 *value) { + return safe_strtou64(str.ToString(), value); } -LIBPROTOBUF_EXPORT bool safe_strtof(const char* str, float* value); -LIBPROTOBUF_EXPORT bool safe_strtod(const char* str, double* value); -inline bool safe_strtof(const string& str, float* value) { - return safe_strtof(str.c_str(), value); +LIBPROTOBUF_EXPORT bool safe_strtof(const char *str, float *value); +LIBPROTOBUF_EXPORT bool safe_strtod(const char *str, double *value); +inline bool safe_strtof(const string &str, float *value) { + return safe_strtof(str.c_str(), value); } -inline bool safe_strtod(const string& str, double* value) { - return safe_strtod(str.c_str(), value); +inline bool safe_strtod(const string &str, double *value) { + return safe_strtod(str.c_str(), value); } -inline bool safe_strtof(StringPiece str, float* value) { - return safe_strtof(str.ToString(), value); +inline bool safe_strtof(StringPiece str, float *value) { + return safe_strtof(str.ToString(), value); } -inline bool safe_strtod(StringPiece str, double* value) { - return safe_strtod(str.ToString(), value); +inline bool safe_strtod(StringPiece str, double *value) { + return safe_strtod(str.ToString(), value); } // ---------------------------------------------------------------------- @@ -464,30 +457,34 @@ inline bool safe_strtod(StringPiece str, double* value) { // DoubleToBuffer() and FloatToBuffer(). static const int kFastToBufferSize = 32; -LIBPROTOBUF_EXPORT char* FastInt32ToBuffer(int32 i, char* buffer); -LIBPROTOBUF_EXPORT char* FastInt64ToBuffer(int64 i, char* buffer); -char* FastUInt32ToBuffer(uint32 i, char* buffer); // inline below -char* FastUInt64ToBuffer(uint64 i, char* buffer); // inline below -LIBPROTOBUF_EXPORT char* FastHexToBuffer(int i, char* buffer); -LIBPROTOBUF_EXPORT char* FastHex64ToBuffer(uint64 i, char* buffer); -LIBPROTOBUF_EXPORT char* FastHex32ToBuffer(uint32 i, char* buffer); +LIBPROTOBUF_EXPORT char *FastInt32ToBuffer(int32 i, char *buffer); +LIBPROTOBUF_EXPORT char *FastInt64ToBuffer(int64 i, char *buffer); +char *FastUInt32ToBuffer(uint32 i, char *buffer); // inline below +char *FastUInt64ToBuffer(uint64 i, char *buffer); // inline below +LIBPROTOBUF_EXPORT char *FastHexToBuffer(int i, char *buffer); +LIBPROTOBUF_EXPORT char *FastHex64ToBuffer(uint64 i, char *buffer); +LIBPROTOBUF_EXPORT char *FastHex32ToBuffer(uint32 i, char *buffer); // at least 22 bytes long -inline char* FastIntToBuffer(int i, char* buffer) { - return (sizeof(i) == 4 ? - FastInt32ToBuffer(i, buffer) : FastInt64ToBuffer(i, buffer)); +inline char *FastIntToBuffer(int i, char *buffer) { + return ( + sizeof(i) == 4 ? FastInt32ToBuffer(i, buffer) + : FastInt64ToBuffer(i, buffer)); } -inline char* FastUIntToBuffer(unsigned int i, char* buffer) { - return (sizeof(i) == 4 ? - FastUInt32ToBuffer(i, buffer) : FastUInt64ToBuffer(i, buffer)); +inline char *FastUIntToBuffer(unsigned int i, char *buffer) { + return ( + sizeof(i) == 4 ? FastUInt32ToBuffer(i, buffer) + : FastUInt64ToBuffer(i, buffer)); } -inline char* FastLongToBuffer(long i, char* buffer) { - return (sizeof(i) == 4 ? - FastInt32ToBuffer(i, buffer) : FastInt64ToBuffer(i, buffer)); +inline char *FastLongToBuffer(long i, char *buffer) { + return ( + sizeof(i) == 4 ? FastInt32ToBuffer(i, buffer) + : FastInt64ToBuffer(i, buffer)); } -inline char* FastULongToBuffer(unsigned long i, char* buffer) { - return (sizeof(i) == 4 ? - FastUInt32ToBuffer(i, buffer) : FastUInt64ToBuffer(i, buffer)); +inline char *FastULongToBuffer(unsigned long i, char *buffer) { + return ( + sizeof(i) == 4 ? FastUInt32ToBuffer(i, buffer) + : FastUInt64ToBuffer(i, buffer)); } // ---------------------------------------------------------------------- @@ -506,24 +503,22 @@ inline char* FastULongToBuffer(unsigned long i, char* buffer) { // terminating the string). // ---------------------------------------------------------------------- -LIBPROTOBUF_EXPORT char* FastInt32ToBufferLeft(int32 i, char* buffer); -LIBPROTOBUF_EXPORT char* FastUInt32ToBufferLeft(uint32 i, char* buffer); -LIBPROTOBUF_EXPORT char* FastInt64ToBufferLeft(int64 i, char* buffer); -LIBPROTOBUF_EXPORT char* FastUInt64ToBufferLeft(uint64 i, char* buffer); +LIBPROTOBUF_EXPORT char *FastInt32ToBufferLeft(int32 i, char *buffer); +LIBPROTOBUF_EXPORT char *FastUInt32ToBufferLeft(uint32 i, char *buffer); +LIBPROTOBUF_EXPORT char *FastInt64ToBufferLeft(int64 i, char *buffer); +LIBPROTOBUF_EXPORT char *FastUInt64ToBufferLeft(uint64 i, char *buffer); // Just define these in terms of the above. -inline char* FastUInt32ToBuffer(uint32 i, char* buffer) { - FastUInt32ToBufferLeft(i, buffer); - return buffer; +inline char *FastUInt32ToBuffer(uint32 i, char *buffer) { + FastUInt32ToBufferLeft(i, buffer); + return buffer; } -inline char* FastUInt64ToBuffer(uint64 i, char* buffer) { - FastUInt64ToBufferLeft(i, buffer); - return buffer; +inline char *FastUInt64ToBuffer(uint64 i, char *buffer) { + FastUInt64ToBufferLeft(i, buffer); + return buffer; } -inline string SimpleBtoa(bool value) { - return value ? "true" : "false"; -} +inline string SimpleBtoa(bool value) { return value ? "true" : "false"; } // ---------------------------------------------------------------------- // SimpleItoa() @@ -560,8 +555,8 @@ LIBPROTOBUF_EXPORT string SimpleItoa(unsigned long long i); LIBPROTOBUF_EXPORT string SimpleDtoa(double value); LIBPROTOBUF_EXPORT string SimpleFtoa(float value); -LIBPROTOBUF_EXPORT char* DoubleToBuffer(double i, char* buffer); -LIBPROTOBUF_EXPORT char* FloatToBuffer(float i, char* buffer); +LIBPROTOBUF_EXPORT char *DoubleToBuffer(double i, char *buffer); +LIBPROTOBUF_EXPORT char *FloatToBuffer(float i, char *buffer); // In practice, doubles should never need more than 24 bytes and floats // should never need more than 14 (including null terminators), but we @@ -572,100 +567,99 @@ static const int kFloatToBufferSize = 24; namespace strings { enum PadSpec { - NO_PAD = 1, - ZERO_PAD_2, - ZERO_PAD_3, - ZERO_PAD_4, - ZERO_PAD_5, - ZERO_PAD_6, - ZERO_PAD_7, - ZERO_PAD_8, - ZERO_PAD_9, - ZERO_PAD_10, - ZERO_PAD_11, - ZERO_PAD_12, - ZERO_PAD_13, - ZERO_PAD_14, - ZERO_PAD_15, - ZERO_PAD_16, + NO_PAD = 1, + ZERO_PAD_2, + ZERO_PAD_3, + ZERO_PAD_4, + ZERO_PAD_5, + ZERO_PAD_6, + ZERO_PAD_7, + ZERO_PAD_8, + ZERO_PAD_9, + ZERO_PAD_10, + ZERO_PAD_11, + ZERO_PAD_12, + ZERO_PAD_13, + ZERO_PAD_14, + ZERO_PAD_15, + ZERO_PAD_16, }; struct Hex { - uint64 value; - enum PadSpec spec; - template - explicit Hex(Int v, PadSpec s = NO_PAD) - : spec(s) { - // Prevent sign-extension by casting integers to - // their unsigned counterparts. + uint64 value; + enum PadSpec spec; + template explicit Hex(Int v, PadSpec s = NO_PAD) : spec(s) { + // Prevent sign-extension by casting integers to + // their unsigned counterparts. #ifdef LANG_CXX11 - static_assert( - sizeof(v) == 1 || sizeof(v) == 2 || sizeof(v) == 4 || sizeof(v) == 8, - "Unknown integer type"); + static_assert( + sizeof(v) == 1 || sizeof(v) == 2 || sizeof(v) == 4 || sizeof(v) == 8, + "Unknown integer type"); #endif - value = sizeof(v) == 1 ? static_cast(v) - : sizeof(v) == 2 ? static_cast(v) - : sizeof(v) == 4 ? static_cast(v) - : static_cast(v); - } + value = sizeof(v) == 1 + ? static_cast(v) + : sizeof(v) == 2 ? static_cast(v) + : sizeof(v) == 4 ? static_cast(v) + : static_cast(v); + } }; struct LIBPROTOBUF_EXPORT AlphaNum { - const char *piece_data_; // move these to string_ref eventually - size_t piece_size_; // move these to string_ref eventually + const char *piece_data_; // move these to string_ref eventually + size_t piece_size_; // move these to string_ref eventually - char digits[kFastToBufferSize]; + char digits[kFastToBufferSize]; - // No bool ctor -- bools convert to an integral type. - // A bool ctor would also convert incoming pointers (bletch). + // No bool ctor -- bools convert to an integral type. + // A bool ctor would also convert incoming pointers (bletch). - AlphaNum(int32 i32) - : piece_data_(digits), - piece_size_(FastInt32ToBufferLeft(i32, digits) - &digits[0]) {} - AlphaNum(uint32 u32) - : piece_data_(digits), - piece_size_(FastUInt32ToBufferLeft(u32, digits) - &digits[0]) {} - AlphaNum(int64 i64) - : piece_data_(digits), - piece_size_(FastInt64ToBufferLeft(i64, digits) - &digits[0]) {} - AlphaNum(uint64 u64) - : piece_data_(digits), - piece_size_(FastUInt64ToBufferLeft(u64, digits) - &digits[0]) {} + AlphaNum(int32 i32) + : piece_data_(digits), + piece_size_(FastInt32ToBufferLeft(i32, digits) - &digits[0]) {} + AlphaNum(uint32 u32) + : piece_data_(digits), + piece_size_(FastUInt32ToBufferLeft(u32, digits) - &digits[0]) {} + AlphaNum(int64 i64) + : piece_data_(digits), + piece_size_(FastInt64ToBufferLeft(i64, digits) - &digits[0]) {} + AlphaNum(uint64 u64) + : piece_data_(digits), + piece_size_(FastUInt64ToBufferLeft(u64, digits) - &digits[0]) {} - AlphaNum(float f) - : piece_data_(digits), piece_size_(strlen(FloatToBuffer(f, digits))) {} - AlphaNum(double f) - : piece_data_(digits), piece_size_(strlen(DoubleToBuffer(f, digits))) {} + AlphaNum(float f) + : piece_data_(digits), piece_size_(strlen(FloatToBuffer(f, digits))) {} + AlphaNum(double f) + : piece_data_(digits), piece_size_(strlen(DoubleToBuffer(f, digits))) {} - AlphaNum(Hex hex); + AlphaNum(Hex hex); - AlphaNum(const char* c_str) - : piece_data_(c_str), piece_size_(strlen(c_str)) {} - // TODO: Add a string_ref constructor, eventually - // AlphaNum(const StringPiece &pc) : piece(pc) {} + AlphaNum(const char *c_str) + : piece_data_(c_str), piece_size_(strlen(c_str)) {} + // TODO: Add a string_ref constructor, eventually + // AlphaNum(const StringPiece &pc) : piece(pc) {} - AlphaNum(const string& str) - : piece_data_(str.data()), piece_size_(str.size()) {} + AlphaNum(const string &str) + : piece_data_(str.data()), piece_size_(str.size()) {} - AlphaNum(StringPiece str) - : piece_data_(str.data()), piece_size_(str.size()) {} + AlphaNum(StringPiece str) + : piece_data_(str.data()), piece_size_(str.size()) {} - AlphaNum(internal::StringPiecePod str) - : piece_data_(str.data()), piece_size_(str.size()) {} + AlphaNum(internal::StringPiecePod str) + : piece_data_(str.data()), piece_size_(str.size()) {} - size_t size() const { return piece_size_; } - const char *data() const { return piece_data_; } + size_t size() const { return piece_size_; } + const char *data() const { return piece_data_; } private: - // Use ":" not ':' - AlphaNum(char c); // NOLINT(runtime/explicit) + // Use ":" not ':' + AlphaNum(char c); // NOLINT(runtime/explicit) - // Disallow copy and assign. - AlphaNum(const AlphaNum&); - void operator=(const AlphaNum&); + // Disallow copy and assign. + AlphaNum(const AlphaNum &); + void operator=(const AlphaNum &); }; -} // namespace strings +} // namespace strings using strings::AlphaNum; @@ -692,32 +686,29 @@ using strings::AlphaNum; // be a reference into str. // ---------------------------------------------------------------------- -LIBPROTOBUF_EXPORT string StrCat(const AlphaNum& a, const AlphaNum& b); -LIBPROTOBUF_EXPORT string 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& e); -LIBPROTOBUF_EXPORT string StrCat(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); -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); -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& i); +LIBPROTOBUF_EXPORT string StrCat(const AlphaNum &a, const AlphaNum &b); +LIBPROTOBUF_EXPORT string +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 &e); +LIBPROTOBUF_EXPORT string StrCat( + 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); +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); +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 &i); -inline string StrCat(const AlphaNum& a) { return string(a.data(), a.size()); } +inline string StrCat(const AlphaNum &a) { return string(a.data(), a.size()); } // ---------------------------------------------------------------------- // StrAppend() @@ -740,14 +731,14 @@ inline string StrCat(const AlphaNum& a) { return string(a.data(), a.size()); } // worked around as consecutive calls to StrAppend are quite efficient. // ---------------------------------------------------------------------- -LIBPROTOBUF_EXPORT void StrAppend(string* dest, const AlphaNum& a); -LIBPROTOBUF_EXPORT void 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, - const AlphaNum& d); +LIBPROTOBUF_EXPORT void StrAppend(string *dest, const AlphaNum &a); +LIBPROTOBUF_EXPORT void +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, + const AlphaNum &d); // ---------------------------------------------------------------------- // Join() @@ -755,22 +746,20 @@ LIBPROTOBUF_EXPORT void StrAppend(string* dest, const AlphaNum& a, // the C-string "delim" as a separator between components. // ---------------------------------------------------------------------- template -void Join(Iterator start, Iterator end, - const char* delim, string* result) { - for (Iterator it = start; it != end; ++it) { - if (it != start) { - result->append(delim); - } - StrAppend(result, *it); - } +void Join(Iterator start, Iterator end, const char *delim, string *result) { + for (Iterator it = start; it != end; ++it) { + if (it != start) { + result->append(delim); + } + StrAppend(result, *it); + } } template -string Join(const Range& components, - const char* delim) { - string result; - Join(components.begin(), components.end(), delim, &result); - return result; +string Join(const Range &components, const char *delim) { + string result; + Join(components.begin(), components.end(), delim, &result); + return result; } // ---------------------------------------------------------------------- @@ -786,9 +775,8 @@ LIBPROTOBUF_EXPORT string ToHex(uint64 num); // // NOTE: The string pieces must not overlap s. // ---------------------------------------------------------------------- -LIBPROTOBUF_EXPORT int GlobalReplaceSubstring(const string& substring, - const string& replacement, - string* s); +LIBPROTOBUF_EXPORT int GlobalReplaceSubstring( + const string &substring, const string &replacement, string *s); // ---------------------------------------------------------------------- // Base64Unescape() @@ -796,7 +784,7 @@ LIBPROTOBUF_EXPORT int GlobalReplaceSubstring(const string& substring, // writes it to "dest". If src contains invalid characters, dest is cleared // and the function returns false. Returns true on success. // ---------------------------------------------------------------------- -LIBPROTOBUF_EXPORT bool Base64Unescape(StringPiece src, string* dest); +LIBPROTOBUF_EXPORT bool Base64Unescape(StringPiece src, string *dest); // ---------------------------------------------------------------------- // WebSafeBase64Unescape() @@ -809,16 +797,16 @@ LIBPROTOBUF_EXPORT bool Base64Unescape(StringPiece src, string* dest); // returns false (with dest empty) if src contains invalid chars; for // this version src and dest must be different strings. // ---------------------------------------------------------------------- -LIBPROTOBUF_EXPORT int WebSafeBase64Unescape(const char* src, int slen, - char* dest, int szdest); -LIBPROTOBUF_EXPORT bool WebSafeBase64Unescape(StringPiece src, string* dest); +LIBPROTOBUF_EXPORT int +WebSafeBase64Unescape(const char *src, int slen, char *dest, int szdest); +LIBPROTOBUF_EXPORT bool WebSafeBase64Unescape(StringPiece src, string *dest); // Return the length to use for the output buffer given to the base64 escape // routines. Make sure to use the same value for do_padding in both. // This function may return incorrect results if given input_len values that // are extremely high, which should happen rarely. -LIBPROTOBUF_EXPORT int CalculateBase64EscapedLen(int input_len, - bool do_padding); +LIBPROTOBUF_EXPORT int +CalculateBase64EscapedLen(int input_len, bool do_padding); // Use this version when calling Base64Escape without a do_padding arg. LIBPROTOBUF_EXPORT int CalculateBase64EscapedLen(int input_len); @@ -834,27 +822,27 @@ LIBPROTOBUF_EXPORT int CalculateBase64EscapedLen(int input_len); // to escape them. It also has an extra parameter "do_padding", // which when set to false will prevent padding with "=". // ---------------------------------------------------------------------- -LIBPROTOBUF_EXPORT int Base64Escape(const unsigned char* src, int slen, - char* dest, int szdest); +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, bool do_padding); + 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); +LIBPROTOBUF_EXPORT void Base64Escape(StringPiece src, string *dest); // Encode src into dest web-safely without padding. -LIBPROTOBUF_EXPORT void WebSafeBase64Escape(StringPiece src, string* dest); +LIBPROTOBUF_EXPORT void WebSafeBase64Escape(StringPiece src, string *dest); // Encode src into dest web-safely with padding. -LIBPROTOBUF_EXPORT void WebSafeBase64EscapeWithPadding(StringPiece src, - string* dest); +LIBPROTOBUF_EXPORT void +WebSafeBase64EscapeWithPadding(StringPiece src, string *dest); -LIBPROTOBUF_EXPORT void Base64Escape(const unsigned char* src, int szsrc, - string* dest, bool do_padding); -LIBPROTOBUF_EXPORT void WebSafeBase64Escape(const unsigned char* src, int szsrc, - string* dest, bool do_padding); +LIBPROTOBUF_EXPORT void Base64Escape( + const unsigned char *src, int szsrc, string *dest, bool do_padding); +LIBPROTOBUF_EXPORT void WebSafeBase64Escape( + const unsigned char *src, int szsrc, string *dest, bool do_padding); inline bool IsValidCodePoint(uint32 code_point) { - return code_point < 0xD800 || - (code_point >= 0xE000 && code_point <= 0x10FFFF); + return code_point < 0xD800 || + (code_point >= 0xE000 && code_point <= 0x10FFFF); } static const int UTFmax = 4; @@ -864,15 +852,15 @@ static const int UTFmax = 4; // in any external dependencies. The output buffer must be as least 4 bytes // large. // ---------------------------------------------------------------------- -LIBPROTOBUF_EXPORT int EncodeAsUTF8Char(uint32 code_point, char* output); +LIBPROTOBUF_EXPORT int EncodeAsUTF8Char(uint32 code_point, char *output); // ---------------------------------------------------------------------- // UTF8FirstLetterNumBytes() // Length of the first UTF-8 character. // ---------------------------------------------------------------------- -LIBPROTOBUF_EXPORT int UTF8FirstLetterNumBytes(const char* src, int len); +LIBPROTOBUF_EXPORT int UTF8FirstLetterNumBytes(const char *src, int len); -} // namespace protobuf -} // namespace google +} // namespace protobuf +} // namespace google -#endif // GOOGLE_PROTOBUF_STUBS_STRUTIL_H__ +#endif // GOOGLE_PROTOBUF_STUBS_STRUTIL_H__ diff --git a/src/lib/config/text_format/text_format.cpp b/src/lib/config/text_format/text_format.cpp old mode 100755 new mode 100644 index cc942c036..c001fd410 --- a/src/lib/config/text_format/text_format.cpp +++ b/src/lib/config/text_format/text_format.cpp @@ -35,7 +35,7 @@ // Forked from LibProtobuf for BTS Config by Eric Harding on 5/29/2013 #ifdef _WIN32 -#pragma warning (disable: 4273 4800 4018) +#pragma warning(disable : 4273 4800 4018) #endif #ifdef __GNUC__ @@ -45,23 +45,23 @@ #endif #include -#include -#include -#include #include +#include +#include +#include #include using std::vector; #include "text_format.h" +#include "strutil.h" #include +#include #include +#include #include #include #include -#include -#include -#include "strutil.h" using namespace std; using namespace google::protobuf; @@ -69,7 +69,6 @@ using namespace google::protobuf; namespace bts { namespace google { namespace protobuf { - // =========================================================================== // Internal class for parsing an ASCII representation of a Protocol Message. @@ -81,699 +80,714 @@ namespace protobuf { // Makes code slightly more readable. The meaning of "DO(foo)" is // "Execute foo and fail if it fails.", where failure is indicated by // returning false. Borrowed from parser.cc (Thanks Kenton!). -#define DO(STATEMENT) if (STATEMENT) {} else return false +#define DO(STATEMENT) \ + if (STATEMENT) { \ + } else \ + return false class TextFormat::Parser::ParserImpl { public: + // Determines if repeated values for a non-repeated field are + // permitted, e.g., the string "foo: 1 foo: 2" for a + // required/optional field named "foo". + enum SingularOverwritePolicy { + ALLOW_SINGULAR_OVERWRITES = 0, // the last value is retained + FORBID_SINGULAR_OVERWRITES = 1, // an error is issued + }; - // Determines if repeated values for a non-repeated field are - // permitted, e.g., the string "foo: 1 foo: 2" for a - // required/optional field named "foo". - enum SingularOverwritePolicy { - ALLOW_SINGULAR_OVERWRITES = 0, // the last value is retained - FORBID_SINGULAR_OVERWRITES = 1, // an error is issued - }; + ParserImpl( + const Descriptor *root_message_type, + io::ZeroCopyInputStream *input_stream, + io::ErrorCollector *error_collector, IDeferValueLookup *lookup, + TextFormat::Finder *finder, + SingularOverwritePolicy singular_overwrite_policy) + : error_collector_(error_collector), lookup_(lookup), finder_(finder), + tokenizer_error_collector_(this), + tokenizer_(input_stream, &tokenizer_error_collector_), + root_message_type_(root_message_type), + singular_overwrite_policy_(singular_overwrite_policy), + had_errors_(false), location_(), current_message_(NULL) { + // For backwards-compatibility with proto1, we need to allow the 'f' + // suffix for floats. + tokenizer_.set_allow_f_after_float(true); - ParserImpl(const Descriptor* root_message_type, - io::ZeroCopyInputStream* input_stream, - io::ErrorCollector* error_collector, - IDeferValueLookup* lookup, - TextFormat::Finder* finder, - SingularOverwritePolicy singular_overwrite_policy) - : error_collector_(error_collector), - lookup_(lookup), - finder_(finder), - tokenizer_error_collector_(this), - tokenizer_(input_stream, &tokenizer_error_collector_), - root_message_type_(root_message_type), - singular_overwrite_policy_(singular_overwrite_policy), - had_errors_(false), location_(), current_message_(NULL) { - // For backwards-compatibility with proto1, we need to allow the 'f' suffix - // for floats. - tokenizer_.set_allow_f_after_float(true); + // '#' starts a comment. + tokenizer_.set_comment_style(io::Tokenizer::SH_COMMENT_STYLE); - // '#' starts a comment. - tokenizer_.set_comment_style(io::Tokenizer::SH_COMMENT_STYLE); + // Consume the starting token. + tokenizer_.Next(); + } + ~ParserImpl() {} - // Consume the starting token. - tokenizer_.Next(); - } - ~ParserImpl() { } + // Parses the ASCII representation specified in input and saves the + // information into the output pointer (a Message). Returns + // false if an error occurs (an error will also be logged to + // GOOGLE_LOG(ERROR)). + bool Parse(Message *output) { + // Consume fields until we cannot do so anymore. + while (true) { + if (LookingAtType(io::Tokenizer::TYPE_END)) { + return !had_errors_; + } - // Parses the ASCII representation specified in input and saves the - // information into the output pointer (a Message). Returns - // false if an error occurs (an error will also be logged to - // GOOGLE_LOG(ERROR)). - bool Parse(Message* output) { - // Consume fields until we cannot do so anymore. - while(true) { - if (LookingAtType(io::Tokenizer::TYPE_END)) { - return !had_errors_; + DO(ConsumeField(output)); } + } - DO(ConsumeField(output)); - } - } - - bool ParseField(const FieldDescriptor* field, Message* output) { - bool suc; - if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { - suc = ConsumeFieldMessage(output, output->GetReflection(), field); - } else { - suc = ConsumeFieldValue(output, output->GetReflection(), field); - } - return suc && LookingAtType(io::Tokenizer::TYPE_END); - } - - void ReportError(int line, int col, const string& message) { - had_errors_ = true; - if (error_collector_ == NULL) { - if (line >= 0) { - GOOGLE_LOG(ERROR) << "Error parsing text-format " - << root_message_type_->full_name() - << ": " << (line + 1) << ":" - << (col + 1) << ": " << message; + bool ParseField(const FieldDescriptor *field, Message *output) { + bool suc; + if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { + suc = ConsumeFieldMessage(output, output->GetReflection(), field); } else { - GOOGLE_LOG(ERROR) << "Error parsing text-format " - << root_message_type_->full_name() - << ": " << message; + suc = ConsumeFieldValue(output, output->GetReflection(), field); } - } else { - error_collector_->AddError(line, col, message); - } - } + return suc && LookingAtType(io::Tokenizer::TYPE_END); + } - void ReportWarning(int line, int col, const string& message) { - if (error_collector_ == NULL) { - if (line >= 0) { - GOOGLE_LOG(WARNING) << "Warning parsing text-format " - << root_message_type_->full_name() - << ": " << (line + 1) << ":" - << (col + 1) << ": " << message; + void ReportError(int line, int col, const string &message) { + had_errors_ = true; + if (error_collector_ == NULL) { + if (line >= 0) { + GOOGLE_LOG(ERROR) + << "Error parsing text-format " + << root_message_type_->full_name() << ": " << (line + 1) << ":" + << (col + 1) << ": " << message; + } else { + GOOGLE_LOG(ERROR) + << "Error parsing text-format " + << root_message_type_->full_name() << ": " << message; + } } else { - GOOGLE_LOG(WARNING) << "Warning parsing text-format " - << root_message_type_->full_name() - << ": " << message; + error_collector_->AddError(line, col, message); } - } else { - error_collector_->AddWarning(line, col, message); - } - } + } + + void ReportWarning(int line, int col, const string &message) { + if (error_collector_ == NULL) { + if (line >= 0) { + GOOGLE_LOG(WARNING) + << "Warning parsing text-format " + << root_message_type_->full_name() << ": " << (line + 1) << ":" + << (col + 1) << ": " << message; + } else { + GOOGLE_LOG(WARNING) + << "Warning parsing text-format " + << root_message_type_->full_name() << ": " << message; + } + } else { + error_collector_->AddWarning(line, col, message); + } + } private: - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ParserImpl); + GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ParserImpl); - // Reports an error with the given message with information indicating - // the position (as derived from the current token). - void ReportError(const string& message) { - ReportError(tokenizer_.current().line, tokenizer_.current().column, - message); - } + // Reports an error with the given message with information indicating + // the position (as derived from the current token). + void ReportError(const string &message) { + ReportError( + tokenizer_.current().line, tokenizer_.current().column, message); + } - // Reports a warning with the given message with information indicating - // the position (as derived from the current token). - void ReportWarning(const string& message) { - ReportWarning(tokenizer_.current().line, tokenizer_.current().column, - message); - } + // Reports a warning with the given message with information indicating + // the position (as derived from the current token). + void ReportWarning(const string &message) { + ReportWarning( + tokenizer_.current().line, tokenizer_.current().column, message); + } - // Consumes the specified message with the given starting delimeter. - // This method checks to see that the end delimeter at the conclusion of - // the consumption matches the starting delimeter passed in here. - bool ConsumeMessage(Message* message, const string delimeter) { - while (!LookingAt(">") && !LookingAt("}")) { - DO(ConsumeField(message)); - } + // Consumes the specified message with the given starting delimeter. + // This method checks to see that the end delimeter at the conclusion of + // the consumption matches the starting delimeter passed in here. + bool ConsumeMessage(Message *message, const string delimeter) { + while (!LookingAt(">") && !LookingAt("}")) { + DO(ConsumeField(message)); + } - // Confirm that we have a valid ending delimeter. - DO(Consume(delimeter)); + // Confirm that we have a valid ending delimeter. + DO(Consume(delimeter)); - return true; - } + return true; + } - // - // BTS: Patched 1.14.2013 to allow skipping of unknown fields in text format - // - void ConsumeUnknownMessage() { - int stack = 0; - std::string token = tokenizer_.current().text; - if (token == ":") { - tokenizer_.Next(); - // Consume A single value - if (LookingAtType(io::Tokenizer::TYPE_STRING)) { - ConsumeString(&token); - } else { - tokenizer_.Next(); - } - } else { - // Consume a message type {...} - do { - if (LookingAt("{")) stack++; - if (LookingAt("}")) stack--; + // + // BTS: Patched 1.14.2013 to allow skipping of unknown fields in text format + // + void ConsumeUnknownMessage() { + int stack = 0; + std::string token = tokenizer_.current().text; + if (token == ":") { + tokenizer_.Next(); + // Consume A single value + if (LookingAtType(io::Tokenizer::TYPE_STRING)) { + ConsumeString(&token); + } else { tokenizer_.Next(); - } while(stack > 0); - } - } - - - // Consumes the current field (as returned by the tokenizer) on the - // passed in message. - bool ConsumeField(Message* message) { - const Reflection* reflection = message->GetReflection(); - const Descriptor* descriptor = message->GetDescriptor(); - - string field_name; - - const FieldDescriptor* field = NULL; - - if (TryConsume("[")) { - // Extension. - DO(ConsumeIdentifier(&field_name)); - while (TryConsume(".")) { - string part; - DO(ConsumeIdentifier(&part)); - field_name += "."; - field_name += part; - } - DO(Consume("]")); - - field = (finder_ != NULL - ? finder_->FindExtension(message, field_name) - : reflection->FindKnownExtensionByName(field_name)); - - if (field == NULL) { - ReportError("Extension \"" + field_name + "\" is not defined or " - "is not an extension of \"" + - descriptor->full_name() + "\"."); - return false; - } - } else { - DO(ConsumeIdentifier(&field_name)); - - field = descriptor->FindFieldByName(field_name); - // Group names are expected to be capitalized as they appear in the - // .proto file, which actually matches their type names, not their field - // names. - if (field == NULL) { - string lower_field_name = field_name; - LowerString(&lower_field_name); - field = descriptor->FindFieldByName(lower_field_name); - // If the case-insensitive match worked but the field is NOT a group, - if (field != NULL && field->type() != FieldDescriptor::TYPE_GROUP) { - field = NULL; - } - } - // Again, special-case group names as described above. - if (field != NULL && field->type() == FieldDescriptor::TYPE_GROUP - && field->message_type()->name() != field_name) { - field = NULL; - } - - if (field == NULL) { - ReportWarning("Message type \"" + descriptor->full_name() + - "\" has no field named \"" + field_name + "\"."); - ConsumeUnknownMessage(); - return true; - } - } - - // Fail if the field is not repeated and it has already been specified. - if ((singular_overwrite_policy_ == FORBID_SINGULAR_OVERWRITES) && - !field->is_repeated() && reflection->HasField(*message, field)) { - ReportError("Non-repeated field \"" + field_name + - "\" is specified multiple times."); - return false; - } - - // Perform special handling for embedded message types. - if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { - // ':' is optional here. - TryConsume(":"); - DO(ConsumeFieldMessage(message, reflection, field)); - } else { - DO(Consume(":")); - if (field->is_repeated() && TryConsume("[")) { - // Short repeated format, e.g. "foo: [1, 2, 3]" - while (true) { - DO(ConsumeFieldValue(message, reflection, field)); - if (TryConsume("]")) { - break; - } - DO(Consume(",")); - } + } } else { - DO(ConsumeFieldValue(message, reflection, field)); + // Consume a message type {...} + do { + if (LookingAt("{")) + stack++; + if (LookingAt("}")) + stack--; + tokenizer_.Next(); + } while (stack > 0); } - } + } - // For historical reasons, fields may optionally be separated by commas or - // semicolons. - TryConsume(";") || TryConsume(","); + // Consumes the current field (as returned by the tokenizer) on the + // passed in message. + bool ConsumeField(Message *message) { + const Reflection *reflection = message->GetReflection(); + const Descriptor *descriptor = message->GetDescriptor(); - if (field->options().deprecated()) { - ReportWarning("text format contains deprecated field \"" - + field_name + "\""); - } + string field_name; - return true; - } + const FieldDescriptor *field = NULL; - string current_location() { - string res; - vector::iterator iter = location_.begin(); - for (; iter != location_.end(); ++iter) { - if (iter - location_.begin() == 1) { - GOOGLE_CHECK(**iter == "value"); - continue; // skip .value - } - if (res.length() > 0) res.append("."); + if (TryConsume("[")) { + // Extension. + DO(ConsumeIdentifier(&field_name)); + while (TryConsume(".")) { + string part; + DO(ConsumeIdentifier(&part)); + field_name += "."; + field_name += part; + } + DO(Consume("]")); - res.append(**iter); - } - return res; - } + field = + (finder_ != NULL + ? finder_->FindExtension(message, field_name) + : reflection->FindKnownExtensionByName(field_name)); - // Handle BTS deferred values - bool TryConsumeDeferredValue(Message* message, - const Reflection* reflection, - const FieldDescriptor* field) { - if (lookup_) { - string token; - int line = tokenizer_.current().line + 1; - int col = tokenizer_.current().column; - int size = field->is_repeated() ? reflection->FieldSize(*message, field) : 1; - if (TryConsume("@")) { - ConsumeDottedIdentifier(&token); - lookup_->defer_value(message, reflection, field, size, line, col, token, current_location(), current_message_); + if (field == NULL) { + ReportError( + "Extension \"" + field_name + + "\" is not defined or " + "is not an extension of \"" + + descriptor->full_name() + "\"."); + return false; + } + } else { + DO(ConsumeIdentifier(&field_name)); + + field = descriptor->FindFieldByName(field_name); + // Group names are expected to be capitalized as they appear in the + // .proto file, which actually matches their type names, not their + // field names. + if (field == NULL) { + string lower_field_name = field_name; + LowerString(&lower_field_name); + field = descriptor->FindFieldByName(lower_field_name); + // If the case-insensitive match worked but the field is NOT a + // group, + if (field != NULL && field->type() != FieldDescriptor::TYPE_GROUP) { + field = NULL; + } + } + // Again, special-case group names as described above. + if (field != NULL && field->type() == FieldDescriptor::TYPE_GROUP && + field->message_type()->name() != field_name) { + field = NULL; + } + + if (field == NULL) { + ReportWarning( + "Message type \"" + descriptor->full_name() + + "\" has no field named \"" + field_name + "\"."); + ConsumeUnknownMessage(); + return true; + } + } + + // Fail if the field is not repeated and it has already been specified. + if ((singular_overwrite_policy_ == FORBID_SINGULAR_OVERWRITES) && + !field->is_repeated() && reflection->HasField(*message, field)) { + ReportError( + "Non-repeated field \"" + field_name + + "\" is specified multiple times."); + return false; + } + + // Perform special handling for embedded message types. + if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { + // ':' is optional here. + TryConsume(":"); + DO(ConsumeFieldMessage(message, reflection, field)); + } else { + DO(Consume(":")); + if (field->is_repeated() && TryConsume("[")) { + // Short repeated format, e.g. "foo: [1, 2, 3]" + while (true) { + DO(ConsumeFieldValue(message, reflection, field)); + if (TryConsume("]")) { + break; + } + DO(Consume(",")); + } + } else { + DO(ConsumeFieldValue(message, reflection, field)); + } + } + + // For historical reasons, fields may optionally be separated by commas or + // semicolons. + TryConsume(";") || TryConsume(","); + + if (field->options().deprecated()) { + ReportWarning( + "text format contains deprecated field \"" + field_name + "\""); + } + + return true; + } + + string current_location() { + string res; + vector::iterator iter = location_.begin(); + for (; iter != location_.end(); ++iter) { + if (iter - location_.begin() == 1) { + GOOGLE_CHECK(**iter == "value"); + continue; // skip .value + } + if (res.length() > 0) + res.append("."); + + res.append(**iter); + } + return res; + } + + // Handle BTS deferred values + bool TryConsumeDeferredValue( + Message *message, const Reflection *reflection, + const FieldDescriptor *field) { + if (lookup_) { + string token; + int line = tokenizer_.current().line + 1; + int col = tokenizer_.current().column; + int size = + field->is_repeated() ? reflection->FieldSize(*message, field) : 1; + if (TryConsume("@")) { + ConsumeDottedIdentifier(&token); + lookup_->defer_value( + message, reflection, field, size, line, col, token, + current_location(), current_message_); + return true; + } else if (TryConsume("$")) { + ConsumeDottedIdentifier(&token); + lookup_->defer_value( + message, reflection, field, size, line, col, '$' + token, + current_location(), current_message_); + return true; + } + } + return false; + } + + bool ConsumeFieldMessage( + Message *message, const Reflection *reflection, + const FieldDescriptor *field) { + location_.push_back(&field->name()); + if (TryConsumeDeferredValue(message, reflection, field)) { + location_.pop_back(); return true; } - else if (TryConsume("$")) { - ConsumeDottedIdentifier(&token); - lookup_->defer_value(message, reflection, field, size, line, col, '$' + token, current_location(), current_message_); + if (location_.size() == 3) { + current_message_ = message; + } + + string delimeter; + if (TryConsume("<")) { + delimeter = ">"; + } else { + DO(Consume("{")); + delimeter = "}"; + } + + if (field->is_repeated()) { + DO(ConsumeMessage(reflection->AddMessage(message, field), delimeter)); + } else { + DO(ConsumeMessage( + reflection->MutableMessage(message, field), delimeter)); + } + + location_.pop_back(); + // if (set_current) { current_message_ = nullptr; } + return true; + } + + bool ConsumeFieldValue( + Message *message, const Reflection *reflection, + const FieldDescriptor *field) { + + location_.push_back(&field->name()); + if (TryConsumeDeferredValue(message, reflection, field)) { + location_.pop_back(); return true; } - } - return false; - } - - bool ConsumeFieldMessage(Message* message, - const Reflection* reflection, - const FieldDescriptor* field) { - location_.push_back(&field->name()); - if (TryConsumeDeferredValue(message, reflection, field)) { - location_.pop_back(); - return true; - } - if (location_.size() == 3) { - current_message_ = message; - } - - string delimeter; - if (TryConsume("<")) { - delimeter = ">"; - } else { - DO(Consume("{")); - delimeter = "}"; - } - - if (field->is_repeated()) { - DO(ConsumeMessage(reflection->AddMessage(message, field), delimeter)); - } else { - DO(ConsumeMessage(reflection->MutableMessage(message, field), - delimeter)); - } - - location_.pop_back(); - //if (set_current) { current_message_ = nullptr; } - return true; - } - - bool ConsumeFieldValue(Message* message, - const Reflection* reflection, - const FieldDescriptor* field) { - - location_.push_back(&field->name()); - if (TryConsumeDeferredValue(message, reflection, field)) { - location_.pop_back(); - return true; - } // Define an easy to use macro for setting fields. This macro checks // to see if the field is repeated (in which case we need to use the Add // methods or not (in which case we need to use the Set methods). -#define SET_FIELD(CPPTYPE, VALUE) \ - if (field->is_repeated()) { \ - reflection->Add##CPPTYPE(message, field, VALUE); \ - } else { \ - reflection->Set##CPPTYPE(message, field, VALUE); \ - } \ +#define SET_FIELD(CPPTYPE, VALUE) \ + if (field->is_repeated()) { \ + reflection->Add##CPPTYPE(message, field, VALUE); \ + } else { \ + reflection->Set##CPPTYPE(message, field, VALUE); \ + } - switch(field->cpp_type()) { + switch (field->cpp_type()) { case FieldDescriptor::CPPTYPE_INT32: { - int64 value; - DO(ConsumeSignedInteger(&value, kint32max)); - SET_FIELD(Int32, static_cast(value)); - break; + int64 value; + DO(ConsumeSignedInteger(&value, kint32max)); + SET_FIELD(Int32, static_cast(value)); + break; } case FieldDescriptor::CPPTYPE_UINT32: { - uint64 value; - DO(ConsumeUnsignedInteger(&value, kuint32max)); - SET_FIELD(UInt32, static_cast(value)); - break; + uint64 value; + DO(ConsumeUnsignedInteger(&value, kuint32max)); + SET_FIELD(UInt32, static_cast(value)); + break; } case FieldDescriptor::CPPTYPE_INT64: { - int64 value; - DO(ConsumeSignedInteger(&value, kint64max)); - SET_FIELD(Int64, value); - break; + int64 value; + DO(ConsumeSignedInteger(&value, kint64max)); + SET_FIELD(Int64, value); + break; } case FieldDescriptor::CPPTYPE_UINT64: { - uint64 value; - DO(ConsumeUnsignedInteger(&value, kuint64max)); - SET_FIELD(UInt64, value); - break; + uint64 value; + DO(ConsumeUnsignedInteger(&value, kuint64max)); + SET_FIELD(UInt64, value); + break; } case FieldDescriptor::CPPTYPE_FLOAT: { - double value; - DO(ConsumeDouble(&value)); - SET_FIELD(Float, static_cast(value)); - break; + double value; + DO(ConsumeDouble(&value)); + SET_FIELD(Float, static_cast(value)); + break; } case FieldDescriptor::CPPTYPE_DOUBLE: { - double value; - DO(ConsumeDouble(&value)); - SET_FIELD(Double, value); - break; + double value; + DO(ConsumeDouble(&value)); + SET_FIELD(Double, value); + break; } case FieldDescriptor::CPPTYPE_STRING: { - string value; - DO(ConsumeString(&value)); - SET_FIELD(String, value); - break; + string value; + DO(ConsumeString(&value)); + SET_FIELD(String, value); + break; } case FieldDescriptor::CPPTYPE_BOOL: { - if (LookingAtType(io::Tokenizer::TYPE_INTEGER)) { - uint64 value; - DO(ConsumeUnsignedInteger(&value, 1)); - SET_FIELD(Bool, value); - } else { - string value; - DO(ConsumeIdentifier(&value)); - if (value == "true" || value == "t") { - SET_FIELD(Bool, true); - } else if (value == "false" || value == "f") { - SET_FIELD(Bool, false); - } else { - ReportError("Invalid value for boolean field \"" + field->name() - + "\". Value: \"" + value + "\"."); - return false; - } - } - break; + if (LookingAtType(io::Tokenizer::TYPE_INTEGER)) { + uint64 value; + DO(ConsumeUnsignedInteger(&value, 1)); + SET_FIELD(Bool, value); + } else { + string value; + DO(ConsumeIdentifier(&value)); + if (value == "true" || value == "t") { + SET_FIELD(Bool, true); + } else if (value == "false" || value == "f") { + SET_FIELD(Bool, false); + } else { + ReportError( + "Invalid value for boolean field \"" + field->name() + + "\". Value: \"" + value + "\"."); + return false; + } + } + break; } case FieldDescriptor::CPPTYPE_ENUM: { - string value; - const EnumDescriptor* enum_type = field->enum_type(); - const EnumValueDescriptor* enum_value = NULL; + string value; + const EnumDescriptor *enum_type = field->enum_type(); + const EnumValueDescriptor *enum_value = NULL; - if (LookingAtType(io::Tokenizer::TYPE_IDENTIFIER)) { - DO(ConsumeIdentifier(&value)); - // Find the enumeration value. - enum_value = enum_type->FindValueByName(value); + if (LookingAtType(io::Tokenizer::TYPE_IDENTIFIER)) { + DO(ConsumeIdentifier(&value)); + // Find the enumeration value. + enum_value = enum_type->FindValueByName(value); - } else if (LookingAt("-") || - LookingAtType(io::Tokenizer::TYPE_INTEGER)) { - int64 int_value; - DO(ConsumeSignedInteger(&int_value, kint32max)); - value = SimpleItoa(int_value); // for error reporting - enum_value = enum_type->FindValueByNumber(int_value); - } else { - ReportError("Expected integer or identifier."); - return false; - } + } else if ( + LookingAt("-") || LookingAtType(io::Tokenizer::TYPE_INTEGER)) { + int64 int_value; + DO(ConsumeSignedInteger(&int_value, kint32max)); + value = SimpleItoa(int_value); // for error reporting + enum_value = enum_type->FindValueByNumber(int_value); + } else { + ReportError("Expected integer or identifier."); + return false; + } - if (enum_value == NULL) { - ReportError("Unknown enumeration value of \"" + value + "\" for " - "field \"" + field->name() + "\"."); - return false; - } + if (enum_value == NULL) { + ReportError( + "Unknown enumeration value of \"" + value + + "\" for " + "field \"" + + field->name() + "\"."); + return false; + } - SET_FIELD(Enum, enum_value); - break; + SET_FIELD(Enum, enum_value); + break; } case FieldDescriptor::CPPTYPE_MESSAGE: { - // We should never get here. Put here instead of a default - // so that if new types are added, we get a nice compiler warning. - GOOGLE_LOG(FATAL) << "Reached an unintended state: CPPTYPE_MESSAGE"; - break; + // We should never get here. Put here instead of a default + // so that if new types are added, we get a nice compiler warning. + GOOGLE_LOG(FATAL) << "Reached an unintended state: CPPTYPE_MESSAGE"; + break; + } } - } #undef SET_FIELD - location_.pop_back(); - return true; - } + location_.pop_back(); + return true; + } - // Returns true if the current token's text is equal to that specified. - bool LookingAt(const string& text) { - return tokenizer_.current().text == text; - } + // Returns true if the current token's text is equal to that specified. + bool LookingAt(const string &text) { + return tokenizer_.current().text == text; + } - // Returns true if the current token's type is equal to that specified. - bool LookingAtType(io::Tokenizer::TokenType token_type) { - return tokenizer_.current().type == token_type; - } + // Returns true if the current token's type is equal to that specified. + bool LookingAtType(io::Tokenizer::TokenType token_type) { + return tokenizer_.current().type == token_type; + } - // Consumes an identifier and saves its value in the identifier parameter. - // Returns false if the token is not of type IDENTFIER. - bool ConsumeIdentifier(string* identifier) { - if (!LookingAtType(io::Tokenizer::TYPE_IDENTIFIER)) { - ReportError("Expected identifier."); - return false; - } - - *identifier = tokenizer_.current().text; - - tokenizer_.Next(); - return true; - } - - bool ConsumeDottedIdentifier(string* identifier) { - if (!LookingAtType(io::Tokenizer::TYPE_IDENTIFIER)) { - ReportError("Expected identifier."); - return false; - } - - *identifier = tokenizer_.current().text; - tokenizer_.Next(); - - while(true) { - if (TryConsume(".")) { - *identifier += "."; - *identifier += tokenizer_.current().text; - tokenizer_.Next(); - continue; - } - if (TryConsume("[")) { - *identifier += "["; - *identifier += tokenizer_.current().text; - tokenizer_.Next(); - if (Consume("]")) { - *identifier += "]"; - continue; - } - else { - ReportError("Expected ']'"); - } - } - break; - } - return true; - } - - // Consumes a string and saves its value in the text parameter. - // Returns false if the token is not of type STRING. - bool ConsumeString(string* text) { - if (!LookingAtType(io::Tokenizer::TYPE_STRING)) { - ReportError("Expected string."); - return false; - } - - text->clear(); - while (LookingAtType(io::Tokenizer::TYPE_STRING)) { - io::Tokenizer::ParseStringAppend(tokenizer_.current().text, text); - - tokenizer_.Next(); - } - - return true; - } - - // Consumes a uint64 and saves its value in the value parameter. - // Returns false if the token is not of type INTEGER. - bool ConsumeUnsignedInteger(uint64* value, uint64 max_value) { - if (!LookingAtType(io::Tokenizer::TYPE_INTEGER)) { - ReportError("Expected integer."); - return false; - } - - if (!io::Tokenizer::ParseInteger(tokenizer_.current().text, - max_value, value)) { - ReportError("Integer out of range."); - return false; - } - - tokenizer_.Next(); - return true; - } - - // Consumes an int64 and saves its value in the value parameter. - // Note that since the tokenizer does not support negative numbers, - // we actually may consume an additional token (for the minus sign) in this - // method. Returns false if the token is not an integer - // (signed or otherwise). - bool ConsumeSignedInteger(int64* value, uint64 max_value) { - bool negative = false; - - if (TryConsume("-")) { - negative = true; - // Two's complement always allows one more negative integer than - // positive. - ++max_value; - } - - uint64 unsigned_value; - - DO(ConsumeUnsignedInteger(&unsigned_value, max_value)); - - *value = static_cast(unsigned_value); - - if (negative) { - *value = -*value; - } - - return true; - } - - // Consumes a double and saves its value in the value parameter. - // Note that since the tokenizer does not support negative numbers, - // we actually may consume an additional token (for the minus sign) in this - // method. Returns false if the token is not a double - // (signed or otherwise). - bool ConsumeDouble(double* value) { - bool negative = false; - - if (TryConsume("-")) { - negative = true; - } - - // A double can actually be an integer, according to the tokenizer. - // Therefore, we must check both cases here. - if (LookingAtType(io::Tokenizer::TYPE_INTEGER)) { - // We have found an integer value for the double. - uint64 integer_value; - DO(ConsumeUnsignedInteger(&integer_value, kuint64max)); - - *value = static_cast(integer_value); - } else if (LookingAtType(io::Tokenizer::TYPE_FLOAT)) { - // We have found a float value for the double. - *value = io::Tokenizer::ParseFloat(tokenizer_.current().text); - - // Mark the current token as consumed. - tokenizer_.Next(); - } else if (LookingAtType(io::Tokenizer::TYPE_IDENTIFIER)) { - string text = tokenizer_.current().text; - LowerString(&text); - if (text == "inf" || text == "infinity") { - *value = std::numeric_limits::infinity(); - tokenizer_.Next(); - } else if (text == "nan") { - *value = std::numeric_limits::quiet_NaN(); - tokenizer_.Next(); - } else { - ReportError("Expected double."); - return false; + // Consumes an identifier and saves its value in the identifier parameter. + // Returns false if the token is not of type IDENTFIER. + bool ConsumeIdentifier(string *identifier) { + if (!LookingAtType(io::Tokenizer::TYPE_IDENTIFIER)) { + ReportError("Expected identifier."); + return false; } - } else { - ReportError("Expected double."); - return false; - } - if (negative) { - *value = -*value; - } + *identifier = tokenizer_.current().text; - return true; - } - - // Consumes a token and confirms that it matches that specified in the - // value parameter. Returns false if the token found does not match that - // which was specified. - bool Consume(const string& value) { - const string& current_value = tokenizer_.current().text; - - if (current_value != value) { - ReportError("Expected \"" + value + "\", found \"" + current_value - + "\"."); - return false; - } - - tokenizer_.Next(); - - return true; - } - - // Attempts to consume the supplied value. Returns false if a the - // token found does not match the value specified. - bool TryConsume(const string& value) { - if (tokenizer_.current().text == value) { tokenizer_.Next(); return true; - } else { - return false; - } - } + } - // An internal instance of the Tokenizer's error collector, used to - // collect any base-level parse errors and feed them to the ParserImpl. - class ParserErrorCollector : public io::ErrorCollector { - public: - explicit ParserErrorCollector(TextFormat::Parser::ParserImpl* parser) : - parser_(parser) { } + bool ConsumeDottedIdentifier(string *identifier) { + if (!LookingAtType(io::Tokenizer::TYPE_IDENTIFIER)) { + ReportError("Expected identifier."); + return false; + } - virtual ~ParserErrorCollector() { }; + *identifier = tokenizer_.current().text; + tokenizer_.Next(); - virtual void AddError(int line, int column, const string& message) { - parser_->ReportError(line, column, message); - } + while (true) { + if (TryConsume(".")) { + *identifier += "."; + *identifier += tokenizer_.current().text; + tokenizer_.Next(); + continue; + } + if (TryConsume("[")) { + *identifier += "["; + *identifier += tokenizer_.current().text; + tokenizer_.Next(); + if (Consume("]")) { + *identifier += "]"; + continue; + } else { + ReportError("Expected ']'"); + } + } + break; + } + return true; + } - virtual void AddWarning(int line, int column, const string& message) { - parser_->ReportWarning(line, column, message); - } + // Consumes a string and saves its value in the text parameter. + // Returns false if the token is not of type STRING. + bool ConsumeString(string *text) { + if (!LookingAtType(io::Tokenizer::TYPE_STRING)) { + ReportError("Expected string."); + return false; + } - private: - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ParserErrorCollector); - TextFormat::Parser::ParserImpl* parser_; - }; + text->clear(); + while (LookingAtType(io::Tokenizer::TYPE_STRING)) { + io::Tokenizer::ParseStringAppend(tokenizer_.current().text, text); - io::ErrorCollector* error_collector_; - IDeferValueLookup* lookup_; - TextFormat::Finder* finder_; - ParserErrorCollector tokenizer_error_collector_; - io::Tokenizer tokenizer_; - const Descriptor* root_message_type_; - SingularOverwritePolicy singular_overwrite_policy_; - bool had_errors_; - vector location_; - Message* current_message_; + tokenizer_.Next(); + } + + return true; + } + + // Consumes a uint64 and saves its value in the value parameter. + // Returns false if the token is not of type INTEGER. + bool ConsumeUnsignedInteger(uint64 *value, uint64 max_value) { + if (!LookingAtType(io::Tokenizer::TYPE_INTEGER)) { + ReportError("Expected integer."); + return false; + } + + if (!io::Tokenizer::ParseInteger( + tokenizer_.current().text, max_value, value)) { + ReportError("Integer out of range."); + return false; + } + + tokenizer_.Next(); + return true; + } + + // Consumes an int64 and saves its value in the value parameter. + // Note that since the tokenizer does not support negative numbers, + // we actually may consume an additional token (for the minus sign) in this + // method. Returns false if the token is not an integer + // (signed or otherwise). + bool ConsumeSignedInteger(int64 *value, uint64 max_value) { + bool negative = false; + + if (TryConsume("-")) { + negative = true; + // Two's complement always allows one more negative integer than + // positive. + ++max_value; + } + + uint64 unsigned_value; + + DO(ConsumeUnsignedInteger(&unsigned_value, max_value)); + + *value = static_cast(unsigned_value); + + if (negative) { + *value = -*value; + } + + return true; + } + + // Consumes a double and saves its value in the value parameter. + // Note that since the tokenizer does not support negative numbers, + // we actually may consume an additional token (for the minus sign) in this + // method. Returns false if the token is not a double + // (signed or otherwise). + bool ConsumeDouble(double *value) { + bool negative = false; + + if (TryConsume("-")) { + negative = true; + } + + // A double can actually be an integer, according to the tokenizer. + // Therefore, we must check both cases here. + if (LookingAtType(io::Tokenizer::TYPE_INTEGER)) { + // We have found an integer value for the double. + uint64 integer_value; + DO(ConsumeUnsignedInteger(&integer_value, kuint64max)); + + *value = static_cast(integer_value); + } else if (LookingAtType(io::Tokenizer::TYPE_FLOAT)) { + // We have found a float value for the double. + *value = io::Tokenizer::ParseFloat(tokenizer_.current().text); + + // Mark the current token as consumed. + tokenizer_.Next(); + } else if (LookingAtType(io::Tokenizer::TYPE_IDENTIFIER)) { + string text = tokenizer_.current().text; + LowerString(&text); + if (text == "inf" || text == "infinity") { + *value = std::numeric_limits::infinity(); + tokenizer_.Next(); + } else if (text == "nan") { + *value = std::numeric_limits::quiet_NaN(); + tokenizer_.Next(); + } else { + ReportError("Expected double."); + return false; + } + } else { + ReportError("Expected double."); + return false; + } + + if (negative) { + *value = -*value; + } + + return true; + } + + // Consumes a token and confirms that it matches that specified in the + // value parameter. Returns false if the token found does not match that + // which was specified. + bool Consume(const string &value) { + const string ¤t_value = tokenizer_.current().text; + + if (current_value != value) { + ReportError( + "Expected \"" + value + "\", found \"" + current_value + "\"."); + return false; + } + + tokenizer_.Next(); + + return true; + } + + // Attempts to consume the supplied value. Returns false if a the + // token found does not match the value specified. + bool TryConsume(const string &value) { + if (tokenizer_.current().text == value) { + tokenizer_.Next(); + return true; + } else { + return false; + } + } + + // An internal instance of the Tokenizer's error collector, used to + // collect any base-level parse errors and feed them to the ParserImpl. + class ParserErrorCollector : public io::ErrorCollector { + public: + explicit ParserErrorCollector(TextFormat::Parser::ParserImpl *parser) + : parser_(parser) {} + + virtual ~ParserErrorCollector(){}; + + virtual void AddError(int line, int column, const string &message) { + parser_->ReportError(line, column, message); + } + + virtual void AddWarning(int line, int column, const string &message) { + parser_->ReportWarning(line, column, message); + } + + private: + GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ParserErrorCollector); + TextFormat::Parser::ParserImpl *parser_; + }; + + io::ErrorCollector *error_collector_; + IDeferValueLookup *lookup_; + TextFormat::Finder *finder_; + ParserErrorCollector tokenizer_error_collector_; + io::Tokenizer tokenizer_; + const Descriptor *root_message_type_; + SingularOverwritePolicy singular_overwrite_policy_; + bool had_errors_; + vector location_; + Message *current_message_; }; #undef DO @@ -783,605 +797,582 @@ class TextFormat::Parser::ParserImpl { // from the Printer found in //google/protobuf/io/printer.h class TextFormat::Printer::TextGenerator { public: - explicit TextGenerator(io::ZeroCopyOutputStream* output, - int initial_indent_level) - : output_(output), - buffer_(NULL), - buffer_size_(0), - at_start_of_line_(true), - failed_(false), - indent_(""), - initial_indent_level_(initial_indent_level) { - indent_.resize(initial_indent_level_ * 2, ' '); - } + explicit TextGenerator( + io::ZeroCopyOutputStream *output, int initial_indent_level) + : output_(output), buffer_(NULL), buffer_size_(0), + at_start_of_line_(true), failed_(false), indent_(""), + initial_indent_level_(initial_indent_level) { + indent_.resize(initial_indent_level_ * 2, ' '); + } - ~TextGenerator() { - // Only BackUp() if we're sure we've successfully called Next() at least - // once. - if (buffer_size_ > 0) { - output_->BackUp(buffer_size_); - } - } - - // Indent text by two spaces. After calling Indent(), two spaces will be - // inserted at the beginning of each line of text. Indent() may be called - // multiple times to produce deeper indents. - void Indent() { - indent_ += " "; - } - - // Reduces the current indent level by two spaces, or crashes if the indent - // level is zero. - void Outdent() { - if (indent_.empty() || - indent_.size() < (size_t) initial_indent_level_ * 2) { - GOOGLE_LOG(DFATAL) << " Outdent() without matching Indent()."; - return; - } - - indent_.resize(indent_.size() - 2); - } - - // Print text to the output stream. - void Print(const string& str) { - Print(str.data(), str.size()); - } - - // Print text to the output stream. - void Print(const char* text) { - Print(text, strlen(text)); - } - - // Print text to the output stream. - void Print(const char* text, int size) { - int pos = 0; // The number of bytes we've written so far. - - for (int i = 0; i < size; i++) { - if (text[i] == '\n') { - // Saw newline. If there is more text, we may need to insert an indent - // here. So, write what we have so far, including the '\n'. - Write(text + pos, i - pos + 1); - pos = i + 1; - - // Setting this true will cause the next Write() to insert an indent - // first. - at_start_of_line_ = true; + ~TextGenerator() { + // Only BackUp() if we're sure we've successfully called Next() at least + // once. + if (buffer_size_ > 0) { + output_->BackUp(buffer_size_); } - } + } - // Write the rest. - Write(text + pos, size - pos); - } + // Indent text by two spaces. After calling Indent(), two spaces will be + // inserted at the beginning of each line of text. Indent() may be called + // multiple times to produce deeper indents. + void Indent() { indent_ += " "; } - // True if any write to the underlying stream failed. (We don't just - // crash in this case because this is an I/O failure, not a programming - // error.) - bool failed() const { return failed_; } + // Reduces the current indent level by two spaces, or crashes if the indent + // level is zero. + void Outdent() { + if (indent_.empty() || + indent_.size() < (size_t)initial_indent_level_ * 2) { + GOOGLE_LOG(DFATAL) << " Outdent() without matching Indent()."; + return; + } + + indent_.resize(indent_.size() - 2); + } + + // Print text to the output stream. + void Print(const string &str) { Print(str.data(), str.size()); } + + // Print text to the output stream. + void Print(const char *text) { Print(text, strlen(text)); } + + // Print text to the output stream. + void Print(const char *text, int size) { + int pos = 0; // The number of bytes we've written so far. + + for (int i = 0; i < size; i++) { + if (text[i] == '\n') { + // Saw newline. If there is more text, we may need to insert an + // indent here. So, write what we have so far, including the '\n'. + Write(text + pos, i - pos + 1); + pos = i + 1; + + // Setting this true will cause the next Write() to insert an indent + // first. + at_start_of_line_ = true; + } + } + + // Write the rest. + Write(text + pos, size - pos); + } + + // True if any write to the underlying stream failed. (We don't just + // crash in this case because this is an I/O failure, not a programming + // error.) + bool failed() const { return failed_; } private: - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(TextGenerator); + GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(TextGenerator); - void Write(const char* data, int size) { - if (failed_) return; - if (size == 0) return; + void Write(const char *data, int size) { + if (failed_) + return; + if (size == 0) + return; - if (at_start_of_line_) { - // Insert an indent. - at_start_of_line_ = false; - Write(indent_.data(), indent_.size()); - if (failed_) return; - } + if (at_start_of_line_) { + // Insert an indent. + at_start_of_line_ = false; + Write(indent_.data(), indent_.size()); + if (failed_) + return; + } - while (size > buffer_size_) { - // Data exceeds space in the buffer. Copy what we can and request a - // new buffer. - memcpy(buffer_, data, buffer_size_); - data += buffer_size_; - size -= buffer_size_; - void* void_buffer; - failed_ = !output_->Next(&void_buffer, &buffer_size_); - if (failed_) return; - buffer_ = reinterpret_cast(void_buffer); - } + while (size > buffer_size_) { + // Data exceeds space in the buffer. Copy what we can and request a + // new buffer. + memcpy(buffer_, data, buffer_size_); + data += buffer_size_; + size -= buffer_size_; + void *void_buffer; + failed_ = !output_->Next(&void_buffer, &buffer_size_); + if (failed_) + return; + buffer_ = reinterpret_cast(void_buffer); + } - // Buffer is big enough to receive the data; copy it. - memcpy(buffer_, data, size); - buffer_ += size; - buffer_size_ -= size; - } + // Buffer is big enough to receive the data; copy it. + memcpy(buffer_, data, size); + buffer_ += size; + buffer_size_ -= size; + } - io::ZeroCopyOutputStream* const output_; - char* buffer_; - int buffer_size_; - bool at_start_of_line_; - bool failed_; + io::ZeroCopyOutputStream *const output_; + char *buffer_; + int buffer_size_; + bool at_start_of_line_; + bool failed_; - string indent_; - int initial_indent_level_; + string indent_; + int initial_indent_level_; }; // =========================================================================== -TextFormat::Finder::~Finder() { -} +TextFormat::Finder::~Finder() {} TextFormat::Parser::Parser() - : error_collector_(NULL), - lookup_(NULL), - finder_(NULL), - allow_partial_(false) { -} + : error_collector_(NULL), lookup_(NULL), finder_(NULL), + allow_partial_(false) {} TextFormat::Parser::~Parser() {} -bool TextFormat::Parser::Parse(io::ZeroCopyInputStream* input, - Message* output) { - //output->Clear(); - ParserImpl parser(output->GetDescriptor(), input, error_collector_, lookup_, - finder_, ParserImpl::FORBID_SINGULAR_OVERWRITES); - return MergeUsingImpl(input, output, &parser); +bool TextFormat::Parser::Parse( + io::ZeroCopyInputStream *input, Message *output) { + // output->Clear(); + ParserImpl parser( + output->GetDescriptor(), input, error_collector_, lookup_, finder_, + ParserImpl::FORBID_SINGULAR_OVERWRITES); + return MergeUsingImpl(input, output, &parser); } -bool TextFormat::Parser::ParseFromString(const string& input, - Message* output) { - io::ArrayInputStream input_stream(input.data(), input.size()); - return Parse(&input_stream, output); +bool TextFormat::Parser::ParseFromString(const string &input, Message *output) { + io::ArrayInputStream input_stream(input.data(), input.size()); + return Parse(&input_stream, output); } -bool TextFormat::Parser::Merge(io::ZeroCopyInputStream* input, - Message* output) { - ParserImpl parser(output->GetDescriptor(), input, error_collector_, lookup_, - finder_, ParserImpl::ALLOW_SINGULAR_OVERWRITES); - return MergeUsingImpl(input, output, &parser); +bool TextFormat::Parser::Merge( + io::ZeroCopyInputStream *input, Message *output) { + ParserImpl parser( + output->GetDescriptor(), input, error_collector_, lookup_, finder_, + ParserImpl::ALLOW_SINGULAR_OVERWRITES); + return MergeUsingImpl(input, output, &parser); } -bool TextFormat::Parser::MergeFromString(const string& input, - Message* output) { - io::ArrayInputStream input_stream(input.data(), input.size()); - return Merge(&input_stream, output); +bool TextFormat::Parser::MergeFromString(const string &input, Message *output) { + io::ArrayInputStream input_stream(input.data(), input.size()); + return Merge(&input_stream, output); } -bool TextFormat::Parser::MergeUsingImpl(io::ZeroCopyInputStream*, - Message* output, - ParserImpl* parser_impl) { - if (!parser_impl->Parse(output)) return false; - if (!allow_partial_ && !output->IsInitialized()) { - vector missing_fields; - output->FindInitializationErrors(&missing_fields); - parser_impl->ReportError(-1, 0, "Message missing required fields: " + - JoinStrings(missing_fields, ", ")); - return false; - } - return true; +bool TextFormat::Parser::MergeUsingImpl( + io::ZeroCopyInputStream *, Message *output, ParserImpl *parser_impl) { + if (!parser_impl->Parse(output)) + return false; + if (!allow_partial_ && !output->IsInitialized()) { + vector missing_fields; + output->FindInitializationErrors(&missing_fields); + parser_impl->ReportError( + -1, 0, + "Message missing required fields: " + + JoinStrings(missing_fields, ", ")); + return false; + } + return true; } bool TextFormat::Parser::ParseFieldValueFromString( - const string& input, - const FieldDescriptor* field, - Message* output) { - io::ArrayInputStream input_stream(input.data(), input.size()); - ParserImpl parser(output->GetDescriptor(), &input_stream, error_collector_, lookup_, - finder_, ParserImpl::ALLOW_SINGULAR_OVERWRITES); - return parser.ParseField(field, output); + const string &input, const FieldDescriptor *field, Message *output) { + io::ArrayInputStream input_stream(input.data(), input.size()); + ParserImpl parser( + output->GetDescriptor(), &input_stream, error_collector_, lookup_, + finder_, ParserImpl::ALLOW_SINGULAR_OVERWRITES); + return parser.ParseField(field, output); } -/* static */ bool TextFormat::Parse(io::ZeroCopyInputStream* input, - Message* output) { - return Parser().Parse(input, output); +/* static */ bool +TextFormat::Parse(io::ZeroCopyInputStream *input, Message *output) { + return Parser().Parse(input, output); } -/* static */ bool TextFormat::Merge(io::ZeroCopyInputStream* input, - Message* output) { - return Parser().Merge(input, output); +/* static */ bool +TextFormat::Merge(io::ZeroCopyInputStream *input, Message *output) { + return Parser().Merge(input, output); } -/* static */ bool TextFormat::ParseFromString(const string& input, - Message* output) { - return Parser().ParseFromString(input, output); +/* static */ bool +TextFormat::ParseFromString(const string &input, Message *output) { + return Parser().ParseFromString(input, output); } -/* static */ bool TextFormat::MergeFromString(const string& input, - Message* output) { - return Parser().MergeFromString(input, output); +/* static */ bool +TextFormat::MergeFromString(const string &input, Message *output) { + return Parser().MergeFromString(input, output); } // =========================================================================== TextFormat::Printer::Printer() - : initial_indent_level_(0), - single_line_mode_(false), - use_short_repeated_primitives_(false), - utf8_string_escaping_(false) {} + : initial_indent_level_(0), single_line_mode_(false), + use_short_repeated_primitives_(false), utf8_string_escaping_(false) {} TextFormat::Printer::~Printer() {} -bool TextFormat::Printer::PrintToString(const Message& message, - string* output) const { - GOOGLE_DCHECK(output) << "output specified is NULL"; +bool TextFormat::Printer::PrintToString( + const Message &message, string *output) const { + GOOGLE_DCHECK(output) << "output specified is NULL"; - output->clear(); - io::StringOutputStream output_stream(output); + output->clear(); + io::StringOutputStream output_stream(output); - bool result = Print(message, &output_stream); + bool result = Print(message, &output_stream); - return result; + return result; } bool TextFormat::Printer::PrintUnknownFieldsToString( - const UnknownFieldSet& unknown_fields, - string* output) const { - GOOGLE_DCHECK(output) << "output specified is NULL"; + const UnknownFieldSet &unknown_fields, string *output) const { + GOOGLE_DCHECK(output) << "output specified is NULL"; - output->clear(); - io::StringOutputStream output_stream(output); - return PrintUnknownFields(unknown_fields, &output_stream); + output->clear(); + io::StringOutputStream output_stream(output); + return PrintUnknownFields(unknown_fields, &output_stream); } -bool TextFormat::Printer::Print(const Message& message, - io::ZeroCopyOutputStream* output) const { - TextGenerator generator(output, initial_indent_level_); +bool TextFormat::Printer::Print( + const Message &message, io::ZeroCopyOutputStream *output) const { + TextGenerator generator(output, initial_indent_level_); - Print(message, generator); + Print(message, generator); - // Output false if the generator failed internally. - return !generator.failed(); + // Output false if the generator failed internally. + return !generator.failed(); } bool TextFormat::Printer::PrintUnknownFields( - const UnknownFieldSet& unknown_fields, - io::ZeroCopyOutputStream* output) const { - TextGenerator generator(output, initial_indent_level_); + const UnknownFieldSet &unknown_fields, + io::ZeroCopyOutputStream *output) const { + TextGenerator generator(output, initial_indent_level_); - PrintUnknownFields(unknown_fields, generator); + PrintUnknownFields(unknown_fields, generator); - // Output false if the generator failed internally. - return !generator.failed(); + // Output false if the generator failed internally. + return !generator.failed(); } -void TextFormat::Printer::Print(const Message& message, - TextGenerator& generator) const { - const Reflection* reflection = message.GetReflection(); - vector fields; - reflection->ListFields(message, &fields); - for (size_t i = 0; i < fields.size(); i++) { - PrintField(message, reflection, fields[i], generator); - } - PrintUnknownFields(reflection->GetUnknownFields(message), generator); +void TextFormat::Printer::Print( + const Message &message, TextGenerator &generator) const { + const Reflection *reflection = message.GetReflection(); + vector fields; + reflection->ListFields(message, &fields); + for (size_t i = 0; i < fields.size(); i++) { + PrintField(message, reflection, fields[i], generator); + } + PrintUnknownFields(reflection->GetUnknownFields(message), generator); } void TextFormat::Printer::PrintFieldValueToString( - const Message& message, - const FieldDescriptor* field, - int index, - string* output) const { + const Message &message, const FieldDescriptor *field, int index, + string *output) const { - GOOGLE_DCHECK(output) << "output specified is NULL"; + GOOGLE_DCHECK(output) << "output specified is NULL"; - output->clear(); - io::StringOutputStream output_stream(output); - TextGenerator generator(&output_stream, initial_indent_level_); + output->clear(); + io::StringOutputStream output_stream(output); + TextGenerator generator(&output_stream, initial_indent_level_); - PrintFieldValue(message, message.GetReflection(), field, index, generator); + PrintFieldValue(message, message.GetReflection(), field, index, generator); } -void TextFormat::Printer::PrintField(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) { - PrintShortRepeatedField(message, reflection, field, generator); - return; - } +void TextFormat::Printer::PrintField( + 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) { + PrintShortRepeatedField(message, reflection, field, generator); + return; + } - int count = 0; + int count = 0; - if (field->is_repeated()) { - count = reflection->FieldSize(message, field); - } else if (reflection->HasField(message, field)) { - count = 1; - } + if (field->is_repeated()) { + count = reflection->FieldSize(message, field); + } else if (reflection->HasField(message, field)) { + count = 1; + } - for (int j = 0; j < count; ++j) { - PrintFieldName(message, reflection, field, generator); + for (int j = 0; j < count; ++j) { + PrintFieldName(message, reflection, field, generator); - if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { - if (single_line_mode_) { - generator.Print(" { "); + if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { + if (single_line_mode_) { + generator.Print(" { "); + } else { + generator.Print(" {\n"); + generator.Indent(); + } } else { - generator.Print(" {\n"); - generator.Indent(); + generator.Print(": "); } - } else { - generator.Print(": "); - } - // Write the field value. - int field_index = j; - if (!field->is_repeated()) { - field_index = -1; - } + // Write the field value. + int field_index = j; + if (!field->is_repeated()) { + field_index = -1; + } - PrintFieldValue(message, reflection, field, field_index, generator); + PrintFieldValue(message, reflection, field, field_index, generator); - if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { - if (single_line_mode_) { - generator.Print("} "); + if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { + if (single_line_mode_) { + generator.Print("} "); + } else { + generator.Outdent(); + generator.Print("}\n"); + } } else { - generator.Outdent(); - generator.Print("}\n"); + if (single_line_mode_) { + generator.Print(" "); + } else { + generator.Print("\n"); + } } - } else { - if (single_line_mode_) { - generator.Print(" "); - } else { - generator.Print("\n"); - } - } - } + } } void TextFormat::Printer::PrintShortRepeatedField( - const Message& message, - const Reflection* reflection, - const FieldDescriptor* field, - TextGenerator& generator) const { - // Print primitive repeated field in short form. - PrintFieldName(message, reflection, field, generator); + const Message &message, const Reflection *reflection, + const FieldDescriptor *field, TextGenerator &generator) const { + // Print primitive repeated field in short form. + PrintFieldName(message, reflection, field, generator); - int size = reflection->FieldSize(message, field); - generator.Print(": ["); - for (int i = 0; i < size; i++) { - if (i > 0) generator.Print(", "); - PrintFieldValue(message, reflection, field, i, generator); - } - if (single_line_mode_) { - generator.Print("] "); - } else { - generator.Print("]\n"); - } + int size = reflection->FieldSize(message, field); + generator.Print(": ["); + for (int i = 0; i < size; i++) { + if (i > 0) + generator.Print(", "); + PrintFieldValue(message, reflection, field, i, generator); + } + if (single_line_mode_) { + generator.Print("] "); + } else { + generator.Print("]\n"); + } } -void TextFormat::Printer::PrintFieldName(const Message&, - const Reflection*, - const FieldDescriptor* field, - TextGenerator& generator) const { - if (field->is_extension()) { - generator.Print("["); - // We special-case MessageSet elements for compatibility with proto1. - if (field->containing_type()->options().message_set_wire_format() - && field->type() == FieldDescriptor::TYPE_MESSAGE - && field->is_optional() - && field->extension_scope() == field->message_type()) { - generator.Print(field->message_type()->full_name()); - } else { - generator.Print(field->full_name()); - } - generator.Print("]"); - } else { - if (field->type() == FieldDescriptor::TYPE_GROUP) { - // Groups must be serialized with their original capitalization. - generator.Print(field->message_type()->name()); - } else { - generator.Print(field->name()); - } - } +void TextFormat::Printer::PrintFieldName( + const Message &, const Reflection *, const FieldDescriptor *field, + TextGenerator &generator) const { + if (field->is_extension()) { + generator.Print("["); + // We special-case MessageSet elements for compatibility with proto1. + if (field->containing_type()->options().message_set_wire_format() && + field->type() == FieldDescriptor::TYPE_MESSAGE && + field->is_optional() && + field->extension_scope() == field->message_type()) { + generator.Print(field->message_type()->full_name()); + } else { + generator.Print(field->full_name()); + } + generator.Print("]"); + } else { + if (field->type() == FieldDescriptor::TYPE_GROUP) { + // Groups must be serialized with their original capitalization. + generator.Print(field->message_type()->name()); + } else { + generator.Print(field->name()); + } + } } void TextFormat::Printer::PrintFieldValue( - 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"; + 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"; - switch (field->cpp_type()) { -#define OUTPUT_FIELD(CPPTYPE, METHOD, TO_STRING) \ - case FieldDescriptor::CPPTYPE_##CPPTYPE: \ - generator.Print(TO_STRING(field->is_repeated() ? \ - reflection->GetRepeated##METHOD(message, field, index) : \ - reflection->Get##METHOD(message, field))); \ - break; \ + switch (field->cpp_type()) { +#define OUTPUT_FIELD(CPPTYPE, METHOD, TO_STRING) \ + case FieldDescriptor::CPPTYPE_##CPPTYPE: \ + generator.Print(TO_STRING( \ + field->is_repeated() \ + ? reflection->GetRepeated##METHOD(message, field, index) \ + : reflection->Get##METHOD(message, field))); \ + break; - OUTPUT_FIELD( INT32, Int32, SimpleItoa); - OUTPUT_FIELD( INT64, Int64, SimpleItoa); + OUTPUT_FIELD(INT32, Int32, SimpleItoa); + OUTPUT_FIELD(INT64, Int64, SimpleItoa); OUTPUT_FIELD(UINT32, UInt32, SimpleItoa); OUTPUT_FIELD(UINT64, UInt64, SimpleItoa); - OUTPUT_FIELD( FLOAT, Float, SimpleFtoa); + OUTPUT_FIELD(FLOAT, Float, SimpleFtoa); OUTPUT_FIELD(DOUBLE, Double, SimpleDtoa); #undef OUTPUT_FIELD - case FieldDescriptor::CPPTYPE_STRING: { - string scratch; - const string& value = field->is_repeated() ? - reflection->GetRepeatedStringReference( - message, field, index, &scratch) : - reflection->GetStringReference(message, field, &scratch); + case FieldDescriptor::CPPTYPE_STRING: { + string scratch; + const string &value = + field->is_repeated() + ? reflection->GetRepeatedStringReference( + message, field, index, &scratch) + : reflection->GetStringReference(message, field, &scratch); - generator.Print("\""); - if (utf8_string_escaping_) { - generator.Print(strings::Utf8SafeCEscape(value)); - } else { - generator.Print(CEscape(value)); - } - generator.Print("\""); - - break; + generator.Print("\""); + if (utf8_string_escaping_) { + generator.Print(strings::Utf8SafeCEscape(value)); + } else { + generator.Print(CEscape(value)); } + generator.Print("\""); - case FieldDescriptor::CPPTYPE_BOOL: - if (field->is_repeated()) { - generator.Print(reflection->GetRepeatedBool(message, field, index) - ? "true" : "false"); - } else { - generator.Print(reflection->GetBool(message, field) - ? "true" : "false"); - } - break; + break; + } - case FieldDescriptor::CPPTYPE_ENUM: - generator.Print(field->is_repeated() ? - reflection->GetRepeatedEnum(message, field, index)->name() : - reflection->GetEnum(message, field)->name()); - break; + case FieldDescriptor::CPPTYPE_BOOL: + if (field->is_repeated()) { + generator.Print( + reflection->GetRepeatedBool(message, field, index) ? "true" + : "false"); + } else { + generator.Print( + reflection->GetBool(message, field) ? "true" : "false"); + } + break; - case FieldDescriptor::CPPTYPE_MESSAGE: - Print(field->is_repeated() ? - reflection->GetRepeatedMessage(message, field, index) : - reflection->GetMessage(message, field), - generator); - break; - } + case FieldDescriptor::CPPTYPE_ENUM: + generator.Print( + field->is_repeated() + ? reflection->GetRepeatedEnum(message, field, index)->name() + : reflection->GetEnum(message, field)->name()); + break; + + case FieldDescriptor::CPPTYPE_MESSAGE: + Print( + field->is_repeated() + ? reflection->GetRepeatedMessage(message, field, index) + : reflection->GetMessage(message, field), + generator); + break; + } } -/* static */ bool TextFormat::Print(const Message& message, - io::ZeroCopyOutputStream* output) { - return Printer().Print(message, output); +/* static */ bool +TextFormat::Print(const Message &message, io::ZeroCopyOutputStream *output) { + return Printer().Print(message, output); } /* static */ bool TextFormat::PrintUnknownFields( - const UnknownFieldSet& unknown_fields, - io::ZeroCopyOutputStream* output) { - return Printer().PrintUnknownFields(unknown_fields, output); + const UnknownFieldSet &unknown_fields, io::ZeroCopyOutputStream *output) { + return Printer().PrintUnknownFields(unknown_fields, output); } -/* static */ bool TextFormat::PrintToString( - const Message& message, string* output) { - return Printer().PrintToString(message, output); +/* static */ bool +TextFormat::PrintToString(const Message &message, string *output) { + return Printer().PrintToString(message, output); } /* static */ bool TextFormat::PrintUnknownFieldsToString( - const UnknownFieldSet& unknown_fields, string* output) { - return Printer().PrintUnknownFieldsToString(unknown_fields, output); + const UnknownFieldSet &unknown_fields, string *output) { + return Printer().PrintUnknownFieldsToString(unknown_fields, output); } /* static */ void TextFormat::PrintFieldValueToString( - const Message& message, - const FieldDescriptor* field, - int index, - string* output) { - return Printer().PrintFieldValueToString(message, field, index, output); + const Message &message, const FieldDescriptor *field, int index, + string *output) { + return Printer().PrintFieldValueToString(message, field, index, output); } /* static */ bool TextFormat::ParseFieldValueFromString( - const string& input, - const FieldDescriptor* field, - Message* message) { - return Parser().ParseFieldValueFromString(input, field, message); + const string &input, const FieldDescriptor *field, Message *message) { + return Parser().ParseFieldValueFromString(input, field, message); } // Prints an integer as hex with a fixed number of digits dependent on the // integer type. -template -static string PaddedHex(IntType value) { - string result; - result.reserve(sizeof(value) * 2); - for (int i = sizeof(value) * 2 - 1; i >= 0; i--) { - result.push_back(int_to_hex_digit(value >> (i*4) & 0x0F)); - } - return result; +template static string PaddedHex(IntType value) { + string result; + result.reserve(sizeof(value) * 2); + for (int i = sizeof(value) * 2 - 1; i >= 0; i--) { + result.push_back(int_to_hex_digit(value >> (i * 4) & 0x0F)); + } + return result; } void TextFormat::Printer::PrintUnknownFields( - const UnknownFieldSet& unknown_fields, TextGenerator& generator) const { - for (int i = 0; i < unknown_fields.field_count(); i++) { - const UnknownField& field = unknown_fields.field(i); - string field_number = SimpleItoa(field.number()); + const UnknownFieldSet &unknown_fields, TextGenerator &generator) const { + for (int i = 0; i < unknown_fields.field_count(); i++) { + const UnknownField &field = unknown_fields.field(i); + string field_number = SimpleItoa(field.number()); - switch (field.type()) { + switch (field.type()) { case UnknownField::TYPE_VARINT: - generator.Print(field_number); - generator.Print(": "); - generator.Print(SimpleItoa(field.varint())); - if (single_line_mode_) { - generator.Print(" "); - } else { - generator.Print("\n"); - } - break; + generator.Print(field_number); + generator.Print(": "); + generator.Print(SimpleItoa(field.varint())); + if (single_line_mode_) { + generator.Print(" "); + } else { + generator.Print("\n"); + } + break; case UnknownField::TYPE_FIXED32: { - generator.Print(field_number); - generator.Print(": 0x"); - char buffer[kFastToBufferSize]; - generator.Print(FastHex32ToBuffer(field.fixed32(), buffer)); - if (single_line_mode_) { - generator.Print(" "); - } else { - generator.Print("\n"); - } - break; + generator.Print(field_number); + generator.Print(": 0x"); + char buffer[kFastToBufferSize]; + generator.Print(FastHex32ToBuffer(field.fixed32(), buffer)); + if (single_line_mode_) { + generator.Print(" "); + } else { + generator.Print("\n"); + } + break; } case UnknownField::TYPE_FIXED64: { - generator.Print(field_number); - generator.Print(": 0x"); - char buffer[kFastToBufferSize]; - generator.Print(FastHex64ToBuffer(field.fixed64(), buffer)); - if (single_line_mode_) { - generator.Print(" "); - } else { - generator.Print("\n"); - } - break; + generator.Print(field_number); + generator.Print(": 0x"); + char buffer[kFastToBufferSize]; + generator.Print(FastHex64ToBuffer(field.fixed64(), buffer)); + if (single_line_mode_) { + generator.Print(" "); + } else { + generator.Print("\n"); + } + break; } case UnknownField::TYPE_LENGTH_DELIMITED: { - generator.Print(field_number); - const string& value = field.length_delimited(); - UnknownFieldSet embedded_unknown_fields; - if (!value.empty() && embedded_unknown_fields.ParseFromString(value)) { - // This field is parseable as a Message. - // So it is probably an embedded message. - if (single_line_mode_) { - generator.Print(" { "); - } else { - generator.Print(" {\n"); - generator.Indent(); - } - PrintUnknownFields(embedded_unknown_fields, generator); - if (single_line_mode_) { - generator.Print("} "); - } else { - generator.Outdent(); - generator.Print("}\n"); - } - } else { - // This field is not parseable as a Message. - // So it is probably just a plain string. - generator.Print(": \""); - generator.Print(CEscape(value)); - generator.Print("\""); - if (single_line_mode_) { - generator.Print(" "); - } else { - generator.Print("\n"); - } - } - break; + generator.Print(field_number); + const string &value = field.length_delimited(); + UnknownFieldSet embedded_unknown_fields; + if (!value.empty() && embedded_unknown_fields.ParseFromString(value)) { + // This field is parseable as a Message. + // So it is probably an embedded message. + if (single_line_mode_) { + generator.Print(" { "); + } else { + generator.Print(" {\n"); + generator.Indent(); + } + PrintUnknownFields(embedded_unknown_fields, generator); + if (single_line_mode_) { + generator.Print("} "); + } else { + generator.Outdent(); + generator.Print("}\n"); + } + } else { + // This field is not parseable as a Message. + // So it is probably just a plain string. + generator.Print(": \""); + generator.Print(CEscape(value)); + generator.Print("\""); + if (single_line_mode_) { + generator.Print(" "); + } else { + generator.Print("\n"); + } + } + break; } case UnknownField::TYPE_GROUP: - generator.Print(field_number); - if (single_line_mode_) { - generator.Print(" { "); - } else { - generator.Print(" {\n"); - generator.Indent(); - } - PrintUnknownFields(field.group(), generator); - if (single_line_mode_) { - generator.Print("} "); - } else { - generator.Outdent(); - generator.Print("}\n"); - } - break; - } - } -} - -} // namespace protobuf -} // namespace google + generator.Print(field_number); + if (single_line_mode_) { + generator.Print(" { "); + } else { + generator.Print(" {\n"); + generator.Indent(); + } + PrintUnknownFields(field.group(), generator); + if (single_line_mode_) { + generator.Print("} "); + } else { + generator.Outdent(); + generator.Print("}\n"); + } + break; + } + } } +} // namespace protobuf +} // namespace google +} // namespace bts diff --git a/src/lib/config/text_format/text_format.h b/src/lib/config/text_format/text_format.h old mode 100755 new mode 100644 index 01ae25d6e..575bdd6fd --- a/src/lib/config/text_format/text_format.h +++ b/src/lib/config/text_format/text_format.h @@ -37,16 +37,15 @@ // // Forked from LibProtobuf for BTS Config by Eric Harding on 5/29/2013 -// - +// #ifndef GOOGLE_PROTOBUF_TEXT_FORMAT_H__ #define GOOGLE_PROTOBUF_TEXT_FORMAT_H__ #pragma once -#include -#include #include +#include +#include #ifdef __GNUC__ #pragma GCC diagnostic push @@ -54,12 +53,12 @@ #endif namespace google { - namespace protobuf { - namespace io { - class ErrorCollector; // tokenizer.h - } - } +namespace protobuf { +namespace io { +class ErrorCollector; // tokenizer.h } +} // namespace protobuf +} // namespace google namespace bts { namespace google { @@ -67,14 +66,15 @@ namespace protobuf { using namespace ::google::protobuf; - 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; + 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; }; - // This class implements protocol buffer text format. Printing and parsing // protocol messages in text format is useful for debugging and human editing // of messages. @@ -82,239 +82,226 @@ public: // This class is really a namespace that contains only static methods. class TextFormat { public: - // Outputs a textual representation of the given message to the given - // output stream. - static bool Print(const Message& message, io::ZeroCopyOutputStream* output); + // Outputs a textual representation of the given message to the given + // output stream. + static bool Print(const Message &message, io::ZeroCopyOutputStream *output); - // Print the fields in an UnknownFieldSet. They are printed by tag number - // only. Embedded messages are heuristically identified by attempting to - // parse them. - static bool PrintUnknownFields(const UnknownFieldSet& unknown_fields, - io::ZeroCopyOutputStream* output); + // Print the fields in an UnknownFieldSet. They are printed by tag number + // only. Embedded messages are heuristically identified by attempting to + // parse them. + static bool PrintUnknownFields( + const UnknownFieldSet &unknown_fields, io::ZeroCopyOutputStream *output); - // Like Print(), but outputs directly to a string. - static bool PrintToString(const Message& message, string* output); + // Like Print(), but outputs directly to a string. + static bool PrintToString(const Message &message, string *output); - // Like PrintUnknownFields(), but outputs directly to a string. - static bool PrintUnknownFieldsToString(const UnknownFieldSet& unknown_fields, - string* output); + // Like PrintUnknownFields(), but outputs directly to a string. + static bool PrintUnknownFieldsToString( + const UnknownFieldSet &unknown_fields, string *output); - // Outputs a textual representation of the value of the field supplied on - // the message supplied. For non-repeated fields, an index of -1 must - // 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, - string* output); + // Outputs a textual representation of the value of the field supplied on + // the message supplied. For non-repeated fields, an index of -1 must + // 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, + string *output); - // Class for those users which require more fine-grained control over how - // a protobuffer message is printed out. - class Printer { - public: - Printer(); - ~Printer(); + // Class for those users which require more fine-grained control over how + // a protobuffer message is printed out. + class Printer { + public: + Printer(); + ~Printer(); - // Like TextFormat::Print - bool Print(const Message& message, io::ZeroCopyOutputStream* output) const; - // Like TextFormat::PrintUnknownFields - bool PrintUnknownFields(const UnknownFieldSet& unknown_fields, - io::ZeroCopyOutputStream* output) const; - // Like TextFormat::PrintToString - bool PrintToString(const Message& message, string* output) const; - // Like TextFormat::PrintUnknownFieldsToString - bool PrintUnknownFieldsToString(const UnknownFieldSet& unknown_fields, - string* output) const; - // Like TextFormat::PrintFieldValueToString - void PrintFieldValueToString(const Message& message, - const FieldDescriptor* field, - int index, - string* output) const; + // Like TextFormat::Print + bool + Print(const Message &message, io::ZeroCopyOutputStream *output) const; + // Like TextFormat::PrintUnknownFields + bool PrintUnknownFields( + const UnknownFieldSet &unknown_fields, + io::ZeroCopyOutputStream *output) const; + // Like TextFormat::PrintToString + bool PrintToString(const Message &message, string *output) const; + // Like TextFormat::PrintUnknownFieldsToString + bool PrintUnknownFieldsToString( + const UnknownFieldSet &unknown_fields, string *output) const; + // Like TextFormat::PrintFieldValueToString + void PrintFieldValueToString( + const Message &message, const FieldDescriptor *field, int index, + string *output) const; - // Adjust the initial indent level of all output. Each indent level is - // equal to two spaces. - void SetInitialIndentLevel(int indent_level) { - initial_indent_level_ = indent_level; - } + // Adjust the initial indent level of all output. Each indent level is + // equal to two spaces. + void SetInitialIndentLevel(int indent_level) { + initial_indent_level_ = indent_level; + } - // If printing in single line mode, then the entire message will be output - // on a single line with no line breaks. - void SetSingleLineMode(bool single_line_mode) { - single_line_mode_ = single_line_mode; - } + // If printing in single line mode, then the entire message will be output + // on a single line with no line breaks. + void SetSingleLineMode(bool single_line_mode) { + single_line_mode_ = single_line_mode; + } - // Set true to print repeated primitives in a format like: - // field_name: [1, 2, 3, 4] - // instead of printing each value on its own line. Short format applies - // only to primitive values -- i.e. everything except strings and - // sub-messages/groups. - void SetUseShortRepeatedPrimitives(bool use_short_repeated_primitives) { - use_short_repeated_primitives_ = use_short_repeated_primitives; - } + // Set true to print repeated primitives in a format like: + // field_name: [1, 2, 3, 4] + // instead of printing each value on its own line. Short format applies + // only to primitive values -- i.e. everything except strings and + // sub-messages/groups. + void SetUseShortRepeatedPrimitives(bool use_short_repeated_primitives) { + use_short_repeated_primitives_ = use_short_repeated_primitives; + } - // Set true to output UTF-8 instead of ASCII. The only difference - // is that bytes >= 0x80 in string fields will not be escaped, - // because they are assumed to be part of UTF-8 multi-byte - // sequences. - void SetUseUtf8StringEscaping(bool as_utf8) { - utf8_string_escaping_ = as_utf8; - } + // Set true to output UTF-8 instead of ASCII. The only difference + // is that bytes >= 0x80 in string fields will not be escaped, + // because they are assumed to be part of UTF-8 multi-byte + // sequences. + void SetUseUtf8StringEscaping(bool as_utf8) { + utf8_string_escaping_ = as_utf8; + } - private: - // Forward declaration of an internal class used to print the text - // output to the OutputStream (see text_format.cc for implementation). - class TextGenerator; + private: + // Forward declaration of an internal class used to print the text + // output to the OutputStream (see text_format.cc for implementation). + class TextGenerator; - // Internal Print method, used for writing to the OutputStream via - // the TextGenerator class. - void Print(const Message& message, - TextGenerator& generator) const; + // Internal Print method, used for writing to the OutputStream via + // the TextGenerator class. + void Print(const Message &message, TextGenerator &generator) const; - // Print a single field. - void PrintField(const Message& message, - const Reflection* reflection, - const FieldDescriptor* field, - TextGenerator& generator) const; + // Print a single field. + void PrintField( + 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; + // Print a repeated primitive field in short form. + void PrintShortRepeatedField( + 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; + // 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; - // 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, - 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, + TextGenerator &generator) const; - // Print the fields in an UnknownFieldSet. They are printed by tag number - // only. Embedded messages are heuristically identified by attempting to - // parse them. - void PrintUnknownFields(const UnknownFieldSet& unknown_fields, - TextGenerator& generator) const; + // Print the fields in an UnknownFieldSet. They are printed by tag number + // only. Embedded messages are heuristically identified by attempting to + // parse them. + void PrintUnknownFields( + const UnknownFieldSet &unknown_fields, + TextGenerator &generator) const; - int initial_indent_level_; + int initial_indent_level_; - bool single_line_mode_; + bool single_line_mode_; - bool use_short_repeated_primitives_; + bool use_short_repeated_primitives_; - bool utf8_string_escaping_; - }; + bool utf8_string_escaping_; + }; - // Parses a text-format protocol message from the given input stream to - // the given message object. This function parses the format written - // by Print(). - static bool Parse(io::ZeroCopyInputStream* input, Message* output); - // Like Parse(), but reads directly from a string. - static bool ParseFromString(const string& input, Message* output); + // Parses a text-format protocol message from the given input stream to + // the given message object. This function parses the format written + // by Print(). + static bool Parse(io::ZeroCopyInputStream *input, Message *output); + // Like Parse(), but reads directly from a string. + static bool ParseFromString(const string &input, Message *output); - // Like Parse(), but the data is merged into the given message, as if - // using Message::MergeFrom(). - static bool Merge(io::ZeroCopyInputStream* input, Message* output); - // Like Merge(), but reads directly from a string. - static bool MergeFromString(const string& input, Message* output); + // Like Parse(), but the data is merged into the given message, as if + // using Message::MergeFrom(). + static bool Merge(io::ZeroCopyInputStream *input, Message *output); + // Like Merge(), but reads directly from a string. + static bool MergeFromString(const string &input, Message *output); - // Parse the given text as a single field value and store it into the - // given field of the given message. If the field is a repeated field, - // the new value will be added to the end - static bool ParseFieldValueFromString(const string& input, - const FieldDescriptor* field, - Message* message); + // Parse the given text as a single field value and store it into the + // given field of the given message. If the field is a repeated field, + // the new value will be added to the end + static bool ParseFieldValueFromString( + const string &input, const FieldDescriptor *field, Message *message); - // Interface that TextFormat::Parser can use to find extensions. - // This class may be extended in the future to find more information - // like fields, etc. - class Finder { - public: - virtual ~Finder(); + // Interface that TextFormat::Parser can use to find extensions. + // This class may be extended in the future to find more information + // like fields, etc. + class Finder { + public: + virtual ~Finder(); - // Try to find an extension of *message by fully-qualified field - // name. Returns NULL if no extension is known for this name or number. - virtual const FieldDescriptor* FindExtension( - Message* message, - const string& name) const = 0; - }; + // Try to find an extension of *message by fully-qualified field + // name. Returns NULL if no extension is known for this name or number. + virtual const FieldDescriptor * + FindExtension(Message *message, const string &name) const = 0; + }; - // For more control over parsing, use this class. - class Parser { - public: - Parser(); - ~Parser(); + // For more control over parsing, use this class. + class Parser { + public: + Parser(); + ~Parser(); - // Like TextFormat::Parse(). - bool Parse(io::ZeroCopyInputStream* input, Message* output); - // Like TextFormat::ParseFromString(). - bool ParseFromString(const string& input, Message* output); - // Like TextFormat::Merge(). - bool Merge(io::ZeroCopyInputStream* input, Message* output); - // Like TextFormat::MergeFromString(). - bool MergeFromString(const string& input, Message* output); + // Like TextFormat::Parse(). + bool Parse(io::ZeroCopyInputStream *input, Message *output); + // Like TextFormat::ParseFromString(). + bool ParseFromString(const string &input, Message *output); + // Like TextFormat::Merge(). + bool Merge(io::ZeroCopyInputStream *input, Message *output); + // Like TextFormat::MergeFromString(). + bool MergeFromString(const string &input, Message *output); - void SetValueLookup(IDeferValueLookup* lookup) { - lookup_ = lookup; - } + void SetValueLookup(IDeferValueLookup *lookup) { lookup_ = lookup; } - // Set where to report parse errors. If NULL (the default), errors will - // be printed to stderr. - void RecordErrorsTo(io::ErrorCollector* error_collector) { - error_collector_ = error_collector; - } + // Set where to report parse errors. If NULL (the default), errors will + // be printed to stderr. + void RecordErrorsTo(io::ErrorCollector *error_collector) { + error_collector_ = error_collector; + } - // Set how parser finds extensions. If NULL (the default), the - // parser will use the standard Reflection object associated with - // the message being parsed. - void SetFinder(Finder* finder) { - finder_ = finder; - } + // Set how parser finds extensions. If NULL (the default), the + // parser will use the standard Reflection object associated with + // the message being parsed. + void SetFinder(Finder *finder) { finder_ = finder; } - // Normally parsing fails if, after parsing, output->IsInitialized() - // returns false. Call AllowPartialMessage(true) to skip this check. - void AllowPartialMessage(bool allow) { - allow_partial_ = allow; - } + // Normally parsing fails if, after parsing, output->IsInitialized() + // returns false. Call AllowPartialMessage(true) to skip this check. + void AllowPartialMessage(bool allow) { allow_partial_ = allow; } - // Like TextFormat::ParseFieldValueFromString - bool ParseFieldValueFromString(const string& input, - const FieldDescriptor* field, - Message* output); + // Like TextFormat::ParseFieldValueFromString + bool ParseFieldValueFromString( + const string &input, const FieldDescriptor *field, Message *output); - private: - // Forward declaration of an internal class used to parse text - // representations (see text_format.cc for implementation). - class ParserImpl; + private: + // Forward declaration of an internal class used to parse text + // representations (see text_format.cc for implementation). + class ParserImpl; - // Like TextFormat::Merge(). The provided implementation is used - // to do the parsing. - bool MergeUsingImpl(io::ZeroCopyInputStream* input, - Message* output, - ParserImpl* parser_impl); + // Like TextFormat::Merge(). The provided implementation is used + // to do the parsing. + bool MergeUsingImpl( + io::ZeroCopyInputStream *input, Message *output, + ParserImpl *parser_impl); - io::ErrorCollector* error_collector_; - IDeferValueLookup* lookup_; - Finder* finder_; - bool allow_partial_; - }; + io::ErrorCollector *error_collector_; + IDeferValueLookup *lookup_; + Finder *finder_; + bool allow_partial_; + }; private: - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(TextFormat); + GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(TextFormat); }; -} // namespace protobuf -} // namespace google -} +} // namespace protobuf +} // namespace google +} // namespace bts #ifdef __GNUC__ #pragma GCC diagnostic pop #endif -#endif // GOOGLE_PROTOBUF_TEXT_FORMAT_H__ +#endif // GOOGLE_PROTOBUF_TEXT_FORMAT_H__ diff --git a/src/lib/domain_model/Security.cpp b/src/lib/domain_model/Security.cpp index 7b43b4ae9..d6d81e959 100644 --- a/src/lib/domain_model/Security.cpp +++ b/src/lib/domain_model/Security.cpp @@ -32,7 +32,7 @@ std::string descriptor(api::Security const &sec) { return "No descriptor for non glbx / ice exchange"; } -api::SecurityType security_type(api::Security const&sec) { +api::SecurityType security_type(api::Security const &sec) { if (sec.has_future()) return api::SecurityType::SECURITYTYPE_FUTURE; else if (sec.has_option()) @@ -79,8 +79,9 @@ boost::gregorian::date expiration(api::Security const &security) { } } -bool is_expired(api::Security const &security, datetime::PTime const &now, - uint32_t sod_hh, uint32_t sod_mm) { +bool is_expired( + 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()) return false; @@ -93,7 +94,7 @@ bool is_expired(api::Security const &security, datetime::PTime const &now, bool is_expired(api::Security const &security, datetime::PTime const &now) { const auto &sod = config::get(); - return is_expired(security,now,sod.sod_hh(),sod.sod_mm()); + return is_expired(security, now, sod.sod_hh(), sod.sod_mm()); } bool is_expired(api::Security const &security) { diff --git a/src/lib/domain_model/Security.h b/src/lib/domain_model/Security.h index 7ce9762d0..1bba0f0a4 100644 --- a/src/lib/domain_model/Security.h +++ b/src/lib/domain_model/Security.h @@ -19,14 +19,14 @@ namespace bts { namespace api { class Security; class ICEExchangeData; -} +} // namespace api namespace securities { SecurityKey security_key(api::Security const &); std::string to_str(api::Security const &); std::pair from_str(std::string const &); std::string descriptor(api::Security const &); -api::SecurityType security_type(api::Security const&); +api::SecurityType security_type(api::Security const &); inline std::string const &side_name(api::Side side) { return api::Side_Name(side); @@ -83,7 +83,7 @@ inline bool is_better(api::Side side, Price p1, Price p2) { } inline bool is_worse(api::Side s, Price p1, Price p2) { - return is_better(s,p2,p1); + return is_better(s, p2, p1); } template void apply_to_both_sides(C c) { @@ -124,13 +124,14 @@ inline Price better_price(api::Side side, Price p1, Price p2) { return is_equal_or_better(side, p1, p2) ? p1 : p2; } -// Returns the worst possible price representable in the Price data type for the side in question +// Returns the worst possible price representable in the Price data type for the +// side in question inline Price worst_price(api::Side side) { switch (side) { case api::SIDE_BUY: - return Price {std::numeric_limits::min()}; + return Price{std::numeric_limits::min()}; case api::SIDE_SELL: - return Price {std::numeric_limits::max()}; + return Price{std::numeric_limits::max()}; default: bts_assert(false); break; @@ -155,8 +156,8 @@ inline Price encode_exchange_price(api::Security const &sec, Price in) { return in; } -inline double raw_round_to_quote_price(double raw_price, double tick_size, - api::Side side) { +inline double +raw_round_to_quote_price(double raw_price, double tick_size, api::Side side) { double factor = 1000000000; auto i_price = llround(factor * raw_price); auto i_tick_size = llround(tick_size * factor); @@ -184,9 +185,8 @@ inline double raw_round_to_quote_price(double raw_price, double tick_size, return new_i_price / factor; } -inline double -checked_round_to_quote_price(const api::ContractSpecification &spec, - double price, api::Side side) { +inline double checked_round_to_quote_price( + const api::ContractSpecification &spec, double price, api::Side side) { if (std::isnan(price)) return price; if (price < -spec.price_break() || price > spec.price_break()) { @@ -200,8 +200,8 @@ checked_round_to_quote_price(const api::ContractSpecification &spec, } } -inline Price round_to_quote_price(api::Security const &sec, Price in, - api::Side side) { +inline Price +round_to_quote_price(api::Security const &sec, Price in, api::Side side) { auto p = in.value(); bts_assert_d(!std::isnan(p)); if (p < -sec.contract_spec().price_break() || @@ -217,8 +217,9 @@ boost::gregorian::date expiration(api::Security const &sec); 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, uint32_t sod_mm); +bool is_expired( + api::Security const &security, datetime::PTime const &now, uint32_t sod_hh, + uint32_t sod_mm); inline Price tick_size(api::Security const &sec) { return Price(sec.contract_spec().low_tick()); @@ -227,16 +228,16 @@ inline Price tick_size(api::Security const &sec) { // Looking to round md::IntPrice? Look in IntPrice.h // computes price_2 - price_1 in ticks -inline int price_diff_to_ticks(double price_1, double price_2, - double tick_size) { +inline int +price_diff_to_ticks(double price_1, double price_2, double tick_size) { return static_cast(std::round((price_2 - price_1) / tick_size)); } // returns the difference (in ticks) bw and order and a market. // if the order has crossed the market, returns -ve ticks // (ie the buy order price > market_price or // sell_order_price < market_price) -inline int order_diff_market(double order_price, double market_price, - api::Side side, double tick_size) { +inline int order_diff_market( + double order_price, double market_price, api::Side side, double tick_size) { switch (side) { case api::SIDE_BUY: return price_diff_to_ticks(order_price, market_price, tick_size); @@ -252,8 +253,8 @@ inline int order_diff_market(double order_price, double market_price, // simple double equality can not be used to compare prices. // this function deems 2 prices to be equal if they are within // 1 % of the tick size -inline bool test_price_equality(double price_1, double price_2, - double tick_size) { +inline bool +test_price_equality(double price_1, double price_2, double tick_size) { return std::fabs(price_2 - price_1) < 0.01 * tick_size; } inline bool gr_than_eq(double p1, double p2, double tick_size) { @@ -274,20 +275,20 @@ inline bool test_price_equality(double price_1, double price_2) { // ice specialization ///////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// -inline bool is_ice_spread(const bts::api::ICEExchangeData& ice_data){ - const auto& strip = ice_data.strip_name(); +inline bool is_ice_spread(const bts::api::ICEExchangeData &ice_data) { + const auto &strip = ice_data.strip_name(); return strip.find("/") != std::string::npos; } -inline bool is_strip(const bts::api::Security& sec){ - return sec.has_ice() && sec.has_spread() && !is_ice_spread(sec.ice()); +inline bool is_strip(const bts::api::Security &sec) { + return sec.has_ice() && sec.has_spread() && !is_ice_spread(sec.ice()); } -inline bool is_spread_of_strips(const bts::api::Security& sec){ - if(sec.has_spread()) - if (sec.has_ice()){ - const auto& spr = sec.spread(); - for (const auto& l : spr.legs()) +inline bool is_spread_of_strips(const bts::api::Security &sec) { + if (sec.has_spread()) + if (sec.has_ice()) { + const auto &spr = sec.spread(); + for (const auto &l : spr.legs()) // assumption : either all legs are strips or none return is_strip(l.security()); } diff --git a/src/lib/domain_model/SecurityKey.h b/src/lib/domain_model/SecurityKey.h index d9e3021b2..fd55d3f05 100644 --- a/src/lib/domain_model/SecurityKey.h +++ b/src/lib/domain_model/SecurityKey.h @@ -1,5 +1,5 @@ #pragma once #include "lib/utils/ValueWrapper.h" namespace bts { -using SecurityKey = utils::ValueWrapper; +using SecurityKey = utils::ValueWrapper; } \ No newline at end of file diff --git a/src/lib/domain_model/SecurityTests.cpp b/src/lib/domain_model/SecurityTests.cpp index e95f1b5d2..d5a42d892 100644 --- a/src/lib/domain_model/SecurityTests.cpp +++ b/src/lib/domain_model/SecurityTests.cpp @@ -1,99 +1,91 @@ #include "catch/catch.hpp" -#include #include +#include namespace bts { int security_tests = 0; namespace securities { -TEST_CASE ("Security name formatting tests" , "[securities]") -{ - SECTION("FB") - { +TEST_CASE("Security name formatting tests", "[securities]") { + SECTION("FB") { std::string example = "GE:FB 02Y H0"; - std::regex rx ("(\\w+)\\:FB (\\d+)Y (\\w+)"); + std::regex rx("(\\w+)\\:FB (\\d+)Y (\\w+)"); std::smatch matches; - REQUIRE(std::regex_match(example,matches,rx)); + REQUIRE(std::regex_match(example, matches, rx)); // for (auto const &m : matches) // std::cout << "match: " << m.str() << "\n"; - } + } - SECTION("BS") - { + SECTION("BS") { std::string example = "GE:BS 2YH0 2YH2"; std::regex rx("(\\w+)\\:BS (\\d+)Y(\\w+) (\\d+)Y(\\w+)"); std::smatch matches; - REQUIRE(std::regex_match(example,matches,rx)); + REQUIRE(std::regex_match(example, matches, rx)); // for (auto const &m : matches) // std::cout << "match: " << m.str() << "\n"; - } + } - SECTION("BF") - { + SECTION("BF") { std::string example = "GE:BF Z4-U5-M6"; std::regex rx("(\\w+)\\:BF (\\w+)-(\\w+)-(\\w+)"); std::smatch matches; - REQUIRE(std::regex_match(example,matches,rx)); + REQUIRE(std::regex_match(example, matches, rx)); // for (auto const &m : matches) // std::cout << "match: " << m.str() << "\n"; - } + } - SECTION("CF") - { + SECTION("CF") { std::string example = "GE:CF H0H1H2H3"; std::regex rx("(\\w+)\\:CF (\\w\\w)(\\w\\w)(\\w\\w)(\\w\\w)"); std::smatch matches; - REQUIRE(std::regex_match(example,matches,rx)); + REQUIRE(std::regex_match(example, matches, rx)); // for (auto const &m : matches) // std::cout << "match: " << m.str() << "\n"; - } + } - SECTION("DF") - { + SECTION("DF") { std::string example = "GE:DF Z7H8M8U8"; std::regex rx("(\\w+)\\:DF (\\w\\w)(\\w\\w)(\\w\\w)(\\w\\w)"); std::smatch matches; - REQUIRE(std::regex_match(example,matches,rx)); + REQUIRE(std::regex_match(example, matches, rx)); // for (auto const &m : matches) // std::cout << "match: " << m.str() << "\n"; - } + } - SECTION("MP") - { + SECTION("MP") { std::string example = "GE:MP H0 1YM0"; std::regex rx("(\\w+)\\:MP (\\w\\w) \\w\\w(\\w\\w)"); std::smatch matches; - REQUIRE(std::regex_match(example,matches,rx)); + REQUIRE(std::regex_match(example, matches, rx)); // for (auto const &m : matches) // std::cout << "match: " << m.str() << "\n"; - } + } - SECTION("PB") - { + SECTION("PB") { std::string example = "GE:PB Z7-Z8-Z9"; std::regex rx("(\\w+)\\:PB (\\w\\w)-(\\w\\w)-(\\w\\w)"); std::smatch matches; - REQUIRE(std::regex_match(example,matches,rx)); + REQUIRE(std::regex_match(example, matches, rx)); // for (auto const &m : matches) // std::cout << "match: " << m.str() << "\n"; - } - SECTION("PS") - { + } + SECTION("PS") { std::string example = "GE:PS H0-H1"; std::regex rx("(\\w+)\\:PS (\\w\\w)-(\\w\\w)"); std::smatch matches; - REQUIRE(std::regex_match(example,matches,rx)); + REQUIRE(std::regex_match(example, matches, rx)); // for (auto const &m : matches) // std::cout << "match: " << m.str() << "\n"; - } + } } -}} +} // namespace securities +} // namespace bts diff --git a/src/lib/domain_model/common.h b/src/lib/domain_model/common.h index af6f2a590..886f3baf6 100644 --- a/src/lib/domain_model/common.h +++ b/src/lib/domain_model/common.h @@ -3,12 +3,11 @@ #include #include -#include "lib/utils/ValueWrapper.h" #include "lib/domain_model/SecurityKey.h" +#include "lib/utils/ValueWrapper.h" namespace bts { -using Price = utils::ValueWrapper; -using Quantity = utils::ValueWrapper; -using UserLogin = utils::ValueWrapper; -} - +using Price = utils::ValueWrapper; +using Quantity = utils::ValueWrapper; +using UserLogin = utils::ValueWrapper; +} // namespace bts diff --git a/src/lib/domain_model/sod.cpp b/src/lib/domain_model/sod.cpp index 6cbdfe419..70ab8d41f 100644 --- a/src/lib/domain_model/sod.cpp +++ b/src/lib/domain_model/sod.cpp @@ -2,25 +2,20 @@ #include "lib/config/config.h" #include "lib/config/protos/orders_fills_cleanup.pb.h" - namespace bts { namespace sod { -datetime::PTime get_sod_for (datetime::PTime const&this_time) { +datetime::PTime get_sod_for(datetime::PTime const &this_time) { const auto &sod = config::get(); - auto sod_time = datetime::make_ptime (this_time.date().year(), - this_time.date().month().as_number(), - this_time.date().day().as_number(), - sod.sod_hh(), - sod.sod_mm(), - 0,0); + auto sod_time = datetime::make_ptime( + this_time.date().year(), this_time.date().month().as_number(), + this_time.date().day().as_number(), sod.sod_hh(), sod.sod_mm(), 0, 0); if (sod_time > this_time) sod_time -= boost::gregorian::date_duration(1); return sod_time; } -datetime::PTime get_current_sod() { - return get_sod_for(datetime::local_now()); -} +datetime::PTime get_current_sod() { return get_sod_for(datetime::local_now()); } -}} +} // namespace sod +} // namespace bts diff --git a/src/lib/domain_model/sod.h b/src/lib/domain_model/sod.h index 1583c0255..b66229f0f 100644 --- a/src/lib/domain_model/sod.h +++ b/src/lib/domain_model/sod.h @@ -6,7 +6,8 @@ namespace bts { namespace sod { -datetime::PTime get_sod_for (datetime::PTime const&this_time) ; +datetime::PTime get_sod_for(datetime::PTime const &this_time); datetime::PTime get_current_sod(); -}} +} // namespace sod +} // namespace bts diff --git a/src/lib/domain_model/tests/domain_tests.cpp b/src/lib/domain_model/tests/domain_tests.cpp index 82e131589..3fc8ed772 100644 --- a/src/lib/domain_model/tests/domain_tests.cpp +++ b/src/lib/domain_model/tests/domain_tests.cpp @@ -156,11 +156,13 @@ TEST_CASE("expiration_tests", "[security]") { using namespace boost::gregorian; auto spread = utils::pb::from_string(spread_txt); - REQUIRE(securities::expiration(spread) == - date(greg_year(2019), greg_month(1), greg_day(20))); + REQUIRE( + securities::expiration(spread) == + date(greg_year(2019), greg_month(1), greg_day(20))); auto &leg = spread.spread().legs(1).security(); - REQUIRE(securities::expiration(leg) == - date(greg_year(3020), greg_month(6), greg_day(19))); + REQUIRE( + securities::expiration(leg) == + date(greg_year(3020), greg_month(6), greg_day(19))); REQUIRE(securities::is_expired(spread)); REQUIRE(!securities::is_expired(leg)); } diff --git a/src/lib/expression/BooleanGrammar.cpp b/src/lib/expression/BooleanGrammar.cpp old mode 100755 new mode 100644 index 33441b972..b1235aa79 --- a/src/lib/expression/BooleanGrammar.cpp +++ b/src/lib/expression/BooleanGrammar.cpp @@ -21,8 +21,9 @@ ph::function const property_expr; ph::function list_expr; // For the sake of build performance this is instantiated here -// and referenced by ExpressionEvaluator so that minor changes +// and referenced by ExpressionEvaluator so that minor changes // to ExpressionEvaluator don't take 30 seconds to build. BooleanGrammar boolean_string_grammar; -}}//namespace +} // namespace expression +} // namespace bts diff --git a/src/lib/expression/BooleanGrammar.h b/src/lib/expression/BooleanGrammar.h old mode 100755 new mode 100644 index 81fb30a5d..11baa3ff3 --- a/src/lib/expression/BooleanGrammar.h +++ b/src/lib/expression/BooleanGrammar.h @@ -4,95 +4,120 @@ #include "lib/utils/bts_no_copy.h" #include +#include +#include #include #include -#include -#include #include /* * Using and modifying this grammar: * - * Boost::spirit is a fantastically complex bit of technology which could take years to master. - * I'll try to describe the conventsions followed in this grammar which form a more comprehensible - * sub-set. + * Boost::spirit is a fantastically complex bit of technology which could take + * years to master. I'll try to describe the conventsions followed in this + * grammar which form a more comprehensible sub-set. * - * spirit::utree is a generic syntax type which can act as the result (aka "property") of an expression or grammar. - * boost::spirit can act on any arbitrary type using template based duck typing and a set of rules to transform the result - * of your expressions to those types. However, this is incredibly tricky to get right and the error messages aren't very - * useful. Whenever possible try to use utree as the result type of your grammar elements. It should support any type needed - * for a typical parse grammar. To learn more about utree see the slides and talk - * here: http://boost-spirit.com/home/2011/06/12/ast-construction-with-the-universal-tree/ - * and docs here http://www.boost.org/doc/libs/1_47_0/libs/spirit/doc/html/spirit/support/utree.html + * spirit::utree is a generic syntax type which can act as the result (aka + * "property") of an expression or grammar. boost::spirit can act on any + * arbitrary type using template based duck typing and a set of rules to + * transform the result of your expressions to those types. However, this is + * incredibly tricky to get right and the error messages aren't very useful. + * Whenever possible try to use utree as the result type of your grammar + * elements. It should support any type needed for a typical parse grammar. To + * learn more about utree see the slides and talk here: + * http://boost-spirit.com/home/2011/06/12/ast-construction-with-the-universal-tree/ + * and docs here + * http://www.boost.org/doc/libs/1_47_0/libs/spirit/doc/html/spirit/support/utree.html * * Note: - * In utree there are 2 string type nodes. The standard std::string represents a quoted string value and utf8_symbol_range_type represents - * an operator or key word in your grammar. - * - * Note 2: - * When you modify your grammar keep an eye on the raw build output. There is a lot of debug information that gets printed but not included in the Visual Studio - * error log. + * In utree there are 2 string type nodes. The standard std::string + * represents a quoted string value and utf8_symbol_range_type represents an + * operator or key word in your grammar. * - * This is not meant ot be a complete tutorial so you should also read though the spirit docs. + * Note 2: + * When you modify your grammar keep an eye on the raw build output. There + * is a lot of debug information that gets printed but not included in the + * Visual Studio error log. + * + * This is not meant ot be a complete tutorial so you should also read though + * the spirit docs. * * Basics: * * ** Example 0 * Most spirit parse expressions will look something like this: * a = b [X] >> ";" - * this means a will be a parser which matches b followed by a literal semicolon. The statement inside the [ ] is called a "semantic action" - * When b is matched it will evaluate the semantic action X passing in the result (or property) of b as _1. The final result is always available - * as _val. - * If X takes the form _val = _1 it assigns the result of b to a assuming their type is compatible (nearly all types are compatible with utree) - * If X takes the form [myoperator(_val, _1)] then _val and _1 are passed in to your user defined operator and you can modify the utree AST directly. - * + * this means a will be a parser which matches b followed by a literal + * semicolon. The statement inside the [ ] is called a "semantic action" When b + * is matched it will evaluate the semantic action X passing in the result (or + * property) of b as _1. The final result is always available as _val. If X + * takes the form _val = _1 it assigns the result of b to a assuming their type + * is compatible (nearly all types are compatible with utree) If X takes the + * form [myoperator(_val, _1)] then _val and _1 are passed in to your user + * defined operator and you can modify the utree AST directly. + * * ** Example 1 - * rule term = + * rule term = * bool_ [_val = _1] * | '!' >> bool_ [not_expr(_val, _1)] * - * If this encounters the phrase "true" the first part matches and we evaluate [_val = _1] the boolean is automatically converted to a utree (which contains a bool) - * If we have "!true" the second part matches and we evaluate [not_expr(_val, _1)] which calls our unary_operator class passing in expr which is the result property - * on term and rhs which is the bool value automatically converted to a utree. The operator is then free to modify the result (expr) directly. In this - * case it pushes 2 child nodes into expr a not operator and the original utree bool node. + * If this encounters the phrase "true" the first part matches and we evaluate + * [_val = _1] the boolean is automatically converted to a utree (which contains + * a bool) If we have "!true" the second part matches and we evaluate + * [not_expr(_val, _1)] which calls our unary_operator class passing in expr + * which is the result property on term and rhs which is the bool value + * automatically converted to a utree. The operator is then free to modify the + * result (expr) directly. In this case it pushes 2 child nodes into expr a not + * operator and the original utree bool node. * * * ** Example 2 - * rule quoted_string = + * rule quoted_string = * char_("'\"") * >> (lexeme[*(alnum [_val += _1] | space [_val += _1])]) * >> char_("'\""); * - * This is currently the only rule in this grammar which does not use a utree. Here we use a regular std::string rule because in each semantic action we want to append - * the new character to the result. If this semantic action was not there at all the resulting property would be a vector which included the quotes. This would - * be OK beause boost::spirit can automatically convert a vector to a std::string but we prefer to remove the quotes now. - * lexeme[] - is a spirit transform which tells the parser to ignore space skipping for the expression. In this case [ ] do not indicate a semantic action. - * *( ) - a kleene star indicateing 0 or more matches of the contained grammar. - * char_('") - this syntax matches either of the contained string literals. + * This is currently the only rule in this grammar which does not use a utree. + * Here we use a regular std::string rule because in each semantic action we + * want to append the new character to the result. If this semantic action was + * not there at all the resulting property would be a vector which + * included the quotes. This would be OK beause boost::spirit can automatically + * convert a vector to a std::string but we prefer to remove the quotes + * now. lexeme[] - is a spirit transform which tells the parser to ignore space + * skipping for the expression. In this case [ ] do not indicate a semantic + * action. + * *( ) - a kleene star indicateing 0 or more matches of the contained + * grammar. char_('") - this syntax matches either of the contained string + * literals. * * * ** Example 3 - * This is an excerpt from the term expression that might help you understand how the types flow though boost::spirit (and why utree is so useful). + * This is an excerpt from the term expression that might help you understand + * how the types flow though boost::spirit (and why utree is so useful). * * ("in" >> ((list | property) [in_expr(_val, _1)] * | _internal_string [in_expr(_val, _1)])) * - * Q: Why did we separate quoted_string from (list | property) even though they both appear to have the same semantic action? - * In this case list and property both have the result type utree but quoted_string has the result type std::string. Since in_expr() has overloads for both - * a right hand utree and a right hand std::string so shoudln't it do the right thing? - * A: If we wrote (list | property | quoted_string) [in_expr(_val, _1] the type of _1 would not be either utree or string but a union of both types. Specifically - * it would be a boost::variant; Since we don't provide an in_expr::operator() overload for that compilation would fail. + * Q: Why did we separate quoted_string from (list | property) even though + * they both appear to have the same semantic action? In this case list and + * property both have the result type utree but quoted_string has the result + * type std::string. Since in_expr() has overloads for both a right hand utree + * and a right hand std::string so shoudln't it do the right thing? A: If we + * wrote (list | property | quoted_string) [in_expr(_val, _1] the type of _1 + * would not be either utree or string but a union of both types. Specifically + * it would be a boost::variant; Since we don't provide an + * in_expr::operator() overload for that compilation would fail. * */ #ifdef __GNUC__ #pragma GCC diagnostic push -// Disble effc++ for this file because a lot of the spirit base classes don't include a virtual destructor +// Disble effc++ for this file because a lot of the spirit base classes don't +// include a virtual destructor #pragma GCC diagnostic ignored "-Weffc++" #endif - namespace bts { namespace expression { @@ -101,35 +126,26 @@ namespace ph = boost::phoenix; namespace sp = boost::spirit; // Base operator holds the result type -struct base_operator -{ - template - struct result { typedef void type; }; +struct base_operator { + template struct result { typedef void type; }; - base_operator(const std::string& name) - : _name(name) - {} + base_operator(const std::string &name) : _name(name) {} -protected: + protected: std::string _name; }; // Class of operator that acts on a left and right side -struct binary_operator : public base_operator -{ - binary_operator(const std::string& name) - : base_operator(name) - {} +struct binary_operator : public base_operator { + binary_operator(const std::string &name) : base_operator(name) {} - void operator()(sp::utree& expr, const sp::utree& rhs) const - { + void operator()(sp::utree &expr, const sp::utree &rhs) const { sp::utree lhs; lhs.swap(expr); expr.push_back(sp::utf8_symbol_type(_name)); expr.push_back(lhs); expr.push_back(rhs); } - }; extern ph::function const and_expr; extern ph::function const or_expr; @@ -143,14 +159,10 @@ extern ph::function const neq_expr; extern ph::function const match_expr; // "!" -struct unary_operator : public base_operator -{ - unary_operator(const std::string& name) - : base_operator(name) - {} +struct unary_operator : public base_operator { + unary_operator(const std::string &name) : base_operator(name) {} - void operator()(sp::utree& expr, const sp::utree & rhs) const - { + void operator()(sp::utree &expr, const sp::utree &rhs) const { expr.push_back(sp::utf8_symbol_type(_name)); expr.push_back(rhs); } @@ -160,14 +172,11 @@ extern ph::function not_expr; // // The property expression needs to accept a raw vector of characters. // -struct property_expr_type -{ - template - struct result { typedef void type; }; +struct property_expr_type { + template struct result { typedef void type; }; - void operator() (sp::utree& expr, const std::vector& rhs) const - { - std::string prop_name(rhs.begin (), rhs.end ()); + void operator()(sp::utree &expr, const std::vector &rhs) const { + std::string prop_name(rhs.begin(), rhs.end()); expr.clear(); expr.push_back(sp::utf8_symbol_type("property")); expr.push_back(sp::utf8_symbol_type(prop_name)); @@ -178,15 +187,11 @@ extern ph::function const property_expr; // // The list expression simply concatenates values in to one utree node // -struct list_expr_type -{ - template - struct result { typedef void type; }; +struct list_expr_type { + template struct result { typedef void type; }; - void operator()(sp::utree& expr, const sp::utree& rhs) const - { - if (expr.empty()) - { + void operator()(sp::utree &expr, const sp::utree &rhs) const { + if (expr.empty()) { expr.push_back(sp::utf8_symbol_type("list")); } expr.push_back(rhs); @@ -195,75 +200,65 @@ struct list_expr_type extern ph::function list_expr; template -class BooleanGrammar : public qi::grammar -{ -public: - BooleanGrammar() - : BooleanGrammar::base_type(_expression) - { +class BooleanGrammar + : public qi::grammar { + public: + BooleanGrammar() : BooleanGrammar::base_type(_expression) { using namespace qi; using qi::_1; // // Basic types - // + // - // quoted string's property is std::string instead of utree b/c we need to keep the type compatible with the += operator to build up the string contents - _internal_string = - char_("'\"") - >> (lexeme[*(alnum | space | (punct - char_("'\""))) [_val += _1]]) - >> char_("'\""); + // quoted string's property is std::string instead of utree b/c we need to + // keep the type compatible with the += operator to build up the string + // contents + _internal_string = + char_("'\"") >> + (lexeme[*(alnum | space | (punct - char_("'\"")))[_val += _1]]) >> + char_("'\""); _quoted_string = _internal_string; - - // [1,2,3,4] - sorry no lists of lists - _list = '[' >> (_primitive [list_expr(_val, _1)] % ',') >> ']'; - // A property is an unquoted token which will be passed to an IPropertyEvaluator - // to be turned into a primitive value or a list. - _property = lexeme[(+(alnum | char_("_.$")))] [property_expr(_val, _1)]; - - _primitive = - qi::no_case[qi::bool_] [_val = _1] - | qi::double_ [_val = _1] - | _quoted_string [_val = _1] - | _property [_val = _1] - | _list [_val = _1] - | '!' >> _primitive [not_expr(_val, _1)] - | '(' >> _expression [_val = _1] >> ')' - ; - + // [1,2,3,4] - sorry no lists of lists + _list = '[' >> (_primitive[list_expr(_val, _1)] % ',') >> ']'; + + // A property is an unquoted token which will be passed to an + // IPropertyEvaluator to be turned into a primitive value or a list. + _property = lexeme[(+(alnum | char_("_.$")))][property_expr(_val, _1)]; + + _primitive = qi::no_case[qi::bool_][_val = _1] | qi::double_[_val = _1] | + _quoted_string[_val = _1] | _property[_val = _1] | + _list[_val = _1] | '!' >> _primitive[not_expr(_val, _1)] | + '(' >> _expression[_val = _1] >> ')'; + // // operators // - - _expression = - _term [_val = _1] - >> *( - ("and" >> _term [and_expr(_val, _1)]) - | ("&&" >> _term [and_expr(_val, _1)]) - | ("or" >> _term [or_expr(_val, _1)]) - | ("||" >> _term [or_expr(_val, _1)]) - ); - _term = - _primitive [_val = _1] - >> *( ("in" >> ((_list | _property | _quoted_string) [in_expr(_val, _1)])) - | ("~=" >> (( _property | _quoted_string) [match_expr(_val, _1)])) - | (">" >> _primitive [gt_expr(_val, _1)]) - | (">=" >> _primitive [gte_expr(_val, _1)]) - | ("<" >> _primitive [lt_expr(_val, _1)]) - | ("<=" >> _primitive [lte_expr(_val, _1)]) - | ("==" >> _primitive [eq_expr(_val, _1)]) - | ("=" >> _primitive [eq_expr(_val, _1)]) - | ("!=" >> _primitive [neq_expr(_val, _1)]) - ); + _expression = _term[_val = _1] >> *(("and" >> _term[and_expr(_val, _1)]) | + ("&&" >> _term[and_expr(_val, _1)]) | + ("or" >> _term[or_expr(_val, _1)]) | + ("||" >> _term[or_expr(_val, _1)])); + _term = _primitive[_val = _1] >> + *(("in" >> + ((_list | _property | _quoted_string)[in_expr(_val, _1)])) | + ("~=" >> ((_property | _quoted_string)[match_expr(_val, _1)])) | + (">" >> _primitive[gt_expr(_val, _1)]) | + (">=" >> _primitive[gte_expr(_val, _1)]) | + ("<" >> _primitive[lt_expr(_val, _1)]) | + ("<=" >> _primitive[lte_expr(_val, _1)]) | + ("==" >> _primitive[eq_expr(_val, _1)]) | + ("=" >> _primitive[eq_expr(_val, _1)]) | + ("!=" >> _primitive[neq_expr(_val, _1)])); } -private: + private: BTS_NO_COPY(BooleanGrammar); qi::rule _internal_string; - qi::rule _expression, _primitive, _term, _list, _property, _quoted_string; + qi::rule _expression, _primitive, _term, + _list, _property, _quoted_string; }; extern BooleanGrammar boolean_string_grammar; @@ -272,5 +267,6 @@ extern BooleanGrammar boolean_string_grammar; #pragma GCC diagnostic pop #endif -}}//namespace +} // namespace expression +} // namespace bts #endif diff --git a/src/lib/expression/ExpressionEvaluator.cpp b/src/lib/expression/ExpressionEvaluator.cpp old mode 100755 new mode 100644 index 8c4ecfce3..381241193 --- a/src/lib/expression/ExpressionEvaluator.cpp +++ b/src/lib/expression/ExpressionEvaluator.cpp @@ -1,13 +1,13 @@ #include "ExpressionEvaluator.h" #include "BooleanGrammar.h" -#include "ParserExceptions.h" #include "IPropertyEvaluator.h" +#include "ParserExceptions.h" -#include -#include -#include #include // iequals #include +#include +#include +#include namespace qi = boost::spirit::qi; namespace sp = boost::spirit; @@ -16,147 +16,139 @@ using namespace std; namespace bts { namespace expression { -class ExpressionEvaluatorImpl -{ -public: +class ExpressionEvaluatorImpl { + public: ExpressionEvaluatorImpl(std::shared_ptr property_eval); ~ExpressionEvaluatorImpl(); - bool eval(const std::string& expression) const; - bool check_valid(const std::string& expression, std::string* failed_property) const; - void pre_parse(const string& expression, sp::utree& parse_result) const; - void pre_parse(const std::vector& expressions, std::vector& asts) const; - bool eval_ast(const boost::spirit::utree& ast) const; - Value eval_to_value(const std::string& expression) const; + bool eval(const std::string &expression) const; + bool check_valid( + const std::string &expression, std::string *failed_property) const; + void pre_parse(const string &expression, sp::utree &parse_result) const; + void pre_parse( + const std::vector &expressions, + std::vector &asts) const; + bool eval_ast(const boost::spirit::utree &ast) const; + Value eval_to_value(const std::string &expression) const; -private: + private: BTS_NO_COPY(ExpressionEvaluatorImpl); - bool parse(std::string::const_iterator& begin, const std::string::const_iterator& end, boost::spirit::utree& result) const; - bool check_properties(const boost::spirit::utree& node, std::string* failed_property) const; - Value eval_node(const boost::spirit::utree& node) const; - - inline bool op_and(boost::spirit::utree::const_iterator& args) const; - inline bool op_or(boost::spirit::utree::const_iterator& args) const; - inline bool op_in(boost::spirit::utree::const_iterator& args) const; - inline bool op_gt(boost::spirit::utree::const_iterator& args) const; - inline bool op_gte(boost::spirit::utree::const_iterator& args) const; - inline bool op_lt(boost::spirit::utree::const_iterator& args) const; - inline bool op_lte(boost::spirit::utree::const_iterator& args) const; + bool parse( + std::string::const_iterator &begin, + const std::string::const_iterator &end, + boost::spirit::utree &result) const; + bool check_properties( + const boost::spirit::utree &node, std::string *failed_property) const; + Value eval_node(const boost::spirit::utree &node) const; + + inline bool op_and(boost::spirit::utree::const_iterator &args) const; + inline bool op_or(boost::spirit::utree::const_iterator &args) const; + inline bool op_in(boost::spirit::utree::const_iterator &args) const; + inline bool op_gt(boost::spirit::utree::const_iterator &args) const; + inline bool op_gte(boost::spirit::utree::const_iterator &args) const; + inline bool op_lt(boost::spirit::utree::const_iterator &args) const; + inline bool op_lte(boost::spirit::utree::const_iterator &args) const; inline bool op_eq(boost::spirit::utree::const_iterator args) const; - inline bool op_neq(boost::spirit::utree::const_iterator& args) const; - inline bool op_match(boost::spirit::utree::const_iterator& args) const; + inline bool op_neq(boost::spirit::utree::const_iterator &args) const; + inline bool op_match(boost::spirit::utree::const_iterator &args) const; - - inline bool op_not(const boost::spirit::utree& operand) const; - inline Value op_list(const boost::spirit::utree& operands) const; - inline Value op_prop(const boost::spirit::utree& operand) const; + inline bool op_not(const boost::spirit::utree &operand) const; + inline Value op_list(const boost::spirit::utree &operands) const; + inline Value op_prop(const boost::spirit::utree &operand) const; const std::shared_ptr _property_eval; mutable RecursionGuard _recursion_guard; }; +ExpressionEvaluatorImpl::ExpressionEvaluatorImpl( + std::shared_ptr property_eval) + : _property_eval(property_eval), _recursion_guard() {} -ExpressionEvaluatorImpl::ExpressionEvaluatorImpl(std::shared_ptr property_eval) - : - _property_eval(property_eval), - _recursion_guard() -{ -} +ExpressionEvaluatorImpl::~ExpressionEvaluatorImpl() {} -ExpressionEvaluatorImpl::~ExpressionEvaluatorImpl() -{ -} - -bool ExpressionEvaluatorImpl::eval(const std::string& expression) const -{ +bool ExpressionEvaluatorImpl::eval(const std::string &expression) const { boost::spirit::utree parse_result; pre_parse(expression, parse_result); return eval_ast(parse_result); } -Value ExpressionEvaluatorImpl::eval_to_value(const std::string& expression) const -{ +Value ExpressionEvaluatorImpl::eval_to_value( + const std::string &expression) const { boost::spirit::utree parse_result; pre_parse(expression, parse_result); return eval_node(parse_result); } -void ExpressionEvaluatorImpl::pre_parse(const std::string& expression, boost::spirit::utree& parse_result) const -{ - std::string::const_iterator begin = expression.begin (); - std::string::const_iterator end = expression.end (); +void ExpressionEvaluatorImpl::pre_parse( + const std::string &expression, boost::spirit::utree &parse_result) const { + std::string::const_iterator begin = expression.begin(); + std::string::const_iterator end = expression.end(); bool result = parse(begin, end, parse_result); - if (!result) - { - size_t pos = begin - expression.begin (); + if (!result) { + size_t pos = begin - expression.begin(); throw ParseFailedException(expression, pos); - } + } // std::cout << std::endl << parse_result; } -void ExpressionEvaluatorImpl::pre_parse(const std::vector& expressions, std::vector& asts) const -{ +void ExpressionEvaluatorImpl::pre_parse( + const std::vector &expressions, + std::vector &asts) const { std::vector::const_iterator i; asts.reserve(expressions.size()); - for(i = expressions.begin(); i != expressions.end(); ++i) - { + for (i = expressions.begin(); i != expressions.end(); ++i) { boost::spirit::utree parse_result; pre_parse(*i, parse_result); asts.push_back(parse_result); } } -bool ExpressionEvaluatorImpl::eval_ast(const boost::spirit::utree& ast) const -{ +bool ExpressionEvaluatorImpl::eval_ast(const boost::spirit::utree &ast) const { return value_to_bool(eval_node(ast)); } -bool ExpressionEvaluatorImpl::check_valid(const std::string& expression, std::string* failed_property) const -{ +bool ExpressionEvaluatorImpl::check_valid( + const std::string &expression, std::string *failed_property) const { sp::utree parse_result; - std::string::const_iterator begin = expression.begin (); - std::string::const_iterator end = expression.end (); + std::string::const_iterator begin = expression.begin(); + std::string::const_iterator end = expression.end(); bool result = parse(begin, end, parse_result); - if (result) - { + if (result) { result = check_properties(parse_result, failed_property); } return result; } -bool ExpressionEvaluatorImpl::parse(std::string::const_iterator& begin, const std::string::const_iterator& end, sp::utree& ast) const -{ +bool ExpressionEvaluatorImpl::parse( + 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(begin, end, boolean_string_grammar, qi::ascii::space, ast); - return result && (begin==end); + bool result = qi::phrase_parse( + begin, end, boolean_string_grammar, qi::ascii::space, ast); + return result && (begin == end); } -bool ExpressionEvaluatorImpl::check_properties(const boost::spirit::utree& node, std::string* failed_property) const -{ +bool ExpressionEvaluatorImpl::check_properties( + const boost::spirit::utree &node, std::string *failed_property) const { bool result = true; // a list is either a list [a,b,c] or (operator, arg1, arg2,...) - if (node.which () == sp::utree_type::list_type) - { - boost::spirit::utree::const_iterator iter = node.begin (); - boost::spirit::utree::const_iterator end = node.end (); + if (node.which() == sp::utree_type::list_type) { + boost::spirit::utree::const_iterator iter = node.begin(); + boost::spirit::utree::const_iterator end = node.end(); - const sp::utree& operator_node = node.front(); + const sp::utree &operator_node = node.front(); - if (operator_node.which() == sp::utree_type::symbol_type) - { + if (operator_node.which() == sp::utree_type::symbol_type) { std::string op = get_symbol(operator_node); ++iter; // advanced past operator - if (op == "property") - { + if (op == "property") { std::string symbol = get_symbol(*iter); - if(!_property_eval->get_value(symbol, nullptr)) - { - if (failed_property != nullptr) - { + if (!_property_eval->get_value(symbol, nullptr)) { + if (failed_property != nullptr) { *failed_property = symbol; } return false; @@ -164,106 +156,76 @@ bool ExpressionEvaluatorImpl::check_properties(const boost::spirit::utree& node, } } - for(; result && iter != end; ++iter) - { + for (; result && iter != end; ++iter) { result = check_properties(*iter, failed_property); } - } - else if (node.which () == sp::utree_type::invalid_type) - { + } else if (node.which() == sp::utree_type::invalid_type) { result = false; } return result; } -void check_args(const std::string& op, const sp::utree& node, size_t got, size_t expected) -{ - if (got != expected) - { +void check_args( + const std::string &op, const sp::utree &node, size_t got, size_t expected) { + if (got != expected) { std::ostringstream s_exp; s_exp << node; throw InsuficientArgumentsException(op, s_exp.str(), expected); } } -Value ExpressionEvaluatorImpl::eval_node(const sp::utree& node) const -{ - if (node.which() != sp::utree_type::list_type || node.size() == 1) - { +Value ExpressionEvaluatorImpl::eval_node(const sp::utree &node) const { + if (node.which() != sp::utree_type::list_type || node.size() == 1) { return value_from_utree(node); } - - sp::utree::const_iterator iter = node.begin (); - const sp::utree& operator_node = *iter; + + sp::utree::const_iterator iter = node.begin(); + const sp::utree &operator_node = *iter; ++iter; // advance past operator if (operator_node.which() != sp::utree_type::symbol_type) - throw std::invalid_argument("Operator expression must begin with operator symbol"); + throw std::invalid_argument( + "Operator expression must begin with operator symbol"); std::string op = get_symbol(operator_node); - if (op == "property") - { + if (op == "property") { check_args(op, node, node.size(), 2); return op_prop(*iter); - } - else if (op == "==") - { + } else if (op == "==") { check_args(op, node, node.size(), 3); return op_eq(iter); - } - else if (op == "~=") - { + } else if (op == "~=") { check_args(op, node, node.size(), 3); return op_match(iter); - } - else if (op == "!") - { + } else if (op == "!") { check_args(op, node, node.size(), 2); return op_not(*iter); - } - else if (op == "list") - { + } else if (op == "list") { return op_list(node); - } - else if (op == "and") - { + } else if (op == "and") { check_args(op, node, node.size(), 3); return op_and(iter); - } - else if (op == "or") - { + } else if (op == "or") { check_args(op, node, node.size(), 3); return op_or(iter); - } - else if (op == "in") - { + } else if (op == "in") { check_args(op, node, node.size(), 3); return op_in(iter); - } - else if (op == ">") - { + } else if (op == ">") { check_args(op, node, node.size(), 3); return op_gt(iter); - } - else if (op == ">=") - { + } else if (op == ">=") { check_args(op, node, node.size(), 3); return op_gte(iter); - } - else if (op == "<") - { + } else if (op == "<") { check_args(op, node, node.size(), 3); return op_lt(iter); - } - else if (op == "<=") - { + } else if (op == "<=") { check_args(op, node, node.size(), 3); return op_lte(iter); - } - else if (op == "!=") - { + } else if (op == "!=") { check_args(op, node, node.size(), 3); return op_neq(iter); } @@ -272,32 +234,30 @@ Value ExpressionEvaluatorImpl::eval_node(const sp::utree& node) const throw ParserException(exception_msg); } -bool ExpressionEvaluatorImpl::op_and(boost::spirit::utree::const_iterator& args) const -{ +bool ExpressionEvaluatorImpl::op_and( + boost::spirit::utree::const_iterator &args) const { // short circuit rhs bool left = value_to_bool(eval_node(*args)); args++; return left && value_to_bool(eval_node(*args)); } -bool ExpressionEvaluatorImpl::op_or(boost::spirit::utree::const_iterator& args) const -{ +bool ExpressionEvaluatorImpl::op_or( + boost::spirit::utree::const_iterator &args) const { // short circuit rhs bool left = value_to_bool(eval_node(*args)); return left || value_to_bool(eval_node(*++args)); } -struct InsensitiveStringCompare -{ - InsensitiveStringCompare(const std::string& val) : value(val) { } - const std::string& value; +struct InsensitiveStringCompare { + InsensitiveStringCompare(const std::string &val) : value(val) {} + const std::string &value; - bool operator() (const std::string& val) const - { + bool operator()(const std::string &val) const { return boost::iequals(value, val); } - bool operator() (const Value val) const { + bool operator()(const Value val) const { if (val.which() != ValueType::anything) { return boost::iequals(value, expression::value_to_string(val)); } @@ -305,129 +265,123 @@ struct InsensitiveStringCompare } }; -bool ExpressionEvaluatorImpl::op_in(boost::spirit::utree::const_iterator& args) const -{ +bool ExpressionEvaluatorImpl::op_in( + boost::spirit::utree::const_iterator &args) const { Value left = eval_node(*args); Value right = eval_node(*++args); std::vector vector; - if (right.which() == ValueType::list) - { - vector = boost::get >(right); - if (left.which() == ValueType::string) - { - return std::find_if(vector.begin(), vector.end(), InsensitiveStringCompare(boost::get(left))) != vector.end(); + if (right.which() == ValueType::list) { + vector = boost::get>(right); + if (left.which() == ValueType::string) { + return std::find_if( + vector.begin(), vector.end(), + InsensitiveStringCompare(boost::get(left))) != + vector.end(); + } else { + return std::find(vector.begin(), vector.end(), left) != vector.end(); } - else - { - return std::find(vector.begin (), vector.end (), left) != vector.end (); - } - } - else if (right.which() == ValueType::string) - { + } else if (right.which() == ValueType::string) { string r = boost::get(right); string l = boost::get(left); boost::algorithm::to_lower(r); boost::algorithm::to_lower(l); return r.find(l) != std::string::npos; - } - else - { - throw std::invalid_argument("Right hand argument to 'in' operator must be a list"); + } else { + throw std::invalid_argument( + "Right hand argument to 'in' operator must be a list"); } } -bool ExpressionEvaluatorImpl::op_gt(boost::spirit::utree::const_iterator& args) const -{ +bool ExpressionEvaluatorImpl::op_gt( + boost::spirit::utree::const_iterator &args) const { Value left = eval_node(*args); Value right = eval_node(*++args); return right < left; } -bool ExpressionEvaluatorImpl::op_gte(boost::spirit::utree::const_iterator& args) const -{ +bool ExpressionEvaluatorImpl::op_gte( + boost::spirit::utree::const_iterator &args) const { Value left = eval_node(*args); Value right = eval_node(*++args); return right == left || right < left; } -bool ExpressionEvaluatorImpl::op_lt(boost::spirit::utree::const_iterator& args) const -{ +bool ExpressionEvaluatorImpl::op_lt( + boost::spirit::utree::const_iterator &args) const { Value left = eval_node(*args); Value right = eval_node(*++args); return left < right; } -bool ExpressionEvaluatorImpl::op_lte(boost::spirit::utree::const_iterator& args) const -{ +bool ExpressionEvaluatorImpl::op_lte( + boost::spirit::utree::const_iterator &args) const { Value left = eval_node(*args); Value right = eval_node(*++args); return left == right || left < right; } -bool ExpressionEvaluatorImpl::op_eq(boost::spirit::utree::const_iterator args) const -{ +bool ExpressionEvaluatorImpl::op_eq( + boost::spirit::utree::const_iterator args) const { Value left = eval_node(*args); args++; Value right = eval_node(*args); - if (left.which() == ValueType::string && right.which() == ValueType::string) - { + if (left.which() == ValueType::string && + right.which() == ValueType::string) { return boost::iequals( - boost::get(left), - boost::get(right)); + boost::get(left), boost::get(right)); } return left == right; } -bool ExpressionEvaluatorImpl::op_neq(boost::spirit::utree::const_iterator& args) const -{ +bool ExpressionEvaluatorImpl::op_neq( + boost::spirit::utree::const_iterator &args) const { return !op_eq(args); } -inline bool ExpressionEvaluatorImpl::op_match(boost::spirit::utree::const_iterator& args) const -{ +inline bool ExpressionEvaluatorImpl::op_match( + boost::spirit::utree::const_iterator &args) const { Value left = eval_node(*args); args++; Value right = eval_node(*args); - return ::boost::regex_search(boost::get(left), boost::regex(boost::get(right))); + return ::boost::regex_search( + boost::get(left), + boost::regex(boost::get(right))); } -bool ExpressionEvaluatorImpl::op_not(const boost::spirit::utree& operand) const -{ +bool ExpressionEvaluatorImpl::op_not( + const boost::spirit::utree &operand) const { return !value_to_bool(eval_node(operand)); } -Value ExpressionEvaluatorImpl::op_list(const boost::spirit::utree& operands) const -{ - boost::spirit::utree::const_iterator iter = operands.begin (), end = operands.end (); +Value ExpressionEvaluatorImpl::op_list( + const boost::spirit::utree &operands) const { + boost::spirit::utree::const_iterator iter = operands.begin(), + end = operands.end(); ++iter; // advance over "list" operator - - std::vector list_values; + + std::vector list_values; list_values.reserve(operands.size() - 1); - for (; iter != end; ++iter) - { + for (; iter != end; ++iter) { list_values.push_back(eval_node(*iter)); } return Value(list_values); } -Value ExpressionEvaluatorImpl::op_prop(const sp::utree& node) const -{ +Value ExpressionEvaluatorImpl::op_prop(const sp::utree &node) const { Value result; std::string symbol = get_symbol(node); - if (_recursion_guard.check(symbol)) - { + if (_recursion_guard.check(symbol)) { throw RecursivePropertyGetException(symbol, _recursion_guard.get()); } GuardFrame frame; _recursion_guard.push(symbol, &frame); - if (!_property_eval->get_value(symbol, &result)) - { + if (!_property_eval->get_value(symbol, &result)) { throw InvalidPropertyException(symbol); } @@ -436,43 +390,39 @@ Value ExpressionEvaluatorImpl::op_prop(const sp::utree& node) const // // Outter class method definitions -// +// -ExpressionEvaluator::ExpressionEvaluator(std::shared_ptr property_eval) - : _impl(new ExpressionEvaluatorImpl(property_eval)) -{ -} +ExpressionEvaluator::ExpressionEvaluator( + std::shared_ptr property_eval) + : _impl(new ExpressionEvaluatorImpl(property_eval)) {} -ExpressionEvaluator::~ExpressionEvaluator() -{ -} +ExpressionEvaluator::~ExpressionEvaluator() {} -bool ExpressionEvaluator::eval(const std::string& expression) const -{ +bool ExpressionEvaluator::eval(const std::string &expression) const { return _impl->eval(expression); } -Value ExpressionEvaluator::eval_to_value(const std::string& expression) const -{ +Value ExpressionEvaluator::eval_to_value(const std::string &expression) const { return _impl->eval_to_value(expression); } -bool ExpressionEvaluator::check_valid(const std::string& expression, std::string* failed_property) const -{ +bool ExpressionEvaluator::check_valid( + const std::string &expression, std::string *failed_property) const { return _impl->check_valid(expression, failed_property); } - -void ExpressionEvaluator::pre_parse(const std::string& expression, boost::spirit::utree& ast) const { + +void ExpressionEvaluator::pre_parse( + const std::string &expression, boost::spirit::utree &ast) const { return _impl->pre_parse(expression, ast); } -void ExpressionEvaluator::pre_parse(const std::vector& expressions, std::vector& asts) const -{ +void ExpressionEvaluator::pre_parse( + const std::vector &expressions, + std::vector &asts) const { return _impl->pre_parse(expressions, asts); } -bool ExpressionEvaluator::eval_ast(const boost::spirit::utree& ast) const -{ +bool ExpressionEvaluator::eval_ast(const boost::spirit::utree &ast) const { return _impl->eval_ast(ast); } - -}}//namespace +} // namespace expression +} // namespace bts diff --git a/src/lib/expression/ExpressionEvaluator.h b/src/lib/expression/ExpressionEvaluator.h old mode 100755 new mode 100644 index f2a56f823..e9c030005 --- a/src/lib/expression/ExpressionEvaluator.h +++ b/src/lib/expression/ExpressionEvaluator.h @@ -1,13 +1,13 @@ #ifndef EXPRESSIONEVALUATOR_H_ #define EXPRESSIONEVALUATOR_H_ -#include "Value.h" #include "RecursionGuard.h" +#include "Value.h" -#include -#include -#include #include +#include +#include +#include namespace bts { namespace expression { @@ -15,25 +15,29 @@ namespace expression { class IPropertyEvaluator; class ExpressionEvaluatorImpl; -class ExpressionEvaluator -{ -public: +class ExpressionEvaluator { + public: ExpressionEvaluator(std::shared_ptr property_eval); ~ExpressionEvaluator(); - bool eval(const std::string& expression) const; - Value eval_to_value(const std::string& expression) const; + bool eval(const std::string &expression) const; + Value eval_to_value(const std::string &expression) const; - bool check_valid(const std::string& expression, std::string* failed_property) const; + bool check_valid( + const std::string &expression, std::string *failed_property) const; - void pre_parse(const std::string& expression, boost::spirit::utree& ast) const; - void pre_parse(const std::vector& expressions, std::vector& asts) const; - bool eval_ast(const boost::spirit::utree& ast) const; + void + pre_parse(const std::string &expression, boost::spirit::utree &ast) const; + void pre_parse( + const std::vector &expressions, + std::vector &asts) const; + bool eval_ast(const boost::spirit::utree &ast) const; -private: + private: BTS_NO_COPY(ExpressionEvaluator); std::unique_ptr _impl; }; -}}//namespace +} // namespace expression +} // namespace bts #endif diff --git a/src/lib/expression/IPropertyEvaluator.h b/src/lib/expression/IPropertyEvaluator.h old mode 100755 new mode 100644 index cf13148ff..207b4e25b --- a/src/lib/expression/IPropertyEvaluator.h +++ b/src/lib/expression/IPropertyEvaluator.h @@ -10,14 +10,13 @@ namespace bts { namespace expression { -class IPropertyEvaluator -{ -public: - virtual bool get_value(const std::string& property, Value* out_value) = 0; +class IPropertyEvaluator { + public: + virtual bool get_value(const std::string &property, Value *out_value) = 0; - virtual ~IPropertyEvaluator() { } + virtual ~IPropertyEvaluator() {} }; - -}}//namespace +} // namespace expression +} // namespace bts #endif diff --git a/src/lib/expression/ParserExceptions.cpp b/src/lib/expression/ParserExceptions.cpp old mode 100755 new mode 100644 index f19b0fc74..f0a22c201 --- a/src/lib/expression/ParserExceptions.cpp +++ b/src/lib/expression/ParserExceptions.cpp @@ -1,87 +1,77 @@ #include "ParserExceptions.h" -#include #include +#include namespace bts { namespace expression { - // - // ParserException - // - ParserException::ParserException(const char* what) - : std::logic_error(""), _what(what) - { +// +// ParserException +// +ParserException::ParserException(const char *what) + : std::logic_error(""), _what(what) {} + +ParserException::ParserException(const std::string &what) + : std::logic_error(""), _what(what) {} + +ParserException::ParserException(const ParserException &other) + : std::logic_error(""), _what(other._what) {} + +ParserException &ParserException::operator=(const ParserException &other) { + _what = other._what; + return *this; +} + +const char *ParserException::what() const throw() { return _what.c_str(); } + +ParserException::~ParserException() throw() {} + +// +// ParseFailedException +// +ParseFailedException::ParseFailedException( + const std::string &context, size_t at) + : ParserException( + "Parse failed at position: " + boost::lexical_cast(at) + + " in expression: " + context), + context(context) {} + +// +// InvalidPropertyException +// +InvalidPropertyException::InvalidPropertyException(const std::string &prop_name) + : ParserException("Invalid property name: " + prop_name) {} + +// +// InsuficientArgumentsException +// +InsuficientArgumentsException::InsuficientArgumentsException( + const std::string &op, const std::string &got, size_t expected) + : ParserException(""), expected_argument_count(expected), expression(got) { + std::ostringstream what; + what << "Bad argument count for operator " << op << std::endl + << "expected " << expected_argument_count << " arguments. Got '" + << expression << "'"; + _what = what.str(); +} + +// +// RecursivePropertyGetException +// +RecursivePropertyGetException::RecursivePropertyGetException( + const std::string &property, const std::vector &stack) + : ParserException("") { + std::ostringstream what; + what << "Error evaluating property '" << property + << "': recursive property request at:" << std::endl; + std::vector::const_reverse_iterator iter = stack.rbegin(); + std::vector::const_reverse_iterator end = stack.rend(); + for (; iter != end; iter++) { + what << "> " << *iter << std::endl; } + _what = what.str(); +} - ParserException::ParserException(const std::string& what) - : std::logic_error(""), _what(what) - { - } - - ParserException::ParserException(const ParserException& other) - : std::logic_error(""), _what(other._what) - { - } - - ParserException& ParserException::operator=(const ParserException& other) - { - _what = other._what; - return *this; - } - - const char* ParserException::what() const throw() - { - return _what.c_str(); - } - - ParserException::~ParserException() throw() { } - - - // - // ParseFailedException - // - ParseFailedException::ParseFailedException(const std::string& context, size_t at) - : ParserException("Parse failed at position: " + boost::lexical_cast(at) + " in expression: " + context), - context(context) - { - } - - // - // InvalidPropertyException - // - InvalidPropertyException::InvalidPropertyException(const std::string& prop_name) - : ParserException("Invalid property name: " + prop_name) - {} - - // - // InsuficientArgumentsException - // - InsuficientArgumentsException::InsuficientArgumentsException(const std::string& op, const std::string& got, size_t expected) - : ParserException(""), - expected_argument_count(expected), - expression(got) - { - std::ostringstream what; - what << "Bad argument count for operator " << op << std::endl << "expected " << expected_argument_count << " arguments. Got '" << expression << "'"; - _what = what.str(); - } - - // - // RecursivePropertyGetException - // - RecursivePropertyGetException::RecursivePropertyGetException(const std::string& property, const std::vector& stack) - : ParserException("") - { - std::ostringstream what; - what << "Error evaluating property '" << property << "': recursive property request at:" << std::endl; - std::vector::const_reverse_iterator iter = stack.rbegin (); - std::vector::const_reverse_iterator end = stack.rend (); - for(; iter != end; iter++) - { - what << "> " << *iter << std::endl; - } - _what = what.str(); - } - -}}//namespace +} // namespace expression +} // namespace bts diff --git a/src/lib/expression/ParserExceptions.h b/src/lib/expression/ParserExceptions.h old mode 100755 new mode 100644 index 6069d1207..8ac927f08 --- a/src/lib/expression/ParserExceptions.h +++ b/src/lib/expression/ParserExceptions.h @@ -9,47 +9,45 @@ namespace bts { namespace expression { -struct ParserException : public std::logic_error -{ - ParserException(const char* what); - ParserException(const std::string& what); - ParserException(const ParserException& other); - ParserException& operator=(const ParserException& other); +struct ParserException : public std::logic_error { + ParserException(const char *what); + ParserException(const std::string &what); + ParserException(const ParserException &other); + ParserException &operator=(const ParserException &other); virtual ~ParserException() throw(); - const char* what() const throw(); + const char *what() const throw(); -protected: + protected: std::string _what; }; -struct ParseFailedException : public ParserException -{ - ParseFailedException(const std::string& context, size_t at); +struct ParseFailedException : public ParserException { + ParseFailedException(const std::string &context, size_t at); ~ParseFailedException() throw() {} std::string context; }; -struct InvalidPropertyException : public ParserException -{ - InvalidPropertyException(const std::string& prop_name); +struct InvalidPropertyException : public ParserException { + InvalidPropertyException(const std::string &prop_name); ~InvalidPropertyException() throw() {} }; -struct InsuficientArgumentsException : public ParserException -{ - InsuficientArgumentsException(const std::string& oper, const std::string& expression, size_t expected); +struct InsuficientArgumentsException : public ParserException { + InsuficientArgumentsException( + const std::string &oper, const std::string &expression, size_t expected); ~InsuficientArgumentsException() throw() {} size_t expected_argument_count; std::string expression; }; -struct RecursivePropertyGetException : public ParserException -{ - RecursivePropertyGetException(const std::string& property, const std::vector& stack); +struct RecursivePropertyGetException : public ParserException { + RecursivePropertyGetException( + const std::string &property, const std::vector &stack); ~RecursivePropertyGetException() throw() {} }; -}}//namespace +} // namespace expression +} // namespace bts #endif diff --git a/src/lib/expression/RecursionGuard.h b/src/lib/expression/RecursionGuard.h old mode 100755 new mode 100644 index fa9d5360c..f01827880 --- a/src/lib/expression/RecursionGuard.h +++ b/src/lib/expression/RecursionGuard.h @@ -8,84 +8,63 @@ namespace bts { namespace expression { - template - class RecursionGuard; +template class RecursionGuard; - // Safely pops the stack when destroyed - template - struct GuardFrame - { - GuardFrame () - : _owner (0) - {} - - GuardFrame(RecursionGuard& owner) - : _owner(&owner) - {} +// Safely pops the stack when destroyed +template struct GuardFrame { + GuardFrame() : _owner(0) {} - ~GuardFrame() - { - if (_owner) - { - std::vector& guard = _owner->get(); - guard.pop_back(); - } + GuardFrame(RecursionGuard &owner) : _owner(&owner) {} + + ~GuardFrame() { + if (_owner) { + std::vector &guard = _owner->get(); + guard.pop_back(); } + } - void set_owner (RecursionGuard *owner) - { - _owner = owner; + void set_owner(RecursionGuard *owner) { _owner = owner; } + + private: + BTS_NO_COPY(GuardFrame); + RecursionGuard *_owner; +}; + +template class RecursionGuard { + public: + RecursionGuard() : _recursion_guard() {} + ~RecursionGuard() {} + + std::vector &get() { + std::vector *guard = _recursion_guard.get(); + if (guard == 0) { + guard = new std::vector(); + _recursion_guard.reset(guard); } - - private: - BTS_NO_COPY(GuardFrame); - RecursionGuard* _owner; - }; + return *guard; + } - - template - class RecursionGuard - { - public: - RecursionGuard() - : _recursion_guard() - {} - ~RecursionGuard() - {} + bool check(const T &value) { + std::vector &guard = get(); + typename std::vector::iterator begin = guard.begin(), + end = guard.end(); + bool is_recursive = std::find(begin, end, value) != end; + return is_recursive; + } - std::vector& get() - { - std::vector* guard = _recursion_guard.get(); - if (guard == 0) - { - guard = new std::vector(); - _recursion_guard.reset(guard); - } - return *guard; - } + void push(const T &value, GuardFrame *frame) { + std::vector &guard = get(); + guard.push_back(value); + frame->set_owner(this); + } - bool check(const T& value) - { - std::vector& guard = get(); - typename std::vector::iterator begin = guard.begin (), end = guard.end (); - bool is_recursive = std::find(begin, end, value) != end; - return is_recursive; - } + template friend struct GuardFrame; - void push(const T& value, GuardFrame *frame) - { - std::vector& guard = get(); - guard.push_back(value); - frame->set_owner (this); - } + private: + BTS_NO_COPY(RecursionGuard); + boost::thread_specific_ptr> _recursion_guard; +}; - template - friend struct GuardFrame; - private: - BTS_NO_COPY(RecursionGuard); - boost::thread_specific_ptr > _recursion_guard; - }; - - -}}//namespace +} // namespace expression +} // namespace bts #endif diff --git a/src/lib/expression/Value.cpp b/src/lib/expression/Value.cpp old mode 100755 new mode 100644 index ecb8927de..6cdd0443f --- a/src/lib/expression/Value.cpp +++ b/src/lib/expression/Value.cpp @@ -2,18 +2,16 @@ #include -#include #include +#include namespace bts { namespace expression { namespace sp = boost::spirit; -bool value_to_bool(const Value& val) -{ - switch(val.which()) - { +bool value_to_bool(const Value &val) { + switch (val.which()) { case ValueType::boolean: return boost::get(val); case ValueType::integer: @@ -23,54 +21,49 @@ bool value_to_bool(const Value& val) case ValueType::string: return !boost::get(val).empty(); case ValueType::list: - return boost::get >(val).size() > 0; + return boost::get>(val).size() > 0; default: - throw std::logic_error("Invalid type in variant. Please update this switch statement"); + throw std::logic_error( + "Invalid type in variant. Please update this switch statement"); } } -std::string value_to_string(const Value& val) -{ - switch(val.which()) - { +std::string value_to_string(const Value &val) { + switch (val.which()) { case ValueType::boolean: return boost::get(val) ? "true" : "false"; case ValueType::integer: - return boost::lexical_cast( - boost::get(val)); + return boost::lexical_cast(boost::get(val)); case ValueType::real: // NOLINT - return boost::lexical_cast( - boost::get(val)); + return boost::lexical_cast(boost::get(val)); case ValueType::string: return boost::get(val); case ValueType::list: { auto vals = boost::get>(val); std::string result; - for (const auto& v : vals) { + for (const auto &v : vals) { result += value_to_string(v); } return result; } default: - throw std::logic_error("Invalid type in variant. Please update this switch statement"); + throw std::logic_error( + "Invalid type in variant. Please update this switch statement"); } } -const std::string get_symbol(const sp::utree& node) -{ +const std::string get_symbol(const sp::utree &node) { sp::utf8_symbol_range_type rt = node.get(); - return std::string(rt.begin (),rt.end ()); + return std::string(rt.begin(), rt.end()); } -const std::string get_string(const boost::spirit::utree& node) -{ - sp::utf8_symbol_range_type string_range = node.get(); - return std::string(string_range.begin (), string_range.end ()); +const std::string get_string(const boost::spirit::utree &node) { + sp::utf8_symbol_range_type string_range = + node.get(); + return std::string(string_range.begin(), string_range.end()); } -Value value_from_utree(const boost::spirit::utree& node) -{ - switch(node.which()) - { +Value value_from_utree(const boost::spirit::utree &node) { + switch (node.which()) { case sp::utree_type::bool_type: return Value(node.get()); case sp::utree_type::int_type: @@ -80,8 +73,7 @@ Value value_from_utree(const boost::spirit::utree& node) case sp::utree_type::string_type: return Value(get_string(node)); case sp::utree_type::list_type: - if (node.size() == 1) - { + if (node.size() == 1) { return value_from_utree(node.front()); } // else fall through @@ -91,4 +83,5 @@ Value value_from_utree(const boost::spirit::utree& node) } } -}}//namespace +} // namespace expression +} // namespace bts diff --git a/src/lib/expression/Value.h b/src/lib/expression/Value.h old mode 100755 new mode 100644 index 8d13dcebd..878cd8db6 --- a/src/lib/expression/Value.h +++ b/src/lib/expression/Value.h @@ -6,39 +6,28 @@ namespace boost { namespace spirit { - class utree; -}} - +class utree; +} +} // namespace boost namespace bts { namespace expression { -struct ValueType -{ - enum type { - boolean, - integer, - real, - string, - list, - anything - }; +struct ValueType { + enum type { boolean, integer, real, string, list, anything }; }; typedef boost::make_recursive_variant< - bool, - int, - double, - std::string, - std::vector, - void*>::type Value; + bool, int, double, std::string, std::vector, + void *>::type Value; -bool value_to_bool(const Value& val); -std::string value_to_string(const Value& val); -Value value_from_utree(const boost::spirit::utree& node); +bool value_to_bool(const Value &val); +std::string value_to_string(const Value &val); +Value value_from_utree(const boost::spirit::utree &node); -const std::string get_symbol(const boost::spirit::utree& node); -const std::string get_string(const boost::spirit::utree& node); +const std::string get_symbol(const boost::spirit::utree &node); +const std::string get_string(const boost::spirit::utree &node); -}}//namespace +} // namespace expression +} // namespace bts #endif diff --git a/src/lib/expression/tests/expression_parser_tests.cpp b/src/lib/expression/tests/expression_parser_tests.cpp old mode 100755 new mode 100644 index 55c87286f..253c8580e --- a/src/lib/expression/tests/expression_parser_tests.cpp +++ b/src/lib/expression/tests/expression_parser_tests.cpp @@ -97,8 +97,8 @@ // void simple_operator_test() // { -// ExpressionEvaluator e(BTS_SharedPtr (new EvaluatesToFoo())); -// test_assert(e.eval("!!true")); +// ExpressionEvaluator e(BTS_SharedPtr (new +// EvaluatesToFoo())); test_assert(e.eval("!!true")); // test_assert(e.eval("3 == 3")); // test_assert(e.eval("4 > 3")); // test_assert(e.eval("3 < 6")); @@ -113,43 +113,46 @@ // void test_bool_conversion() // { -// ExpressionEvaluator e(BTS_SharedPtr (new EvaluatesToFoo())); -// test_assert(e.eval("true")); +// ExpressionEvaluator e(BTS_SharedPtr (new +// EvaluatesToFoo())); test_assert(e.eval("true")); // test_assert(e.eval("1")); // test_assert(e.eval("1.5")); // test_assert(e.eval("'true string'")); -// //test_assert(e.eval("[1,2,3]")); // list not valid here - only after "in" -// test_assert(e.eval("Foo.x")); +// //test_assert(e.eval("[1,2,3]")); // list not valid here - only +// after "in" test_assert(e.eval("Foo.x")); // test_assert(e.eval("Foo.list")); // test_assert(!e.eval("''")); // } // void property_validator_test() // { -// ExpressionEvaluator e(BTS_SharedPtr (new EvaluatesToFoo())); -// test_assert(e.check_valid("Foo.bar == 'Foo' or 'x' in [Foo.x, Foo.y, 'z']", nullptr)); -// std::string bad_property; -// test_assert(!e.check_valid("Foo.bar == 'Foo' or 'x' in [Fuu.x, Foo.y, 'z']", &bad_property)); -// test_assert(bad_property == "Fuu.x"); +// ExpressionEvaluator e(BTS_SharedPtr (new +// EvaluatesToFoo())); test_assert(e.check_valid("Foo.bar == 'Foo' or +// 'x' in [Foo.x, Foo.y, 'z']", nullptr)); std::string bad_property; +// test_assert(!e.check_valid("Foo.bar == 'Foo' or 'x' in [Fuu.x, +// Foo.y, 'z']", &bad_property)); test_assert(bad_property == "Fuu.x"); // } // void more_complex_test() // { -// ExpressionEvaluator e(BTS_SharedPtr (new EvaluatesToFoo())); +// ExpressionEvaluator e(BTS_SharedPtr (new +// EvaluatesToFoo())); -// test_assert(e.eval("Foo.bar == 'Foo' and 'b' in ['a', 'b', 'c', Foo.bar]")); -// test_assert(e.eval("Foo.number > 2 or (3.5 <= 7 and Foo.number == 3) or 'x' in ['a', 'b', 'c']")); -// test_assert(!e.eval("(3.5 <= 7 and Foo.number == 3) or 'x' in ['a', 'b', 'c']")); -// test_assert(e.eval("'foo' in Foo.list and Foo.number == 42.0")); -// test_assert(e.eval("!!('oo' in Foo.foo)")); +// test_assert(e.eval("Foo.bar == 'Foo' and 'b' in ['a', 'b', 'c', +// Foo.bar]")); test_assert(e.eval("Foo.number > 2 or (3.5 <= 7 and +// Foo.number == 3) or 'x' in ['a', 'b', 'c']")); +// test_assert(!e.eval("(3.5 <= 7 and Foo.number == 3) or 'x' in ['a', +// 'b', 'c']")); test_assert(e.eval("'foo' in Foo.list and Foo.number +// == 42.0")); test_assert(e.eval("!!('oo' in Foo.foo)")); // test_assert(e.eval("!('ooo' in Foo.foo)")); -// test_assert(e.eval("!false in [false, false, false, false, true, Foo.bool]")); +// test_assert(e.eval("!false in [false, false, false, false, true, +// Foo.bool]")); // } // void recursive_test() // { -// BTS_SharedPtr badprops (new EvaluatesRecursively()); -// ExpressionEvaluator e(badprops); +// BTS_SharedPtr badprops (new +// EvaluatesRecursively()); ExpressionEvaluator e(badprops); // badprops->set_evaluator(&e); // // Try to get the 'fuzzy'property recursively @@ -167,7 +170,6 @@ // }; - // BEGIN_TEST_SUITE(expression_tests) // ADD_TEST(simple_operator_test); // ADD_TEST(test_bool_conversion); diff --git a/src/lib/jetfix/codec/FIXArray.h b/src/lib/jetfix/codec/FIXArray.h index c664b58ea..01fcfc33c 100644 --- a/src/lib/jetfix/codec/FIXArray.h +++ b/src/lib/jetfix/codec/FIXArray.h @@ -1,31 +1,29 @@ #pragma once -#include #include "lib/jetfix/codec/FIXFragment.h" +#include namespace bts { namespace jetfix { -template -class FIXArray -{ -public: - inline char*data () {return &_data[0];} - inline const char*data () const {return &_data[0];} - inline uint32_t capacity () const {return _data.size ();} - inline uint32_t size () const {return _size;} - inline uint32_t checksum () const{return _checksum;} - inline void update (jetfix::FIXFragment const&frag) - { - bts_assert (frag.data () == &_data[0]); - _size = frag.size (); - _checksum = frag.checksum (); +template class FIXArray { + public: + inline char *data() { return &_data[0]; } + inline const char *data() const { return &_data[0]; } + inline uint32_t capacity() const { return _data.size(); } + inline uint32_t size() const { return _size; } + inline uint32_t checksum() const { return _checksum; } + inline void update(jetfix::FIXFragment const &frag) { + bts_assert(frag.data() == &_data[0]); + _size = frag.size(); + _checksum = frag.checksum(); } -private: - std::array _data; + private: + std::array _data; uint32_t _size; uint32_t _checksum; }; -}} +} // namespace jetfix +} // namespace bts diff --git a/src/lib/jetfix/codec/FIXBuffer.h b/src/lib/jetfix/codec/FIXBuffer.h index 0dc30f599..6b235f020 100644 --- a/src/lib/jetfix/codec/FIXBuffer.h +++ b/src/lib/jetfix/codec/FIXBuffer.h @@ -1,80 +1,54 @@ #pragma once -#include -#include #include "lib/utils/bts_assert.h" +#include +#include namespace bts { namespace jetfix { -class FIXBuffer -{ -public: +class FIXBuffer { + public: // memory is owned by someone else - inline FIXBuffer(char *buffer_to_use, uint32_t buffer_capacity) : - _buffer (buffer_to_use), - _size (0), - _capacity (buffer_capacity), - _owns_buffer (false), - _initial_size () - {} + inline FIXBuffer(char *buffer_to_use, uint32_t buffer_capacity) + : _buffer(buffer_to_use), _size(0), _capacity(buffer_capacity), + _owns_buffer(false), _initial_size() {} // a buffer that already has some content - inline FIXBuffer(char *buffer_to_use, uint32_t size, uint32_t capacity): - _buffer (buffer_to_use), - _size (size), - _capacity (capacity), - _owns_buffer (false), - _initial_size (size) - {} + inline FIXBuffer(char *buffer_to_use, uint32_t size, uint32_t capacity) + : _buffer(buffer_to_use), _size(size), _capacity(capacity), + _owns_buffer(false), _initial_size(size) {} // memory owned by this buffer - explicit inline FIXBuffer (uint32_t initial_capacity) : - _buffer (new char[initial_capacity]), - _size (0), - _capacity (initial_capacity), - _owns_buffer (true), - _initial_size () - {} + explicit inline FIXBuffer(uint32_t initial_capacity) + : _buffer(new char[initial_capacity]), _size(0), + _capacity(initial_capacity), _owns_buffer(true), _initial_size() {} - inline FIXBuffer (FIXBuffer const&src) : - _buffer (), - _size (), - _capacity (), - _owns_buffer (false), - _initial_size () - { + inline FIXBuffer(FIXBuffer const &src) + : _buffer(), _size(), _capacity(), _owns_buffer(false), _initial_size() { operator=(src); } - inline FIXBuffer (FIXBuffer &&src) - : - _buffer (src._buffer), - _size (src._size), - _capacity (src._capacity), - _owns_buffer (src._owns_buffer), - _initial_size (src._initial_size) - { + inline FIXBuffer(FIXBuffer &&src) + : _buffer(src._buffer), _size(src._size), _capacity(src._capacity), + _owns_buffer(src._owns_buffer), _initial_size(src._initial_size) { src._buffer = nullptr; src._size = 0; src._capacity = 0; src._owns_buffer = false; src._initial_size = 0; } - - inline ~FIXBuffer () - { + + inline ~FIXBuffer() { if (_owns_buffer) - delete [] _buffer; + delete[] _buffer; } - - inline FIXBuffer&operator=(FIXBuffer const&src) - { - this->~FIXBuffer (); + + inline FIXBuffer &operator=(FIXBuffer const &src) { + this->~FIXBuffer(); if (src._owns_buffer) { _buffer = new char[src._capacity]; - memcpy (_buffer,src._buffer,src._size); - } - else + memcpy(_buffer, src._buffer, src._size); + } else _buffer = src._buffer; _size = src._size; _capacity = src._capacity; @@ -83,15 +57,14 @@ public: return *this; } - inline FIXBuffer&operator=(FIXBuffer &&src) - { - this->~FIXBuffer (); + inline FIXBuffer &operator=(FIXBuffer &&src) { + this->~FIXBuffer(); _buffer = src._buffer; _size = src._size; - _capacity= src._capacity; + _capacity = src._capacity; _owns_buffer = src._owns_buffer; _initial_size = src._initial_size; - + src._buffer = nullptr; src._size = 0; src._capacity = 0; @@ -99,42 +72,38 @@ public: src._initial_size = 0; return *this; } - - inline char* reserve (uint32_t need_bytes) - { + + inline char *reserve(uint32_t need_bytes) { if (_size + need_bytes > _capacity) { - bts_assert_d (_owns_buffer); - _capacity = (_capacity+need_bytes) * 2; + bts_assert_d(_owns_buffer); + _capacity = (_capacity + need_bytes) * 2; auto old_buffer = _buffer; _buffer = new char[_capacity]; - memcpy (_buffer,old_buffer,_size); - delete [] old_buffer; + memcpy(_buffer, old_buffer, _size); + delete[] old_buffer; } return _buffer + _size; } - inline char* get_offset (uint32_t offset) - { - bts_assert (offset <= _size); - return _buffer+offset; - } - - inline char* advance (uint32_t bytes) - { - _size += bytes; - bts_assert_d (_size<=_capacity); - return _buffer+_size; + inline char *get_offset(uint32_t offset) { + bts_assert(offset <= _size); + return _buffer + offset; } - void reset () - {_size = _initial_size;} - - uint32_t size () const {return _size;} - uint32_t capacity () const {return _capacity;} - const char*data () const {return _buffer;} - char*data () {return _buffer;} - -private: + inline char *advance(uint32_t bytes) { + _size += bytes; + bts_assert_d(_size <= _capacity); + return _buffer + _size; + } + + void reset() { _size = _initial_size; } + + uint32_t size() const { return _size; } + uint32_t capacity() const { return _capacity; } + const char *data() const { return _buffer; } + char *data() { return _buffer; } + + private: char *_buffer; uint32_t _size; uint32_t _capacity; @@ -142,4 +111,5 @@ private: uint32_t _initial_size; }; -}} +} // namespace jetfix +} // namespace bts diff --git a/src/lib/jetfix/codec/FIXEncodingStream.h b/src/lib/jetfix/codec/FIXEncodingStream.h index 50642ea38..8b19fad44 100644 --- a/src/lib/jetfix/codec/FIXEncodingStream.h +++ b/src/lib/jetfix/codec/FIXEncodingStream.h @@ -16,16 +16,17 @@ namespace jetfix { // the same FIX headers. class FIXEncodingStream { public: - FIXEncodingStream(config::JetFIX::Connection const &cfg, - uint32_t initial_capacity = 1024 * 10) + FIXEncodingStream( + config::JetFIX::Connection const &cfg, + uint32_t initial_capacity = 1024 * 10) : _msg_header_template(), _header_template_size(), _header_template_checksum(), _buffer(initial_capacity), _message_map(), _current_msg(_buffer), _state(State::OPEN), _seq_num_bm(), _last_seq_num_bm(), _sending_time_bm() { _message_map.reserve(10 * 1024); - FIXBuffer header_buffer(&_msg_header_template[0], - _msg_header_template.size()); + FIXBuffer header_buffer( + &_msg_header_template[0], _msg_header_template.size()); FIXFragment header(header_buffer); // We cannot include body lenght and msg type in the header @@ -52,7 +53,8 @@ class FIXEncodingStream { auto msg_offset = _buffer.size(); _current_msg = FIXFragment(_buffer); - _begin_string_bm = _current_msg.add(std::string_view {"FIX.4.2"}); + _begin_string_bm = + _current_msg.add(std::string_view{"FIX.4.2"}); _body_length_bm = _current_msg.add(0, 6); char mt_encoding[4]; @@ -61,10 +63,12 @@ class FIXEncodingStream { mt_encoding + start, sizeof(mt_encoding) - start); auto header_offset = _buffer.size(); - _message_map.emplace_back(msg_offset, header_offset, 0u, 0u, 0u, - FIXFragment::Bookmark>()); - _current_msg.append(&_msg_header_template[0], _header_template_size, - _header_template_checksum); + _message_map.emplace_back( + msg_offset, header_offset, 0u, 0u, 0u, + FIXFragment::Bookmark>()); + _current_msg.append( + &_msg_header_template[0], _header_template_size, + _header_template_checksum); return _current_msg; } @@ -85,9 +89,10 @@ class FIXEncodingStream { inline const char *data() const { return _buffer.data(); } struct MessageDesc { - MessageDesc(uint32_t offset, uint32_t header_offset, uint32_t size, - uint32_t checksum, uint32_t seq_num, - FIXFragment::Bookmark checksum_bm) + MessageDesc( + 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) {} @@ -117,8 +122,8 @@ class FIXEncodingStream { return s; } - inline uint32_t stamp(uint32_t seq_num, uint32_t last_processed, - std::string const &time_str) { + inline uint32_t stamp( + uint32_t seq_num, uint32_t last_processed, std::string const &time_str) { bts_assert(_state == State::CLOSED); _state = State::STAMPED; @@ -128,8 +133,8 @@ class FIXEncodingStream { FIXFragment frag(_buffer, m.checksum); frag.overwrite(_seq_num_bm.shift(m.header_offset), m.seq_num, 9); - frag.overwrite(_last_seq_num_bm.shift(m.header_offset), last_processed, - 9); + frag.overwrite( + _last_seq_num_bm.shift(m.header_offset), last_processed, 9); frag.overwrite(_sending_time_bm.shift(m.header_offset), time_str); frag.overwrite_checksum(m.checksum_bm, frag.checksum() % 256); } diff --git a/src/lib/jetfix/codec/FIXFragment.h b/src/lib/jetfix/codec/FIXFragment.h index 2bb117781..295f24e59 100644 --- a/src/lib/jetfix/codec/FIXFragment.h +++ b/src/lib/jetfix/codec/FIXFragment.h @@ -1,82 +1,59 @@ #pragma once -#include #include +#include -#include "lib/utils/bts_assert.h" #include "lib/jetfix/codec/FIXBuffer.h" #include "lib/jetfix/codec/Fields.h" +#include "lib/utils/bts_assert.h" namespace bts { namespace jetfix { // helper used to facilitate the encoding of a FIX message fragment -class FIXFragment -{ -public: - FIXFragment(FIXBuffer &buffer,uint32_t checksum) - : - _buffer (&buffer), - _checksum (checksum), - _initial_offset (buffer.size ()), - _owns_buffer (false) - {} - +class FIXFragment { + public: + FIXFragment(FIXBuffer &buffer, uint32_t checksum) + : _buffer(&buffer), _checksum(checksum), _initial_offset(buffer.size()), + _owns_buffer(false) {} + FIXFragment(FIXBuffer &buffer) - : - _buffer (&buffer), - _checksum (0), - _initial_offset (buffer.size ()), - _owns_buffer (false) - {} + : _buffer(&buffer), _checksum(0), _initial_offset(buffer.size()), + _owns_buffer(false) {} - explicit FIXFragment(uint32_t initial_capacity=100) - : - _buffer (new FIXBuffer (initial_capacity)), - _checksum (0), - _initial_offset (0), - _owns_buffer (true) - {} + explicit FIXFragment(uint32_t initial_capacity = 100) + : _buffer(new FIXBuffer(initial_capacity)), _checksum(0), + _initial_offset(0), _owns_buffer(true) {} - ~FIXFragment () - { + ~FIXFragment() { if (_owns_buffer) delete _buffer; } - - FIXFragment (FIXFragment const&src) : - _buffer (), - _checksum (0), - _initial_offset (0), - _owns_buffer () - { + + FIXFragment(FIXFragment const &src) + : _buffer(), _checksum(0), _initial_offset(0), _owns_buffer() { operator=(src); } - FIXFragment (FIXFragment &&src) : - _buffer (std::move (src._buffer)), - _checksum (src._checksum), - _initial_offset (src._initial_offset), - _owns_buffer (src._owns_buffer) - { + FIXFragment(FIXFragment &&src) + : _buffer(std::move(src._buffer)), _checksum(src._checksum), + _initial_offset(src._initial_offset), _owns_buffer(src._owns_buffer) { src._buffer = nullptr; src._checksum = 0; src._initial_offset = 0; src._owns_buffer = false; } - void reset () - { - bts_assert (_owns_buffer); - _buffer->reset (); + void reset() { + bts_assert(_owns_buffer); + _buffer->reset(); } - - FIXFragment&operator=(FIXFragment const&src) - { - this->~FIXFragment (); - - if (src._owns_buffer) - _buffer = new FIXBuffer (*src._buffer); + + FIXFragment &operator=(FIXFragment const &src) { + this->~FIXFragment(); + + if (src._owns_buffer) + _buffer = new FIXBuffer(*src._buffer); else _buffer = src._buffer; _checksum = src._checksum; @@ -85,12 +62,11 @@ public: return *this; } - FIXFragment&operator=(FIXFragment &&src) - { - this->~FIXFragment (); + FIXFragment &operator=(FIXFragment &&src) { + this->~FIXFragment(); _buffer = src._buffer; _owns_buffer = src._owns_buffer; - _checksum= src._checksum; + _checksum = src._checksum; _initial_offset = src._initial_offset; src._buffer = nullptr; src._checksum = 0; @@ -99,25 +75,17 @@ public: return *this; } - template - struct Bookmark - { - Bookmark (uint32_t idx,uint32_t sz,uint32_t checksum) : - offset (idx), - sz (sz), - val_checksum (checksum) - {} - Bookmark () : - offset (0), - sz (0), - val_checksum (0) - {} + template struct Bookmark { + Bookmark(uint32_t idx, uint32_t sz, uint32_t checksum) + : offset(idx), sz(sz), val_checksum(checksum) {} + Bookmark() : offset(0), sz(0), val_checksum(0) {} + + bool valid() const { return sz > 0; } + + Bookmark shift(uint32_t by) const { + return Bookmark(offset + by, sz, val_checksum); + } - bool valid () const {return sz > 0;} - - Bookmark shift (uint32_t by) const - {return Bookmark (offset+by,sz,val_checksum);} - typedef FT Field; uint32_t offset; uint32_t sz; @@ -125,81 +93,79 @@ public: }; template - inline Bookmark add (Args&&... args) - { + inline Bookmark add(Args &&... args) { auto non_value_data_sz = Field::tag_sz + 2; // =,SOH - auto val_max_size = Field::max_value_size (std::forward(args)...); + auto val_max_size = Field::max_value_size(std::forward(args)...); - auto ptr = _buffer->reserve (val_max_size + non_value_data_sz); - std::memcpy (ptr,Field::tag_s,Field::tag_sz); - ptr = _buffer->advance (Field::tag_sz); + auto ptr = _buffer->reserve(val_max_size + non_value_data_sz); + std::memcpy(ptr, Field::tag_s, Field::tag_sz); + ptr = _buffer->advance(Field::tag_sz); *ptr = '='; - ptr = _buffer->advance (1); - auto start_of_value = _buffer->size (); - auto write_result = Field::write (ptr,std::forward(args)...); - ptr = _buffer->advance (write_result.first); + ptr = _buffer->advance(1); + auto start_of_value = _buffer->size(); + auto write_result = Field::write(ptr, std::forward(args)...); + ptr = _buffer->advance(write_result.first); *ptr = 1; - ptr = _buffer->advance (1); + ptr = _buffer->advance(1); _checksum += (write_result.second + Field::tag_checksum + '=' + 1); - return Bookmark (start_of_value,write_result.first, write_result.second); - } - - template - inline Bookmark overwrite (Bookmark const &bm,Args &&... args) - { - _checksum -= bm.val_checksum; - auto ptr = _buffer->get_offset (bm.offset); - auto write_result = Field::write (ptr,std::forward(args)...); - ptr[bm.sz] = 1; // i32_toa, d_toa both put a 0 at end of the number - bts_assert (write_result.first == bm.sz); - _checksum += write_result.second; - return Bookmark (bm.offset,bm.sz, write_result.second); + return Bookmark( + start_of_value, write_result.first, write_result.second); } - inline Bookmark> add_checksum (uint8_t chk) - { + template + inline Bookmark + overwrite(Bookmark const &bm, Args &&... args) { + _checksum -= bm.val_checksum; + auto ptr = _buffer->get_offset(bm.offset); + auto write_result = Field::write(ptr, std::forward(args)...); + ptr[bm.sz] = 1; // i32_toa, d_toa both put a 0 at end of the number + bts_assert(write_result.first == bm.sz); + _checksum += write_result.second; + return Bookmark(bm.offset, bm.sz, write_result.second); + } + + inline Bookmark> add_checksum(uint8_t chk) { auto checksum = _checksum; - auto bm = add> (chk,3); + auto bm = add>(chk, 3); _checksum = checksum; bm.val_checksum = 0; return bm; } - inline Bookmark> overwrite_checksum (Bookmark> const&bm,uint8_t chk) - { + inline Bookmark> + overwrite_checksum(Bookmark> const &bm, uint8_t chk) { auto checksum = _checksum; - overwrite> (bm,chk,3); + overwrite>(bm, chk, 3); _checksum = checksum; return bm; } - - template inline void append (FIX_DATA const &src) - {append (src.data (),src.size (),src.checksum ());} - - inline void append (const char*data, uint32_t data_size, uint32_t data_checksum) - { - auto ptr = _buffer->reserve (data_size); + + template inline void append(FIX_DATA const &src) { + append(src.data(), src.size(), src.checksum()); + } + + inline void + append(const char *data, uint32_t data_size, uint32_t data_checksum) { + auto ptr = _buffer->reserve(data_size); _checksum += data_checksum; - memcpy (ptr,data,data_size); - _buffer->advance (data_size); + memcpy(ptr, data, data_size); + _buffer->advance(data_size); } - std::string to_str () const - { - return std::string (_buffer->data (), - _initial_offset, - _buffer->size ()); + std::string to_str() const { + return std::string(_buffer->data(), _initial_offset, _buffer->size()); } - uint32_t size () const {return _buffer->size () - _initial_offset;} - uint32_t checksum () const {return _checksum; } - const char* data () const {return _buffer->get_offset (_initial_offset);} - -private: + uint32_t size() const { return _buffer->size() - _initial_offset; } + uint32_t checksum() const { return _checksum; } + const char *data() const { return _buffer->get_offset(_initial_offset); } + + private: FIXBuffer *_buffer; size_t _checksum; uint32_t _initial_offset; bool _owns_buffer; }; -}} +} // namespace jetfix +} // namespace bts diff --git a/src/lib/jetfix/codec/FIXMsg.h b/src/lib/jetfix/codec/FIXMsg.h index 519946cbc..5069c7984 100644 --- a/src/lib/jetfix/codec/FIXMsg.h +++ b/src/lib/jetfix/codec/FIXMsg.h @@ -1,111 +1,98 @@ #pragma once +#include #include #include -#include -#include "lib/jetfix/codec/MessageTypes.h" -#include "lib/jetfix/codec/WriterCursor.h" -#include "lib/jetfix/codec/ReaderCursor.h" -#include "lib/jetfix/codec/IFieldReader.h" #include "lib/jetfix/codec/IFIXMsg.h" +#include "lib/jetfix/codec/IFieldReader.h" +#include "lib/jetfix/codec/MessageTypes.h" +#include "lib/jetfix/codec/ReaderCursor.h" +#include "lib/jetfix/codec/WriterCursor.h" #include "lib/jetfix/common/InMsgBuffer.h" -#include "lib/utils/meta_programming.h" #include "lib/tracing/PerfLog.h" +#include "lib/utils/meta_programming.h" namespace bts { namespace jetfix { // a parsed FIX message -template -class FIXMsg : public IFIXMsg -{ -public: +template +class FIXMsg : public IFIXMsg { + public: static const auto tag = fix_tag; - - FIXMsg () : - _fields (), _has_value (), _field_idx (),_trace() - { - index_fields (); + + FIXMsg() : _fields(), _has_value(), _field_idx(), _trace() { + index_fields(); } - FIXMsg (InMsgBuffer const&buffer) : - _fields (), _has_value (), _field_idx (),_trace(buffer.trace()) - { - index_fields (); - read (buffer.data (),buffer.size ()); + FIXMsg(InMsgBuffer const &buffer) + : _fields(), _has_value(), _field_idx(), _trace(buffer.trace()) { + index_fields(); + read(buffer.data(), buffer.size()); } - FIXMsg (std::string const&fix) : _fields (), _has_value (),_field_idx (),_trace() - { - index_fields (); - read (fix); + FIXMsg(std::string const &fix) + : _fields(), _has_value(), _field_idx(), _trace() { + index_fields(); + read(fix); } - MessageTypes msg_type () const override - {return tag;} - - template bool has () const - { - auto field_idx = meta::GetTypeIdxInTuple::value; + MessageTypes msg_type() const override { return tag; } + + template bool has() const { + auto field_idx = meta::GetTypeIdxInTuple::value; return _has_value[field_idx]; } - - template typename Field::Value const &get () const - { - bts_assert (has ()); - return std::get::value> (_fields).value (); - } - - void read (std::string const&str) - { - read (str.data (),str.size ()); + + template typename Field::Value const &get() const { + bts_assert(has()); + return std::get::value>( + _fields) + .value(); } - void read (const char*data, size_t sz) - { - _has_value.reset (); - ReaderCursor cursor (data,sz); - while (!cursor.eof ()) - { - if (!try_read (cursor.read_tag (),cursor)) - cursor.read_field (); + void read(std::string const &str) { read(str.data(), str.size()); } + + void read(const char *data, size_t sz) { + _has_value.reset(); + ReaderCursor cursor(data, sz); + while (!cursor.eof()) { + if (!try_read(cursor.read_tag(), cursor)) + cursor.read_field(); } } - void set_trace (trace::CorID const&trace) {_trace = trace;} - trace::CorID const&trace() const {return _trace;} + void set_trace(trace::CorID const &trace) { _trace = trace; } + trace::CorID const &trace() const { return _trace; } -private: + private: typedef std::tuple FieldTuple; - void index_fields () - { - std::vector rws; - meta::collect_tuple_items (_fields,&rws); + void index_fields() { + std::vector rws; + meta::collect_tuple_items(_fields, &rws); for (auto rw : rws) - _field_idx.push_back (std::make_pair (rw->get_tag (),rw)); + _field_idx.push_back(std::make_pair(rw->get_tag(), rw)); } - bool try_read (uint32_t tag, ReaderCursor &cursor) - { + bool try_read(uint32_t tag, ReaderCursor &cursor) { size_t i = 0; - for (auto &rwp : _field_idx) + for (auto &rwp : _field_idx) if (rwp.first == tag) { - rwp.second->read (cursor); + rwp.second->read(cursor); _has_value[i] = true; return true; - } - else i++; + } else + i++; return false; } - + FieldTuple _fields; std::bitset::value> _has_value; - std::vector> _field_idx; + std::vector> _field_idx; trace::CorID _trace; }; - -}} - +} // namespace jetfix +} // namespace bts diff --git a/src/lib/jetfix/codec/FIXParser.h b/src/lib/jetfix/codec/FIXParser.h index 60d89a725..2b324bfc5 100644 --- a/src/lib/jetfix/codec/FIXParser.h +++ b/src/lib/jetfix/codec/FIXParser.h @@ -1,64 +1,59 @@ #pragma once -#include #include "lib/jetfix/codec/IFIXParser.h" +#include namespace bts { namespace jetfix { // a parser specialized to parse only a specific set of message types, // skiping over unknown types -template -class FIXParser : public IFIXParser -{ -public: - FIXParser() : _parsers (), _parser_idx () - { - std::vector parser_vec; - meta::collect_tuple_items (_parsers,&parser_vec); +template class FIXParser : public IFIXParser { + public: + FIXParser() : _parsers(), _parser_idx() { + std::vector parser_vec; + meta::collect_tuple_items(_parsers, &parser_vec); for (auto p : parser_vec) - _parser_idx.emplace_back (p->tag (),p); - typedef std::pair Pair; - - std::sort (_parser_idx.begin (),_parser_idx.end (), - [] (Pair const&l, Pair const&r) { - return (int) l.first < (int) r.first; - }); + _parser_idx.emplace_back(p->tag(), p); + typedef std::pair Pair; + + std::sort( + _parser_idx.begin(), _parser_idx.end(), + [](Pair const &l, Pair const &r) { + return (int)l.first < (int)r.first; + }); } - IFIXMsgPtr parse (InMsgBuffer const&msg) const override - { - auto type = msg.type (); + IFIXMsgPtr parse(InMsgBuffer const &msg) const override { + auto type = msg.type(); for (auto &p : _parser_idx) if (p.first == type) - return p.second->parse (msg); + return p.second->parse(msg); else if (p.first > type) break; - - return IFIXMsgPtr (); + + return IFIXMsgPtr(); } -private: - struct IParser - { + private: + struct IParser { virtual ~IParser() {} - virtual MessageTypes tag () const = 0; - virtual IFIXMsgPtr parse (InMsgBuffer const&msg) const = 0; + virtual MessageTypes tag() const = 0; + virtual IFIXMsgPtr parse(InMsgBuffer const &msg) const = 0; }; - template struct Parser : public IParser - { - - MessageTypes tag () const override {return MT::tag;} - IFIXMsgPtr parse (InMsgBuffer const&msg) const override - { - auto ptr = std::make_shared (msg); - return std::dynamic_pointer_cast (ptr); + template struct Parser : public IParser { + + MessageTypes tag() const override { return MT::tag; } + IFIXMsgPtr parse(InMsgBuffer const &msg) const override { + auto ptr = std::make_shared(msg); + return std::dynamic_pointer_cast(ptr); } }; std::tuple...> _parsers; - std::vector> _parser_idx; + std::vector> _parser_idx; }; -}} +} // namespace jetfix +} // namespace bts diff --git a/src/lib/jetfix/codec/FIXWriter.h b/src/lib/jetfix/codec/FIXWriter.h index da2c44d93..c5ed7a9b7 100644 --- a/src/lib/jetfix/codec/FIXWriter.h +++ b/src/lib/jetfix/codec/FIXWriter.h @@ -5,16 +5,15 @@ namespace bts { namespace jetfix { -class FIXWriter -{ -public: +class FIXWriter { + public: FIXWriter(); ~FIXWriter(); -private: + private: char *_buffer; size_t _buffer_size; - }; -}} +} // namespace jetfix +} // namespace bts diff --git a/src/lib/jetfix/codec/FieldDefinitions.h b/src/lib/jetfix/codec/FieldDefinitions.h index 4fb4aad2e..7eedb42f1 100644 --- a/src/lib/jetfix/codec/FieldDefinitions.h +++ b/src/lib/jetfix/codec/FieldDefinitions.h @@ -1,8 +1,8 @@ #pragma once -#include #include "Fields.h" #include "Group.h" +#include namespace bts { namespace jetfix { @@ -39,7 +39,7 @@ typedef IntField<14> CumQty; typedef IntField<16> EndSeqNo; typedef IntField<204> CustomerOrFirm; typedef IntField<295> NoQuoteEntries; -typedef IntField<296> NoQuoteSets; +typedef IntField<296> NoQuoteSets; typedef IntField<297> QuoteAckStatus; typedef IntField<298> QuoteCancelType; typedef IntField<299> QuoteEntryIDInt; @@ -77,7 +77,7 @@ typedef StringField<167> SecurityType; typedef StringField<17> ExecID; typedef StringField<19> ExecRefID; typedef StringField<1> Account; -typedef StringField<295> NoQuoteEntriesStr; +typedef StringField<295> NoQuoteEntriesStr; typedef StringField<299> QuoteEntryID; typedef StringField<302> QuoteSetID; typedef StringField<304> TotQuoteEntriesStr; @@ -90,7 +90,7 @@ typedef StringField<41> OrigClOrdID; typedef StringField<440> ClearingAccount; typedef StringField<48> SecurityID; typedef StringField<49> SenderCompID; -typedef StringField<50> SenderSubID ; +typedef StringField<50> SenderSubID; typedef StringField<527> SecondaryExecID; typedef StringField<55> Symbol; typedef StringField<56> TargetCompId; @@ -110,13 +110,13 @@ typedef TimeField<52> SendingTime; typedef TimeField<5979> RequestTime; typedef TimeField<60> TransactTime; -//ICE -typedef IntField<9208> Int_CtiCode; -typedef BigIntField<11> Int_ClOrdID; -typedef BigIntField<37> Int_OrderID; -typedef BigIntField<41> Int_OrigClOrdID; -typedef IntField<109> CompanyID; -typedef IntField<55> Int_Symbol; +// ICE +typedef IntField<9208> Int_CtiCode; +typedef BigIntField<11> Int_ClOrdID; +typedef BigIntField<37> Int_OrderID; +typedef BigIntField<41> Int_OrigClOrdID; +typedef IntField<109> CompanyID; +typedef IntField<55> Int_Symbol; typedef IntField<439> Int_ClearingFirm; typedef StringField<9121> Memo; typedef IntField<103> OrdRejReason; @@ -142,27 +142,16 @@ typedef BigIntField<9705> MifidExecutionDecision; typedef BigIntField<9706> MifidClientIDCode; typedef BigIntField<9707> MifidId; -typedef Group -QuoteEntries; - -typedef Group -QuoteSets; +typedef Group< + NoQuoteEntries, QuoteEntryID, Symbol, SecurityType, SecurityDesc, + SecurityID, SecurityIDSource, TransactTime, BidPx, OfferPx, BidSize, + OfferSize, QuoteEntryRejectReason> + QuoteEntries; + +typedef Group< + NoQuoteSets, QuoteSetID, UnderlyingSecurityDesc, TotQuoteEntries, + QuoteEntries> + QuoteSets; typedef IntField<38> OrderQty; typedef IntField<210> MaxShow; @@ -175,4 +164,6 @@ typedef StringField<355> EncodedText; typedef StringField<1400> EncryptedPasswordMethod; typedef IntField<1401> EncryptedPasswordLen; typedef StringField<1402> EncryptedPassword; -}}} +} // namespace fix +} // namespace jetfix +} // namespace bts diff --git a/src/lib/jetfix/codec/Fields.h b/src/lib/jetfix/codec/Fields.h index 6bdb51d36..79c4e57fe 100644 --- a/src/lib/jetfix/codec/Fields.h +++ b/src/lib/jetfix/codec/Fields.h @@ -1,246 +1,231 @@ #pragma once -#include #include +#include #include -#include "lib/jetfix/codec/ReaderCursor.h" -#include "lib/utils/meta_programming.h" -#include "lib/utils/datetime.h" -#include "lib/jetfix/codec/sum_bytes.h" -#include "lib/jetfix/codec/i32_toa.h" -#include "lib/jetfix/codec/f_toa.h" #include "lib/jetfix/codec/IFieldReader.h" +#include "lib/jetfix/codec/ReaderCursor.h" +#include "lib/jetfix/codec/f_toa.h" +#include "lib/jetfix/codec/i32_toa.h" +#include "lib/jetfix/codec/sum_bytes.h" +#include "lib/utils/datetime.h" +#include "lib/utils/meta_programming.h" namespace bts { namespace jetfix { template -class BaseField : public IFieldReader -{ +class BaseField : public IFieldReader { // compile time calculation of tag checksum template struct calc_checksum; - - template - struct calc_checksum - {static const uint32_t value = N + '0';}; - - template - struct calc_checksum - {static const uint32_t value = (N%10 + '0') + calc_checksum::value;}; + template struct calc_checksum { + static const uint32_t value = N + '0'; + }; -public: + template struct calc_checksum { + static const uint32_t value = + (N % 10 + '0') + calc_checksum::value; + }; + + public: static uint16_t const tag; - static const char* tag_s; - static size_t const tag_sz; - static uint32_t const tag_checksum ; - - typedef ValueType Value; - - BaseField () : _value () {} - const ValueType & value () const {return _value;} + static const char *tag_s; + static size_t const tag_sz; + static uint32_t const tag_checksum; - virtual uint32_t get_tag () - {return tag;} -protected: + typedef ValueType Value; + + BaseField() : _value() {} + const ValueType &value() const { return _value; } + + virtual uint32_t get_tag() { return tag; } + + protected: ValueType _value; }; -template -uint16_t const BaseField::tag = t_tag; +template +uint16_t const BaseField::tag = t_tag; -template -const char* BaseField::tag_s = meta::int_to_string::type::value; +template +const char *BaseField::tag_s = + meta::int_to_string::type::value; -template -size_t const BaseField::tag_sz = meta::int_to_string::size; +template +size_t const BaseField::tag_sz = + meta::int_to_string::size; -template -uint32_t const BaseField::tag_checksum = calc_checksum::value; +template +uint32_t const BaseField::tag_checksum = + calc_checksum < t_tag<10, t_tag>::value; -template -class CharField : public BaseField -{ -public: - typedef BaseField Parent; - - void read (ReaderCursor &cursor) - { - auto loc = cursor.read_field (); - bts_assert (loc.second == 1); - Parent::_value = cursor.data ()[loc.first]; +template class CharField : public BaseField { + public: + typedef BaseField Parent; + + void read(ReaderCursor &cursor) { + auto loc = cursor.read_field(); + bts_assert(loc.second == 1); + Parent::_value = cursor.data()[loc.first]; } - constexpr static uint32_t max_value_size (char ) {return 1;} - static std::pair write (char* buffer,char c) - { + constexpr static uint32_t max_value_size(char) { return 1; } + static std::pair write(char *buffer, char c) { *buffer = c; - return std::make_pair (1,c); + return std::make_pair(1, c); } }; -template -class BoolField : public BaseField -{ -public: - typedef BaseField Parent; +template class BoolField : public BaseField { + public: + typedef BaseField Parent; - void read(ReaderCursor &cursor) - { - auto loc = cursor.read_field (); - bts_assert (loc.second == 1); - Parent::_value = cursor.data ()[loc.first] == 'Y'; + void read(ReaderCursor &cursor) { + auto loc = cursor.read_field(); + bts_assert(loc.second == 1); + Parent::_value = cursor.data()[loc.first] == 'Y'; } - constexpr static uint32_t max_value_size ( bool) {return 1;} - static std::pair write (char *buffer,bool b) - { + constexpr static uint32_t max_value_size(bool) { return 1; } + static std::pair write(char *buffer, bool b) { if (b) *buffer = 'Y'; else *buffer = 'N'; - return std::make_pair (1,*buffer); + return std::make_pair(1, *buffer); } }; -template -class FloatField : public BaseField -{ -public: - typedef BaseField Parent; - - void read (ReaderCursor &cursor) - { - auto loc = cursor.read_field (); - Parent::_value = atof (&(cursor.data ()[loc.first])); +template class FloatField : public BaseField { + public: + typedef BaseField Parent; + + void read(ReaderCursor &cursor) { + auto loc = cursor.read_field(); + Parent::_value = atof(&(cursor.data()[loc.first])); } - static uint32_t max_value_size ( double,int, int pad) - { + static uint32_t max_value_size(double, int, int pad) { if (pad == -1) - return 17; // 15 from FIX spec, 1 for decimal, 1 for sign + return 17; // 15 from FIX spec, 1 for decimal, 1 for sign else - return pad; + return pad; } - - static std::pair write (char*buffer,double d,int decimals, int pad ) - { - auto written = d_toa (d,buffer,max_value_size (d,decimals, pad)+1,decimals,pad); - return std::make_pair (written,sum_bytes (buffer,written)); + + static std::pair + write(char *buffer, double d, int decimals, int pad) { + auto written = + d_toa(d, buffer, max_value_size(d, decimals, pad) + 1, decimals, pad); + return std::make_pair(written, sum_bytes(buffer, written)); } }; -template -class IntField : public BaseField -{ -public: - typedef BaseField Parent; +template class IntField : public BaseField { + public: + typedef BaseField Parent; - void read (ReaderCursor &cursor) - { - auto loc = cursor.read_field (); - Parent::_value = atoi (&(cursor.data ()[loc.first])); + void read(ReaderCursor &cursor) { + auto loc = cursor.read_field(); + Parent::_value = atoi(&(cursor.data()[loc.first])); } - static uint32_t max_value_size (int32_t,int pad = 0) - { + static uint32_t max_value_size(int32_t, int pad = 0) { if (pad == 0) return 11; else return pad; } - - static std::pair write (char*buffer,int32_t i,int pad = 0) - { - auto written = i32_toa (i,buffer,pad); - return std::make_pair (written,sum_bytes (buffer,written)); + + static std::pair + write(char *buffer, int32_t i, int pad = 0) { + auto written = i32_toa(i, buffer, pad); + return std::make_pair(written, sum_bytes(buffer, written)); } }; -template -class BigIntField : public BaseField -{ -public: - typedef BaseField Parent; +template class BigIntField : public BaseField { + public: + typedef BaseField Parent; - void read (ReaderCursor &cursor) - { - auto loc = cursor.read_field (); - Parent::_value = atoll (&(cursor.data ()[loc.first])); + void read(ReaderCursor &cursor) { + auto loc = cursor.read_field(); + Parent::_value = atoll(&(cursor.data()[loc.first])); } - static uint32_t max_value_size (int64_t,int pad = 0) - { + static uint32_t max_value_size(int64_t, int pad = 0) { if (pad == 0) return 20; else return pad; } - - static std::pair write (char*buffer,int64_t i,int pad = 0) - { - auto written = i64_toa (i,buffer,pad); - return std::make_pair (written,sum_bytes (buffer,written)); + + static std::pair + write(char *buffer, int64_t i, int pad = 0) { + auto written = i64_toa(i, buffer, pad); + return std::make_pair(written, sum_bytes(buffer, written)); } }; -template -class StringField : public BaseField -{ -public: - typedef BaseField Parent; +template class StringField : public BaseField { + public: + typedef BaseField Parent; - void read (ReaderCursor &cursor) - { - auto loc = cursor.read_field (); - BaseField::_value = - std::string (cursor.data ()+loc.first,loc.second); + void read(ReaderCursor &cursor) { + auto loc = cursor.read_field(); + BaseField::_value = + std::string(cursor.data() + loc.first, loc.second); } + static uint32_t max_value_size(std::string const &str) { return str.size(); } + static uint32_t max_value_size(const char *, uint32_t sz) { return sz; } - static uint32_t max_value_size (std::string const&str) {return str.size ();} - static uint32_t max_value_size (const char*,uint32_t sz) {return sz;} - - static std::pair write (char*buffer,std::string const &str) - {return write (buffer,str.data (),str.size ());} - + static std::pair + write(char *buffer, std::string const &str) { + return write(buffer, str.data(), str.size()); + } #if __cplusplus >= 201703L - static uint32_t max_value_size (std::string_view const&str) {return str.size ();} - static std::pair write (char*buffer,std::string_view const &str) - {return write (buffer,str.data (),str.size ());} + static uint32_t max_value_size(std::string_view const &str) { + return str.size(); + } + static std::pair + write(char *buffer, std::string_view const &str) { + return write(buffer, str.data(), str.size()); + } #endif - static std::pair write (char*buffer,const char*str,uint32_t sz) - { - memcpy (buffer,str,sz); - return std::make_pair (sz,sum_bytes (buffer,sz)); + static std::pair + write(char *buffer, const char *str, uint32_t sz) { + memcpy(buffer, str, sz); + return std::make_pair(sz, sum_bytes(buffer, sz)); } }; template -class TimeField : public BaseField -{ -public: - typedef BaseField Parent; +class TimeField : public BaseField { + public: + typedef BaseField Parent; - void read (ReaderCursor &cursor) - { - auto loc = cursor.read_field (); - BaseField::_value = - datetime::parse_FIX_timestamp (std::string (cursor.data ()+loc.first,loc.second)); + void read(ReaderCursor &cursor) { + auto loc = cursor.read_field(); + BaseField::_value = + datetime::parse_FIX_timestamp( + std::string(cursor.data() + loc.first, loc.second)); } - constexpr static uint32_t max_value_size (boost::posix_time::ptime const&) - {return sizeof("20121204-14:44:02.000")-1;} + constexpr static uint32_t max_value_size(boost::posix_time::ptime const &) { + return sizeof("20121204-14:44:02.000") - 1; + } - static std::pair write (char*buffer,boost::posix_time::ptime const &t) - { - memcpy (buffer,datetime::FIX_timestamp (t).data (),max_value_size (t)); - return std::make_pair (max_value_size (t),sum_bytes (buffer,max_value_size (t))); + static std::pair + write(char *buffer, boost::posix_time::ptime const &t) { + memcpy(buffer, datetime::FIX_timestamp(t).data(), max_value_size(t)); + return std::make_pair( + max_value_size(t), sum_bytes(buffer, max_value_size(t))); } }; -}} - +} // namespace jetfix +} // namespace bts diff --git a/src/lib/jetfix/codec/Group.h b/src/lib/jetfix/codec/Group.h index 51e6def20..d71b3e412 100644 --- a/src/lib/jetfix/codec/Group.h +++ b/src/lib/jetfix/codec/Group.h @@ -1,134 +1,125 @@ #pragma once -#include #include +#include #include +#include "IFieldReader.h" #include "ReaderCursor.h" #include "WriterCursor.h" -#include "IFieldReader.h" -#include "lib/utils/meta_programming.h" #include "lib/utils/bts_assert.h" +#include "lib/utils/meta_programming.h" namespace bts { namespace jetfix { -template -class GroupElement -{ -public: - GroupElement () : _fields (),_has_value (),_field_idx () {index_fields ();} - - template bool has () const - { - auto field_idx = meta::GetTypeIdxInTuple::value; +template class GroupElement { + public: + GroupElement() : _fields(), _has_value(), _field_idx() { index_fields(); } + + template bool has() const { + auto field_idx = meta::GetTypeIdxInTuple::value; return _has_value[field_idx]; } - - template typename Field::Value const &get () const - { - bts_assert (has ()); - return std::get::value> (_fields).value (); + + template typename Field::Value const &get() const { + bts_assert(has()); + return std::get::value>( + _fields) + .value(); } - void read (ReaderCursor &cursor) - { - _has_value.reset (); - auto &separator = std::get<0> (_fields); - auto tag = cursor.read_tag (); - bts_assert (tag == separator.tag); - separator.read (cursor); + void read(ReaderCursor &cursor) { + _has_value.reset(); + auto &separator = std::get<0>(_fields); + auto tag = cursor.read_tag(); + bts_assert(tag == separator.tag); + separator.read(cursor); _has_value[0] = true; do { - if (!cursor.eof ()) - tag = cursor.read_tag (); + if (!cursor.eof()) + tag = cursor.read_tag(); else break; - } while (tag != separator.tag && try_read (tag,cursor)); + } while (tag != separator.tag && try_read(tag, cursor)); - if (!cursor.eof ()) - cursor.unread_tag (); + if (!cursor.eof()) + cursor.unread_tag(); } - -private: - typedef std::tuple FieldTuple; - void index_fields () - { - std::vector rws; - meta::collect_tuple_items (_fields,&rws); + private: + typedef std::tuple FieldTuple; + + void index_fields() { + std::vector rws; + meta::collect_tuple_items(_fields, &rws); for (auto rw : rws) - _field_idx.push_back (std::make_pair (rw->get_tag (),rw)); + _field_idx.push_back(std::make_pair(rw->get_tag(), rw)); } - bool try_read (uint32_t tag, ReaderCursor &cursor) - { + bool try_read(uint32_t tag, ReaderCursor &cursor) { size_t i = 0; - for (auto &rwp : _field_idx) + for (auto &rwp : _field_idx) if (rwp.first == tag) { - rwp.second->read (cursor); + rwp.second->read(cursor); _has_value[i] = true; return true; - } - else i++; + } else + i++; return false; } FieldTuple _fields; std::bitset::value> _has_value; - std::vector> _field_idx; + std::vector> _field_idx; }; -template -class Group : public IFieldReader -{ -public: +template +class Group : public IFieldReader { + public: typedef Group Value; - typedef GroupElement Element; + typedef GroupElement Element; - Group () : _elements () {} - - Value const &value () const - {return *this;} + Group() : _elements() {} - size_t size () const - {return _elements.size ();} + Value const &value() const { return *this; } - Element const& operator[](size_t idx) const - { - bts_assert (idx < size ()); + size_t size() const { return _elements.size(); } + + Element const &operator[](size_t idx) const { + bts_assert(idx < size()); return _elements[idx]; } - typename std::vector::const_iterator begin () const - {return _elements.begin ();} + typename std::vector::const_iterator begin() const { + return _elements.begin(); + } - typename std::vector::const_iterator end () const - {return _elements.end ();} + typename std::vector::const_iterator end() const { + return _elements.end(); + } - void write (WriterCursor &cursor) - { - CountField::write (cursor,(int) size ()); + void write(WriterCursor &cursor) { + CountField::write(cursor, (int)size()); for (auto &el : _elements) - el.write (cursor); + el.write(cursor); } - - void read (ReaderCursor &cursor) - { + + void read(ReaderCursor &cursor) { CountField count; - count.read (cursor); - _elements.resize (count.value ()); + count.read(cursor); + _elements.resize(count.value()); for (auto &element : _elements) - element.read (cursor); + element.read(cursor); } - uint32_t get_tag () - {return CountField::tag;} + uint32_t get_tag() { return CountField::tag; } -private: + private: std::vector _elements; }; -}} +} // namespace jetfix +} // namespace bts diff --git a/src/lib/jetfix/codec/IFIXMsg.h b/src/lib/jetfix/codec/IFIXMsg.h index 4b8650b78..177185ea0 100644 --- a/src/lib/jetfix/codec/IFIXMsg.h +++ b/src/lib/jetfix/codec/IFIXMsg.h @@ -1,16 +1,16 @@ #pragma once -#include #include "lib/jetfix/codec/MessageTypes.h" +#include namespace bts { namespace jetfix { -class IFIXMsg -{ -public: - virtual MessageTypes msg_type () const = 0; - virtual ~IFIXMsg () {} +class IFIXMsg { + public: + virtual MessageTypes msg_type() const = 0; + virtual ~IFIXMsg() {} }; typedef std::shared_ptr IFIXMsgPtr; -}} +} // namespace jetfix +} // namespace bts diff --git a/src/lib/jetfix/codec/IFIXParser.h b/src/lib/jetfix/codec/IFIXParser.h index e3e1f9f26..08a70a4f9 100644 --- a/src/lib/jetfix/codec/IFIXParser.h +++ b/src/lib/jetfix/codec/IFIXParser.h @@ -1,18 +1,18 @@ #pragma once -#include #include "lib/jetfix/codec/IFIXMsg.h" +#include namespace bts { namespace jetfix { class InMsgBuffer; -class IFIXParser -{ -public: - virtual IFIXMsgPtr parse (InMsgBuffer const&msg) const = 0; - virtual ~IFIXParser () {} +class IFIXParser { + public: + virtual IFIXMsgPtr parse(InMsgBuffer const &msg) const = 0; + virtual ~IFIXParser() {} }; -}} +} // namespace jetfix +} // namespace bts diff --git a/src/lib/jetfix/codec/IFieldReader.h b/src/lib/jetfix/codec/IFieldReader.h index 06cebdd7b..44bcf34df 100644 --- a/src/lib/jetfix/codec/IFieldReader.h +++ b/src/lib/jetfix/codec/IFieldReader.h @@ -6,13 +6,12 @@ namespace bts { namespace jetfix { -class IFieldReader -{ -public: - virtual void read (ReaderCursor &cursor) = 0; - virtual uint32_t get_tag () = 0; - virtual ~IFieldReader () {} +class IFieldReader { + public: + virtual void read(ReaderCursor &cursor) = 0; + virtual uint32_t get_tag() = 0; + virtual ~IFieldReader() {} }; - -}} +} // namespace jetfix +} // namespace bts diff --git a/src/lib/jetfix/codec/MessageDefinitions.h b/src/lib/jetfix/codec/MessageDefinitions.h index 75f45f3e6..31ffdc26a 100644 --- a/src/lib/jetfix/codec/MessageDefinitions.h +++ b/src/lib/jetfix/codec/MessageDefinitions.h @@ -1,124 +1,56 @@ #pragma once -#include #include "lib/jetfix/codec/FIXMsg.h" -#include "lib/jetfix/codec/MessageTypes.h" #include "lib/jetfix/codec/FieldDefinitions.h" +#include "lib/jetfix/codec/MessageTypes.h" +#include namespace bts { namespace jetfix { namespace fix { -typedef FIXMsg -QuoteAcknowledgementMsg; +typedef FIXMsg< + MessageTypes::QuoteAck, QuoteAckStatus, QuoteID, UnsolicitedCancelType, + QuoteRejectReason, Text, QuoteSets> + QuoteAcknowledgementMsg; -typedef FIXMsg -ExecutionReportMsg; +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> + ExecutionReportMsg; -typedef FIXMsg -BusinessMessageRejectMsg; +typedef FIXMsg + BusinessMessageRejectMsg; -typedef FIXMsg -RejectMsg; +typedef FIXMsg RejectMsg; -typedef FIXMsg -CancelRejectMsg; +typedef FIXMsg< + MessageTypes::CancelReject, Account, ClOrdID, ExecID, CXlRejReason, Text, + OrderID, OrigClOrdID, SecurityDesc, CorrelationClOrdID> + CancelRejectMsg; -typedef FIXMsg -ICETraderLoginResponseMsg; +typedef FIXMsg + ICETraderLoginResponseMsg; -typedef FIXMsg -ICETraderLogoutResponseMsg; +typedef FIXMsg + ICETraderLogoutResponseMsg; -typedef FIXMsg -ICEExecutionReportMsg; +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> + ICEExecutionReportMsg; -typedef FIXMsg -ICECancelRejectMsg; - -}}} +typedef FIXMsg< + MessageTypes::CancelReject, Int_OrderID, Int_ClOrdID, Int_OrigClOrdID, + CXlRejReason, Text, Memo> + ICECancelRejectMsg; +} // namespace fix +} // namespace jetfix +} // namespace bts diff --git a/src/lib/jetfix/codec/MessageTypes.h b/src/lib/jetfix/codec/MessageTypes.h index edeb8365e..c3f6a8300 100644 --- a/src/lib/jetfix/codec/MessageTypes.h +++ b/src/lib/jetfix/codec/MessageTypes.h @@ -5,56 +5,56 @@ namespace bts { namespace jetfix { -enum class MessageTypes : uint32_t -{ - Advertisement = '7', - Allocation = 'J', - AllocationACK = 'P', - BidRequest = 'k', - BidResponse = 'l', - BusinessMessageReject = 'j', - Cancel = 'F', - CancelReject = '9', - CancelReplace = 'G', - DontKnowTrade = 'Q', - Email = 'C', - ExecutionReport = '8', - HB = '0', - IndicationOfInterest = '6', - ListCancelRequest = 'K', - ListExecute = 'L', - ListStatus = 'N', - ListStatusRequest = 'M', - ListStrikePrice = 'm', - Logon = 'A', - Logout = '5', - MassQuote = 'i', - NewOrderList = 'E', - NewOrderSingle = 'D', - News = 'B', - OrderStatusRequest = 'H', - Quote = 'S', - QuoteAck = 'b', - QuoteCancel = 'Z', - QuoteRequest = 'R', - QuoteStatusRequest = 'a', - Reject = '3', - ResendRequest = '2', - SecurityDefinition = 'd', - SecurityDefinitionRequest = 'c', - SecurityStatus = 'f', - SecurityStatusRequest = 'e', - SeqReset = '4', - SettlementInstructions = 'T', - TestRequest = '1', - TradingSessionStatus = 'h', +enum class MessageTypes : uint32_t { + Advertisement = '7', + Allocation = 'J', + AllocationACK = 'P', + BidRequest = 'k', + BidResponse = 'l', + BusinessMessageReject = 'j', + Cancel = 'F', + CancelReject = '9', + CancelReplace = 'G', + DontKnowTrade = 'Q', + Email = 'C', + ExecutionReport = '8', + HB = '0', + IndicationOfInterest = '6', + ListCancelRequest = 'K', + ListExecute = 'L', + ListStatus = 'N', + ListStatusRequest = 'M', + ListStrikePrice = 'm', + Logon = 'A', + Logout = '5', + MassQuote = 'i', + NewOrderList = 'E', + NewOrderSingle = 'D', + News = 'B', + OrderStatusRequest = 'H', + Quote = 'S', + QuoteAck = 'b', + QuoteCancel = 'Z', + QuoteRequest = 'R', + QuoteStatusRequest = 'a', + Reject = '3', + ResendRequest = '2', + SecurityDefinition = 'd', + SecurityDefinitionRequest = 'c', + SecurityStatus = 'f', + SecurityStatusRequest = 'e', + SeqReset = '4', + SettlementInstructions = 'T', + TestRequest = '1', + TradingSessionStatus = 'h', TradingSessionStatusRequest = 'g', - MDIncrementalUpdate = 'X', - ICETraderLogin = ('U' << 16) + ('C' << 8) + 'G', - ICETraderLoginResponse = ('U' << 16) + ('C' << 8) + 'I', - ICETraderLogout = ('U' << 16) + ('C' << 8) + 'H', - ICETraderLogoutResponse = ('U' << 16) + ('C' << 8) + 'J', - + MDIncrementalUpdate = 'X', + ICETraderLogin = ('U' << 16) + ('C' << 8) + 'G', + ICETraderLoginResponse = ('U' << 16) + ('C' << 8) + 'I', + ICETraderLogout = ('U' << 16) + ('C' << 8) + 'H', + ICETraderLogoutResponse = ('U' << 16) + ('C' << 8) + 'J', + }; -}} +} +} // namespace bts diff --git a/src/lib/jetfix/codec/ReaderCursor.h b/src/lib/jetfix/codec/ReaderCursor.h index 7a56e650d..a9b3abc56 100644 --- a/src/lib/jetfix/codec/ReaderCursor.h +++ b/src/lib/jetfix/codec/ReaderCursor.h @@ -1,35 +1,26 @@ #pragma once -#include #include "lib/utils/bts_assert.h" +#include namespace bts { namespace jetfix { -class ReaderCursor -{ -public: - ReaderCursor (std::string const &data) : _in_tag (true), - _data (data.data ()), - _idx (0), - _size (data.size ()), - _previous_tag (0) - {} +class ReaderCursor { + public: + ReaderCursor(std::string const &data) + : _in_tag(true), _data(data.data()), _idx(0), _size(data.size()), + _previous_tag(0) {} - ReaderCursor (const char*data, size_t sz) : _in_tag (true), - _data (data), - _idx (0), - _size (sz), - _previous_tag (0) - {} + ReaderCursor(const char *data, size_t sz) + : _in_tag(true), _data(data), _idx(0), _size(sz), _previous_tag(0) {} - uint32_t read_tag () - { - bts_assert (_in_tag); + uint32_t read_tag() { + bts_assert(_in_tag); _previous_tag = _idx; size_t tag = 0; while (_data[_idx] != '=') { - tag = (tag*10) + _data[_idx]-'0'; + tag = (tag * 10) + _data[_idx] - '0'; _idx++; } _idx++; @@ -37,36 +28,34 @@ public: return tag; } - std::pair read_field () - { - bts_assert (!_in_tag); - std::pair result (_idx,0); - while (_data[_idx] != 1) + std::pair read_field() { + bts_assert(!_in_tag); + std::pair result(_idx, 0); + while (_data[_idx] != 1) _idx++; result.second = _idx - result.first; _idx++; _in_tag = true; return result; } - - const char* data () const {return _data;} - void unread_tag () - { - bts_assert (_idx != 0); + const char *data() const { return _data; } + + void unread_tag() { + bts_assert(_idx != 0); _idx = _previous_tag; _in_tag = true; } - bool eof () - {return _idx == _size;} + bool eof() { return _idx == _size; } -private: + private: bool _in_tag; - const char* _data; + const char *_data; size_t _idx; size_t _size; size_t _previous_tag; }; -}} +} // namespace jetfix +} // namespace bts diff --git a/src/lib/jetfix/codec/WriterCursor.h b/src/lib/jetfix/codec/WriterCursor.h index ca84e7490..c20ca5a15 100644 --- a/src/lib/jetfix/codec/WriterCursor.h +++ b/src/lib/jetfix/codec/WriterCursor.h @@ -1,163 +1,140 @@ #pragma once -#include -#include "lib/utils/bts_assert.h" -#include "lib/jetfix/codec/i32_toa.h" #include "lib/jetfix/codec/f_toa.h" +#include "lib/jetfix/codec/i32_toa.h" +#include "lib/utils/bts_assert.h" +#include namespace bts { namespace jetfix { -template -class WriterCursorT -{ -public: - typedef std::pair Loc; +template class WriterCursorT { + public: + typedef std::pair Loc; - WriterCursorT (const WriterCursorT &) = delete; - WriterCursorT (std::string &data, uint32_t cursor=0) : _data (&data),_cursor (cursor) {} - ~WriterCursorT () {reset ();} - WriterCursorT& operator=(const WriterCursorT &) = delete; - - void reassign (std::string &data, uint32_t cursor) - { + WriterCursorT(const WriterCursorT &) = delete; + WriterCursorT(std::string &data, uint32_t cursor = 0) + : _data(&data), _cursor(cursor) {} + ~WriterCursorT() { reset(); } + WriterCursorT &operator=(const WriterCursorT &) = delete; + + void reassign(std::string &data, uint32_t cursor) { _data = &data; _cursor = cursor; } - - void reset () - { + + void reset() { if (_cursor > 0) { - _data->resize (_cursor); + _data->resize(_cursor); _cursor = 0; } } - - void tidy () - { + + void tidy() { if (_cursor > 0) { - _data->resize (_cursor); + _data->resize(_cursor); } } - - void need (size_t n) const - { - if (_cursor + n > _data->size ()) - _data->resize (2*(_cursor + n)); + + void need(size_t n) const { + if (_cursor + n > _data->size()) + _data->resize(2 * (_cursor + n)); } - uint32_t pos () const - {return _cursor;} - - size_t free_bytes () const - { return _data->size () - _cursor;} - - void write_tag (const char *tag, size_t len) - { - write_bytes (tag,len); - *data (_cursor-1) ='='; + uint32_t pos() const { return _cursor; } + + size_t free_bytes() const { return _data->size() - _cursor; } + + void write_tag(const char *tag, size_t len) { + write_bytes(tag, len); + *data(_cursor - 1) = '='; } - void append (WriterCursorT const &src) - { - need (src.pos ()); - memcpy (data (_cursor), - src._data->data (), - src.pos ()); - _cursor+=src.pos (); + void append(WriterCursorT const &src) { + need(src.pos()); + memcpy(data(_cursor), src._data->data(), src.pos()); + _cursor += src.pos(); } - template - inline void append (A const&a) - { - need (a.size ()); - memcpy (data (_cursor), - &a[0], - a.size ()); - _cursor += a.size (); + template inline void append(A const &a) { + need(a.size()); + memcpy(data(_cursor), &a[0], a.size()); + _cursor += a.size(); } - - std::pair write_bytes (const char *from, size_t count) - { - bts_assert_d (free_bytes () >= count + 1); - memcpy (data (_cursor),from,count); - Loc result (_cursor,count); + + std::pair write_bytes(const char *from, size_t count) { + bts_assert_d(free_bytes() >= count + 1); + memcpy(data(_cursor), from, count); + Loc result(_cursor, count); _cursor += count; - *data (_cursor)=1; + *data(_cursor) = 1; _cursor++; return result; } - void overwrite_bytes (Loc l, char const*from, size_t count) - { - bts_assert (l.second == count); - bts_assert (l.first + count < _cursor); - memcpy (data (l.first),from,count); + void overwrite_bytes(Loc l, char const *from, size_t count) { + bts_assert(l.second == count); + bts_assert(l.first + count < _cursor); + memcpy(data(l.first), from, count); } - - std::pair write_float (float f, int pad) - { + + std::pair write_float(float f, int pad) { Loc loc; loc.first = _cursor; - auto written = f_toa (f,data (_cursor),_data->size ()-_cursor,pad); + auto written = f_toa(f, data(_cursor), _data->size() - _cursor, pad); _cursor += written; - bts_assert (free_bytes ()>0); - *data (_cursor) = 1; + bts_assert(free_bytes() > 0); + *data(_cursor) = 1; _cursor++; loc.second = _cursor - loc.first - 1; return loc; } - void overwrite_float (Loc l,float f, int pad) - { - bts_assert (l.first + l.second < _cursor); - auto written = f_toa (f,data (l.first),l.second+1,pad); - *data (l.first+l.second) = 1; - bts_assert (written == (int) l.second); - } - - std::pair write_byte (char byte) - { - bts_assert (_cursor < _data->size ()); - *data (_cursor++)=byte; - *data (_cursor++)=1; - return Loc (_cursor-2,1); + void overwrite_float(Loc l, float f, int pad) { + bts_assert(l.first + l.second < _cursor); + auto written = f_toa(f, data(l.first), l.second + 1, pad); + *data(l.first + l.second) = 1; + bts_assert(written == (int)l.second); } - void overwrite_byte (Loc l,char byte) - { - bts_assert (l.first < _cursor); - *data (l.first)=byte; + std::pair write_byte(char byte) { + bts_assert(_cursor < _data->size()); + *data(_cursor++) = byte; + *data(_cursor++) = 1; + return Loc(_cursor - 2, 1); } - - std::pair write_int (int32_t i,int pad) - { + + void overwrite_byte(Loc l, char byte) { + bts_assert(l.first < _cursor); + *data(l.first) = byte; + } + + std::pair write_int(int32_t i, int pad) { Loc loc; loc.first = _cursor; - auto written = i32_toa (i,data (_cursor),pad); + auto written = i32_toa(i, data(_cursor), pad); _cursor += written; - bts_assert (free_bytes ()>0); - *data (_cursor)=1; + bts_assert(free_bytes() > 0); + *data(_cursor) = 1; _cursor++; loc.second = _cursor - loc.first - 1; return loc; } - void overwrite_int (Loc l,int32_t i,int pad) - { - bts_assert (l.first + l.second < _cursor); - auto written = i32_toa (i,data (l.first),pad); - *data (l.first+l.second) = 1; - bts_assert (written == (int) l.second); + void overwrite_int(Loc l, int32_t i, int pad) { + bts_assert(l.first + l.second < _cursor); + auto written = i32_toa(i, data(l.first), pad); + *data(l.first + l.second) = 1; + bts_assert(written == (int)l.second); } -private: - inline char *data (size_t i) - {return ((char*) (_data->data ()) + i);} + private: + inline char *data(size_t i) { return ((char *)(_data->data()) + i); } Storage *_data; uint32_t _cursor; }; typedef WriterCursorT WriterCursor; -}} +} // namespace jetfix +} // namespace bts diff --git a/src/lib/jetfix/codec/f_toa.h b/src/lib/jetfix/codec/f_toa.h index ed6d8bb65..121685a49 100644 --- a/src/lib/jetfix/codec/f_toa.h +++ b/src/lib/jetfix/codec/f_toa.h @@ -7,7 +7,9 @@ namespace bts { -inline int d_toa(double n, char *buffer, size_t buffer_size, int decimal_digits=-1, int pad = -1) { +inline int d_toa( + 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(); @@ -17,19 +19,17 @@ inline int d_toa(double n, char *buffer, size_t buffer_size, int decimal_digits= // no padding, return the smallest number that contains all the // specified digits double_conversion::StringBuilder builder(buffer, buffer_size); - - if (decimal_digits == -1 ) { - if (c.ToShortest(n,&builder)) + + if (decimal_digits == -1) { + if (c.ToShortest(n, &builder)) return builder.position(); - } - else { - if(c.ToFixed(n,decimal_digits,&builder)) + } else { + if (c.ToFixed(n, decimal_digits, &builder)) return builder.position(); } buffer[0] = 0; return 0; - } - else { + } else { // padding, return something with a fixed size @@ -37,35 +37,34 @@ inline int d_toa(double n, char *buffer, size_t buffer_size, int decimal_digits= bts_assert((int)buffer_size > pad); bts_assert((int)pre_buffer.size() >= pad); - double_conversion::StringBuilder builder(&pre_buffer[0], pre_buffer.size()); + double_conversion::StringBuilder builder( + &pre_buffer[0], pre_buffer.size()); auto ok = false; - if (decimal_digits == -1) - ok = c.ToShortest(n,&builder); + if (decimal_digits == -1) + ok = c.ToShortest(n, &builder); else - ok = c.ToFixed(n,decimal_digits,&builder); - - if(ok) { + ok = c.ToFixed(n, decimal_digits, &builder); + + if (ok) { auto sz = builder.position(); if (sz < pad) { auto n_left_zeros = pad - sz; - memset(&buffer[0], '0',n_left_zeros); - memcpy(&buffer[n_left_zeros], &pre_buffer[0],sz); + memset(&buffer[0], '0', n_left_zeros); + memcpy(&buffer[n_left_zeros], &pre_buffer[0], sz); if (n < 0) { buffer[0] = '-'; buffer[n_left_zeros] = '0'; } - buffer[pad]=0; + buffer[pad] = 0; return pad; } } - for (int i = 0; i < pad;i++) + for (int i = 0; i < pad; i++) buffer[i] = ' '; buffer[pad] = 0; return pad; } } -} - - +} // namespace bts diff --git a/src/lib/jetfix/codec/i32_toa.h b/src/lib/jetfix/codec/i32_toa.h index afc257ebc..e47a5c1f8 100644 --- a/src/lib/jetfix/codec/i32_toa.h +++ b/src/lib/jetfix/codec/i32_toa.h @@ -1,5 +1,6 @@ // SSE2 implementation according to http://0x80.pl/articles/sse-itoa.html -// Modifications: (1) fix incorrect digits (2) accept all ranges (3) write to user provided buffer. +// Modifications: (1) fix incorrect digits (2) accept all ranges (3) write to +// user provided buffer. #pragma once @@ -16,46 +17,56 @@ #define ALIGN_SUF #else #define ALIGN_PRE -#define ALIGN_SUF __attribute__ ((aligned(16))) +#define ALIGN_SUF __attribute__((aligned(16))) #endif const char gDigitsLut[200] = { - '0','0','0','1','0','2','0','3','0','4','0','5','0','6','0','7','0','8','0','9', - '1','0','1','1','1','2','1','3','1','4','1','5','1','6','1','7','1','8','1','9', - '2','0','2','1','2','2','2','3','2','4','2','5','2','6','2','7','2','8','2','9', - '3','0','3','1','3','2','3','3','3','4','3','5','3','6','3','7','3','8','3','9', - '4','0','4','1','4','2','4','3','4','4','4','5','4','6','4','7','4','8','4','9', - '5','0','5','1','5','2','5','3','5','4','5','5','5','6','5','7','5','8','5','9', - '6','0','6','1','6','2','6','3','6','4','6','5','6','6','6','7','6','8','6','9', - '7','0','7','1','7','2','7','3','7','4','7','5','7','6','7','7','7','8','7','9', - '8','0','8','1','8','2','8','3','8','4','8','5','8','6','8','7','8','8','8','9', - '9','0','9','1','9','2','9','3','9','4','9','5','9','6','9','7','9','8','9','9' -}; + '0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5', '0', '6', '0', + '7', '0', '8', '0', '9', '1', '0', '1', '1', '1', '2', '1', '3', '1', '4', + '1', '5', '1', '6', '1', '7', '1', '8', '1', '9', '2', '0', '2', '1', '2', + '2', '2', '3', '2', '4', '2', '5', '2', '6', '2', '7', '2', '8', '2', '9', + '3', '0', '3', '1', '3', '2', '3', '3', '3', '4', '3', '5', '3', '6', '3', + '7', '3', '8', '3', '9', '4', '0', '4', '1', '4', '2', '4', '3', '4', '4', + '4', '5', '4', '6', '4', '7', '4', '8', '4', '9', '5', '0', '5', '1', '5', + '2', '5', '3', '5', '4', '5', '5', '5', '6', '5', '7', '5', '8', '5', '9', + '6', '0', '6', '1', '6', '2', '6', '3', '6', '4', '6', '5', '6', '6', '6', + '7', '6', '8', '6', '9', '7', '0', '7', '1', '7', '2', '7', '3', '7', '4', + '7', '5', '7', '6', '7', '7', '7', '8', '7', '9', '8', '0', '8', '1', '8', + '2', '8', '3', '8', '4', '8', '5', '8', '6', '8', '7', '8', '8', '8', '9', + '9', '0', '9', '1', '9', '2', '9', '3', '9', '4', '9', '5', '9', '6', '9', + '7', '9', '8', '9', '9'}; static const uint32_t kDiv10000 = 0xd1b71759; -ALIGN_PRE static const uint32_t kDiv10000Vector[4] ALIGN_SUF = { kDiv10000, kDiv10000, kDiv10000, kDiv10000 }; -ALIGN_PRE static const uint32_t k10000Vector[4] ALIGN_SUF = { 10000, 10000, 10000, 10000 }; -ALIGN_PRE static const uint16_t kDivPowersVector[8] ALIGN_SUF = { 8389, 5243, 13108, 32768, 8389, 5243, 13108, 32768 }; // 10^3, 10^2, 10^1, 10^0 +ALIGN_PRE static const uint32_t kDiv10000Vector[4] ALIGN_SUF = { + kDiv10000, kDiv10000, kDiv10000, kDiv10000}; +ALIGN_PRE static const uint32_t k10000Vector[4] ALIGN_SUF = { + 10000, 10000, 10000, 10000}; +ALIGN_PRE static const uint16_t kDivPowersVector[8] ALIGN_SUF = { + 8389, 5243, 13108, 32768, + 8389, 5243, 13108, 32768}; // 10^3, 10^2, 10^1, 10^0 ALIGN_PRE static const uint16_t kShiftPowersVector[8] ALIGN_SUF = { - 1 << (16 - (23 + 2 - 16)), - 1 << (16 - (19 + 2 - 16)), - 1 << (16 - 1 - 2), - 1 << (15), - 1 << (16 - (23 + 2 - 16)), - 1 << (16 - (19 + 2 - 16)), - 1 << (16 - 1 - 2), - 1 << (15) -}; -ALIGN_PRE static const uint16_t k10Vector[8] ALIGN_SUF = { 10, 10, 10, 10, 10, 10, 10, 10 }; -ALIGN_PRE static const char kAsciiZero[16] ALIGN_SUF = { '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0' }; + 1 << (16 - (23 + 2 - 16)), 1 << (16 - (19 + 2 - 16)), + 1 << (16 - 1 - 2), 1 << (15), + 1 << (16 - (23 + 2 - 16)), 1 << (16 - (19 + 2 - 16)), + 1 << (16 - 1 - 2), 1 << (15)}; +ALIGN_PRE static const uint16_t k10Vector[8] ALIGN_SUF = {10, 10, 10, 10, + 10, 10, 10, 10}; +ALIGN_PRE static const char kAsciiZero[16] ALIGN_SUF = { + '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0'}; inline __m128i Convert8DigitsSSE2(uint32_t value) { assert(value <= 99999999); - // abcd, efgh = abcdefgh divmod 10000 + // abcd, efgh = abcdefgh divmod 10000 const __m128i abcdefgh = _mm_cvtsi32_si128(value); - const __m128i abcd = _mm_srli_epi64(_mm_mul_epu32(abcdefgh, reinterpret_cast(kDiv10000Vector)[0]), 45); - const __m128i efgh = _mm_sub_epi32(abcdefgh, _mm_mul_epu32(abcd, reinterpret_cast(k10000Vector)[0])); + const __m128i abcd = _mm_srli_epi64( + _mm_mul_epu32( + abcdefgh, reinterpret_cast(kDiv10000Vector)[0]), + 45); + const __m128i efgh = _mm_sub_epi32( + abcdefgh, + _mm_mul_epu32(abcd, reinterpret_cast(k10000Vector)[0])); // v1 = [ abcd, efgh, 0, 0, 0, 0, 0, 0 ] const __m128i v1 = _mm_unpacklo_epi16(abcd, efgh); @@ -63,16 +74,21 @@ inline __m128i Convert8DigitsSSE2(uint32_t value) { // v1a = v1 * 4 = [ abcd * 4, efgh * 4, 0, 0, 0, 0, 0, 0 ] const __m128i v1a = _mm_slli_epi64(v1, 2); - // v2 = [ abcd * 4, abcd * 4, abcd * 4, abcd * 4, efgh * 4, efgh * 4, efgh * 4, efgh * 4 ] + // v2 = [ abcd * 4, abcd * 4, abcd * 4, abcd * 4, efgh * 4, efgh * 4, efgh * + // 4, efgh * 4 ] const __m128i v2a = _mm_unpacklo_epi16(v1a, v1a); const __m128i v2 = _mm_unpacklo_epi32(v2a, v2a); - // v4 = v2 div 10^3, 10^2, 10^1, 10^0 = [ a, ab, abc, abcd, e, ef, efg, efgh ] - const __m128i v3 = _mm_mulhi_epu16(v2, reinterpret_cast(kDivPowersVector)[0]); - const __m128i v4 = _mm_mulhi_epu16(v3, reinterpret_cast(kShiftPowersVector)[0]); + // v4 = v2 div 10^3, 10^2, 10^1, 10^0 = [ a, ab, abc, abcd, e, ef, efg, efgh + // ] + const __m128i v3 = _mm_mulhi_epu16( + v2, reinterpret_cast(kDivPowersVector)[0]); + const __m128i v4 = _mm_mulhi_epu16( + v3, reinterpret_cast(kShiftPowersVector)[0]); // v5 = v4 * 10 = [ a0, ab0, abc0, abcd0, e0, ef0, efg0, efgh0 ] - const __m128i v5 = _mm_mullo_epi16(v4, reinterpret_cast(k10Vector)[0]); + const __m128i v5 = + _mm_mullo_epi16(v4, reinterpret_cast(k10Vector)[0]); // v6 = v5 << 16 = [ 0, a0, ab0, abc0, 0, e0, ef0, efg0 ] const __m128i v6 = _mm_slli_epi64(v5, 16); @@ -86,25 +102,34 @@ inline __m128i Convert8DigitsSSE2(uint32_t value) { inline __m128i ShiftDigits_SSE2(__m128i a, unsigned digit) { assert(digit <= 8); switch (digit) { - case 0: return a; - case 1: return _mm_srli_si128(a, 1); - case 2: return _mm_srli_si128(a, 2); - case 3: return _mm_srli_si128(a, 3); - case 4: return _mm_srli_si128(a, 4); - case 5: return _mm_srli_si128(a, 5); - case 6: return _mm_srli_si128(a, 6); - case 7: return _mm_srli_si128(a, 7); - case 8: return _mm_srli_si128(a, 8); + case 0: + return a; + case 1: + return _mm_srli_si128(a, 1); + case 2: + return _mm_srli_si128(a, 2); + case 3: + return _mm_srli_si128(a, 3); + case 4: + return _mm_srli_si128(a, 4); + case 5: + return _mm_srli_si128(a, 5); + case 6: + return _mm_srli_si128(a, 6); + case 7: + return _mm_srli_si128(a, 7); + case 8: + return _mm_srli_si128(a, 8); } return a; // should not execute here. } -inline int u32_toa(uint32_t value, char* buffer) { +inline int u32_toa(uint32_t value, char *buffer) { char *start = buffer; if (value < 10000) { const uint32_t d1 = (value / 100) << 1; const uint32_t d2 = (value % 100) << 1; - + if (value >= 1000) *buffer++ = gDigitsLut[d1]; if (value >= 100) @@ -113,8 +138,7 @@ inline int u32_toa(uint32_t value, char* buffer) { *buffer++ = gDigitsLut[d2]; *buffer++ = gDigitsLut[d2 + 1]; *buffer++ = '\0'; - } - else if (value < 100000000) { + } else if (value < 100000000) { // value = bbbbcccc const uint32_t b = value / 10000; const uint32_t c = value % 10000; @@ -138,84 +162,100 @@ inline int u32_toa(uint32_t value, char* buffer) { *buffer++ = gDigitsLut[d4]; *buffer++ = gDigitsLut[d4 + 1]; *buffer++ = '\0'; - } - else { + } else { // value = aabbbbbbbb in decimal - + const uint32_t a = value / 100000000; // 1 to 42 value %= 100000000; - + if (a >= 10) { const unsigned i = a << 1; *buffer++ = gDigitsLut[i]; *buffer++ = gDigitsLut[i + 1]; - } - else + } else *buffer++ = '0' + static_cast(a); const __m128i b = Convert8DigitsSSE2(value); - const __m128i ba = _mm_add_epi8(_mm_packus_epi16(_mm_setzero_si128(), b), reinterpret_cast(kAsciiZero)[0]); + const __m128i ba = _mm_add_epi8( + _mm_packus_epi16(_mm_setzero_si128(), b), + reinterpret_cast(kAsciiZero)[0]); const __m128i result = _mm_srli_si128(ba, 8); - _mm_storel_epi64(reinterpret_cast<__m128i*>(buffer), result); + _mm_storel_epi64(reinterpret_cast<__m128i *>(buffer), result); buffer[8] = '\0'; - return buffer+8-start; + return buffer + 8 - start; } - return buffer-start-1; + return buffer - start - 1; } -inline int count_digits (int32_t value) -{ +inline int count_digits(int32_t value) { static auto P01 = 10u; - static auto P02 = P01*10; - static auto P03 = P02*10; - static auto P04 = P03*10; - static auto P05 = P04*10; - static auto P06 = P05*10; - static auto P07 = P06*10; - static auto P08 = P07*10; - static auto P09 = P08*10; + static auto P02 = P01 * 10; + static auto P03 = P02 * 10; + static auto P04 = P03 * 10; + static auto P05 = P04 * 10; + static auto P06 = P05 * 10; + static auto P07 = P06 * 10; + static auto P08 = P07 * 10; + static auto P09 = P08 * 10; uint32_t u = static_cast(value); - if (value < 0) + if (value < 0) u = ~u + 1; - if (u < P01) return 1; - if (u < P02) return 2; - if (u < P03) return 3; - if (u < P04) return 4; - if (u < P05) return 5; - if (u < P06) return 6; - if (u < P07) return 7; - if (u < P08) return 8; - if (u < P09) return 9; + if (u < P01) + return 1; + if (u < P02) + return 2; + if (u < P03) + return 3; + if (u < P04) + return 4; + if (u < P05) + return 5; + if (u < P06) + return 6; + if (u < P07) + return 7; + if (u < P08) + return 8; + if (u < P09) + return 9; return 10; } -inline int count_digits (uint32_t u) -{ +inline int count_digits(uint32_t u) { static auto P01 = 10u; - static auto P02 = P01*10; - static auto P03 = P02*10; - static auto P04 = P03*10; - static auto P05 = P04*10; - static auto P06 = P05*10; - static auto P07 = P06*10; - static auto P08 = P07*10; - static auto P09 = P08*10; + static auto P02 = P01 * 10; + static auto P03 = P02 * 10; + static auto P04 = P03 * 10; + static auto P05 = P04 * 10; + static auto P06 = P05 * 10; + static auto P07 = P06 * 10; + static auto P08 = P07 * 10; + static auto P09 = P08 * 10; - if (u < P01) return 1; - if (u < P02) return 2; - if (u < P03) return 3; - if (u < P04) return 4; - if (u < P05) return 5; - if (u < P06) return 6; - if (u < P07) return 7; - if (u < P08) return 8; - if (u < P09) return 9; + if (u < P01) + return 1; + if (u < P02) + return 2; + if (u < P03) + return 3; + if (u < P04) + return 4; + if (u < P05) + return 5; + if (u < P06) + return 6; + if (u < P07) + return 7; + if (u < P08) + return 8; + if (u < P09) + return 9; return 10; } -inline int i32_toa(int32_t value, char* buffer, int pad) { +inline int i32_toa(int32_t value, char *buffer, int pad) { auto start = buffer; uint32_t u = static_cast(value); if (value < 0) { @@ -223,235 +263,273 @@ inline int i32_toa(int32_t value, char* buffer, int pad) { u = ~u + 1; } if (pad) { - auto digits = count_digits (value); + auto digits = count_digits(value); auto offset = pad - digits; if (offset > 0) { auto start = buffer + offset; - while (buffer != start) - { - *buffer='0'; + while (buffer != start) { + *buffer = '0'; buffer++; } - } - else if (offset < 0) + } else if (offset < 0) return 0; } - return (buffer-start) + u32_toa(u, buffer); + return (buffer - start) + u32_toa(u, buffer); } -inline int u32_toa(uint32_t u, char* buffer, int pad) { +inline int u32_toa(uint32_t u, char *buffer, int pad) { auto start = buffer; if (pad) { - auto digits = count_digits (u); + auto digits = count_digits(u); auto offset = pad - digits; if (offset > 0) { auto start = buffer + offset; - while (buffer != start) - { - *buffer='0'; + while (buffer != start) { + *buffer = '0'; buffer++; } - } - else if (offset < 0) + } else if (offset < 0) return 0; } - return (buffer-start) + u32_toa(u, buffer); + return (buffer - start) + u32_toa(u, buffer); } +/// https://github.com/miloyip/itoa-benchmark -///https://github.com/miloyip/itoa-benchmark +#define BEGIN2(n) \ + do { \ + int t = (n); \ + if (t < 10) \ + *p++ = '0' + t; \ + else { \ + t *= 2; \ + *p++ = gDigitsLut[t]; \ + *p++ = gDigitsLut[t + 1]; \ + } \ + } while (0) +#define MIDDLE2(n) \ + do { \ + int t = (n)*2; \ + *p++ = gDigitsLut[t]; \ + *p++ = gDigitsLut[t + 1]; \ + } while (0) +#define BEGIN4(n) \ + do { \ + int t4 = (n); \ + if (t4 < 100) \ + BEGIN2(t4); \ + else { \ + BEGIN2(t4 / 100); \ + MIDDLE2(t4 % 100); \ + } \ + } while (0) +#define MIDDLE4(n) \ + do { \ + int t4 = (n); \ + MIDDLE2(t4 / 100); \ + MIDDLE2(t4 % 100); \ + } while (0) +#define BEGIN8(n) \ + do { \ + uint32_t t8 = (n); \ + if (t8 < 10000) \ + BEGIN4(t8); \ + else { \ + BEGIN4(t8 / 10000); \ + MIDDLE4(t8 % 10000); \ + } \ + } while (0) +#define MIDDLE8(n) \ + do { \ + uint32_t t8 = (n); \ + MIDDLE4(t8 / 10000); \ + MIDDLE4(t8 % 10000); \ + } while (0) +#define MIDDLE16(n) \ + do { \ + uint64_t t16 = (n); \ + MIDDLE8(t16 / 100000000); \ + MIDDLE8(t16 % 100000000); \ + } while (0) -#define BEGIN2(n) \ - do { \ - int t = (n); \ - if(t < 10) *p++ = '0' + t; \ - else { \ - t *= 2; \ - *p++ = gDigitsLut[t]; \ - *p++ = gDigitsLut[t + 1]; \ - } \ - } while(0) -#define MIDDLE2(n) \ - do { \ - int t = (n) * 2; \ - *p++ = gDigitsLut[t]; \ - *p++ = gDigitsLut[t + 1]; \ - } while(0) -#define BEGIN4(n) \ - do { \ - int t4 = (n); \ - if(t4 < 100) BEGIN2(t4); \ - else { BEGIN2(t4 / 100); MIDDLE2(t4 % 100); } \ - } while(0) -#define MIDDLE4(n) \ - do { \ - int t4 = (n); \ - MIDDLE2(t4 / 100); MIDDLE2(t4 % 100); \ - } while(0) -#define BEGIN8(n) \ - do { \ - uint32_t t8 = (n); \ - if(t8 < 10000) BEGIN4(t8); \ - else { BEGIN4(t8 / 10000); MIDDLE4(t8 % 10000); } \ - } while(0) -#define MIDDLE8(n) \ - do { \ - uint32_t t8 = (n); \ - MIDDLE4(t8 / 10000); MIDDLE4(t8 % 10000); \ - } while(0) -#define MIDDLE16(n) \ - do { \ - uint64_t t16 = (n); \ - MIDDLE8(t16 / 100000000); MIDDLE8(t16 % 100000000); \ - } while(0) - -inline int u64_toa(uint64_t value, char* p) -{ +inline int u64_toa(uint64_t value, char *p) { auto start = p; - if(value < 100000000) BEGIN8(value); - else if(value < 10000000000000000) { BEGIN8(value / 100000000); MIDDLE8(value % 100000000); } - else { BEGIN4(value / 10000000000000000); MIDDLE16(value % 10000000000000000); } - *p = 0; - return p-start; -} + if (value < 100000000) + BEGIN8(value); + else if (value < 10000000000000000) { + BEGIN8(value / 100000000); + MIDDLE8(value % 100000000); + } else { + BEGIN4(value / 10000000000000000); + MIDDLE16(value % 10000000000000000); + } + *p = 0; + return p - start; +} -inline int count_digits (int64_t value) -{ +inline int count_digits(int64_t value) { static auto P01 = 10ull; - static auto P02 = P01*10; - static auto P03 = P02*10; - static auto P04 = P03*10; - static auto P05 = P04*10; - static auto P06 = P05*10; - static auto P07 = P06*10; - static auto P08 = P07*10; - static auto P09 = P08*10; - static auto P10 = P09*10; - static auto P11 = P10*10; - static auto P12 = P11*10; - static auto P13 = P12*10; - static auto P14 = P13*10; - static auto P15 = P14*10; - static auto P16 = P15*10; - static auto P17 = P16*10; - static auto P18 = P17*10; - static auto P19 = P18*10; + static auto P02 = P01 * 10; + static auto P03 = P02 * 10; + static auto P04 = P03 * 10; + static auto P05 = P04 * 10; + static auto P06 = P05 * 10; + static auto P07 = P06 * 10; + static auto P08 = P07 * 10; + static auto P09 = P08 * 10; + static auto P10 = P09 * 10; + static auto P11 = P10 * 10; + static auto P12 = P11 * 10; + static auto P13 = P12 * 10; + static auto P14 = P13 * 10; + static auto P15 = P14 * 10; + static auto P16 = P15 * 10; + static auto P17 = P16 * 10; + static auto P18 = P17 * 10; + static auto P19 = P18 * 10; uint64_t u = static_cast(value); - if (value < 0) + if (value < 0) u = ~u + 1; - if (u < P01) return 1; - if (u < P02) return 2; - if (u < P03) return 3; - if (u < P04) return 4; - if (u < P05) return 5; - if (u < P06) return 6; - if (u < P07) return 7; - if (u < P08) return 8; - if (u < P09) return 9; - if (u < P10) return 10; - if (u < P11) return 11; - if (u < P12) return 12; - if (u < P13) return 13; - if (u < P14) return 14; - if (u < P15) return 15; - if (u < P16) return 16; - if (u < P17) return 17; - if (u < P18) return 18; - if (u < P19) return 19; + if (u < P01) + return 1; + if (u < P02) + return 2; + if (u < P03) + return 3; + if (u < P04) + return 4; + if (u < P05) + return 5; + if (u < P06) + return 6; + if (u < P07) + return 7; + if (u < P08) + return 8; + if (u < P09) + return 9; + if (u < P10) + return 10; + if (u < P11) + return 11; + if (u < P12) + return 12; + if (u < P13) + return 13; + if (u < P14) + return 14; + if (u < P15) + return 15; + if (u < P16) + return 16; + if (u < P17) + return 17; + if (u < P18) + return 18; + if (u < P19) + return 19; return 20; } -inline int count_digits (uint64_t u) -{ +inline int count_digits(uint64_t u) { static auto P01 = 10ull; - static auto P02 = P01*10; - static auto P03 = P02*10; - static auto P04 = P03*10; - static auto P05 = P04*10; - static auto P06 = P05*10; - static auto P07 = P06*10; - static auto P08 = P07*10; - static auto P09 = P08*10; - static auto P10 = P09*10; - static auto P11 = P10*10; - static auto P12 = P11*10; - static auto P13 = P12*10; - static auto P14 = P13*10; - static auto P15 = P14*10; - static auto P16 = P15*10; - static auto P17 = P16*10; - static auto P18 = P17*10; - static auto P19 = P18*10; + static auto P02 = P01 * 10; + static auto P03 = P02 * 10; + static auto P04 = P03 * 10; + static auto P05 = P04 * 10; + static auto P06 = P05 * 10; + static auto P07 = P06 * 10; + static auto P08 = P07 * 10; + static auto P09 = P08 * 10; + static auto P10 = P09 * 10; + static auto P11 = P10 * 10; + static auto P12 = P11 * 10; + static auto P13 = P12 * 10; + static auto P14 = P13 * 10; + static auto P15 = P14 * 10; + static auto P16 = P15 * 10; + static auto P17 = P16 * 10; + static auto P18 = P17 * 10; + static auto P19 = P18 * 10; - if (u < P01) return 1; - if (u < P02) return 2; - if (u < P03) return 3; - if (u < P04) return 4; - if (u < P05) return 5; - if (u < P06) return 6; - if (u < P07) return 7; - if (u < P08) return 8; - if (u < P09) return 9; - if (u < P10) return 10; - if (u < P11) return 11; - if (u < P12) return 12; - if (u < P13) return 13; - if (u < P14) return 14; - if (u < P15) return 15; - if (u < P16) return 16; - if (u < P17) return 17; - if (u < P18) return 18; - if (u < P19) return 19; + if (u < P01) + return 1; + if (u < P02) + return 2; + if (u < P03) + return 3; + if (u < P04) + return 4; + if (u < P05) + return 5; + if (u < P06) + return 6; + if (u < P07) + return 7; + if (u < P08) + return 8; + if (u < P09) + return 9; + if (u < P10) + return 10; + if (u < P11) + return 11; + if (u < P12) + return 12; + if (u < P13) + return 13; + if (u < P14) + return 14; + if (u < P15) + return 15; + if (u < P16) + return 16; + if (u < P17) + return 17; + if (u < P18) + return 18; + if (u < P19) + return 19; return 20; } -inline int i64_toa(int64_t value, char* buffer, int pad) -{ +inline int i64_toa(int64_t value, char *buffer, int pad) { auto start = buffer; uint64_t u = static_cast(value); if (value < 0) { *buffer++ = '-'; u = ~u + 1; } - if (pad) - { - auto digits = count_digits (value); + if (pad) { + auto digits = count_digits(value); auto offset = pad - digits; - if (offset > 0) - { + if (offset > 0) { auto start = buffer + offset; - while (buffer != start) - { - *buffer='0'; + while (buffer != start) { + *buffer = '0'; buffer++; } - } - else if (offset < 0) + } else if (offset < 0) return 0; } - return (buffer-start) + u64_toa(u, buffer); + return (buffer - start) + u64_toa(u, buffer); } -inline int u64_toa(uint64_t u, char* buffer, int pad) -{ +inline int u64_toa(uint64_t u, char *buffer, int pad) { auto start = buffer; - if (pad) - { - auto digits = count_digits (u); + if (pad) { + auto digits = count_digits(u); auto offset = pad - digits; - if (offset > 0) - { + if (offset > 0) { auto start = buffer + offset; - while (buffer != start) - { - *buffer='0'; + while (buffer != start) { + *buffer = '0'; buffer++; } - } - else if (offset < 0) + } else if (offset < 0) return 0; } - return (buffer-start) + u64_toa(u, buffer); + return (buffer - start) + u64_toa(u, buffer); } \ No newline at end of file diff --git a/src/lib/jetfix/codec/sum_bytes.h b/src/lib/jetfix/codec/sum_bytes.h index 4b4947c59..4822b99fb 100644 --- a/src/lib/jetfix/codec/sum_bytes.h +++ b/src/lib/jetfix/codec/sum_bytes.h @@ -5,12 +5,12 @@ namespace bts { namespace jetfix { -inline uint32_t sum_bytes (const char*in_buffer,uint32_t buffer_sz) -{ - uint32_t result =0; - for (size_t i =0; i< buffer_sz;i++) - result+=in_buffer[i]; +inline uint32_t sum_bytes(const char *in_buffer, uint32_t buffer_sz) { + uint32_t result = 0; + for (size_t i = 0; i < buffer_sz; i++) + result += in_buffer[i]; return result; } -}} +} // namespace jetfix +} // namespace bts diff --git a/src/lib/jetfix/common/InMsgBuffer.h b/src/lib/jetfix/common/InMsgBuffer.h index bd1c76f9f..ef0bb68ef 100644 --- a/src/lib/jetfix/common/InMsgBuffer.h +++ b/src/lib/jetfix/common/InMsgBuffer.h @@ -1,12 +1,12 @@ #pragma once -#include -#include -#include -#include -#include "lib/utils/bts_assert.h" #include "lib/jetfix/codec/MessageTypes.h" #include "lib/tracing/PerfLog.h" +#include "lib/utils/bts_assert.h" +#include +#include +#include +#include namespace bts { namespace jetfix { @@ -14,35 +14,26 @@ namespace jetfix { // holds the location and size of a single raw FIX message inside a // shared buffer. allows rudimentary parsing for key fields. -class InMsgBuffer -{ -public: - InMsgBuffer () : _data (),_size (),_type (),_buffer (),_trace() {} - InMsgBuffer (InMsgBuffer const&src) : _data (src._data), - _size (src._size), - _type (src._type), - _buffer (src._buffer), - _trace(src._trace) - {} +class InMsgBuffer { + public: + InMsgBuffer() : _data(), _size(), _type(), _buffer(), _trace() {} + InMsgBuffer(InMsgBuffer const &src) + : _data(src._data), _size(src._size), _type(src._type), + _buffer(src._buffer), _trace(src._trace) {} - InMsgBuffer (std::string const &data) : _data (),_size (),_type (),_buffer (),_trace() - { - _buffer = std::make_shared (data); - _data = _buffer->data (); - _size = _buffer->size (); - _type = get_type (); + InMsgBuffer(std::string const &data) + : _data(), _size(), _type(), _buffer(), _trace() { + _buffer = std::make_shared(data); + _data = _buffer->data(); + _size = _buffer->size(); + _type = get_type(); } - - InMsgBuffer (const char*data, size_t sz, std::shared_ptr const &buffer) - : _data (data), - _size (sz), - _type (get_type ()), - _buffer (buffer), - _trace() - {} - InMsgBuffer &operator=(InMsgBuffer const&msg) - { + InMsgBuffer( + const char *data, size_t sz, std::shared_ptr const &buffer) + : _data(data), _size(sz), _type(get_type()), _buffer(buffer), _trace() {} + + InMsgBuffer &operator=(InMsgBuffer const &msg) { _data = msg._data; _size = msg._size; _type = msg._type; @@ -51,133 +42,124 @@ public: return *this; } - const char*data () const - {return _data;} + const char *data() const { return _data; } - size_t size () const - {return _size;} + size_t size() const { return _size; } - std::string to_str () const - { - return std::string (_data,_size); + std::string to_str() const { return std::string(_data, _size); } + + MessageTypes type() const { return _type; } + + uint32_t get_seq_num() const { + return get_uint_field("\00134=", sizeof("\00134=") - 1); } - - MessageTypes type () const - {return _type;} - uint32_t get_seq_num () const - {return get_uint_field ("\00134=",sizeof("\00134=")-1);} - - uint32_t get_last_seq_num_processed () const - {return get_uint_field ("\001369=",sizeof("\001369=")-1);} - - uint32_t get_new_seq_no () const - {return get_uint_field ("\00136=",sizeof("\00136=")-1);} - - uint32_t get_begin_seq_no () const - {return get_uint_field ("\0017=",sizeof("\0017=")-1);} - - uint32_t get_end_seq_no () const - {return get_uint_field ("\00116=",sizeof("\00116=")-1);} - - bool get_poss_dup_flag () const - {return get_uint_field ("\00143=",sizeof("\00143=")-1)=='Y';} - bool has_poss_dup_flag_flag () const - { - auto loc = - find_field ("\00143=",sizeof("\00143=")-1); - return loc.first != nullptr; + uint32_t get_last_seq_num_processed() const { + return get_uint_field("\001369=", sizeof("\001369=") - 1); } - - bool has_test_req_id () const - { - auto loc = - find_field ("\001112=",sizeof("\001112=")-1); + + uint32_t get_new_seq_no() const { + return get_uint_field("\00136=", sizeof("\00136=") - 1); + } + + uint32_t get_begin_seq_no() const { + return get_uint_field("\0017=", sizeof("\0017=") - 1); + } + + uint32_t get_end_seq_no() const { + return get_uint_field("\00116=", sizeof("\00116=") - 1); + } + + bool get_poss_dup_flag() const { + return get_uint_field("\00143=", sizeof("\00143=") - 1) == 'Y'; + } + bool has_poss_dup_flag_flag() const { + auto loc = find_field("\00143=", sizeof("\00143=") - 1); return loc.first != nullptr; } - bool has_text () const - { - auto loc = - find_field ("\00158=",sizeof("\00158=")-1); + bool has_test_req_id() const { + auto loc = find_field("\001112=", sizeof("\001112=") - 1); return loc.first != nullptr; } - std::string get_text () const - { - if (has_text ()) - return get_string_field ("\00158=",sizeof("\00158=")-1); + bool has_text() const { + auto loc = find_field("\00158=", sizeof("\00158=") - 1); + return loc.first != nullptr; + } + + std::string get_text() const { + if (has_text()) + return get_string_field("\00158=", sizeof("\00158=") - 1); else return ""; } - std::string get_test_req_id () const - {return get_string_field ("\001112=",sizeof("\001112=")-1);} + std::string get_test_req_id() const { + return get_string_field("\001112=", sizeof("\001112=") - 1); + } - trace::CorID const&trace() const {return _trace;} + trace::CorID const &trace() const { return _trace; } - void set_trace(trace::CorID const&t) {_trace = t;} - -private: + void set_trace(trace::CorID const &t) { _trace = t; } + + private: const char *_data; size_t _size; MessageTypes _type; std::shared_ptr _buffer; trace::CorID _trace; - - MessageTypes get_type () const - { - auto loc = find_field ("\00135=",sizeof("\00135=")-1); - bts_assert (loc.first); + + MessageTypes get_type() const { + auto loc = find_field("\00135=", sizeof("\00135=") - 1); + bts_assert(loc.first); uint32_t result = 0; for (auto i = 0ul; i < loc.second; i++) { result *= 256; - result += *(loc.first+i); + result += *(loc.first + i); } - return (MessageTypes) result; + return (MessageTypes)result; } - - uint32_t get_uint_field (const char *field, size_t field_sz) const - { - auto loc = find_field (field,field_sz); - bts_assert (loc.first); + + uint32_t get_uint_field(const char *field, size_t field_sz) const { + auto loc = find_field(field, field_sz); + bts_assert(loc.first); uint32_t result = 0; for (auto i = 0ul; i < loc.second; i++) { result *= 10; - result += *(loc.first+i) - '0'; + result += *(loc.first + i) - '0'; } return result; } - - std::string get_string_field (const char *field, size_t field_sz) const - { - auto loc = find_field (field,field_sz); - bts_assert (loc.first); - return std::string (loc.first,loc.second); + + std::string get_string_field(const char *field, size_t field_sz) const { + auto loc = find_field(field, field_sz); + bts_assert(loc.first); + return std::string(loc.first, loc.second); } - std::pair find_field (const char*fn,size_t field_sz) const - { - auto begin = data (); - auto end = begin + size (); + std::pair + find_field(const char *fn, size_t field_sz) const { + auto begin = data(); + auto end = begin + size(); while (begin != end) { - auto it = std::find (begin,end,*fn); - if (it == end || (end - it) < (int) field_sz) + auto it = std::find(begin, end, *fn); + if (it == end || (end - it) < (int)field_sz) break; - else if (memcmp (it,fn,field_sz) == 0) { + else if (memcmp(it, fn, field_sz) == 0) { // found it it += field_sz; auto field_start = it; - auto field_stop = std::find (field_start,end,1); - bts_assert (field_stop != end); - return std::make_pair (field_start, field_stop - field_start); - } - else + auto field_stop = std::find(field_start, end, 1); + bts_assert(field_stop != end); + return std::make_pair(field_start, field_stop - field_start); + } else begin++; } - return std::make_pair (nullptr,0); + return std::make_pair(nullptr, 0); } }; -}} +} // namespace jetfix +} // namespace bts diff --git a/src/lib/jetfix/common/JetFIXError.h b/src/lib/jetfix/common/JetFIXError.h index dc955a163..9955d77db 100644 --- a/src/lib/jetfix/common/JetFIXError.h +++ b/src/lib/jetfix/common/JetFIXError.h @@ -5,9 +5,8 @@ namespace bts { namespace jetfix { -class JetFIXError -{ -public: +class JetFIXError { + public: enum Code { ERROR_NONE, LOGIN_TIMEOUT, @@ -24,39 +23,26 @@ public: USER_DISCONNECTED }; - JetFIXError () : - _error_code (JetFIXError::ERROR_NONE), - _msg () - {} + JetFIXError() : _error_code(JetFIXError::ERROR_NONE), _msg() {} - JetFIXError (const JetFIXError &src) : - _error_code (src._error_code), - _msg (src._msg) - {} + JetFIXError(const JetFIXError &src) + : _error_code(src._error_code), _msg(src._msg) {} - JetFIXError (JetFIXError::Code error_code, - std::string const&msg) : - _error_code (error_code), - _msg (msg) - {} + JetFIXError(JetFIXError::Code error_code, std::string const &msg) + : _error_code(error_code), _msg(msg) {} - JetFIXError &operator=(const JetFIXError &rhs) - { + JetFIXError &operator=(const JetFIXError &rhs) { _error_code = rhs._error_code; _msg = rhs._msg; return *this; } - - Code error () const - {return _error_code;} - std::string const &msg () const - {return _msg;} - - static const char* code_msg (JetFIXError::Code error_code) - { - switch (error_code) - { + Code error() const { return _error_code; } + + std::string const &msg() const { return _msg; } + + static const char *code_msg(JetFIXError::Code error_code) { + switch (error_code) { case ERROR_NONE: return "No error"; case LOGIN_TIMEOUT: @@ -84,15 +70,14 @@ public: case USER_DISCONNECTED: return "Disconnected by user request"; default: - bts_assert (false); + bts_assert(false); } } - -private: + private: Code _error_code; std::string _msg; }; - -}} +} // namespace jetfix +} // namespace bts diff --git a/src/lib/jetfix/common/OutFIX.cpp b/src/lib/jetfix/common/OutFIX.cpp index 3bf96b68e..8fb37c858 100644 --- a/src/lib/jetfix/common/OutFIX.cpp +++ b/src/lib/jetfix/common/OutFIX.cpp @@ -2,7 +2,6 @@ #include "OutFIX.h" namespace bts { -namespace bluestream { - -}} +namespace bluestream {} +} // namespace bts #endif diff --git a/src/lib/jetfix/common/OutFIX.h b/src/lib/jetfix/common/OutFIX.h index 8da72aaac..11bbd9c4d 100644 --- a/src/lib/jetfix/common/OutFIX.h +++ b/src/lib/jetfix/common/OutFIX.h @@ -1,8 +1,8 @@ #pragma once -#include -#include "lib/utils/TimeStamp.h" #include "lib/jetfix/codec/FIXEncodingStream.h" +#include "lib/utils/TimeStamp.h" +#include #include "lib/config/protos/jetfix.pb.h" @@ -10,25 +10,22 @@ namespace bts { namespace jetfix { class FIXEncodingStream; -}} +} +} // namespace bts namespace bts { namespace jetfix { // a vector of FIX messages intended for transmission to the outside -class OutFIX -{ -public: +class OutFIX { + public: OutFIX(config::JetFIX::Connection const &cfg, size_t n_streams = 1) - : timestamps (), - fix () - { - fix.reserve (n_streams); - for (size_t i = 0; i < n_streams;i++) - fix.emplace_back (cfg); + : timestamps(), fix() { + fix.reserve(n_streams); + for (size_t i = 0; i < n_streams; i++) + fix.emplace_back(cfg); } - enum TimePoint { MD_WRITE_TS, JF_ARRIVE, @@ -40,23 +37,23 @@ public: LAST }; - utils::TimeStamp get_ts (TimePoint tp) - {return timestamps[(int)tp];} + utils::TimeStamp get_ts(TimePoint tp) { return timestamps[(int)tp]; } - void set_ts (TimePoint ts, utils::TimeStamp t) - {timestamps[(int)ts] = t;} + void set_ts(TimePoint ts, utils::TimeStamp t) { timestamps[(int)ts] = t; } - std::array timestamps; + std::array timestamps; std::vector fix; - jetfix::FIXEncodingStream& first_stream() {bts_assert (fix.size()); return fix[0];} + jetfix::FIXEncodingStream &first_stream() { + bts_assert(fix.size()); + return fix[0]; + } void close_all() { for (auto &s : fix) s.close(); } - }; -}} - +} // namespace jetfix +} // namespace bts diff --git a/src/lib/jetfix/common/OutFIXPtr.h b/src/lib/jetfix/common/OutFIXPtr.h index 621621a68..8b5464f42 100644 --- a/src/lib/jetfix/common/OutFIXPtr.h +++ b/src/lib/jetfix/common/OutFIXPtr.h @@ -6,4 +6,5 @@ namespace bts { namespace jetfix { class OutFIX; typedef std::shared_ptr OutFIXPtr; -}} +} // namespace jetfix +} // namespace bts diff --git a/src/lib/jetfix/common/OutMsgVecPtr.h b/src/lib/jetfix/common/OutMsgVecPtr.h index 41355deec..98258fcd9 100644 --- a/src/lib/jetfix/common/OutMsgVecPtr.h +++ b/src/lib/jetfix/common/OutMsgVecPtr.h @@ -5,9 +5,11 @@ namespace bts { namespace jetfix { class FIXEncodingStream; -}} +} +} // namespace bts namespace bts { namespace jetfix { typedef std::shared_ptr> OutMsgVecPtr; -}} +} +} // namespace bts diff --git a/src/lib/jetfix/connection/AsyncReader.cpp b/src/lib/jetfix/connection/AsyncReader.cpp index 9bc48a806..240467bbc 100644 --- a/src/lib/jetfix/connection/AsyncReader.cpp +++ b/src/lib/jetfix/connection/AsyncReader.cpp @@ -17,12 +17,12 @@ namespace jetfix { // frame FIX messages contained in a raw buffer, storing their // location in a vector InMsgBuffer. Returns how many bytes were // successfully framed. -size_t extract(char *start, char *end, - std::shared_ptr const &buffer, - std::vector *msgs) { +size_t extract( + char *start, char *end, std::shared_ptr const &buffer, + std::vector *msgs) { auto first_unprocessed_byte = 0; auto current = start; - + for (;;) { // consume prefix auto this_msg_begin = current; @@ -63,9 +63,10 @@ size_t extract(char *start, char *end, } struct AsyncReader::PImpl { - PImpl(IConnection &connection, std::string const &connection_name, - ICoreGatewayEventSink &sink, trace::PerfLog &l, size_t buffer_sz, - size_t high_water_mark) + PImpl( + 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)), first_pending_msg(0), write_cursor(0), reader_thread(), sink(sink), @@ -99,12 +100,13 @@ struct AsyncReader::PImpl { const std::string *channel; }; -AsyncReader::AsyncReader(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)) {} +AsyncReader::AsyncReader( + 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)) { +} void AsyncReader::start() { auto thread_name = fmt::format("jf_ar_{}", me->connection_name); @@ -156,7 +158,7 @@ void AsyncReader::dispatch() { for (auto &msg : framed_msgs) { trace.sn = msg.get_seq_num(); socket_read_time.shift_ns(1); - me->perf_log.log(trace, socket_read_time,"fix_msg_r"); + me->perf_log.log(trace, socket_read_time, "fix_msg_r"); msg.set_trace(trace); me->sink.in_msg_raw(msg); } @@ -169,8 +171,9 @@ void AsyncReader::dispatch() { me->working_buffer = std::make_shared( std::max(2 * pending_size, me->working_buffer->size()), 0); - memcpy(&((*me->working_buffer)[0]), - &((*old_buffer)[me->first_pending_msg]), pending_size); + memcpy( + &((*me->working_buffer)[0]), + &((*old_buffer)[me->first_pending_msg]), pending_size); me->first_pending_msg = 0; me->write_cursor = pending_size; } diff --git a/src/lib/jetfix/connection/AsyncReader.h b/src/lib/jetfix/connection/AsyncReader.h index 5ef506a28..ddd01197b 100644 --- a/src/lib/jetfix/connection/AsyncReader.h +++ b/src/lib/jetfix/connection/AsyncReader.h @@ -3,7 +3,9 @@ #include namespace bts { -namespace trace {class PerfLog;} +namespace trace { +class PerfLog; +} namespace jetfix { class IConnection; @@ -11,25 +13,24 @@ class ICoreGatewayEventSink; // frames FIX messages from a byte stream (IConnection) and delivers // these to an event sync (ICoreGatewayEventSink) -class AsyncReader -{ -public: - AsyncReader(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 (); +class AsyncReader { + public: + AsyncReader( + 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(); ~AsyncReader(); -private: + private: friend struct AsyncReaderTests; - char *cursor (); - size_t free_bytes (); - void dispatch (); + char *cursor(); + size_t free_bytes(); + void dispatch(); struct PImpl; std::unique_ptr me; }; -}} +} // namespace jetfix +} // namespace bts diff --git a/src/lib/jetfix/connection/IConnection.h b/src/lib/jetfix/connection/IConnection.h index ab8b9b214..00e844614 100644 --- a/src/lib/jetfix/connection/IConnection.h +++ b/src/lib/jetfix/connection/IConnection.h @@ -3,19 +3,22 @@ #include namespace bts { -namespace trace {struct CorID;} +namespace trace { +struct CorID; +} namespace jetfix { -class IConnection -{ -public: - typedef std::array,64> WriteVec; +class IConnection { + public: + typedef std::array, 64> WriteVec; static auto constexpr MaxWriteVecSz = std::tuple_size::value; - virtual bool connect () = 0; - virtual void shutdown () = 0; - virtual int read (char* to_buffer,size_t read_count) = 0; - virtual int write (WriteVec const&vec,size_t vec_size,trace::CorID trace) = 0; - virtual ~IConnection() {}; + virtual bool connect() = 0; + virtual void shutdown() = 0; + virtual int read(char *to_buffer, size_t read_count) = 0; + virtual int + write(WriteVec const &vec, size_t vec_size, trace::CorID trace) = 0; + virtual ~IConnection(){}; }; -}} +} // namespace jetfix +} // namespace bts diff --git a/src/lib/jetfix/connection/IConnectionObserver.h b/src/lib/jetfix/connection/IConnectionObserver.h index 0179d02e7..f07965b39 100644 --- a/src/lib/jetfix/connection/IConnectionObserver.h +++ b/src/lib/jetfix/connection/IConnectionObserver.h @@ -8,15 +8,15 @@ class IncomingMsg; class RawMsg; typedef std::shared_ptr> MsgVecPtr; -class IConnectionObserver -{ -public: - virtual ~IConnectionObserver() {}; - virtual void on_connection_error () = 0; - virtual void on_connection_sync_ack () = 0; - virtual void on_connection_close_ack () = 0; - virtual void on_rcvd (IncomingMsg const &msg) = 0; - virtual void on_sent (MsgVecPtr const &msg) = 0; +class IConnectionObserver { + public: + virtual ~IConnectionObserver(){}; + virtual void on_connection_error() = 0; + virtual void on_connection_sync_ack() = 0; + virtual void on_connection_close_ack() = 0; + virtual void on_rcvd(IncomingMsg const &msg) = 0; + virtual void on_sent(MsgVecPtr const &msg) = 0; }; -}} +} // namespace jetfix +} // namespace bts diff --git a/src/lib/jetfix/connection/SocketConnection.cpp b/src/lib/jetfix/connection/SocketConnection.cpp index b70a58991..14f18541d 100644 --- a/src/lib/jetfix/connection/SocketConnection.cpp +++ b/src/lib/jetfix/connection/SocketConnection.cpp @@ -1,11 +1,11 @@ #include "SocketConnection.h" #include "lib/jetfix/store/session_name.h" #include "lib/logging/logging.h" +#include "lib/tracing/PerfLog.h" #include "lib/tracing/bts_trace.h" #include "lib/utils/TimeStamp.h" #include "lib/utils/bts_assert.h" #include "lib/utils/helper_macros.h" -#include "lib/tracing/PerfLog.h" #include #include @@ -18,15 +18,17 @@ namespace bts { namespace jetfix { -SocketConnection::SocketConnection(bts::config::JetFIX::Connection const &cfg, - trace::PerfLog &perf_log) +SocketConnection::SocketConnection( + bts::config::JetFIX::Connection const &cfg, trace::PerfLog &perf_log) : _fd(-1), _cfg(cfg), _log(cfg.log_fix_stream()), _in_log(), _out_log(), _perf_log(perf_log) { if (_log) { - _in_log.open(std::string("/tmp/fix_raw_read_log_") + session_name(cfg).as_string, - std::ios_base::app); - _out_log.open(std::string("/tmp/fix_raw_write_log_") + session_name(cfg).as_string, - std::ios_base::app); + _in_log.open( + std::string("/tmp/fix_raw_read_log_") + session_name(cfg).as_string, + std::ios_base::app); + _out_log.open( + std::string("/tmp/fix_raw_write_log_") + session_name(cfg).as_string, + std::ios_base::app); } } @@ -53,8 +55,8 @@ bool SocketConnection::connect() { serv_addr.sin_family = AF_INET; serv_addr.sin_port = htons(_cfg.socket_connect_port()); - auto result = inet_pton(AF_INET, _cfg.socket_connect_host_ip().c_str(), - &serv_addr.sin_addr); + auto result = inet_pton( + AF_INET, _cfg.socket_connect_host_ip().c_str(), &serv_addr.sin_addr); bts_assert(result > 0); result = ::connect(_fd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)); @@ -67,8 +69,8 @@ bool SocketConnection::connect() { LOG(Jetfix, Info, "Connected to {}:{}", _cfg.socket_connect_host_ip(), _cfg.socket_connect_port()); int flag = 1; - result = ::setsockopt(_fd, IPPROTO_TCP, TCP_NODELAY, (char *)&flag, - sizeof(int)); + result = ::setsockopt( + _fd, IPPROTO_TCP, TCP_NODELAY, (char *)&flag, sizeof(int)); bts_assert(result == 0); return true; } @@ -96,8 +98,8 @@ int SocketConnection::read(char *to_buffer, size_t read_count) { return result; } -int SocketConnection::write(WriteVec const &vec, size_t vec_size, - trace::CorID trace) { +int SocketConnection::write( + WriteVec const &vec, size_t vec_size, trace::CorID trace) { bts_assert(_fd >= 0); struct iovec iv[MaxWriteVecSz]; @@ -106,12 +108,12 @@ int SocketConnection::write(WriteVec const &vec, size_t vec_size, iv[i].iov_len = vec[i].second; } - _perf_log.log(trace,"before_fix_socket_w"); + _perf_log.log(trace, "before_fix_socket_w"); auto result = ::writev(_fd, iv, (int)vec_size); - _perf_log.log(trace,"after_fix_socket_w"); + _perf_log.log(trace, "after_fix_socket_w"); if (trace.sn) _perf_log.flush(); - + if (_log && result > 0) { for (size_t i = 0; i < vec_size; i++) _out_log.write(vec[i].first, vec[i].second); diff --git a/src/lib/jetfix/connection/SocketConnection.h b/src/lib/jetfix/connection/SocketConnection.h index ebdf75828..42ac53308 100644 --- a/src/lib/jetfix/connection/SocketConnection.h +++ b/src/lib/jetfix/connection/SocketConnection.h @@ -1,27 +1,30 @@ #pragma once -#include -#include #include "IConnection.h" #include "lib/config/protos/jetfix.pb.h" #include "lib/metrics/metrics.h" +#include +#include namespace bts { -namespace trace {class PerfLog;struct CorID;} +namespace trace { +class PerfLog; +struct CorID; +} // namespace trace namespace jetfix { -class SocketConnection : public IConnection -{ -public: - SocketConnection(bts::config::JetFIX::Connection const &cfgl,trace::PerfLog &log); +class SocketConnection : public IConnection { + public: + SocketConnection( + bts::config::JetFIX::Connection const &cfgl, trace::PerfLog &log); ~SocketConnection(); - bool connect () override; - void shutdown () override; - int read (char* to_buffer,size_t read_count) override; - int write (WriteVec const&vec,size_t vec_size,trace::CorID ) override; + bool connect() override; + void shutdown() override; + int read(char *to_buffer, size_t read_count) override; + int write(WriteVec const &vec, size_t vec_size, trace::CorID) override; -private: + private: int _fd; bts::config::JetFIX::Connection const _cfg; bool _log; @@ -30,4 +33,5 @@ private: trace::PerfLog &_perf_log; }; -}} +} // namespace jetfix +} // namespace bts diff --git a/src/lib/jetfix/gateway/CoreGateway.cpp b/src/lib/jetfix/gateway/CoreGateway.cpp index f192a66c7..8e2f445c3 100644 --- a/src/lib/jetfix/gateway/CoreGateway.cpp +++ b/src/lib/jetfix/gateway/CoreGateway.cpp @@ -27,12 +27,12 @@ namespace jetfix { enum class CoreGateway::State { OFF, - PAUSED, - CONNECTING, - READY, - WREADER_DISCONNECT, - WSESSION_TERMINATE - }; + PAUSED, + CONNECTING, + READY, + WREADER_DISCONNECT, + WSESSION_TERMINATE +}; struct CoreGateway::SessionInfo { SessionInfo() : connection(), store(), reader(), session() {} @@ -47,21 +47,21 @@ struct CoreGateway::EventData { typedef void (CoreGateway::*Handler)(EventData const &ev); EventData(const EventData &src) - : handler(src.handler), out_msgs(src.out_msgs), in_msg(src.in_msg), - trace(src.trace), ts(src.ts) {} + : handler(src.handler), out_msgs(src.out_msgs), in_msg(src.in_msg), + trace(src.trace), ts(src.ts) {} EventData() : handler(), out_msgs(), in_msg(), trace(), ts() {} EventData(Handler handler) - : handler(handler), out_msgs(), in_msg(), trace(), ts() {} - EventData(Handler handler, trace::CorID const &trace, - OutFIXPtr const &out_msgs) - : handler(handler), out_msgs(out_msgs), in_msg(), trace(trace), ts() {} + : handler(handler), out_msgs(), in_msg(), trace(), ts() {} + EventData( + Handler handler, trace::CorID const &trace, OutFIXPtr const &out_msgs) + : handler(handler), out_msgs(out_msgs), in_msg(), trace(trace), ts() {} EventData(Handler handler, InMsgBuffer const &in_msg) - : handler(handler), out_msgs(), in_msg(in_msg), trace(), ts() {} + : handler(handler), out_msgs(), in_msg(in_msg), trace(), ts() {} EventData(Handler handler, std::shared_ptr const &ts) - : handler(handler), out_msgs(), in_msg(), trace(), ts(ts) {} + : handler(handler), out_msgs(), in_msg(), trace(), ts(ts) {} EventData &operator=(EventData &src) { handler = src.handler; @@ -88,14 +88,15 @@ struct CoreGateway::EventData { }; struct CoreGateway::PImpl { - PImpl(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(), - session_info(), event_queue(), timer_thread(), destroy(false), - is_on(false), has_replayed(false), send_batch(), recv_batch(), - connection_attempts(0), perf_log(l) { + PImpl( + 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(), + session_info(), event_queue(), timer_thread(), destroy(false), + is_on(false), has_replayed(false), send_batch(), recv_batch(), + connection_attempts(0), perf_log(l) { send_batch.reserve(1024); recv_batch.reserve(1024); } @@ -121,16 +122,15 @@ struct CoreGateway::PImpl { std::thread CoreGateway::make_timer_thread() { auto thread_name = fmt::format("jf_tmr_{}", me->cfg.name()); - return threading::make_thread(thread_name, - std::bind(&CoreGateway::call_time, this)); + return threading::make_thread( + thread_name, std::bind(&CoreGateway::call_time, this)); } -CoreGateway::CoreGateway(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)) { +CoreGateway::CoreGateway( + 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(); } @@ -144,7 +144,7 @@ CoreGateway::~CoreGateway() { me->timer_thread.join(); } -config::JetFIX::Connection const &CoreGateway::cfg() {return me->cfg;} +config::JetFIX::Connection const &CoreGateway::cfg() { return me->cfg; } void CoreGateway::send(OutFIXPtr const &fix, trace::CorID trace) { me->event_queue.push(EventData(&CoreGateway::sync_send, trace, fix)); @@ -200,7 +200,7 @@ void CoreGateway::dispatch_events() { if (me->send_batch.size() || me->recv_batch.size()) { for (auto &ev : me->send_batch) (this->*ev.handler)(ev); - for (auto &ev : me->recv_batch) + for (auto &ev : me->recv_batch) (this->*ev.handler)(ev); me->send_batch.clear(); me->recv_batch.clear(); @@ -211,7 +211,7 @@ void CoreGateway::call_time() { while (!me->destroy) { std::this_thread::sleep_for(10ms); auto ts = std::make_shared( - datetime::FIX_timestamp(datetime::now())); + datetime::FIX_timestamp(datetime::now())); me->event_queue.push(EventData(&CoreGateway::sync_time, ts)); // NOLINT } } @@ -432,8 +432,8 @@ void CoreGateway::sync_time(EventData const &ev) { case State::OFF: break; case State::PAUSED: - if (datetime::is_at_least_secs_old(me->start_of_pause, - me->cfg.seconds_to_pause())) { + if (datetime::is_at_least_secs_old( + me->start_of_pause, me->cfg.seconds_to_pause())) { LOG(Jetfix, Info, "Pause period ended for jetfix connection {}", me->cfg.name()); me->session_info = std::make_unique(); @@ -445,7 +445,8 @@ void CoreGateway::sync_time(EventData const &ev) { if (!me->has_replayed) { auto msgs_to_replay = me->session_info->store->replay(); - LOG(Jetfix, Warn, "Replaying {} FIX msgs", msgs_to_replay.size()); + LOG(Jetfix, Warn, "Replaying {} FIX msgs", + msgs_to_replay.size()); me->observer.replay(msgs_to_replay); me->has_replayed = true; } @@ -470,13 +471,13 @@ void CoreGateway::sync_time(EventData const &ev) { me->cfg.name()); me->session_info->session.reset(new Session( - me->cfg, *me->session_info->connection, - *me->session_info->store, *this, - []() { return utils::TimeStamp::now(); }, me->perf_log)); + me->cfg, *me->session_info->connection, + *me->session_info->store, *this, + []() { return utils::TimeStamp::now(); }, me->perf_log)); me->session_info->reader.reset(new AsyncReader( - *me->session_info->connection, me->cfg.name(), *this, - me->perf_log, me->cfg.msg_buffer_sz(), - me->cfg.msg_high_water_mark())); + *me->session_info->connection, me->cfg.name(), *this, + me->perf_log, me->cfg.msg_buffer_sz(), + me->cfg.msg_high_water_mark())); me->session_info->reader->start(); me->session_info->session->start(); transition(State::CONNECTING); diff --git a/src/lib/jetfix/gateway/CoreGateway.h b/src/lib/jetfix/gateway/CoreGateway.h index fe4f3f38f..adb5fd7c1 100644 --- a/src/lib/jetfix/gateway/CoreGateway.h +++ b/src/lib/jetfix/gateway/CoreGateway.h @@ -1,79 +1,82 @@ #pragma once -#include #include +#include -#include "lib/jetfix/gateway/ICoreGatewayEventSink.h" #include "lib/jetfix/common/OutFIXPtr.h" +#include "lib/jetfix/gateway/ICoreGatewayEventSink.h" #include "lib/orderman/orderman_utils/orderman_common.h" #include "lib/config/protos/jetfix.pb.h" namespace bts { -namespace trace {class PerfLog;} +namespace trace { +class PerfLog; +} namespace jetfix { class ICoreGatewayObserver; class IConnection; class IFIXStore; class OutMsgsBuffer; -class CoreGateway : ICoreGatewayEventSink -{ -public: - typedef std::function ConnectionFactory; - typedef std::function StoreFactory; +class CoreGateway : ICoreGatewayEventSink { + public: + typedef std::function + ConnectionFactory; + typedef std::function + StoreFactory; + + CoreGateway( + config::JetFIX::Connection const &cfg, ICoreGatewayObserver &observer, + ConnectionFactory const &conn_factory, StoreFactory const &store_factory, + trace::PerfLog &); - CoreGateway(config::JetFIX::Connection const &cfg, - ICoreGatewayObserver &observer, - ConnectionFactory const &conn_factory, - StoreFactory const &store_factory, - trace::PerfLog &); - ~CoreGateway(); config::JetFIX::Connection const &cfg(); - - void start (); - void stop (); - void send (OutFIXPtr const &msgs, trace::CorID trace); - void dispatch_events (); -// for certification use only - void send_hb (); - void send_test_request (); + void start(); + void stop(); + void send(OutFIXPtr const &msgs, trace::CorID trace); + void dispatch_events(); -private: + // for certification use only + void send_hb(); + void send_test_request(); + + private: enum class State; struct SessionInfo; struct PImpl; struct EventData; - void session_ready () override; - void session_terminated () override; - void reader_disconnected () override; - void in_msg_raw (InMsgBuffer const &msg) override; - void in_msg_sequenced (InMsgBuffer const &msg) override; + void session_ready() override; + void session_terminated() override; + void reader_disconnected() override; + void in_msg_raw(InMsgBuffer const &msg) override; + void in_msg_sequenced(InMsgBuffer const &msg) override; - void call_time (); + void call_time(); - void sync_start (EventData const &); - void sync_stop (EventData const &); - void sync_send (EventData const &); - void sync_send_hb (EventData const&); - void sync_send_test_request (EventData const&); - void sync_session_ready (EventData const&) ; - void sync_session_terminated (EventData const&); - void sync_reader_disconnected (EventData const&) ; - void sync_in_msg_raw (EventData const&) ; - void sync_in_msg_sequenced (EventData const&) ; - void sync_time (EventData const&); + void sync_start(EventData const &); + void sync_stop(EventData const &); + void sync_send(EventData const &); + void sync_send_hb(EventData const &); + void sync_send_test_request(EventData const &); + void sync_session_ready(EventData const &); + void sync_session_terminated(EventData const &); + void sync_reader_disconnected(EventData const &); + void sync_in_msg_raw(EventData const &); + void sync_in_msg_sequenced(EventData const &); + void sync_time(EventData const &); - void pause_or_shutdown (); - void transition (State new_state); - void check_state_invariants (); - const char* state_name (State st); + void pause_or_shutdown(); + void transition(State new_state); + void check_state_invariants(); + const char *state_name(State st); std::thread make_timer_thread(); - + std::unique_ptr me; }; -}} +} // namespace jetfix +} // namespace bts diff --git a/src/lib/jetfix/gateway/ICoreGatewayEventSink.h b/src/lib/jetfix/gateway/ICoreGatewayEventSink.h index dfe5955a7..68877cc7f 100644 --- a/src/lib/jetfix/gateway/ICoreGatewayEventSink.h +++ b/src/lib/jetfix/gateway/ICoreGatewayEventSink.h @@ -1,21 +1,21 @@ #pragma once -#include #include "lib/jetfix/common/InMsgBuffer.h" +#include namespace bts { namespace jetfix { class JetFIXError; -class ICoreGatewayEventSink -{ -public: - virtual void session_ready () = 0; - virtual void session_terminated () = 0; - virtual void reader_disconnected () = 0; - virtual void in_msg_raw (InMsgBuffer const &msg) = 0; - virtual void in_msg_sequenced (InMsgBuffer const &msg) = 0; - virtual ~ICoreGatewayEventSink() {}; +class ICoreGatewayEventSink { + public: + virtual void session_ready() = 0; + virtual void session_terminated() = 0; + virtual void reader_disconnected() = 0; + virtual void in_msg_raw(InMsgBuffer const &msg) = 0; + virtual void in_msg_sequenced(InMsgBuffer const &msg) = 0; + virtual ~ICoreGatewayEventSink(){}; }; -}} +} // namespace jetfix +} // namespace bts diff --git a/src/lib/jetfix/gateway/ICoreGatewayObserver.h b/src/lib/jetfix/gateway/ICoreGatewayObserver.h index 29649d5d2..293915236 100644 --- a/src/lib/jetfix/gateway/ICoreGatewayObserver.h +++ b/src/lib/jetfix/gateway/ICoreGatewayObserver.h @@ -1,19 +1,19 @@ #pragma once -#include #include "lib/jetfix/common/InMsgBuffer.h" +#include namespace bts { namespace jetfix { -class ICoreGatewayObserver -{ -public: - virtual ~ICoreGatewayObserver() {}; - virtual void ready () = 0; - virtual void disconnect () = 0; - virtual void msg (InMsgBuffer const &msg) = 0; - virtual void replay (std::vector const &msgs) = 0; +class ICoreGatewayObserver { + public: + virtual ~ICoreGatewayObserver(){}; + virtual void ready() = 0; + virtual void disconnect() = 0; + virtual void msg(InMsgBuffer const &msg) = 0; + virtual void replay(std::vector const &msgs) = 0; }; -}} +} // namespace jetfix +} // namespace bts diff --git a/src/lib/jetfix/gateway/JetFIXGateway.cpp b/src/lib/jetfix/gateway/JetFIXGateway.cpp index 4cfc5efb3..df22ecb1b 100644 --- a/src/lib/jetfix/gateway/JetFIXGateway.cpp +++ b/src/lib/jetfix/gateway/JetFIXGateway.cpp @@ -2,8 +2,6 @@ #include "JetFIXGateway.h" namespace bts { -namespace jetfix { - -}} +namespace jetfix {} +} // namespace bts #endif - diff --git a/src/lib/jetfix/gateway/JetFIXGateway.h b/src/lib/jetfix/gateway/JetFIXGateway.h index f834ee111..f8a798111 100644 --- a/src/lib/jetfix/gateway/JetFIXGateway.h +++ b/src/lib/jetfix/gateway/JetFIXGateway.h @@ -1,134 +1,124 @@ #pragma once -#include #include "lib/jetfix/gateway/CoreGateway.h" +#include -#include "lib/jetfix/gateway/ICoreGatewayObserver.h" #include "lib/jetfix/connection/SocketConnection.h" +#include "lib/jetfix/gateway/ICoreGatewayObserver.h" #include "lib/jetfix/store/FIXFileStore.h" -#include "lib/utils/meta_programming.h" #include "lib/orderman/orderman_utils/orderman_common.h" #include "lib/tracing/PerfLog.h" +#include "lib/utils/meta_programming.h" #include "lib/config/protos/jetfix.pb.h" namespace bts { -namespace trace {class PerfLog;} +namespace trace { +class PerfLog; +} namespace jetfix { // A parsing layer over CoreGateway -template -class JetFIXGateway : ICoreGatewayObserver -{ -public: +template class JetFIXGateway : ICoreGatewayObserver { + public: JetFIXGateway(config::JetFIX::Connection const &cfg, trace::PerfLog &log) - : - _core (cfg,*this, - - [&log] (config::JetFIX::Connection const &cfg) - {return new SocketConnection (cfg,log);}, - - [] (config::JetFIX::Connection const &cfg) - { return new FIXFileStore (cfg);}, + : _core( + cfg, *this, + + [&log](config::JetFIX::Connection const &cfg) { + return new SocketConnection(cfg, log); + }, + + [](config::JetFIX::Connection const &cfg) { + return new FIXFileStore(cfg); + }, log), - _dispatchers (), - _dispatcher_idx (), - _on_ready ([](){}), - _on_disconnect ([](){}), - _on_begin_replay ([](){}), - _on_end_replay ([](){}), - _perf_log(log) - { - std::vector disp_vec; - meta::collect_tuple_items (_dispatchers,&disp_vec); + _dispatchers(), _dispatcher_idx(), _on_ready([]() {}), + _on_disconnect([]() {}), _on_begin_replay([]() {}), + _on_end_replay([]() {}), _perf_log(log) { + std::vector disp_vec; + meta::collect_tuple_items(_dispatchers, &disp_vec); for (auto d : disp_vec) { d->set_log(_perf_log); - _dispatcher_idx.emplace_back (d->tag (),d); + _dispatcher_idx.emplace_back(d->tag(), d); } } - - void start () {_core.start ();} - void stop () {_core.stop ();} - void send (OutFIXPtr const &msgs,trace::CorID trace ) {_core.send (msgs,trace);} - void dispatch_events () {_core.dispatch_events ();} - config::JetFIX::Connection const&cfg () {return _core.cfg();} - - std::function &on_ready () {return _on_ready;} - std::function &on_disconnect () {return _on_disconnect;} - std::function &on_begin_replay () {return _on_begin_replay;} - std::function &on_end_replay () {return _on_end_replay;} - - template - std::function &on () - { - return std::get, - DispatcherTuple>::value> (_dispatchers).handler; + void start() { _core.start(); } + void stop() { _core.stop(); } + void send(OutFIXPtr const &msgs, trace::CorID trace) { + _core.send(msgs, trace); } - - // for CERT purposes - void send_hb () {_core.send_hb ();} - void send_test_request () {_core.send_test_request ();} + void dispatch_events() { _core.dispatch_events(); } + config::JetFIX::Connection const &cfg() { return _core.cfg(); } -private: - struct IDispatcher - { - virtual MessageTypes tag () const = 0; - virtual void dispatch (InMsgBuffer const&msg) = 0; + std::function &on_ready() { return _on_ready; } + std::function &on_disconnect() { return _on_disconnect; } + std::function &on_begin_replay() { return _on_begin_replay; } + std::function &on_end_replay() { return _on_end_replay; } + + template std::function &on() { + return std:: + get, DispatcherTuple>::value>( + _dispatchers) + .handler; + } + + // for CERT purposes + void send_hb() { _core.send_hb(); } + void send_test_request() { _core.send_test_request(); } + + private: + struct IDispatcher { + virtual MessageTypes tag() const = 0; + virtual void dispatch(InMsgBuffer const &msg) = 0; virtual void set_log(trace::PerfLog &) = 0; }; - template - struct Dispatcher : public IDispatcher - { - typedef std::function Handler; - - Dispatcher () : msg (), handler ([](MT const&){}) {} - - MessageTypes tag () const override {return MT::tag;} + template struct Dispatcher : public IDispatcher { + typedef std::function Handler; - void set_log(trace::PerfLog &l) override { - log = &l; - } + Dispatcher() : msg(), handler([](MT const &) {}) {} - void dispatch (InMsgBuffer const&in_msg) override - { - msg.read (in_msg.data (),in_msg.size ()); + MessageTypes tag() const override { return MT::tag; } + + void set_log(trace::PerfLog &l) override { log = &l; } + + void dispatch(InMsgBuffer const &in_msg) override { + msg.read(in_msg.data(), in_msg.size()); msg.set_trace(in_msg.trace()); - handler (msg); + handler(msg); } - + MT msg; Handler handler; trace::PerfLog *log; }; - - typedef std::tuple...> DispatcherTuple; - - void ready () override {_on_ready ();} - - void disconnect () override {_on_disconnect ();} - void msg (InMsgBuffer const&msg) override - { - auto t = msg.type (); + typedef std::tuple...> DispatcherTuple; + + void ready() override { _on_ready(); } + + void disconnect() override { _on_disconnect(); } + + void msg(InMsgBuffer const &msg) override { + auto t = msg.type(); for (auto &d : _dispatcher_idx) if (d.first == t) - d.second->dispatch (msg); + d.second->dispatch(msg); } - - void replay (std::vector const &msgs) override - { - _on_begin_replay (); - for (auto const &m :msgs) - msg (m); - _on_end_replay (); + + void replay(std::vector const &msgs) override { + _on_begin_replay(); + for (auto const &m : msgs) + msg(m); + _on_end_replay(); } CoreGateway _core; std::tuple...> _dispatchers; - std::vector> _dispatcher_idx; + std::vector> _dispatcher_idx; std::function _on_ready; std::function _on_disconnect; std::function _on_begin_replay; @@ -136,4 +126,5 @@ private: trace::PerfLog &_perf_log; }; -}} +} // namespace jetfix +} // namespace bts diff --git a/src/lib/jetfix/gateway/Session.cpp b/src/lib/jetfix/gateway/Session.cpp index 8ca0d6804..6689392de 100644 --- a/src/lib/jetfix/gateway/Session.cpp +++ b/src/lib/jetfix/gateway/Session.cpp @@ -23,20 +23,20 @@ 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); +OutFIXPtr make_logon( + 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(config::JetFIX::Connection const &session_cfg, - uint32_t min, uint32_t max); -OutFIXPtr make_hb(config::JetFIX::Connection const &session_cfg, - std::string const &req_id); +OutFIXPtr make_resend_request( + config::JetFIX::Connection const &session_cfg, uint32_t min, uint32_t max); +OutFIXPtr make_hb( + config::JetFIX::Connection const &session_cfg, std::string const &req_id); OutFIXPtr make_hb(config::JetFIX::Connection const &session_cfg); -OutFIXPtr make_test_request(config::JetFIX::Connection const &session_cfg, - std::string const &tr_id); -OutFIXPtr make_seq_reset(config::JetFIX::Connection const &session_cfg, - uint32_t end); +OutFIXPtr make_test_request( + config::JetFIX::Connection const &session_cfg, std::string const &tr_id); +OutFIXPtr +make_seq_reset(config::JetFIX::Connection const &session_cfg, uint32_t end); enum class Session::State { WLOGON, @@ -56,9 +56,10 @@ struct Session::RecoveryState { }; struct Session::PImpl { - PImpl(config::JetFIX::Connection const &cfg, IConnection &connection, - IFIXStore &store, ICoreGatewayEventSink &sink, Clock const &clock, - trace::PerfLog &perf_log) + PImpl( + 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), begin_of_this_session(), last_seq_num(), last_seq_num_processed(), @@ -87,9 +88,10 @@ struct Session::PImpl { std::unique_ptr recovery_state; }; -Session::Session(config::JetFIX::Connection const &cfg, IConnection &connection, - IFIXStore &store, ICoreGatewayEventSink &sink, - Clock const &clock, trace::PerfLog &perf_log) +Session::Session( + 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)) {} Session::~Session() { @@ -104,8 +106,9 @@ void Session::start() { me->last_seq_num = me->begin_of_this_session; me->last_seq_num_processed = me->store.last_seq_num_processed(); transition(State::WLOGON); - internal_send(make_logon(me->last_seq_num + 1, me->last_seq_num_processed, - *me->current_time, me->cfg)); + internal_send(make_logon( + me->last_seq_num + 1, me->last_seq_num_processed, *me->current_time, + me->cfg)); } void Session::send(OutFIXPtr const &msgs, trace::CorID trace) { @@ -216,8 +219,9 @@ void Session::time(std::shared_ptr const &time_str) { if (seconds_elapsed(me->last_sent_msg_timestamp) > me->cfg.seconds_between_hbs()) internal_send(make_hb(me->cfg)); - else if (seconds_elapsed(me->last_rcvd_msg_timestamp) > - me->cfg.seconds_between_hbs() * me->cfg.max_missed_hbs()) + else if ( + seconds_elapsed(me->last_rcvd_msg_timestamp) > + me->cfg.seconds_between_hbs() * me->cfg.max_missed_hbs()) logout(JetFIXError::HB_TIMEOUT); break; case State::WLOGOUT: @@ -291,23 +295,26 @@ void Session::on_logon(InMsgBuffer const &msg) { void Session::on_logout(InMsgBuffer const &msg) { switch (me->state) { case State::WLOGON: - terminate_session(JetFIXError::LOGGED_OUT_BY_EXCHANGE, - (boost::format(". %s") % msg.get_text()).str()); + terminate_session( + JetFIXError::LOGGED_OUT_BY_EXCHANGE, + (boost::format(". %s") % msg.get_text()).str()); break; case State::RECOVER: internal_send(make_logout(me->cfg)); buffer(msg); - terminate_session(JetFIXError::LOGGED_OUT_BY_EXCHANGE, - (boost::format(". %s") % msg.get_text()).str()); + terminate_session( + JetFIXError::LOGGED_OUT_BY_EXCHANGE, + (boost::format(". %s") % msg.get_text()).str()); break; case State::WTR_REPLY: case State::READY: deliver(msg); internal_send(make_logout(me->cfg)); - terminate_session(JetFIXError::LOGGED_OUT_BY_EXCHANGE, - (boost::format(". %s") % msg.get_text()).str()); + terminate_session( + JetFIXError::LOGGED_OUT_BY_EXCHANGE, + (boost::format(". %s") % msg.get_text()).str()); break; case State::WLOGOUT: deliver(msg); @@ -507,8 +514,9 @@ void Session::buffer(InMsgBuffer const &msg) { bts_assert(me->recovery_state); me->recovery_state->buffered_msgs[sn] = msg; - bts_assert(me->recovery_state->buffered_msgs.begin()->first > - me->last_seq_num_processed + 1); + bts_assert( + me->recovery_state->buffered_msgs.begin()->first > + me->last_seq_num_processed + 1); } void Session::buffer_or_deliver(InMsgBuffer const &msg) { @@ -557,8 +565,8 @@ void Session::internal_send(trace::CorID trace, OutFIXPtr const &msgs) { msgs->set_ts(OutFIX::PRE_STAMP, utils::TimeStamp::now()); for (size_t i = 0; i < msgs->fix.size(); i++) { auto &s = msgs->fix[i]; - me->last_seq_num = s.stamp(me->last_seq_num, me->last_seq_num_processed, - *me->current_time); + me->last_seq_num = s.stamp( + me->last_seq_num, me->last_seq_num_processed, *me->current_time); data_vec[i].first = s.data(); data_vec[i].second = s.size(); } @@ -621,8 +629,8 @@ bool match_with_incoming_sn_too_small(std::string const &msg, uint32_t *sn) { return false; } -void Session::terminate_session(JetFIXError::Code error, - std::string const &extra_info) { +void Session::terminate_session( + JetFIXError::Code error, std::string const &extra_info) { me->recovery_state.reset(); auto level = Info; @@ -726,9 +734,9 @@ std::pair Session::find_first_incoming_msg_gap() { if (me->recovery_state->buffered_msgs.empty()) return std::make_pair(0u, 0u); else - return std::make_pair(me->last_seq_num_processed + 1, - me->recovery_state->buffered_msgs.begin()->first - - 1); + return std::make_pair( + me->last_seq_num_processed + 1, + me->recovery_state->buffered_msgs.begin()->first - 1); } bool Session::resend_request_active() { @@ -764,9 +772,10 @@ const char *Session::state_name(State state) { } } -OutFIXPtr make_logon(uint32_t seq_num, uint32_t last_seq_num_processed, - std::string const &time_str, - config::JetFIX::Connection const &session_cfg) { +OutFIXPtr make_logon( + 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); auto &stream = result->fix.back(); auto &buffer = stream.new_msg(MessageTypes::Logon); @@ -783,17 +792,18 @@ OutFIXPtr make_logon(uint32_t seq_num, uint32_t last_seq_num_processed, const char *application = "O2"; #endif - if(session_cfg.platform() == bts::config::JetFIX_Connection_JetFIXPlatform_ICE || - session_cfg.platform() == bts::config::JetFIX_Connection_JetFIXPlatform_SIMICE) - { + if (session_cfg.platform() == + bts::config::JetFIX_Connection_JetFIXPlatform_ICE || + session_cfg.platform() == + bts::config::JetFIX_Connection_JetFIXPlatform_SIMICE) { std::string sender_comp_id = session_cfg.sender_subid(); buffer.add(sender_comp_id); buffer.add(std::string_view{"1.0"}); - buffer.add(sender_comp_id); - - buffer.add(session_cfg.user_name()); + buffer.add(sender_comp_id); + + buffer.add(session_cfg.user_name()); buffer.add(session_cfg.raw_data().size()); - buffer.add(session_cfg.raw_data()); + buffer.add(session_cfg.raw_data()); buffer.add(0); buffer.add(1); buffer.add(1); @@ -857,8 +867,8 @@ OutFIXPtr make_logout(config::JetFIX::Connection const &session_cfg) { return result; } -OutFIXPtr make_resend_request(config::JetFIX::Connection const &session_cfg, - uint32_t min, uint32_t max) { +OutFIXPtr make_resend_request( + config::JetFIX::Connection const &session_cfg, uint32_t min, uint32_t max) { auto result = std::make_shared(session_cfg); auto &stream = result->fix.back(); auto &buffer = stream.new_msg(MessageTypes::ResendRequest); @@ -872,8 +882,8 @@ OutFIXPtr make_resend_request(config::JetFIX::Connection const &session_cfg, return result; } -OutFIXPtr make_hb(config::JetFIX::Connection const &session_cfg, - std::string const &req_id) { +OutFIXPtr make_hb( + config::JetFIX::Connection const &session_cfg, std::string const &req_id) { auto result = std::make_shared(session_cfg); auto &stream = result->fix.back(); auto &buffer = stream.new_msg(MessageTypes::HB); @@ -896,8 +906,8 @@ OutFIXPtr make_hb(config::JetFIX::Connection const &session_cfg) { return result; } -OutFIXPtr make_test_request(config::JetFIX::Connection const &session_cfg, - std::string const &req_id) { +OutFIXPtr make_test_request( + config::JetFIX::Connection const &session_cfg, std::string const &req_id) { auto result = std::make_shared(session_cfg); auto &stream = result->fix.back(); auto &buffer = stream.new_msg(MessageTypes::TestRequest); @@ -909,8 +919,8 @@ OutFIXPtr make_test_request(config::JetFIX::Connection const &session_cfg, return result; } -OutFIXPtr make_seq_reset(config::JetFIX::Connection const &session_cfg, - uint32_t end) { +OutFIXPtr +make_seq_reset(config::JetFIX::Connection const &session_cfg, uint32_t end) { auto result = std::make_shared(session_cfg); auto &stream = result->fix.back(); auto &buffer = stream.new_msg(MessageTypes::SeqReset); diff --git a/src/lib/jetfix/gateway/Session.h b/src/lib/jetfix/gateway/Session.h index 4bda9b475..7c0b5bd31 100644 --- a/src/lib/jetfix/gateway/Session.h +++ b/src/lib/jetfix/gateway/Session.h @@ -1,86 +1,86 @@ #pragma once -#include #include +#include #include "lib/jetfix/common/InMsgBuffer.h" #include "lib/jetfix/common/JetFIXError.h" -#include "lib/utils/datetime.h" #include "lib/jetfix/common/OutFIXPtr.h" #include "lib/orderman/orderman_utils/orderman_common.h" #include "lib/tracing/PerfLog.h" +#include "lib/utils/datetime.h" #include "lib/config/protos/jetfix.pb.h" namespace bts { -namespace utils {class TimeStamp;} +namespace utils { +class TimeStamp; +} namespace jetfix { class IConnection; class IFIXStore; class ICoreGatewayEventSink; -class Session -{ -public: - typedef std::function Clock; - - Session(config::JetFIX::Connection const &cfg, - IConnection &connection, - IFIXStore &store, - ICoreGatewayEventSink &sink, - Clock const &clock, - trace::PerfLog &perf_log); +class Session { + public: + typedef std::function Clock; + + Session( + config::JetFIX::Connection const &cfg, IConnection &connection, + IFIXStore &store, ICoreGatewayEventSink &sink, Clock const &clock, + trace::PerfLog &perf_log); ~Session(); - void start (); - void send (OutFIXPtr const&, trace::CorID); - void receive (InMsgBuffer const&); - void shutdown (); - void time (std::shared_ptr const&time_str); + void start(); + void send(OutFIXPtr const &, trace::CorID); + void receive(InMsgBuffer const &); + void shutdown(); + void time(std::shared_ptr const &time_str); // only intended for Certification - void send_hb(); - void send_test_request (); + void send_hb(); + void send_test_request(); -private: + private: enum class State; enum class Stats; struct PImpl; struct RecoveryState; + void on_logon(InMsgBuffer const &msg); + void on_logout(InMsgBuffer const &msg); + void on_test_request(InMsgBuffer const &msg); + void on_resend_request(InMsgBuffer const &msg); + void on_seq_reset(InMsgBuffer const &msg); + void on_hb(InMsgBuffer const &msg); + void on_app(InMsgBuffer const &msg); - void on_logon (InMsgBuffer const&msg); - void on_logout (InMsgBuffer const&msg); - void on_test_request (InMsgBuffer const&msg); - void on_resend_request(InMsgBuffer const&msg); - void on_seq_reset (InMsgBuffer const&msg); - void on_hb (InMsgBuffer const &msg); - void on_app (InMsgBuffer const &msg); + void deliver(InMsgBuffer const &msg); + void buffer(InMsgBuffer const &msg); + void buffer_or_deliver(InMsgBuffer const &msg); - void deliver (InMsgBuffer const&msg); - void buffer (InMsgBuffer const &msg); - void buffer_or_deliver (InMsgBuffer const&msg); + void internal_send(trace::CorID, OutFIXPtr const &); + void internal_send(OutFIXPtr const &); + void logout(JetFIXError::Code reason); + void logout(JetFIXError::Code reason, std::string const &extra_info); + void terminate_session(JetFIXError::Code reason); + void + terminate_session(JetFIXError::Code reason, std::string const &extra_info); - void internal_send (trace::CorID , OutFIXPtr const&); - void internal_send (OutFIXPtr const&); - void logout (JetFIXError::Code reason); - void logout (JetFIXError::Code reason,std::string const &extra_info); - void terminate_session (JetFIXError::Code reason); - void terminate_session (JetFIXError::Code reason,std::string const&extra_info); + int32_t seconds_elapsed(utils::TimeStamp since); - int32_t seconds_elapsed (utils::TimeStamp since); + void send_seq_reset(uint32_t sn, uint32_t new_sn); + void send_resend_request(); + void send_sync_test_request(); - void send_seq_reset (uint32_t sn, uint32_t new_sn); - void send_resend_request (); - void send_sync_test_request (); + void update_resend_request_progress(); + std::pair find_first_incoming_msg_gap(); + bool resend_request_active(); - void update_resend_request_progress (); - std::pair find_first_incoming_msg_gap (); - bool resend_request_active (); - - void transition (State new_state); - static const char * state_name (State state); + void transition(State new_state); + static const char *state_name(State state); std::unique_ptr me; }; -}} +} // namespace jetfix +} // namespace bts diff --git a/src/lib/jetfix/jetfix.h b/src/lib/jetfix/jetfix.h index d6e9e0f48..e0c7f4ccf 100644 --- a/src/lib/jetfix/jetfix.h +++ b/src/lib/jetfix/jetfix.h @@ -1,5 +1,5 @@ #pragma once +#include "lib/jetfix/codec/FIXFragment.h" #include "lib/jetfix/codec/FieldDefinitions.h" #include "lib/jetfix/codec/MessageDefinitions.h" #include "lib/jetfix/gateway/JetFIXGateway.h" -#include "lib/jetfix/codec/FIXFragment.h" diff --git a/src/lib/jetfix/store/FIXFileStore.cpp b/src/lib/jetfix/store/FIXFileStore.cpp index 1085209c7..165e8b66b 100644 --- a/src/lib/jetfix/store/FIXFileStore.cpp +++ b/src/lib/jetfix/store/FIXFileStore.cpp @@ -102,9 +102,9 @@ std::string seqnum_path(std::string const &base_path) { return result.string(); } -std::string store_path(std::string base_path, - std::string const &connection_name, - std::string const &session_name) { +std::string store_path( + std::string base_path, std::string const &connection_name, + std::string const &session_name) { if (base_path.empty()) base_path = os::bts_data_path(); boost::filesystem::path result = utils::normalize_data_path(base_path); @@ -122,9 +122,8 @@ bool is_valid_store_line(std::string const &line) { return std::regex_match(line, store_line_rx); } -std::map -load_replay(config::JetFIX::Connection const &cfg, std::string const &path, - uint32_t) { +std::map load_replay( + config::JetFIX::Connection const &cfg, std::string const &path, uint32_t) { std::map result; if (boost::filesystem::exists(path)) { @@ -142,8 +141,8 @@ load_replay(config::JetFIX::Connection const &cfg, std::string const &path, if (line_buffer[22] == '<') { auto ts = datetime::parse_FIX_timestamp(line_buffer.substr(0, 21)); - if (!datetime::is_at_least_secs_old(ts, - cfg.seconds_to_replay())) { + if (!datetime::is_at_least_secs_old( + ts, cfg.seconds_to_replay())) { InMsgBuffer msg(line_buffer.substr(24)); auto sn = msg.get_seq_num(); result[sn] = msg; @@ -156,22 +155,24 @@ load_replay(config::JetFIX::Connection const &cfg, std::string const &path, return result; } -void save_fix(std::ostream &out, const char *data, size_t size, - bool is_outgoing) { +void save_fix( + std::ostream &out, const char *data, size_t size, bool is_outgoing) { out << datetime::FIX_timestamp(datetime::now()) << " " << (is_outgoing ? ">" : "<") << " "; out.write(data, size); out << std::endl; } -void save_seq_nums(std::string const &path, uint32_t last_seq_num, - uint32_t last_seq_num_processed) { +void save_seq_nums( + 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, - uint32_t *last_seq_num_processed) { +void load_seq_nums( + std::string const &path, uint32_t *last_seq_num, + uint32_t *last_seq_num_processed) { if (boost::filesystem::exists(path)) { std::ifstream f(path); f >> *last_seq_num >> *last_seq_num_processed; @@ -182,8 +183,8 @@ void load_seq_nums(std::string const &path, uint32_t *last_seq_num, } } -FIXFileStore::FIXFileStore(config::JetFIX::Connection const &cfg, - std::string base_path) +FIXFileStore::FIXFileStore( + config::JetFIX::Connection const &cfg, std::string base_path) : me(new PImpl(cfg)) { auto sn = session_name(cfg).as_string; me->active = sn.size() > 0; @@ -289,10 +290,12 @@ void FIXFileStore::write() { for (auto &encoded_stream : ev.out_msgs->fix) for (auto &mm : encoded_stream.msg_map()) { me->last_seq_num = std::max(me->last_seq_num, mm.seq_num); - save_seq_nums(me->seq_num_path, me->last_seq_num, - me->last_seq_num_processed); - save_fix(me->fix_store, encoded_stream.data() + mm.offset, - mm.size, true); + save_seq_nums( + me->seq_num_path, me->last_seq_num, + me->last_seq_num_processed); + save_fix( + me->fix_store, encoded_stream.data() + mm.offset, mm.size, + true); } me->fix_store.flush(); } else if (ev.in_msg.size()) { @@ -300,12 +303,12 @@ void FIXFileStore::write() { me->fix_store.flush(); } else if (ev.has_last_msg_processed) { me->last_seq_num_processed = ev.last_msg_processed; - save_seq_nums(me->seq_num_path, me->last_seq_num, - me->last_seq_num_processed); + save_seq_nums( + me->seq_num_path, me->last_seq_num, me->last_seq_num_processed); } else if (ev.has_seq_num) { me->last_seq_num = ev.seq_num; - save_seq_nums(me->seq_num_path, me->last_seq_num, - me->last_seq_num_processed); + save_seq_nums( + me->seq_num_path, me->last_seq_num, me->last_seq_num_processed); } else bts_assert(false); } else diff --git a/src/lib/jetfix/store/FIXFileStore.h b/src/lib/jetfix/store/FIXFileStore.h index 5e0f5040b..20d49ab44 100644 --- a/src/lib/jetfix/store/FIXFileStore.h +++ b/src/lib/jetfix/store/FIXFileStore.h @@ -1,34 +1,36 @@ #pragma once -#include -#include "lib/jetfix/store/IFIXStore.h" #include "lib/config/protos/jetfix.pb.h" +#include "lib/jetfix/store/IFIXStore.h" +#include namespace bts { namespace jetfix { -class FIXFileStore : public IFIXStore -{ -public: - FIXFileStore(config::JetFIX::Connection const&cfg,std::string base_path=""); +class FIXFileStore : public IFIXStore { + public: + FIXFileStore( + config::JetFIX::Connection const &cfg, std::string base_path = ""); ~FIXFileStore(); - - bool session_active () const override; - std::vector replay () const override; - uint32_t last_seq_num () const override; - uint32_t last_seq_num_processed () const override; - - void store (InMsgBuffer const&buffer) override; - void store (OutFIXPtr const&msgs) override; - void set_last_msg_processed (uint32_t last_msg_processed) override; + + bool session_active() const override; + std::vector replay() const override; + uint32_t last_seq_num() const override; + uint32_t last_seq_num_processed() const override; + + void store(InMsgBuffer const &buffer) override; + void store(OutFIXPtr const &msgs) override; + void set_last_msg_processed(uint32_t last_msg_processed) override; void set_last_seq_num(uint32_t last_seq_num) override; -private: + + private: struct PImpl; struct Event; - void write (); + void write(); std::unique_ptr me; }; -bool is_valid_store_line(std::string const&) ; +bool is_valid_store_line(std::string const &); -}} +} // namespace jetfix +} // namespace bts diff --git a/src/lib/jetfix/store/IFIXStore.h b/src/lib/jetfix/store/IFIXStore.h index acaf05458..685d21cd8 100644 --- a/src/lib/jetfix/store/IFIXStore.h +++ b/src/lib/jetfix/store/IFIXStore.h @@ -1,28 +1,27 @@ #pragma once +#include "lib/jetfix/common/OutFIXPtr.h" #include #include -#include "lib/jetfix/common/OutFIXPtr.h" - namespace bts { namespace jetfix { class InMsgBuffer; -class IFIXStore -{ -public: - virtual ~IFIXStore() {}; +class IFIXStore { + public: + virtual ~IFIXStore(){}; - virtual bool session_active () const = 0; - virtual std::vector replay () const = 0; - virtual uint32_t last_seq_num () const = 0; - virtual uint32_t last_seq_num_processed () const = 0; + virtual bool session_active() const = 0; + virtual std::vector replay() const = 0; + virtual uint32_t last_seq_num() const = 0; + virtual uint32_t last_seq_num_processed() const = 0; - virtual void store (OutFIXPtr const&msgs) = 0; - virtual void store (InMsgBuffer const&buffer) = 0; - virtual void set_last_msg_processed (uint32_t last_msg_processed) = 0; + virtual void store(OutFIXPtr const &msgs) = 0; + virtual void store(InMsgBuffer const &buffer) = 0; + virtual void set_last_msg_processed(uint32_t last_msg_processed) = 0; virtual void set_last_seq_num(uint32_t last_seq_num) = 0; }; -}} +} // namespace jetfix +} // namespace bts diff --git a/src/lib/jetfix/store/session_name.cpp b/src/lib/jetfix/store/session_name.cpp index 81c965e05..f73c7f51b 100644 --- a/src/lib/jetfix/store/session_name.cpp +++ b/src/lib/jetfix/store/session_name.cpp @@ -1,134 +1,136 @@ #include "session_name.h" #include "lib/utils/bts_assert.h" -#include #include "lib/utils/datetime.h" +#include namespace bts { namespace jetfix { -boost::gregorian::greg_weekday parse_weekday (std::string weekday_str) -{ - boost::to_lower (weekday_str); +boost::gregorian::greg_weekday parse_weekday(std::string weekday_str) { + boost::to_lower(weekday_str); for (int i = 0; i < 7; i++) { - auto gw_day = boost::gregorian::greg_weekday (i); - auto prefix = std::string (gw_day.as_short_string ()); - boost::to_lower (prefix); - if (weekday_str.find (prefix) == 0) + auto gw_day = boost::gregorian::greg_weekday(i); + auto prefix = std::string(gw_day.as_short_string()); + boost::to_lower(prefix); + if (weekday_str.find(prefix) == 0) return gw_day; } - bts_assert (false); - return boost::gregorian::greg_weekday (0); + bts_assert(false); + return boost::gregorian::greg_weekday(0); } -datetime::PTime closest_before (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 ()) - return datetime::PTime (ref_date.date (),time_of_day); +datetime::PTime closest_before( + 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()) + return datetime::PTime(ref_date.date(), time_of_day); else { - return datetime::PTime (ref_date.date () - boost::gregorian::date_duration (7), - time_of_day); + return datetime::PTime( + ref_date.date() - boost::gregorian::date_duration(7), time_of_day); } } else { auto distance = - ref_date.date ().day_of_week ().as_number () - - weekday.as_number (); + ref_date.date().day_of_week().as_number() - weekday.as_number(); if (distance < 0) distance += 7; - return datetime::PTime (ref_date.date () - boost::gregorian::date_duration (distance), - time_of_day); + return datetime::PTime( + ref_date.date() - boost::gregorian::date_duration(distance), + time_of_day); } } -bool in_session (datetime::PTime const &ref_date, - boost::posix_time::time_duration time_of_day_start, - boost::posix_time::time_duration time_of_day_end) -{ - auto t = ref_date.time_of_day (); +bool in_session( + datetime::PTime const &ref_date, + boost::posix_time::time_duration time_of_day_start, + boost::posix_time::time_duration time_of_day_end) { + auto t = ref_date.time_of_day(); if (time_of_day_start < time_of_day_end) return t >= time_of_day_start && t <= time_of_day_end; else return t >= time_of_day_start || t <= time_of_day_end; } -bool in_session (datetime::PTime const &ref_date, - boost::gregorian::greg_weekday weekday_start, - boost::posix_time::time_duration time_of_day_start, - boost::gregorian::greg_weekday weekday_end, - boost::posix_time::time_duration time_of_day_end) -{ - auto closest_earlier_start = closest_before (ref_date,weekday_start,time_of_day_start); - auto closest_earlier_end = closest_before (ref_date,weekday_end,time_of_day_end); - return closest_earlier_end time_of_day_end && - start_of_session.time_of_day () <= time_of_day_end) - start_of_session -= boost::gregorian::date_duration (1); + + if (time_of_day_start > time_of_day_end && + start_of_session.time_of_day() <= time_of_day_end) + start_of_session -= boost::gregorian::date_duration(1); using namespace boost::posix_time; - ptime epoch(boost::gregorian::date(1970,1,1)); + ptime epoch(boost::gregorian::date(1970, 1, 1)); ptime session_start_date(start_of_session.date()); result.as_uint64_t = (session_start_date - epoch).total_milliseconds(); - sprintf (&(result.as_string[0]), "%04d-%02d-%02d", - (unsigned short) start_of_session.date ().year (), - start_of_session.date ().month ().as_number (), - start_of_session.date ().day ().as_number ()); + sprintf( + &(result.as_string[0]), "%04d-%02d-%02d", + (unsigned short)start_of_session.date().year(), + start_of_session.date().month().as_number(), + start_of_session.date().day().as_number()); return result; } -SessionName session_name (datetime::PTime const &ref_date, - boost::gregorian::greg_weekday weekday_start, - boost::posix_time::time_duration time_of_day_start, - boost::gregorian::greg_weekday weekday_end, - boost::posix_time::time_duration time_of_day_end) -{ - if (in_session (ref_date,weekday_start,time_of_day_start,weekday_end,time_of_day_end)) - return session_name_from_ptime (closest_before (ref_date,weekday_start,time_of_day_start), - boost::posix_time::time_duration(0, 0, 0), - boost::posix_time::time_duration(0, 0, 1)); +SessionName session_name( + datetime::PTime const &ref_date, + boost::gregorian::greg_weekday weekday_start, + boost::posix_time::time_duration time_of_day_start, + boost::gregorian::greg_weekday weekday_end, + boost::posix_time::time_duration time_of_day_end) { + if (in_session( + ref_date, weekday_start, time_of_day_start, weekday_end, + time_of_day_end)) + return session_name_from_ptime( + closest_before(ref_date, weekday_start, time_of_day_start), + boost::posix_time::time_duration(0, 0, 0), + boost::posix_time::time_duration(0, 0, 1)); else return {}; } -SessionName session_name (datetime::PTime const &ref_date, - boost::posix_time::time_duration time_of_day_start, - boost::posix_time::time_duration time_of_day_end) -{ - if (in_session (ref_date,time_of_day_start,time_of_day_end)) - return session_name_from_ptime (ref_date, time_of_day_start, time_of_day_end); +SessionName session_name( + datetime::PTime const &ref_date, + boost::posix_time::time_duration time_of_day_start, + boost::posix_time::time_duration time_of_day_end) { + if (in_session(ref_date, time_of_day_start, time_of_day_end)) + return session_name_from_ptime( + ref_date, time_of_day_start, time_of_day_end); else return {}; } -SessionName session_name (config::JetFIX::Connection const &session_cfg) -{ - auto now = datetime::local_now (); - - if (session_cfg.has_start_day ()) { - bts_assert (session_cfg.has_end_day ()); - return session_name (now, - parse_weekday (session_cfg.start_day ()), - datetime::parse_duration (session_cfg.start_time ()), - parse_weekday (session_cfg.end_day ()), - datetime::parse_duration (session_cfg.end_time ())); - } else - return session_name (now, - datetime::parse_duration (session_cfg.start_time ()), - datetime::parse_duration (session_cfg.end_time ())); +SessionName session_name(config::JetFIX::Connection const &session_cfg) { + auto now = datetime::local_now(); + + if (session_cfg.has_start_day()) { + bts_assert(session_cfg.has_end_day()); + return session_name( + now, parse_weekday(session_cfg.start_day()), + datetime::parse_duration(session_cfg.start_time()), + parse_weekday(session_cfg.end_day()), + datetime::parse_duration(session_cfg.end_time())); + } else + return session_name( + now, datetime::parse_duration(session_cfg.start_time()), + datetime::parse_duration(session_cfg.end_time())); } -}} - - +} // namespace jetfix +} // namespace bts diff --git a/src/lib/jetfix/store/session_name.h b/src/lib/jetfix/store/session_name.h index 1d1ad8c0b..b48f57e03 100644 --- a/src/lib/jetfix/store/session_name.h +++ b/src/lib/jetfix/store/session_name.h @@ -19,34 +19,38 @@ 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, - boost::posix_time::time_duration time_of_day); +datetime::PTime closest_before( + datetime::PTime const &ref_date, boost::gregorian::greg_weekday weekday, + boost::posix_time::time_duration time_of_day); -bool in_session(datetime::PTime const &ref_date, - boost::gregorian::greg_weekday weekday_start, - boost::posix_time::time_duration time_of_day_start, - boost::gregorian::greg_weekday weekday_end, - boost::posix_time::time_duration time_of_day_end); +bool in_session( + datetime::PTime const &ref_date, + boost::gregorian::greg_weekday weekday_start, + boost::posix_time::time_duration time_of_day_start, + boost::gregorian::greg_weekday weekday_end, + boost::posix_time::time_duration time_of_day_end); -bool in_session(datetime::PTime const &ref_date, - boost::posix_time::time_duration time_of_day_start, - boost::posix_time::time_duration time_of_day_end); +bool in_session( + datetime::PTime const &ref_date, + boost::posix_time::time_duration time_of_day_start, + boost::posix_time::time_duration time_of_day_end); struct SessionName { std::string as_string; uint64_t as_uint64_t; - bool empty() const {return as_string.empty();}; + bool empty() const { return as_string.empty(); }; }; -SessionName session_name(datetime::PTime const &ref_date, - boost::gregorian::greg_weekday weekday_start, - boost::posix_time::time_duration time_of_day_start, - boost::gregorian::greg_weekday weekday_end, - boost::posix_time::time_duration time_of_day_end); -SessionName session_name(datetime::PTime const &ref_date, - boost::posix_time::time_duration time_of_day_start, - boost::posix_time::time_duration time_of_day_end); +SessionName session_name( + datetime::PTime const &ref_date, + boost::gregorian::greg_weekday weekday_start, + boost::posix_time::time_duration time_of_day_start, + boost::gregorian::greg_weekday weekday_end, + boost::posix_time::time_duration time_of_day_end); +SessionName session_name( + datetime::PTime const &ref_date, + boost::posix_time::time_duration time_of_day_start, + boost::posix_time::time_duration time_of_day_end); SessionName session_name(config::JetFIX::Connection const &session_cfg); } // namespace jetfix diff --git a/src/lib/jetfix/tests/async_reader_tests.cpp b/src/lib/jetfix/tests/async_reader_tests.cpp index d75fff0f2..e7169dc04 100644 --- a/src/lib/jetfix/tests/async_reader_tests.cpp +++ b/src/lib/jetfix/tests/async_reader_tests.cpp @@ -1,9 +1,9 @@ #include "catch/catch.hpp" -#include "lib/jetfix/connection/AsyncReader.h" #include "lib/jetfix/common/InMsgBuffer.h" -#include "lib/jetfix/gateway/ICoreGatewayEventSink.h" +#include "lib/jetfix/connection/AsyncReader.h" #include "lib/jetfix/connection/IConnection.h" +#include "lib/jetfix/gateway/ICoreGatewayEventSink.h" #include "lib/jetfix/tests/sample_fix.h" #include @@ -11,151 +11,149 @@ namespace bts { namespace jetfix { -const static char *sample_logon = - "8=FIX.4.2" "\001" - "9=127" "\001" - "35=A" "\001" - "34=25" "\001" - "369=1" "\001" - "52=20150427-19:05:18.922" "\001" - "49=CME" "\001" - "50=G" "\001" - "56=1U7001N" "\001" - "57=BLUESTREAM" "\001" - "143=US,NC" "\001" - "98=0" "\001" - "108=30" "\001" - "1603=O2" "\001" - "1604=1.0" "\001" - "1605=BTS" "\001" - "10=046\001"; +const static char *sample_logon = "8=FIX.4.2" + "\001" + "9=127" + "\001" + "35=A" + "\001" + "34=25" + "\001" + "369=1" + "\001" + "52=20150427-19:05:18.922" + "\001" + "49=CME" + "\001" + "50=G" + "\001" + "56=1U7001N" + "\001" + "57=BLUESTREAM" + "\001" + "143=US,NC" + "\001" + "98=0" + "\001" + "108=30" + "\001" + "1603=O2" + "\001" + "1604=1.0" + "\001" + "1605=BTS" + "\001" + "10=046\001"; -const static char *sample_mass_quote = - "8=FIX.4.2\001" - "9=304\001" - "35=i\001" - "34=61\001" - "49=1U7001N\001" - "50=bluestream\001" - "52=20150427-19:29:40.610\001" - "56=CME\001" - "57=G\001" - "142=US,NC\001" - "117=58\001" - "204=1\001" +const static char *sample_mass_quote = "8=FIX.4.2\001" + "9=304\001" + "35=i\001" + "34=61\001" + "49=1U7001N\001" + "50=bluestream\001" + "52=20150427-19:29:40.610\001" + "56=CME\001" + "57=G\001" + "142=US,NC\001" + "117=58\001" + "204=1\001" - "1028=N\001" - "7928=bluestream\001" - "9702=1\001" - "9771=TESTACC\001" + "1028=N\001" + "7928=bluestream\001" + "9702=1\001" + "9771=TESTACC\001" - "296=1\001" - "302=1\001" - "304=2\001" - "295=2\001" + "296=1\001" + "302=1\001" + "304=2\001" + "295=2\001" - "299=10857\001" - "55=EZ\001" - "167=OPT\001" - "107=ESK5 C1855\001" - "132=25200\001" - "133=25350\001" - "134=1\001" - "135=1\001" + "299=10857\001" + "55=EZ\001" + "167=OPT\001" + "107=ESK5 C1855\001" + "132=25200\001" + "133=25350\001" + "134=1\001" + "135=1\001" - "299=10856\001" - "55=EZ\001" - "167=OPT\001" - "107=ESK5 C1890\001" - "132=25201\001" - "133=25351\001" - "134=2\001" - "135=2\001" + "299=10856\001" + "55=EZ\001" + "167=OPT\001" + "107=ESK5 C1890\001" + "132=25201\001" + "133=25351\001" + "134=2\001" + "135=2\001" - "10=046\001"; + "10=046\001"; -struct MyGWObserver : public ICoreGatewayEventSink -{ +struct MyGWObserver : public ICoreGatewayEventSink { bool got_eof; std::vector msgs; - MyGWObserver () : got_eof (false), msgs () {} + MyGWObserver() : got_eof(false), msgs() {} - void session_ready () - {REQUIRE(false);} + void session_ready() { REQUIRE(false); } - void session_terminated () - {REQUIRE(false);} + void session_terminated() { REQUIRE(false); } - void reader_disconnected () - {got_eof = true;} + void reader_disconnected() { got_eof = true; } - void in_msg_raw (InMsgBuffer const &msg) - {msgs.emplace_back (msg);} + void in_msg_raw(InMsgBuffer const &msg) { msgs.emplace_back(msg); } - void in_msg_sequenced (InMsgBuffer const &) - {REQUIRE(false);} + void in_msg_sequenced(InMsgBuffer const &) { REQUIRE(false); } }; -struct Connection : public IConnection -{ - Connection (std::istream &str) : str (str) - {} - - bool connect () {return true;} - void shutdown () {} +struct Connection : public IConnection { + Connection(std::istream &str) : str(str) {} - int read (char* to_buffer,size_t read_count) - { - str.read (to_buffer,read_count); - return str.gcount (); + bool connect() { return true; } + void shutdown() {} + + int read(char *to_buffer, size_t read_count) { + str.read(to_buffer, read_count); + return str.gcount(); } - int write (WriteVec const&,size_t, trace::CorID ) - {return -1;} - + int write(WriteVec const &, size_t, trace::CorID) { return -1; } + std::istream &str; }; - -TEST_CASE ("JetFIX AsyncReaderTests", "[jetfix]") -{ + +TEST_CASE("JetFIX AsyncReaderTests", "[jetfix]") { trace::PerfLog l; - - SECTION ("jeftix_smoke") - { + + SECTION("jeftix_smoke") { std::stringstream str; str << sample_logon << sample_mass_quote; - Connection c (str); + Connection c(str); MyGWObserver ob; { - AsyncReader r (c,"test",ob,l,10,5); - r.start (); + AsyncReader r(c, "test", ob, l, 10, 5); + r.start(); } - + REQUIRE(ob.got_eof); - REQUIRE(ob.msgs.size () == 2); + REQUIRE(ob.msgs.size() == 2); } - - SECTION ("jeftix_parse_big_file") - { + + SECTION("jeftix_parse_big_file") { std::stringstream f(sample_fix()); - Connection c (f); + Connection c(f); MyGWObserver ob; { - AsyncReader r (c,"test",ob,l,10,5); - r.start (); + AsyncReader r(c, "test", ob, l, 10, 5); + r.start(); } - REQUIRE (ob.got_eof); - REQUIRE (ob.msgs.size () == 1000); + REQUIRE(ob.got_eof); + REQUIRE(ob.msgs.size() == 1000); } -} - - -}} - - +} +} // namespace jetfix +} // namespace bts diff --git a/src/lib/jetfix/tests/decoding_tests.cpp b/src/lib/jetfix/tests/decoding_tests.cpp index bbb18fa21..9a76e1a1f 100644 --- a/src/lib/jetfix/tests/decoding_tests.cpp +++ b/src/lib/jetfix/tests/decoding_tests.cpp @@ -1,161 +1,158 @@ #include "catch/catch.hpp" +#include "lib/jetfix/codec/FIXFragment.h" +#include "lib/jetfix/codec/FIXMsg.h" +#include "lib/jetfix/codec/FIXParser.h" +#include "lib/jetfix/codec/FieldDefinitions.h" #include "lib/jetfix/codec/Fields.h" #include "lib/jetfix/codec/Group.h" -#include "lib/jetfix/codec/FIXMsg.h" -#include "lib/jetfix/codec/FieldDefinitions.h" -#include "lib/jetfix/connection/IConnectionObserver.h" #include "lib/jetfix/common/InMsgBuffer.h" -#include "lib/jetfix/codec/FIXParser.h" -#include "lib/jetfix/codec/FIXFragment.h" +#include "lib/jetfix/connection/IConnectionObserver.h" #include "lib/utils/TimeStamp.h" namespace bts { namespace jetfix { -const static char *sample_logon_header = - "8=FIX.4.2" "\001" - "9=127" "\001" - "35=A" "\001" - "34=25" "\001" - "369=1" "\001" - "52=20150427-19:05:18.922" "\001" - "49=CME" "\001" - "50=G" "\001" - "56=1U7001N" "\001" - "57=BLUESTREAM" "\001" - "143=US,NC" "\001"; +const static char *sample_logon_header = "8=FIX.4.2" + "\001" + "9=127" + "\001" + "35=A" + "\001" + "34=25" + "\001" + "369=1" + "\001" + "52=20150427-19:05:18.922" + "\001" + "49=CME" + "\001" + "50=G" + "\001" + "56=1U7001N" + "\001" + "57=BLUESTREAM" + "\001" + "143=US,NC" + "\001"; -const static char *sample_mass_quote = - "8=FIX.4.2\001" - "9=234\001" - "35=i\001" - "34=61\001" - "49=1U7001N\001" - "50=bluestream\001" - "52=20150427-19:29:40.610\001" - "56=CME\001" - "57=G\001" - "142=US,NC\001" - "117=58\001" - "204=1\001" +const static char *sample_mass_quote = "8=FIX.4.2\001" + "9=234\001" + "35=i\001" + "34=61\001" + "49=1U7001N\001" + "50=bluestream\001" + "52=20150427-19:29:40.610\001" + "56=CME\001" + "57=G\001" + "142=US,NC\001" + "117=58\001" + "204=1\001" - "1028=N\001" - "7928=bluestream\001" - "9702=1\001" - "9771=TESTACC\001" + "1028=N\001" + "7928=bluestream\001" + "9702=1\001" + "9771=TESTACC\001" - "296=1\001" - "302=1\001" - "304=2\001" - "295=2\001" + "296=1\001" + "302=1\001" + "304=2\001" + "295=2\001" - "299=10857\001" - "55=EZ\001" - "167=OPT\001" - "107=ESK5 C1855\001" - "132=25200\001" - "133=25350\001" - "134=1\001" - "135=1\001" + "299=10857\001" + "55=EZ\001" + "167=OPT\001" + "107=ESK5 C1855\001" + "132=25200\001" + "133=25350\001" + "134=1\001" + "135=1\001" - "299=10856\001" - "55=EZ\001" - "167=OPT\001" - "107=ESK5 C1890\001" - "132=25201\001" - "133=25351\001" - "134=2\001" - "135=2\001"; + "299=10856\001" + "55=EZ\001" + "167=OPT\001" + "107=ESK5 C1890\001" + "132=25201\001" + "133=25351\001" + "134=2\001" + "135=2\001"; -TEST_CASE ("Jetfix InMsgTests" ,"[jetfix]") -{ - SECTION ("basic_parsing_works") - { - InMsgBuffer msg (sample_logon_header,strlen(sample_logon_header)-1,std::shared_ptr()); - REQUIRE (msg.type ()==MessageTypes::Logon); - REQUIRE (msg.get_seq_num ()==25); - REQUIRE (msg.get_last_seq_num_processed ()==1); +TEST_CASE("Jetfix InMsgTests", "[jetfix]") { + SECTION("basic_parsing_works") { + InMsgBuffer msg( + sample_logon_header, strlen(sample_logon_header) - 1, + std::shared_ptr()); + REQUIRE(msg.type() == MessageTypes::Logon); + REQUIRE(msg.get_seq_num() == 25); + REQUIRE(msg.get_last_seq_num_processed() == 1); } } - -TEST_CASE("Jeftix ParserTests","[jetfix]") -{ - SECTION("parse_logon") - { +TEST_CASE("Jeftix ParserTests", "[jetfix]") { + SECTION("parse_logon") { using namespace fix; - typedef FIXMsg - LogonMsg; + typedef FIXMsg< + MessageTypes::Logon, BeginString, BodyLength, MsgType, MsgSeqNum, + LastSeqNumProcessed, SendingTime, SenderCompID, SenderSubID, + TargetCompId, TargetSubID, TargetLocationID> + LogonMsg; LogonMsg m; - m.read (sample_logon_header); - REQUIRE (m.get()=="FIX.4.2"); - REQUIRE (m.get()== 127); - REQUIRE (m.get()=="A"); - REQUIRE (m.get()==25); - REQUIRE (m.get()==1); - REQUIRE (m.get()==datetime::make_ptime (2015,4,27,19,5,18,922)); - REQUIRE (m.get()=="CME"); - REQUIRE (m.get()=="G"); - REQUIRE (m.get()=="1U7001N"); - REQUIRE (m.get()=="BLUESTREAM"); - REQUIRE (m.get()=="US,NC"); + m.read(sample_logon_header); + REQUIRE(m.get() == "FIX.4.2"); + REQUIRE(m.get() == 127); + REQUIRE(m.get() == "A"); + REQUIRE(m.get() == 25); + REQUIRE(m.get() == 1); + REQUIRE( + m.get() == + datetime::make_ptime(2015, 4, 27, 19, 5, 18, 922)); + REQUIRE(m.get() == "CME"); + REQUIRE(m.get() == "G"); + REQUIRE(m.get() == "1U7001N"); + REQUIRE(m.get() == "BLUESTREAM"); + REQUIRE(m.get() == "US,NC"); } - SECTION("parse_group") - { + SECTION("parse_group") { using namespace fix; - typedef FIXMsg MassQuote; + typedef FIXMsg< + MessageTypes::MassQuote, QuoteID, CustomerOrFirm, QuoteSets, + ManualOrderIndicator> + MassQuote; MassQuote m; - m.read (sample_mass_quote); - REQUIRE (m.get()=="58"); - REQUIRE (m.get()==1); - REQUIRE (m.get()==false); - - auto &qs = m.get (); - REQUIRE (qs.size ()==1); - REQUIRE (qs[0].get()=="1"); - REQUIRE (qs[0].get()==2); + m.read(sample_mass_quote); + REQUIRE(m.get() == "58"); + REQUIRE(m.get() == 1); + REQUIRE(m.get() == false); - auto &qe = qs[0].get (); - REQUIRE (qe.size ()==2); - REQUIRE (qe[0].get()=="10857"); - REQUIRE (qe[0].get()=="EZ"); - REQUIRE (qe[0].get()=="OPT"); - REQUIRE (qe[0].get()=="ESK5 C1855"); - REQUIRE (qe[0].get()==25200); - REQUIRE (qe[0].get()==25350); - REQUIRE (qe[0].get()==1); - REQUIRE (qe[0].get()==1); + auto &qs = m.get(); + REQUIRE(qs.size() == 1); + REQUIRE(qs[0].get() == "1"); + REQUIRE(qs[0].get() == 2); - REQUIRE (qe[1].get()=="10856"); - REQUIRE (qe[1].get()=="EZ"); - REQUIRE (qe[1].get()=="OPT"); - REQUIRE (qe[1].get()=="ESK5 C1890"); - REQUIRE (qe[1].get()==25201); - REQUIRE (qe[1].get()==25351); - REQUIRE (qe[1].get()==2); - REQUIRE (qe[1].get()==2); + auto &qe = qs[0].get(); + REQUIRE(qe.size() == 2); + REQUIRE(qe[0].get() == "10857"); + REQUIRE(qe[0].get() == "EZ"); + REQUIRE(qe[0].get() == "OPT"); + REQUIRE(qe[0].get() == "ESK5 C1855"); + REQUIRE(qe[0].get() == 25200); + REQUIRE(qe[0].get() == 25350); + REQUIRE(qe[0].get() == 1); + REQUIRE(qe[0].get() == 1); + + REQUIRE(qe[1].get() == "10856"); + REQUIRE(qe[1].get() == "EZ"); + REQUIRE(qe[1].get() == "OPT"); + REQUIRE(qe[1].get() == "ESK5 C1890"); + REQUIRE(qe[1].get() == 25201); + REQUIRE(qe[1].get() == 25351); + REQUIRE(qe[1].get() == 2); + REQUIRE(qe[1].get() == 2); } } - -}} - +} // namespace jetfix +} // namespace bts diff --git a/src/lib/jetfix/tests/fix_encoding_stream_tests.cpp b/src/lib/jetfix/tests/fix_encoding_stream_tests.cpp index c5ea8a16f..eda41fe36 100644 --- a/src/lib/jetfix/tests/fix_encoding_stream_tests.cpp +++ b/src/lib/jetfix/tests/fix_encoding_stream_tests.cpp @@ -6,104 +6,99 @@ namespace bts { namespace jetfix { -static config::JetFIX::Connection get_jetfix_cfg () -{ +static config::JetFIX::Connection get_jetfix_cfg() { config::JetFIX::Connection jfcfg; - jfcfg.set_name ("test"); - jfcfg.set_socket_connect_host_ip ("10.96.18.160"); - jfcfg.set_socket_connect_port (9999); - jfcfg.set_sender_compid ("O2TESTER"); - jfcfg.set_target_compid ("BTS"); - jfcfg.set_target_subid ("BTS"); + jfcfg.set_name("test"); + jfcfg.set_socket_connect_host_ip("10.96.18.160"); + jfcfg.set_socket_connect_port(9999); + jfcfg.set_sender_compid("O2TESTER"); + jfcfg.set_target_compid("BTS"); + jfcfg.set_target_subid("BTS"); - jfcfg.set_use_persisted_quote_ids (false); - jfcfg.set_start_time ("00:30:00"); - jfcfg.set_end_time ("23:30:00"); - jfcfg.set_start_day ("sunday"); - jfcfg.set_end_day ("friday"); - jfcfg.set_log_fix_stream (true); - jfcfg.set_seconds_to_pause (10); - jfcfg.set_sender_subid ("BTS"); - jfcfg.set_raw_data ("1U7"); - jfcfg.set_self_match_prevention_id ("bluestream"); + jfcfg.set_use_persisted_quote_ids(false); + jfcfg.set_start_time("00:30:00"); + jfcfg.set_end_time("23:30:00"); + jfcfg.set_start_day("sunday"); + jfcfg.set_end_day("friday"); + jfcfg.set_log_fix_stream(true); + jfcfg.set_seconds_to_pause(10); + jfcfg.set_sender_subid("BTS"); + jfcfg.set_raw_data("1U7"); + jfcfg.set_self_match_prevention_id("bluestream"); return jfcfg; } -TEST_CASE("JetFIX FIX Encoding","[jetfix_encoding]") -{ - SECTION("smoke") - { - FIXEncodingStream stream (get_jetfix_cfg ()); - auto &msg = stream.new_msg (MessageTypes::MassQuote); - msg.add ("hello",5); - auto &msg2 = stream.new_msg (MessageTypes::Advertisement); - msg2.add("olleh",5); - stream.close (); +TEST_CASE("JetFIX FIX Encoding", "[jetfix_encoding]") { + SECTION("smoke") { + FIXEncodingStream stream(get_jetfix_cfg()); + auto &msg = stream.new_msg(MessageTypes::MassQuote); + msg.add("hello", 5); + auto &msg2 = stream.new_msg(MessageTypes::Advertisement); + msg2.add("olleh", 5); + stream.close(); - auto out = stream.to_str (); - REQUIRE (out.size ()); + auto out = stream.to_str(); + REQUIRE(out.size()); } - SECTION("body_lenght_is_correct") - { + SECTION("body_lenght_is_correct") { using namespace fix; - FIXEncodingStream stream (get_jetfix_cfg ()); - auto &msg = stream.new_msg (MessageTypes::MassQuote); - msg.add ("hello",5); - stream.close (); + FIXEncodingStream stream(get_jetfix_cfg()); + auto &msg = stream.new_msg(MessageTypes::MassQuote); + msg.add("hello", 5); + stream.close(); - auto str = stream.to_human_str (); - REQUIRE (str.compare (0,strlen ("8=FIX.4.2|9=000092|"), "8=FIX.4.2|9=000092|")==0); + auto str = stream.to_human_str(); + REQUIRE( + str.compare( + 0, strlen("8=FIX.4.2|9=000092|"), "8=FIX.4.2|9=000092|") == 0); } - SECTION("checksum_is_correct") - { - char target [] = - "8=FIX.4.2\0019=000092\00135=i\00134=000000000\001369=000000000\001" - "52=20150427-19:05:18.923\00149=O2TESTER\00156=BTS\00157=BTS\001" - "58=hello\001"; - + SECTION("checksum_is_correct") { + char target[] = + "8=FIX.4.2\0019=000092\00135=i\00134=000000000\001369=000000000\001" + "52=20150427-19:05:18.923\00149=O2TESTER\00156=BTS\00157=BTS\001" + "58=hello\001"; + uint32_t byte_sum = 0; for (auto c : target) byte_sum += c; - FIXEncodingStream stream (get_jetfix_cfg ()); - auto &msg = stream.new_msg (MessageTypes::MassQuote); - msg.add ("hello",5); - stream.close (); + FIXEncodingStream stream(get_jetfix_cfg()); + auto &msg = stream.new_msg(MessageTypes::MassQuote); + msg.add("hello", 5); + stream.close(); // std::string human_target(target); // std::replace(human_target.begin(), human_target.end(),'\001','|'); // std::cout << human_target << "\n"; // std::cout << stream.to_human_str() << "\n"; - auto chk = stream.msg_map ()[0].checksum; - REQUIRE (chk==byte_sum); + auto chk = stream.msg_map()[0].checksum; + REQUIRE(chk == byte_sum); } - SECTION("stamp_works") - { - FIXEncodingStream stream (get_jetfix_cfg ()); - auto &msg = stream.new_msg (MessageTypes::MassQuote); - msg.add ("hello",5); - stream.close (); - stream.stamp (1,1000,"20150427-19:05:18.922"); + SECTION("stamp_works") { + FIXEncodingStream stream(get_jetfix_cfg()); + auto &msg = stream.new_msg(MessageTypes::MassQuote); + msg.add("hello", 5); + stream.close(); + stream.stamp(1, 1000, "20150427-19:05:18.922"); std::string lit = - "8=FIX.4.2\0019=000092\00135=i\00134=000000002\001369=000001000\001" - "52=20150427-19:05:18.922\00149=O2TESTER\00156=BTS\00157=BTS\001" - "58=hello\001"; + "8=FIX.4.2\0019=000092\00135=i\00134=000000002\001369=000001000\001" + "52=20150427-19:05:18.922\00149=O2TESTER\00156=BTS\00157=BTS\001" + "58=hello\001"; uint32_t lit_checksum = 0; for (auto c : lit) lit_checksum += c; std::ostringstream s; - s << lit << "10=" << std::setfill('0') << std::setw(3) << (lit_checksum % 256) << "\001"; - lit = s.str (); + s << lit << "10=" << std::setfill('0') << std::setw(3) + << (lit_checksum % 256) << "\001"; + lit = s.str(); - REQUIRE (lit==stream.to_str ()); + REQUIRE(lit == stream.to_str()); } - } - -}} - +} // namespace jetfix +} // namespace bts diff --git a/src/lib/jetfix/tests/fix_fragment_tests.cpp b/src/lib/jetfix/tests/fix_fragment_tests.cpp index 5757a55b6..919a7a1bf 100644 --- a/src/lib/jetfix/tests/fix_fragment_tests.cpp +++ b/src/lib/jetfix/tests/fix_fragment_tests.cpp @@ -7,194 +7,198 @@ namespace bts { namespace jetfix { -TEST_CASE ("JetFIX Field2Tests", "[jetfix]") -{ - SECTION("char_tests") - { - char out[] = {0,0}; +TEST_CASE("JetFIX Field2Tests", "[jetfix]") { + SECTION("char_tests") { + char out[] = {0, 0}; typedef CharField<123> Field; - - REQUIRE (Field::max_value_size ('A')==1); - auto result = Field::write (out,'A'); - REQUIRE (Field::tag_s==std::string ("123")); - REQUIRE (Field::tag_sz==3); - REQUIRE (Field::tag_checksum=='1'+'2'+'3'); - REQUIRE (result.first==1); - REQUIRE (result.second=='A'); - REQUIRE (out[0]=='A'); - REQUIRE (out[1]==0); + + REQUIRE(Field::max_value_size('A') == 1); + auto result = Field::write(out, 'A'); + REQUIRE(Field::tag_s == std::string("123")); + REQUIRE(Field::tag_sz == 3); + REQUIRE(Field::tag_checksum == '1' + '2' + '3'); + REQUIRE(result.first == 1); + REQUIRE(result.second == 'A'); + REQUIRE(out[0] == 'A'); + REQUIRE(out[1] == 0); } - SECTION("bool_tests") - { - char out[] = {0,0}; + SECTION("bool_tests") { + char out[] = {0, 0}; typedef BoolField<9> Field; - REQUIRE (Field::max_value_size (true)==1); - REQUIRE (Field::tag_s==std::string ("9")); - REQUIRE (Field::tag_sz==1); - REQUIRE (Field::tag_checksum=='9'); + REQUIRE(Field::max_value_size(true) == 1); + REQUIRE(Field::tag_s == std::string("9")); + REQUIRE(Field::tag_sz == 1); + REQUIRE(Field::tag_checksum == '9'); - auto result = Field::write (out,true); - REQUIRE (result.first==1); - REQUIRE (result.second=='Y'); - REQUIRE (out[0]=='Y'); - REQUIRE (out[1]==0); + auto result = Field::write(out, true); + REQUIRE(result.first == 1); + REQUIRE(result.second == 'Y'); + REQUIRE(out[0] == 'Y'); + REQUIRE(out[1] == 0); - result = Field::write (out,false); - REQUIRE (result.first==1); - REQUIRE (result.second=='N'); - REQUIRE (out[0]=='N'); - REQUIRE (out[1]==0); + result = Field::write(out, false); + REQUIRE(result.first == 1); + REQUIRE(result.second == 'N'); + REQUIRE(out[0] == 'N'); + REQUIRE(out[1] == 0); } - SECTION("float_tests") - { - std::string out (20, ' '); + SECTION("float_tests") { + std::string out(20, ' '); typedef FloatField<123> Field; - REQUIRE (Field::max_value_size (1.2,-1,6)==6); + REQUIRE(Field::max_value_size(1.2, -1, 6) == 6); - auto result = Field::write (&out[0],1.2,-1,6); - REQUIRE (result.first==6); - REQUIRE (result.second=='0'+'0'+'0'+'1'+'.'+'2'); - REQUIRE (out.compare (0,6,"0001.2") == 0); - REQUIRE (out[6]=='\0'); + auto result = Field::write(&out[0], 1.2, -1, 6); + REQUIRE(result.first == 6); + REQUIRE(result.second == '0' + '0' + '0' + '1' + '.' + '2'); + REQUIRE(out.compare(0, 6, "0001.2") == 0); + REQUIRE(out[6] == '\0'); } - SECTION("int_tests") - { - std::string out (20, ' '); + SECTION("int_tests") { + std::string out(20, ' '); typedef IntField<123> Field; - REQUIRE(Field::max_value_size (12,3)==3); + REQUIRE(Field::max_value_size(12, 3) == 3); - auto result = Field::write (&out[0],12,3); - REQUIRE (result.first==3); - REQUIRE (result.second=='0'+'1'+'2'); - REQUIRE (out.compare (0,3,"012") == 0); - REQUIRE (out[4]==' '); + auto result = Field::write(&out[0], 12, 3); + REQUIRE(result.first == 3); + REQUIRE(result.second == '0' + '1' + '2'); + REQUIRE(out.compare(0, 3, "012") == 0); + REQUIRE(out[4] == ' '); } - SECTION("string_tests") - { - std::string out (20, ' '); + SECTION("string_tests") { + std::string out(20, ' '); typedef StringField<123> Field; - REQUIRE(Field::max_value_size (std::string_view{"hello"})==5); + REQUIRE(Field::max_value_size(std::string_view{"hello"}) == 5); - auto result = Field::write (&out[0],std::string_view{"hello"}); - REQUIRE (result.first==5); - REQUIRE (result.second=='h'+'e'+'l'+'l'+'o'); - REQUIRE (out.compare (0,5,"hello") == 0); - REQUIRE (out[6]==' '); + auto result = Field::write(&out[0], std::string_view{"hello"}); + REQUIRE(result.first == 5); + REQUIRE(result.second == 'h' + 'e' + 'l' + 'l' + 'o'); + REQUIRE(out.compare(0, 5, "hello") == 0); + REQUIRE(out[6] == ' '); } - SECTION("ptime_tests") - { - std::string out (50, ' '); + SECTION("ptime_tests") { + std::string out(50, ' '); typedef TimeField<123> Field; - const char*t_s = "20150427-19:05:18.922"; - auto result = Field::write (&out[0],datetime::parse_FIX_timestamp (t_s)); - REQUIRE (result.first==strlen (t_s)); - REQUIRE (out.compare (0,strlen (t_s),t_s) == 0); - REQUIRE (out[strlen (t_s)]==' '); + const char *t_s = "20150427-19:05:18.922"; + auto result = Field::write(&out[0], datetime::parse_FIX_timestamp(t_s)); + REQUIRE(result.first == strlen(t_s)); + REQUIRE(out.compare(0, strlen(t_s), t_s) == 0); + REQUIRE(out[strlen(t_s)] == ' '); } - } +TEST_CASE("JetFIX FIXFragmentTests", "[jetfix]") { + SECTION("encoding_works") { + FIXFragment g(0); + g.add>('a'); + g.add>(1.2, -1, 6); + g.add>(std::string_view{"hello"}); + g.add>(123, 3); + const char *t_s = "20150427-19:05:18.922"; + g.add>(datetime::parse_FIX_timestamp(t_s)); + g.add>(true); -TEST_CASE ("JetFIX FIXFragmentTests" , "[jetfix]") -{ - SECTION("encoding_works") - { - FIXFragment g (0); - g.add> ('a'); - g.add> (1.2,-1,6); - g.add> (std::string_view{"hello"}); - g.add> (123,3); - const char*t_s = "20150427-19:05:18.922"; - g.add> (datetime::parse_FIX_timestamp (t_s)); - g.add> (true); - - std::string out = g.to_str (); - REQUIRE (out == - "1=a" "\001" - "2=0001.2" "\001" - "3=hello" "\001" - "4=123" "\001" - "5=20150427-19:05:18.922" "\001" - "6=Y" "\001"); + std::string out = g.to_str(); + REQUIRE( + out == "1=a" + "\001" + "2=0001.2" + "\001" + "3=hello" + "\001" + "4=123" + "\001" + "5=20150427-19:05:18.922" + "\001" + "6=Y" + "\001"); uint32_t checksum = 0; for (auto c : out) - checksum +=c; - REQUIRE (checksum==g.checksum ()); + checksum += c; + REQUIRE(checksum == g.checksum()); } - SECTION("bookmarking_works") - { - const char*t_s1 = "20150427-19:05:18.922"; - const char*t_s2 = "20150427-19:05:18.923"; + SECTION("bookmarking_works") { + const char *t_s1 = "20150427-19:05:18.922"; + const char *t_s2 = "20150427-19:05:18.923"; FIXFragment g; - auto c_bm = g.add> ('a'); - auto f_bm = g.add> (1.2,-1,6); - auto s_bm = g.add> (std::string_view{"hello"}); - auto i_bm = g.add> (123,3); - auto t_bm = g.add> (datetime::parse_FIX_timestamp (t_s1)); - auto b_bm = g.add> (true); + auto c_bm = g.add>('a'); + auto f_bm = g.add>(1.2, -1, 6); + auto s_bm = g.add>(std::string_view{"hello"}); + auto i_bm = g.add>(123, 3); + auto t_bm = g.add>(datetime::parse_FIX_timestamp(t_s1)); + auto b_bm = g.add>(true); - g.overwrite (c_bm,'b'); - g.overwrite (f_bm,1.3,-1,6); - g.overwrite (s_bm,std::string_view {"olleh"}); - g.overwrite (i_bm,321,3); - g.overwrite (t_bm,(datetime::parse_FIX_timestamp (t_s2))); - g.overwrite (b_bm,false); + g.overwrite(c_bm, 'b'); + g.overwrite(f_bm, 1.3, -1, 6); + g.overwrite(s_bm, std::string_view{"olleh"}); + g.overwrite(i_bm, 321, 3); + g.overwrite(t_bm, (datetime::parse_FIX_timestamp(t_s2))); + g.overwrite(b_bm, false); - std::string out = g.to_str (); - REQUIRE (out== "1=b" "\001" - "2=0001.3" "\001" - "3=olleh" "\001" - "4=321" "\001" - "5=20150427-19:05:18.923" "\001" - "6=N" "\001"); + std::string out = g.to_str(); + REQUIRE( + out == "1=b" + "\001" + "2=0001.3" + "\001" + "3=olleh" + "\001" + "4=321" + "\001" + "5=20150427-19:05:18.923" + "\001" + "6=N" + "\001"); uint32_t checksum = 0; for (auto c : out) - checksum +=c; - REQUIRE (checksum==g.checksum ()); + checksum += c; + REQUIRE(checksum == g.checksum()); } - - SECTION("append_works") - { - FIXFragment g1;; - g1.add> ('a'); - g1.add> (1.2,-1,6); - g1.add> (std::string_view{"hello"}); - auto chk1 = g1.checksum (); - + + SECTION("append_works") { + FIXFragment g1; + ; + g1.add>('a'); + g1.add>(1.2, -1, 6); + g1.add>(std::string_view{"hello"}); + auto chk1 = g1.checksum(); + FIXFragment g2; - g2.add> (std::string_view{"goodbye"}); - g2.add> (321,3); - auto chk2 = g2.checksum (); + g2.add>(std::string_view{"goodbye"}); + g2.add>(321, 3); + auto chk2 = g2.checksum(); - g1.append (g2); + g1.append(g2); - std::string out = g1.to_str (); - REQUIRE (out== "1=a" "\001" - "2=0001.2" "\001" - "3=hello" "\001" - "4=goodbye" "\001" - "5=321" "\001"); + std::string out = g1.to_str(); + REQUIRE( + out == "1=a" + "\001" + "2=0001.2" + "\001" + "3=hello" + "\001" + "4=goodbye" + "\001" + "5=321" + "\001"); - REQUIRE (chk1+chk2==g1.checksum ()); + REQUIRE(chk1 + chk2 == g1.checksum()); } - } - -}} - - +} // namespace jetfix +} // namespace bts diff --git a/src/lib/jetfix/tests/jetfix_performance_tests.cpp b/src/lib/jetfix/tests/jetfix_performance_tests.cpp index 676aebb7a..dbedf1abd 100644 --- a/src/lib/jetfix/tests/jetfix_performance_tests.cpp +++ b/src/lib/jetfix/tests/jetfix_performance_tests.cpp @@ -1,263 +1,233 @@ #include "catch/catch.hpp" +#include "lib/jetfix/codec/FIXFragment.h" +#include "lib/jetfix/codec/FIXMsg.h" +#include "lib/jetfix/codec/FIXParser.h" +#include "lib/jetfix/codec/FieldDefinitions.h" #include "lib/jetfix/codec/Fields.h" #include "lib/jetfix/codec/Group.h" -#include "lib/jetfix/codec/FIXMsg.h" -#include "lib/jetfix/codec/FieldDefinitions.h" -#include "lib/jetfix/connection/IConnectionObserver.h" #include "lib/jetfix/common/InMsgBuffer.h" -#include "lib/jetfix/codec/FIXParser.h" -#include "lib/jetfix/codec/FIXFragment.h" -#include "lib/utils/TimeStamp.h" +#include "lib/jetfix/connection/IConnectionObserver.h" #include "lib/logging/logging.h" +#include "lib/utils/TimeStamp.h" namespace bts { namespace jetfix { +TEST_CASE("JetFIX Performance Tests", "[jetfix] [benchmark]") { + const char *mq_char = "8=FIX.4.2\001" + "9=305\001" + "35=i\001" + "34=61\001" + "49=1U7001N\001" + "50=bluestream\001" + "52=20150427-19:29:40.610\001" + "56=CME\001" + "57=G\001" + "142=US,NC\001" -TEST_CASE ("JetFIX Performance Tests", "[jetfix] [benchmark]") -{ - const char* mq_char = - "8=FIX.4.2\001" - "9=305\001" - "35=i\001" - "34=61\001" - "49=1U7001N\001" - "50=bluestream\001" - "52=20150427-19:29:40.610\001" - "56=CME\001" - "57=G\001" - "142=US,NC\001" + "117=58\001" + "204=1\001" + "1028=N\001" + "7928=bluestream\001" + "9702=1\001" + "9771=TESTACC\001" + "296=1\001" + "302=1\001" + "304=2\001" + "295=2\001" - "117=58\001" - "204=1\001" - "1028=N\001" - "7928=bluestream\001" - "9702=1\001" - "9771=TESTACC\001" - "296=1\001" - "302=1\001" - "304=2\001" - "295=2\001" + "299=10857\001" + "55=EZ\001" + "167=OPT\001" + "107=ESK5 C1855\001" + "132=25200\001" + "133=25350\001" + "134=1\001" + "135=1\001" - "299=10857\001" - "55=EZ\001" - "167=OPT\001" - "107=ESK5 C1855\001" - "132=25200\001" - "133=25350\001" - "134=1\001" - "135=1\001" + "299=10856\001" + "55=EZ\001" + "167=OPT\001" + "107=ESK5 C1890\001" + "132=25201\001" + "133=25351\001" + "134=2\001" + "135=2\001" + "10=002\001"; - "299=10856\001" - "55=EZ\001" - "167=OPT\001" - "107=ESK5 C1890\001" - "132=25201\001" - "133=25351\001" - "134=2\001" - "135=2\001" - "10=002\001"; - - SECTION("decode_jetfix") - { - std::string mqs (mq_char); + SECTION("decode_jetfix") { + std::string mqs(mq_char); using namespace fix; - typedef FIXMsg MassQuote; + typedef FIXMsg< + MessageTypes::MassQuote, BeginString, BodyLength, MsgType, MsgSeqNum, + SenderCompID, SenderSubID, SendingTime, TargetCompId, TargetSubID, + SenderLocationID, QuoteID, CustomerOrFirm, ManualOrderIndicator, + SelfMatchPreventionID, CtiCode, MMAccount, QuoteSets, Checksum> + MassQuote; MassQuote mq; std::vector times; - for (int i = 0; i < 10000;i++) { - auto start = utils::TimeStamp::now (); - mq.read (mqs); - auto stop = utils::TimeStamp::now (); - times.push_back ((stop-start).microseconds ()); + for (int i = 0; i < 10000; i++) { + auto start = utils::TimeStamp::now(); + mq.read(mqs); + auto stop = utils::TimeStamp::now(); + times.push_back((stop - start).microseconds()); } - std::sort (times.begin (),times.end ()); - LOG(Testing,Info,"decode_jetfix t: {}us", times[times.size ()/2] ); + std::sort(times.begin(), times.end()); + LOG(Testing, Info, "decode_jetfix t: {}us", times[times.size() / 2]); } - SECTION("decode_with_parser") - { - auto fix = std::make_shared (mq_char); - + SECTION("decode_with_parser") { + auto fix = std::make_shared(mq_char); + using namespace fix; - typedef FIXMsg MassQuote; + typedef FIXMsg< + MessageTypes::MassQuote, BeginString, BodyLength, MsgType, MsgSeqNum, + SenderCompID, SenderSubID, SendingTime, TargetCompId, TargetSubID, + SenderLocationID, QuoteID, CustomerOrFirm, ManualOrderIndicator, + SelfMatchPreventionID, CtiCode, MMAccount, QuoteSets, Checksum> + MassQuote; MassQuote mq; FIXParser parser; std::vector result; - result.reserve (10000); - + result.reserve(10000); + std::vector times; - for (int i = 0; i < 10000;i++) { - auto start = utils::TimeStamp::now (); - result.emplace_back (parser.parse (InMsgBuffer (fix->data (),fix->size (),fix))); - auto stop = utils::TimeStamp::now (); - times.push_back ((stop-start).microseconds ()); + for (int i = 0; i < 10000; i++) { + auto start = utils::TimeStamp::now(); + result.emplace_back( + parser.parse(InMsgBuffer(fix->data(), fix->size(), fix))); + auto stop = utils::TimeStamp::now(); + times.push_back((stop - start).microseconds()); } - std::sort (times.begin (),times.end ()); - LOG(Testing,Info,"decode_with_parser t: {}us", times[times.size ()/2] ); + std::sort(times.begin(), times.end()); + LOG(Testing, Info, "decode_with_parser t: {}us", times[times.size() / 2]); } - - SECTION("encode_jetfix") - { + + SECTION("encode_jetfix") { std::vector times; - for (int i = 0; i < 1000;i++) { - - auto start = utils::TimeStamp::now (); - for (int n = 0; n < 100;n++) { + for (int i = 0; i < 1000; i++) { + + auto start = utils::TimeStamp::now(); + for (int n = 0; n < 100; n++) { FIXFragment g; using namespace fix; - g.add("58",sizeof("58")-1); + g.add("58", sizeof("58") - 1); g.add(1); g.add(true); - g.add("bluestream",sizeof("bluestream")-1); + g.add( + "bluestream", sizeof("bluestream") - 1); g.add('1'); - g.add("TESTACC",sizeof("TESTACC")-1); + g.add("TESTACC", sizeof("TESTACC") - 1); g.add(1); - g.add("302",sizeof("302")-1); + g.add("302", sizeof("302") - 1); g.add(2); - g.add (2); + g.add(2); - g.add("10857",sizeof("10857")-1); - g.add("55",sizeof("55")-1); - g.add("ESK5 C1855",sizeof("ESK5 C1855")-1); - g.add("OPT",sizeof("OPT")-1); - g.add(25200.0,-1,-1); + g.add("10857", sizeof("10857") - 1); + g.add("55", sizeof("55") - 1); + g.add("ESK5 C1855", sizeof("ESK5 C1855") - 1); + g.add("OPT", sizeof("OPT") - 1); + g.add(25200.0, -1, -1); g.add(1); - g.add(25200.0,-1,-1); + g.add(25200.0, -1, -1); g.add(1); - g.add("10857",sizeof("10857")-1); - g.add("55",sizeof("55")-1); - g.add("ESK5 C1855",sizeof("ESK5 C1855")-1); - g.add("OPT",sizeof("OPT")-1); - g.add(25200.0,-1,-1); + g.add("10857", sizeof("10857") - 1); + g.add("55", sizeof("55") - 1); + g.add("ESK5 C1855", sizeof("ESK5 C1855") - 1); + g.add("OPT", sizeof("OPT") - 1); + g.add(25200.0, -1, -1); g.add(1); - g.add(25200.0,-1,-1); + g.add(25200.0, -1, -1); g.add(1); - g.add(2,3); + g.add(2, 3); } - auto stop = utils::TimeStamp::now (); - times.push_back ((stop-start).microseconds ()); + auto stop = utils::TimeStamp::now(); + times.push_back((stop - start).microseconds()); } - std::sort (times.begin (),times.end ()); - LOG(Testing,Info,"encode_jetfix t: {}us", times[times.size ()/2] / 100 ); + std::sort(times.begin(), times.end()); + LOG(Testing, Info, "encode_jetfix t: {}us", + times[times.size() / 2] / 100); } - - SECTION("templated_encoding") - { + + SECTION("templated_encoding") { using namespace fix; std::vector times; FIXFragment header; - header.add("58",sizeof("58")-1); + header.add("58", sizeof("58") - 1); header.add(1); header.add(true); - header.add("bluestream",sizeof("bluestream")-1); + header.add("bluestream", sizeof("bluestream") - 1); header.add('1'); - header.add("TESTACC",sizeof("TESTACC")-1); + header.add("TESTACC", sizeof("TESTACC") - 1); header.add(1); - header.add("302",sizeof("302")-1); + header.add("302", sizeof("302") - 1); FIXFragment qt1; - auto qt1_quote_entry_id = qt1.add("10857",sizeof("10857")-1); - qt1.add("55",sizeof("55")-1); - qt1.add("ESK5 C1855",sizeof("ESK5 C1855")-1); - qt1.add("OPT",sizeof("OPT")-1); + auto qt1_quote_entry_id = + qt1.add("10857", sizeof("10857") - 1); + qt1.add("55", sizeof("55") - 1); + qt1.add("ESK5 C1855", sizeof("ESK5 C1855") - 1); + qt1.add("OPT", sizeof("OPT") - 1); - auto qt1_bid_px = qt1.add(25200.0,-1,-1); + auto qt1_bid_px = qt1.add(25200.0, -1, -1); auto qt1_bid_sz = qt1.add(1); - auto qt1_offer_px = qt1.add(25200.0,-1,-1); + auto qt1_offer_px = qt1.add(25200.0, -1, -1); auto qt1_offer_sz = qt1.add(1); FIXFragment qt2; - auto qt2_quote_entry_id = qt2.add("10857",sizeof("10857")-1); - qt2.add("55",sizeof("55")-1); - qt2.add("ESK5 C1855",sizeof("ESK5 C1855")-1); - qt2.add("OPT",sizeof("OPT")-1); + auto qt2_quote_entry_id = + qt2.add("10857", sizeof("10857") - 1); + qt2.add("55", sizeof("55") - 1); + qt2.add("ESK5 C1855", sizeof("ESK5 C1855") - 1); + qt2.add("OPT", sizeof("OPT") - 1); - auto qt2_bid_px = qt2.add(25200.0,-1,-1); + auto qt2_bid_px = qt2.add(25200.0, -1, -1); auto qt2_bid_sz = qt2.add(1); - auto qt2_offer_px = qt2.add(25200.0,-1,-1); + auto qt2_offer_px = qt2.add(25200.0, -1, -1); auto qt2_offer_sz = qt2.add(1); FIXFragment g; - for (int i = 0; i < 1000;i++) { - auto start = utils::TimeStamp::now (); - for (int n = 0; n < 100;n++) { - g.reset (); - g.append (header); + for (int i = 0; i < 1000; i++) { + auto start = utils::TimeStamp::now(); + for (int n = 0; n < 100; n++) { + g.reset(); + g.append(header); g.add(2); - g.add (2); + g.add(2); - qt1.overwrite (qt1_quote_entry_id,"10857",sizeof("10857")-1); - qt1.overwrite (qt1_bid_px,25200.0,-1,-1); - qt1.overwrite (qt1_bid_sz,1); - qt1.overwrite (qt1_offer_px,25200.0,-1,-1); - qt1.overwrite (qt1_offer_sz,1); - g.append (qt1); + qt1.overwrite(qt1_quote_entry_id, "10857", sizeof("10857") - 1); + qt1.overwrite(qt1_bid_px, 25200.0, -1, -1); + qt1.overwrite(qt1_bid_sz, 1); + qt1.overwrite(qt1_offer_px, 25200.0, -1, -1); + qt1.overwrite(qt1_offer_sz, 1); + g.append(qt1); - qt2.overwrite (qt2_quote_entry_id,"10857",sizeof("10857")-1); - qt2.overwrite (qt2_bid_px,25200.0,-1,-1); - qt2.overwrite (qt2_bid_sz,1); - qt2.overwrite (qt2_offer_px,25200.0,-1,-1); - qt2.overwrite (qt2_offer_sz,1); - g.append (qt2); + qt2.overwrite(qt2_quote_entry_id, "10857", sizeof("10857") - 1); + qt2.overwrite(qt2_bid_px, 25200.0, -1, -1); + qt2.overwrite(qt2_bid_sz, 1); + qt2.overwrite(qt2_offer_px, 25200.0, -1, -1); + qt2.overwrite(qt2_offer_sz, 1); + g.append(qt2); - g.add(2,3); + g.add(2, 3); } - auto stop = utils::TimeStamp::now (); - times.push_back ((stop-start).microseconds ()); + auto stop = utils::TimeStamp::now(); + times.push_back((stop - start).microseconds()); } - std::sort (times.begin (),times.end ()); - LOG(Testing,Info,"templated_encoding t: {}us", times[times.size ()/2] / 100 ); + std::sort(times.begin(), times.end()); + LOG(Testing, Info, "templated_encoding t: {}us", + times[times.size() / 2] / 100); } - } - -}} - - +} // namespace jetfix +} // namespace bts diff --git a/src/lib/jetfix/tests/sample_fix.cpp b/src/lib/jetfix/tests/sample_fix.cpp index 34a07e05e..d10e0adb5 100644 --- a/src/lib/jetfix/tests/sample_fix.cpp +++ b/src/lib/jetfix/tests/sample_fix.cpp @@ -2,1015 +2,4531 @@ namespace bts { namespace jetfix { -const char* data [] = { - "8=FIX.4.2\0019=132\00135=A\00134=1\00149=1U7001N\00150=bluestream\00152=20150427-19:05:17.032\00156=CME\00157=G\001142=US,NC\00195=3\00196=1U7\00198=0\001108=30\0011603=O2\0011604=1.0\0011605=BTS\00110=251\001", - "8=FIX.4.2\0019=127\00135=A\00134=25\001369=1\00152=20150427-19:05:18.922\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00198=0\001108=30\0011603=O2\0011604=1.0\0011605=BTS\00110=199\001", - "8=FIX.4.2\0019=91\00135=2\00134=2\00149=1U7001N\00150=bluestream\00152=20150427-19:05:18.951\00156=CME\00157=G\001142=US,NC\0017=1\00116=0\00110=209\001", - "8=FIX.4.2\0019=104\00135=1\00134=26\001369=1\00152=20150427-19:05:18.923\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001112=IDi8yfsl3t\00110=236\001", - "8=FIX.4.2\0019=114\00135=Z\00134=3\00149=1U7001N\00150=bluestream\00152=20150427-19:05:18.995\00156=CME\00157=G\001142=US,NC\001117=1\001295=1\00155=N/A\001298=4\0011028=N\00110=156\001", - "8=FIX.4.2\0019=136\00135=b\00134=1\001369=2\00152=20150427-19:05:18.974\00143=Y\00149=CME\00150=G\00156=1U7001N\001122=20150427-05:32:56.995\001117=CMEEW719\001297=3\0019772=0\0019774=EW\0019775=E\00110=028\001", - "8=FIX.4.2\0019=136\00135=b\00134=2\001369=2\00152=20150427-19:05:18.974\00143=Y\00149=CME\00150=G\00156=1U7001N\001122=20150427-05:32:57.021\001117=CME1V415\001297=3\0019772=0\0019774=1V\0019775=E\00110=217\001", - "8=FIX.4.2\0019=136\00135=b\00134=3\001369=2\00152=20150427-19:05:18.974\00143=Y\00149=CME\00150=G\00156=1U7001N\001122=20150427-05:32:57.068\001117=CMEEZ522\001297=3\0019772=0\0019774=EZ\0019775=E\00110=020\001", - "8=FIX.4.2\0019=136\00135=b\00134=4\001369=2\00152=20150427-19:05:18.974\00143=Y\00149=CME\00150=G\00156=1U7001N\001122=20150427-05:38:15.601\001117=CMEEW979\001297=3\0019772=0\0019774=EW\0019775=E\00110=024\001", - "8=FIX.4.2\0019=136\00135=b\00134=5\001369=2\00152=20150427-19:05:18.974\00143=Y\00149=CME\00150=G\00156=1U7001N\001122=20150427-05:38:15.629\001117=CME1V656\001297=3\0019772=0\0019774=1V\0019775=E\00110=241\001", - "8=FIX.4.2\0019=136\00135=b\00134=6\001369=2\00152=20150427-19:05:18.974\00143=Y\00149=CME\00150=G\00156=1U7001N\001122=20150427-05:38:15.765\001117=CMEEZ848\001297=3\0019772=0\0019774=EZ\0019775=E\00110=038\001", - "8=FIX.4.2\0019=137\00135=b\00134=7\001369=2\00152=20150427-19:05:18.974\00143=Y\00149=CME\00150=G\00156=1U7001N\001122=20150427-06:01:56.206\001117=CMEEW1242\001297=3\0019772=0\0019774=EW\0019775=E\00110=057\001", - "8=FIX.4.2\0019=136\00135=b\00134=8\001369=2\00152=20150427-19:05:18.974\00143=Y\00149=CME\00150=G\00156=1U7001N\001122=20150427-06:01:56.298\001117=CME1V902\001297=3\0019772=0\0019774=1V\0019775=E\00110=236\001", - "8=FIX.4.2\0019=137\00135=b\00134=9\001369=2\00152=20150427-19:05:18.974\00143=Y\00149=CME\00150=G\00156=1U7001N\001122=20150427-06:01:56.350\001117=CMEEZ1179\001297=3\0019772=0\0019774=EZ\0019775=E\00110=074\001", - "8=FIX.4.2\0019=138\00135=b\00134=10\001369=2\00152=20150427-19:05:18.974\00143=Y\00149=CME\00150=G\00156=1U7001N\001122=20150427-12:29:44.126\001117=CMEEW1619\001297=3\0019772=0\0019774=EW\0019775=E\00110=113\001", - "8=FIX.4.2\0019=138\00135=b\00134=11\001369=2\00152=20150427-19:05:18.975\00143=Y\00149=CME\00150=G\00156=1U7001N\001122=20150427-12:29:44.213\001117=CME1V1265\001297=3\0019772=0\0019774=1V\0019775=E\00110=067\001", - "8=FIX.4.2\0019=138\00135=b\00134=12\001369=2\00152=20150427-19:05:18.975\00143=Y\00149=CME\00150=G\00156=1U7001N\001122=20150427-12:29:44.238\001117=CMEEZ1627\001297=3\0019772=0\0019774=EZ\0019775=E\00110=125\001", - "8=FIX.4.2\0019=138\00135=b\00134=13\001369=2\00152=20150427-19:05:18.975\00143=Y\00149=CME\00150=G\00156=1U7001N\001122=20150427-13:42:19.772\001117=CMEEW1911\001297=3\0019772=0\0019774=EW\0019775=E\00110=117\001", - "8=FIX.4.2\0019=138\00135=b\00134=14\001369=2\00152=20150427-19:05:18.975\00143=Y\00149=CME\00150=G\00156=1U7001N\001122=20150427-13:42:19.861\001117=CME1V1529\001297=3\0019772=0\0019774=1V\0019775=E\00110=080\001", - "8=FIX.4.2\0019=138\00135=b\00134=15\001369=2\00152=20150427-19:05:18.975\00143=Y\00149=CME\00150=G\00156=1U7001N\001122=20150427-13:42:19.881\001117=CMEEZ1986\001297=3\0019772=0\0019774=EZ\0019775=E\00110=138\001", - "8=FIX.4.2\0019=138\00135=b\00134=16\001369=2\00152=20150427-19:05:18.975\00143=Y\00149=CME\00150=G\00156=1U7001N\001122=20150427-13:43:28.781\001117=CMEEW2172\001297=3\0019772=0\0019774=EW\0019775=E\00110=121\001", - "8=FIX.4.2\0019=138\00135=b\00134=17\001369=2\00152=20150427-19:05:18.975\00143=Y\00149=CME\00150=G\00156=1U7001N\001122=20150427-13:43:28.816\001117=CME1V1771\001297=3\0019772=0\0019774=1V\0019775=E\00110=083\001", - "8=FIX.4.2\0019=138\00135=b\00134=18\001369=2\00152=20150427-19:05:18.975\00143=Y\00149=CME\00150=G\00156=1U7001N\001122=20150427-13:43:28.975\001117=CMEEZ2313\001297=3\0019772=0\0019774=EZ\0019775=E\00110=131\001", - "8=FIX.4.2\0019=138\00135=b\00134=19\001369=2\00152=20150427-19:05:18.975\00143=Y\00149=CME\00150=G\00156=1U7001N\001122=20150427-16:41:14.395\001117=CMEEW2518\001297=3\0019772=0\0019774=EW\0019775=E\00110=125\001", - "8=FIX.4.2\0019=138\00135=b\00134=20\001369=2\00152=20150427-19:05:18.975\00143=Y\00149=CME\00150=G\00156=1U7001N\001122=20150427-16:41:14.421\001117=CME1V2089\001297=3\0019772=0\0019774=1V\0019775=E\00110=068\001", - "8=FIX.4.2\0019=138\00135=b\00134=21\001369=2\00152=20150427-19:05:18.975\00143=Y\00149=CME\00150=G\00156=1U7001N\001122=20150427-16:41:14.618\001117=CMEEZ2730\001297=3\0019772=0\0019774=EZ\0019775=E\00110=118\001", - "8=FIX.4.2\0019=138\00135=b\00134=22\001369=2\00152=20150427-19:05:18.975\00143=Y\00149=CME\00150=G\00156=1U7001N\001122=20150427-18:03:09.895\001117=CMEEW2822\001297=3\0019772=0\0019774=EW\0019775=E\00110=126\001", - "8=FIX.4.2\0019=138\00135=b\00134=23\001369=2\00152=20150427-19:05:18.975\00143=Y\00149=CME\00150=G\00156=1U7001N\001122=20150427-18:03:09.967\001117=CME1V2364\001297=3\0019772=0\0019774=1V\0019775=E\00110=086\001", - "8=FIX.4.2\0019=138\00135=b\00134=24\001369=2\00152=20150427-19:05:18.975\00143=Y\00149=CME\00150=G\00156=1U7001N\001122=20150427-18:03:10.251\001117=CMEEZ3102\001297=3\0019772=0\0019774=EZ\0019775=E\00110=104\001", - "8=FIX.4.2\0019=97\00135=0\00134=4\00149=1U7001N\00150=bluestream\00152=20150427-19:05:19.053\00156=CME\00157=G\001142=US,NC\001112=IDi8yfsl3t\00110=187\001", - "8=FIX.4.2\0019=132\00135=4\00134=25\001369=2\00152=20150427-19:05:18.975\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001122=20150427-19:05:18.975\001143=US,NC\00136=27\001123=Y\00110=225\001", - "8=FIX.4.2\0019=123\00135=b\00134=27\001369=3\00152=20150427-19:05:19.026\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=1\001297=4\0011028=N\0019772=0\0019774=1V\00110=017\001", - "8=FIX.4.2\0019=123\00135=b\00134=28\001369=3\00152=20150427-19:05:19.026\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=1\001297=4\0011028=N\0019772=0\0019774=96\00110=250\001", - "8=FIX.4.2\0019=123\00135=b\00134=29\001369=3\00152=20150427-19:05:19.026\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=1\001297=4\0011028=N\0019772=0\0019774=EW\00110=040\001", - "8=FIX.4.2\0019=123\00135=b\00134=30\001369=3\00152=20150427-19:05:19.026\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=1\001297=4\0011028=N\0019772=0\0019774=EZ\00110=035\001", - "8=FIX.4.2\0019=123\00135=b\00134=31\001369=3\00152=20150427-19:05:19.026\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=1\001297=4\0011028=N\0019772=0\0019774=T$\00110=253\001", - "8=FIX.4.2\0019=123\00135=b\00134=32\001369=3\00152=20150427-19:05:19.026\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=1\001297=4\0011028=N\0019772=0\0019774=TE\00110=031\001", - "8=FIX.4.2\0019=132\00135=A\00134=5\00149=1U7001N\00150=bluestream\00152=20150427-19:06:35.838\00156=CME\00157=G\001142=US,NC\00195=3\00196=1U7\00198=0\001108=30\0011603=O2\0011604=1.0\0011605=BTS\00110=014\001", - "8=FIX.4.2\0019=127\00135=A\00134=39\001369=5\00152=20150427-19:06:37.384\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00198=0\001108=30\0011603=O2\0011604=1.0\0011605=BTS\00110=212\001", - "8=FIX.4.2\0019=92\00135=2\00134=6\00149=1U7001N\00150=bluestream\00152=20150427-19:06:37.412\00156=CME\00157=G\001142=US,NC\0017=33\00116=0\00110=005\001", - "8=FIX.4.2\0019=104\00135=1\00134=40\001369=5\00152=20150427-19:06:37.384\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001112=IDi8yfsl3u\00110=240\001", - "8=FIX.4.2\0019=164\00135=b\00134=33\001369=6\00152=20150427-19:06:37.437\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-19:05:25.280\001143=US,NC\001117=CME1V2624\001297=4\0011028=N\0019772=0\0019774=1V\0019775=A\00110=249\001", - "8=FIX.4.2\0019=164\00135=b\00134=34\001369=6\00152=20150427-19:06:37.437\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-19:05:25.280\001143=US,NC\001117=CMEEW3099\001297=4\0011028=N\0019772=0\0019774=EW\0019775=A\00110=043\001", - "8=FIX.4.2\0019=163\00135=b\00134=35\001369=6\00152=20150427-19:06:37.437\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-19:05:25.280\001143=US,NC\001117=CMET$121\001297=4\0011028=N\0019772=0\0019774=T$\0019775=A\00110=162\001", - "8=FIX.4.2\0019=164\00135=b\00134=36\001369=6\00152=20150427-19:06:37.437\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-19:05:25.280\001143=US,NC\001117=CMEEZ3435\001297=4\0011028=N\0019772=0\0019774=EZ\0019775=A\00110=045\001", - "8=FIX.4.2\0019=163\00135=b\00134=37\001369=6\00152=20150427-19:06:37.437\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-19:05:25.280\001143=US,NC\001117=CMETE200\001297=4\0011028=N\0019772=0\0019774=TE\0019775=A\00110=228\001", - "8=FIX.4.2\0019=114\00135=Z\00134=7\00149=1U7001N\00150=bluestream\00152=20150427-19:06:37.493\00156=CME\00157=G\001142=US,NC\001117=5\001295=1\00155=N/A\001298=4\0011028=N\00110=159\001", - "8=FIX.4.2\0019=163\00135=b\00134=38\001369=6\00152=20150427-19:06:37.437\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-19:05:25.282\001143=US,NC\001117=CME96114\001297=4\0011028=N\0019772=0\0019774=96\0019775=A\00110=151\001", - "8=FIX.4.2\0019=97\00135=0\00134=8\00149=1U7001N\00150=bluestream\00152=20150427-19:06:37.538\00156=CME\00157=G\001142=US,NC\001112=IDi8yfsl3u\00110=201\001", - "8=FIX.4.2\0019=132\00135=4\00134=39\001369=6\00152=20150427-19:06:37.437\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001122=20150427-19:06:37.437\001143=US,NC\00136=41\001123=Y\00110=220\001", - "8=FIX.4.2\0019=123\00135=b\00134=41\001369=7\00152=20150427-19:06:37.518\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=5\001297=4\0011028=N\0019772=0\0019774=96\00110=004\001", - "8=FIX.4.2\0019=123\00135=b\00134=42\001369=7\00152=20150427-19:06:37.524\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=5\001297=4\0011028=N\0019772=0\0019774=1V\00110=026\001", - "8=FIX.4.2\0019=123\00135=b\00134=43\001369=7\00152=20150427-19:06:37.524\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=5\001297=4\0011028=N\0019772=0\0019774=EW\00110=048\001", - "8=FIX.4.2\0019=123\00135=b\00134=44\001369=7\00152=20150427-19:06:37.524\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=5\001297=4\0011028=N\0019772=0\0019774=EZ\00110=052\001", - "8=FIX.4.2\0019=123\00135=b\00134=45\001369=7\00152=20150427-19:06:37.530\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=5\001297=4\0011028=N\0019772=0\0019774=T$\00110=011\001", - "8=FIX.4.2\0019=123\00135=b\00134=46\001369=7\00152=20150427-19:06:37.530\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=5\001297=4\0011028=N\0019772=0\0019774=TE\00110=045\001", - "8=FIX.4.2\0019=82\00135=0\00134=9\00149=1U7001N\00150=bluestream\00152=20150427-19:07:07.873\00156=CME\00157=G\001142=US,NC\00110=094\001", - "8=FIX.4.2\0019=89\00135=0\00134=47\001369=9\00152=20150427-19:07:08.078\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=111\001", - "8=FIX.4.2\0019=83\00135=0\00134=10\00149=1U7001N\00150=bluestream\00152=20150427-19:07:37.905\00156=CME\00157=G\001142=US,NC\00110=134\001", - "8=FIX.4.2\0019=90\00135=0\00134=48\001369=10\00152=20150427-19:07:39.084\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=145\001", - "8=FIX.4.2\0019=83\00135=0\00134=11\00149=1U7001N\00150=bluestream\00152=20150427-19:08:07.937\00156=CME\00157=G\001142=US,NC\00110=138\001", - "8=FIX.4.2\0019=90\00135=0\00134=49\001369=11\00152=20150427-19:08:10.088\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=141\001", - "8=FIX.4.2\0019=83\00135=0\00134=12\00149=1U7001N\00150=bluestream\00152=20150427-19:08:37.968\00156=CME\00157=G\001142=US,NC\00110=146\001", - "8=FIX.4.2\0019=90\00135=0\00134=50\001369=12\00152=20150427-19:08:41.093\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=134\001", - "8=FIX.4.2\0019=83\00135=0\00134=13\00149=1U7001N\00150=bluestream\00152=20150427-19:09:07.000\00156=CME\00157=G\001142=US,NC\00110=122\001", - "8=FIX.4.2\0019=90\00135=0\00134=51\001369=13\00152=20150427-19:09:12.098\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=140\001", - "8=FIX.4.2\0019=83\00135=0\00134=14\00149=1U7001N\00150=bluestream\00152=20150427-19:09:37.031\00156=CME\00157=G\001142=US,NC\00110=130\001", - "8=FIX.4.2\0019=90\00135=0\00134=52\001369=14\00152=20150427-19:09:43.106\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=136\001", - "8=FIX.4.2\0019=133\00135=A\00134=15\00149=1U7001N\00150=bluestream\00152=20150427-19:11:24.357\00156=CME\00157=G\001142=US,NC\00195=3\00196=1U7\00198=0\001108=30\0011603=O2\0011604=1.0\0011605=BTS\00110=054\001", - "8=FIX.4.2\0019=128\00135=A\00134=59\001369=15\00152=20150427-19:11:25.963\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00198=0\001108=30\0011603=O2\0011604=1.0\0011605=BTS\00110=004\001", - "8=FIX.4.2\0019=93\00135=2\00134=16\00149=1U7001N\00150=bluestream\00152=20150427-19:11:25.992\00156=CME\00157=G\001142=US,NC\0017=53\00116=0\00110=063\001", - "8=FIX.4.2\0019=105\00135=1\00134=60\001369=15\00152=20150427-19:11:25.963\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001112=IDi8yfsl3v\00110=033\001", - "8=FIX.4.2\0019=116\00135=Z\00134=17\00149=1U7001N\00150=bluestream\00152=20150427-19:11:26.014\00156=CME\00157=G\001142=US,NC\001117=15\001295=1\00155=N/A\001298=4\0011028=N\00110=242\001", - "8=FIX.4.2\0019=165\00135=b\00134=53\001369=16\00152=20150427-19:11:26.018\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-19:09:54.204\001143=US,NC\001117=CME1V2628\001297=4\0011028=N\0019772=0\0019774=1V\0019775=A\00110=040\001", - "8=FIX.4.2\0019=165\00135=b\00134=54\001369=16\00152=20150427-19:11:26.018\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-19:09:54.204\001143=US,NC\001117=CMEEW3103\001297=4\0011028=N\0019772=0\0019774=EW\0019775=A\00110=072\001", - "8=FIX.4.2\0019=165\00135=b\00134=55\001369=16\00152=20150427-19:11:26.019\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-19:09:54.204\001143=US,NC\001117=CMEEZ3439\001297=4\0011028=N\0019772=0\0019774=EZ\0019775=A\00110=092\001", - "8=FIX.4.2\0019=164\00135=b\00134=56\001369=16\00152=20150427-19:11:26.019\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-19:09:54.207\001143=US,NC\001117=CME96115\001297=4\0011028=N\0019772=0\0019774=96\0019775=A\00110=195\001", - "8=FIX.4.2\0019=164\00135=b\00134=57\001369=16\00152=20150427-19:11:26.019\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-19:09:54.207\001143=US,NC\001117=CMET$122\001297=4\0011028=N\0019772=0\0019774=T$\0019775=A\00110=212\001", - "8=FIX.4.2\0019=164\00135=b\00134=58\001369=16\00152=20150427-19:11:26.019\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-19:09:54.207\001143=US,NC\001117=CMETE201\001297=4\0011028=N\0019772=0\0019774=TE\0019775=A\00110=021\001", - "8=FIX.4.2\0019=98\00135=0\00134=18\00149=1U7001N\00150=bluestream\00152=20150427-19:11:26.100\00156=CME\00157=G\001142=US,NC\001112=IDi8yfsl3v\00110=231\001", - "8=FIX.4.2\0019=133\00135=4\00134=59\001369=16\00152=20150427-19:11:26.019\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001122=20150427-19:11:26.019\001143=US,NC\00136=61\001123=Y\00110=254\001", - "8=FIX.4.2\0019=125\00135=b\00134=61\001369=17\00152=20150427-19:11:26.070\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=15\001297=4\0011028=N\0019772=0\0019774=T$\00110=102\001", - "8=FIX.4.2\0019=125\00135=b\00134=62\001369=17\00152=20150427-19:11:26.070\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=15\001297=4\0011028=N\0019772=0\0019774=TE\00110=136\001", - "8=FIX.4.2\0019=125\00135=b\00134=63\001369=17\00152=20150427-19:11:26.072\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=15\001297=4\0011028=N\0019772=0\0019774=96\00110=097\001", - "8=FIX.4.2\0019=125\00135=b\00134=64\001369=17\00152=20150427-19:11:26.076\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=15\001297=4\0011028=N\0019772=0\0019774=1V\00110=126\001", - "8=FIX.4.2\0019=125\00135=b\00134=65\001369=17\00152=20150427-19:11:26.076\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=15\001297=4\0011028=N\0019772=0\0019774=EW\00110=148\001", - "8=FIX.4.2\0019=125\00135=b\00134=66\001369=17\00152=20150427-19:11:26.076\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=15\001297=4\0011028=N\0019772=0\0019774=EZ\00110=152\001", - "8=FIX.4.2\0019=105\00135=1\00134=67\001369=18\00152=20150427-19:11:56.129\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001112=IDi8yfsl3w\00110=042\001", - "8=FIX.4.2\0019=98\00135=0\00134=19\00149=1U7001N\00150=bluestream\00152=20150427-19:11:56.156\00156=CME\00157=G\001142=US,NC\001112=IDi8yfsl3w\00110=247\001", - "8=FIX.4.2\0019=83\00135=0\00134=20\00149=1U7001N\00150=bluestream\00152=20150427-19:12:26.423\00156=CME\00157=G\001142=US,NC\00110=124\001", - "8=FIX.4.2\0019=90\00135=0\00134=68\001369=20\00152=20150427-19:12:27.135\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=138\001", - "8=FIX.4.2\0019=83\00135=0\00134=21\00149=1U7001N\00150=bluestream\00152=20150427-19:12:56.454\00156=CME\00157=G\001142=US,NC\00110=132\001", - "8=FIX.4.2\0019=90\00135=0\00134=69\001369=21\00152=20150427-19:12:58.140\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=140\001", - "8=FIX.4.2\0019=83\00135=0\00134=22\00149=1U7001N\00150=bluestream\00152=20150427-19:13:26.485\00156=CME\00157=G\001142=US,NC\00110=135\001", - "8=FIX.4.2\0019=90\00135=0\00134=70\001369=22\00152=20150427-19:13:29.146\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=138\001", - "8=FIX.4.2\0019=83\00135=0\00134=23\00149=1U7001N\00150=bluestream\00152=20150427-19:13:56.517\00156=CME\00157=G\001142=US,NC\00110=135\001", - "8=FIX.4.2\0019=90\00135=0\00134=71\001369=23\00152=20150427-19:14:00.150\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=125\001", - "8=FIX.4.2\0019=83\00135=0\00134=24\00149=1U7001N\00150=bluestream\00152=20150427-19:14:26.549\00156=CME\00157=G\001142=US,NC\00110=139\001", - "8=FIX.4.2\0019=90\00135=0\00134=72\001369=24\00152=20150427-19:14:31.157\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=138\001", - "8=FIX.4.2\0019=83\00135=0\00134=25\00149=1U7001N\00150=bluestream\00152=20150427-19:14:56.581\00156=CME\00157=G\001142=US,NC\00110=139\001", - "8=FIX.4.2\0019=90\00135=0\00134=73\001369=25\00152=20150427-19:15:02.164\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=137\001", - "8=FIX.4.2\0019=83\00135=0\00134=26\00149=1U7001N\00150=bluestream\00152=20150427-19:15:26.611\00156=CME\00157=G\001142=US,NC\00110=132\001", - "8=FIX.4.2\0019=90\00135=0\00134=74\001369=26\00152=20150427-19:15:33.169\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=148\001", - "8=FIX.4.2\0019=83\00135=0\00134=27\00149=1U7001N\00150=bluestream\00152=20150427-19:15:56.642\00156=CME\00157=G\001142=US,NC\00110=140\001", - "8=FIX.4.2\0019=90\00135=0\00134=75\001369=27\00152=20150427-19:16:04.174\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=145\001", - "8=FIX.4.2\0019=83\00135=0\00134=28\00149=1U7001N\00150=bluestream\00152=20150427-19:16:26.672\00156=CME\00157=G\001142=US,NC\00110=142\001", - "8=FIX.4.2\0019=90\00135=0\00134=76\001369=28\00152=20150427-19:16:35.180\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=148\001", - "8=FIX.4.2\0019=83\00135=0\00134=29\00149=1U7001N\00150=bluestream\00152=20150427-19:16:56.703\00156=CME\00157=G\001142=US,NC\00110=141\001", - "8=FIX.4.2\0019=90\00135=0\00134=77\001369=29\00152=20150427-19:17:06.186\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=155\001", - "8=FIX.4.2\0019=83\00135=0\00134=30\00149=1U7001N\00150=bluestream\00152=20150427-19:17:26.734\00156=CME\00157=G\001142=US,NC\00110=135\001", - "8=FIX.4.2\0019=90\00135=0\00134=78\001369=30\00152=20150427-19:17:37.191\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=148\001", - "8=FIX.4.2\0019=83\00135=0\00134=31\00149=1U7001N\00150=bluestream\00152=20150427-19:17:56.765\00156=CME\00157=G\001142=US,NC\00110=143\001", - "8=FIX.4.2\0019=90\00135=0\00134=79\001369=31\00152=20150427-19:18:08.196\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=154\001", - "8=FIX.4.2\0019=83\00135=0\00134=32\00149=1U7001N\00150=bluestream\00152=20150427-19:18:26.797\00156=CME\00157=G\001142=US,NC\00110=147\001", - "8=FIX.4.2\0019=90\00135=0\00134=80\001369=32\00152=20150427-19:18:39.203\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=140\001", - "8=FIX.4.2\0019=83\00135=0\00134=33\00149=1U7001N\00150=bluestream\00152=20150427-19:18:56.830\00156=CME\00157=G\001142=US,NC\00110=139\001", - "8=FIX.4.2\0019=90\00135=0\00134=81\001369=33\00152=20150427-19:19:10.207\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=136\001", - "8=FIX.4.2\0019=83\00135=0\00134=34\00149=1U7001N\00150=bluestream\00152=20150427-19:19:26.862\00156=CME\00157=G\001142=US,NC\00110=143\001", - "8=FIX.4.2\0019=90\00135=0\00134=82\001369=34\00152=20150427-19:19:41.212\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=138\001", - "8=FIX.4.2\0019=83\00135=0\00134=35\00149=1U7001N\00150=bluestream\00152=20150427-19:19:56.893\00156=CME\00157=G\001142=US,NC\00110=151\001", - "8=FIX.4.2\0019=90\00135=0\00134=83\001369=35\00152=20150427-19:20:12.217\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=135\001", - "8=FIX.4.2\0019=83\00135=0\00134=36\00149=1U7001N\00150=bluestream\00152=20150427-19:20:26.925\00156=CME\00157=G\001142=US,NC\00110=137\001", - "8=FIX.4.2\0019=90\00135=0\00134=84\001369=36\00152=20150427-19:20:43.222\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=137\001", - "8=FIX.4.2\0019=83\00135=0\00134=37\00149=1U7001N\00150=bluestream\00152=20150427-19:20:56.955\00156=CME\00157=G\001142=US,NC\00110=144\001", - "8=FIX.4.2\0019=90\00135=0\00134=85\001369=37\00152=20150427-19:21:14.227\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=143\001", - "8=FIX.4.2\0019=83\00135=0\00134=38\00149=1U7001N\00150=bluestream\00152=20150427-19:21:26.987\00156=CME\00157=G\001142=US,NC\00110=148\001", - "8=FIX.4.2\0019=90\00135=0\00134=86\001369=38\00152=20150427-19:21:45.232\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=145\001", - "8=FIX.4.2\0019=133\00135=A\00134=39\00149=1U7001N\00150=bluestream\00152=20150427-19:22:00.231\00156=CME\00157=G\001142=US,NC\00195=3\00196=1U7\00198=0\001108=30\0011603=O2\0011604=1.0\0011605=BTS\00110=047\001", - "8=FIX.4.2\0019=128\00135=A\00134=93\001369=39\00152=20150427-19:22:01.752\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00198=0\001108=30\0011603=O2\0011604=1.0\0011605=BTS\00110=000\001", - "8=FIX.4.2\0019=93\00135=2\00134=40\00149=1U7001N\00150=bluestream\00152=20150427-19:22:01.780\00156=CME\00157=G\001142=US,NC\0017=87\00116=0\00110=058\001", - "8=FIX.4.2\0019=105\00135=1\00134=94\001369=39\00152=20150427-19:22:01.752\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001112=IDi8yfsl3x\00110=040\001", - "8=FIX.4.2\0019=116\00135=Z\00134=41\00149=1U7001N\00150=bluestream\00152=20150427-19:22:01.784\00156=CME\00157=G\001142=US,NC\001117=39\001295=1\00155=N/A\001298=4\0011028=N\00110=254\001", - "8=FIX.4.2\0019=165\00135=b\00134=87\001369=40\00152=20150427-19:22:01.802\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-19:21:56.933\001143=US,NC\001117=CME1V2635\001297=4\0011028=N\0019772=0\0019774=1V\0019775=A\00110=043\001", - "8=FIX.4.2\0019=165\00135=b\00134=88\001369=40\00152=20150427-19:22:01.802\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-19:21:56.933\001143=US,NC\001117=CMEEW3111\001297=4\0011028=N\0019772=0\0019774=EW\0019775=A\00110=076\001", - "8=FIX.4.2\0019=165\00135=b\00134=89\001369=40\00152=20150427-19:22:01.802\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-19:21:56.934\001143=US,NC\001117=CMEEZ3447\001297=4\0011028=N\0019772=0\0019774=EZ\0019775=A\00110=096\001", - "8=FIX.4.2\0019=164\00135=b\00134=90\001369=40\00152=20150427-19:22:01.802\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-19:21:56.934\001143=US,NC\001117=CME96117\001297=4\0011028=N\0019772=0\0019774=96\0019775=A\00110=190\001", - "8=FIX.4.2\0019=164\00135=b\00134=91\001369=40\00152=20150427-19:22:01.802\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-19:21:56.935\001143=US,NC\001117=CMET$124\001297=4\0011028=N\0019772=0\0019774=T$\0019775=A\00110=208\001", - "8=FIX.4.2\0019=164\00135=b\00134=92\001369=40\00152=20150427-19:22:01.802\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-19:21:56.935\001143=US,NC\001117=CMETE203\001297=4\0011028=N\0019772=0\0019774=TE\0019775=A\00110=017\001", - "8=FIX.4.2\0019=98\00135=0\00134=42\00149=1U7001N\00150=bluestream\00152=20150427-19:22:01.889\00156=CME\00157=G\001142=US,NC\001112=IDi8yfsl3x\00110=249\001", - "8=FIX.4.2\0019=133\00135=4\00134=93\001369=40\00152=20150427-19:22:01.802\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001122=20150427-19:22:01.802\001143=US,NC\00136=95\001123=Y\00110=246\001", - "8=FIX.4.2\0019=125\00135=b\00134=95\001369=41\00152=20150427-19:22:01.852\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=39\001297=4\0011028=N\0019772=0\0019774=96\00110=106\001", - "8=FIX.4.2\0019=125\00135=b\00134=96\001369=41\00152=20150427-19:22:01.855\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=39\001297=4\0011028=N\0019772=0\0019774=1V\00110=134\001", - "8=FIX.4.2\0019=125\00135=b\00134=97\001369=41\00152=20150427-19:22:01.855\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=39\001297=4\0011028=N\0019772=0\0019774=EW\00110=156\001", - "8=FIX.4.2\0019=125\00135=b\00134=98\001369=41\00152=20150427-19:22:01.855\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=39\001297=4\0011028=N\0019772=0\0019774=EZ\00110=160\001", - "8=FIX.4.2\0019=125\00135=b\00134=99\001369=41\00152=20150427-19:22:01.861\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=39\001297=4\0011028=N\0019772=0\0019774=T$\00110=119\001", - "8=FIX.4.2\0019=126\00135=b\00134=100\001369=41\00152=20150427-19:22:01.861\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=39\001297=4\0011028=N\0019772=0\0019774=TE\00110=184\001", - "8=FIX.4.2\0019=83\00135=0\00134=43\00149=1U7001N\00150=bluestream\00152=20150427-19:22:31.264\00156=CME\00157=G\001142=US,NC\00110=129\001", - "8=FIX.4.2\0019=91\00135=0\00134=101\001369=43\00152=20150427-19:22:32.240\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=174\001", - "8=FIX.4.2\0019=83\00135=0\00134=44\00149=1U7001N\00150=bluestream\00152=20150427-19:23:01.296\00156=CME\00157=G\001142=US,NC\00110=133\001", - "8=FIX.4.2\0019=91\00135=0\00134=102\001369=44\00152=20150427-19:23:03.245\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=180\001", - "8=FIX.4.2\0019=83\00135=0\00134=45\00149=1U7001N\00150=bluestream\00152=20150427-19:23:31.328\00156=CME\00157=G\001142=US,NC\00110=133\001", - "8=FIX.4.2\0019=91\00135=0\00134=103\001369=45\00152=20150427-19:23:34.250\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=182\001", - "8=FIX.4.2\0019=83\00135=0\00134=46\00149=1U7001N\00150=bluestream\00152=20150427-19:24:01.360\00156=CME\00157=G\001142=US,NC\00110=128\001", - "8=FIX.4.2\0019=91\00135=0\00134=104\001369=46\00152=20150427-19:24:05.255\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=188\001", - "8=FIX.4.2\0019=83\00135=0\00134=47\00149=1U7001N\00150=bluestream\00152=20150427-19:24:31.390\00156=CME\00157=G\001142=US,NC\00110=135\001", - "8=FIX.4.2\0019=91\00135=0\00134=105\001369=47\00152=20150427-19:24:36.260\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=190\001", - "8=FIX.4.2\0019=83\00135=0\00134=48\00149=1U7001N\00150=bluestream\00152=20150427-19:25:01.421\00156=CME\00157=G\001142=US,NC\00110=129\001", - "8=FIX.4.2\0019=91\00135=0\00134=106\001369=48\00152=20150427-19:25:07.265\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=196\001", - "8=FIX.4.2\0019=83\00135=0\00134=49\00149=1U7001N\00150=bluestream\00152=20150427-19:25:31.450\00156=CME\00157=G\001142=US,NC\00110=135\001", - "8=FIX.4.2\0019=91\00135=0\00134=107\001369=49\00152=20150427-19:25:38.269\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=206\001", - "8=FIX.4.2\0019=83\00135=0\00134=50\00149=1U7001N\00150=bluestream\00152=20150427-19:26:01.480\00156=CME\00157=G\001142=US,NC\00110=128\001", - "8=FIX.4.2\0019=91\00135=0\00134=108\001369=50\00152=20150427-19:26:09.274\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=194\001", - "8=FIX.4.2\0019=83\00135=0\00134=51\00149=1U7001N\00150=bluestream\00152=20150427-19:26:31.511\00156=CME\00157=G\001142=US,NC\00110=127\001", - "8=FIX.4.2\0019=91\00135=0\00134=109\001369=51\00152=20150427-19:26:40.279\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=196\001", - "8=FIX.4.2\0019=83\00135=0\00134=52\00149=1U7001N\00150=bluestream\00152=20150427-19:27:01.542\00156=CME\00157=G\001142=US,NC\00110=130\001", - "8=FIX.4.2\0019=91\00135=0\00134=110\001369=52\00152=20150427-19:27:11.283\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=183\001", - "8=FIX.4.2\0019=83\00135=0\00134=53\00149=1U7001N\00150=bluestream\00152=20150427-19:27:31.573\00156=CME\00157=G\001142=US,NC\00110=138\001", - "8=FIX.4.2\0019=91\00135=0\00134=111\001369=53\00152=20150427-19:27:42.291\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=188\001", - "8=FIX.4.2\0019=83\00135=0\00134=54\00149=1U7001N\00150=bluestream\00152=20150427-19:28:01.603\00156=CME\00157=G\001142=US,NC\00110=131\001", - "8=FIX.4.2\0019=91\00135=0\00134=112\001369=54\00152=20150427-19:28:13.298\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=196\001", - "8=FIX.4.2\0019=83\00135=0\00134=55\00149=1U7001N\00150=bluestream\00152=20150427-19:28:31.633\00156=CME\00157=G\001142=US,NC\00110=138\001", - "8=FIX.4.2\0019=91\00135=0\00134=113\001369=55\00152=20150427-19:28:44.303\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=189\001", - "8=FIX.4.2\0019=83\00135=0\00134=56\00149=1U7001N\00150=bluestream\00152=20150427-19:29:01.665\00156=CME\00157=G\001142=US,NC\00110=142\001", - "8=FIX.4.2\0019=133\00135=A\00134=57\00149=1U7001N\00150=bluestream\00152=20150427-19:29:14.817\00156=CME\00157=G\001142=US,NC\00195=3\00196=1U7\00198=0\001108=30\0011603=O2\0011604=1.0\0011605=BTS\00110=069\001", - "8=FIX.4.2\0019=129\00135=A\00134=120\001369=57\00152=20150427-19:29:16.376\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00198=0\001108=30\0011603=O2\0011604=1.0\0011605=BTS\00110=055\001", - "8=FIX.4.2\0019=94\00135=2\00134=58\00149=1U7001N\00150=bluestream\00152=20150427-19:29:16.404\00156=CME\00157=G\001142=US,NC\0017=114\00116=0\00110=113\001", - "8=FIX.4.2\0019=106\00135=1\00134=121\001369=57\00152=20150427-19:29:16.376\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001112=IDi8yfsl3y\00110=096\001", - "8=FIX.4.2\0019=165\00135=b\00134=114\001369=58\00152=20150427-19:29:16.424\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-19:29:05.528\001143=US,NC\001117=CMET$125\001297=4\0011028=N\0019772=0\0019774=T$\0019775=A\00110=020\001", - "8=FIX.4.2\0019=165\00135=b\00134=115\001369=58\00152=20150427-19:29:16.424\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-19:29:05.528\001143=US,NC\001117=CMETE204\001297=4\0011028=N\0019772=0\0019774=TE\0019775=A\00110=085\001", - "8=FIX.4.2\0019=166\00135=b\00134=116\001369=58\00152=20150427-19:29:16.424\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-19:29:05.531\001143=US,NC\001117=CME1V2639\001297=4\0011028=N\0019772=0\0019774=1V\0019775=A\00110=107\001", - "8=FIX.4.2\0019=166\00135=b\00134=117\001369=58\00152=20150427-19:29:16.425\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-19:29:05.531\001143=US,NC\001117=CMEEW3115\001297=4\0011028=N\0019772=0\0019774=EW\0019775=A\00110=141\001", - "8=FIX.4.2\0019=166\00135=b\00134=118\001369=58\00152=20150427-19:29:16.425\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-19:29:05.531\001143=US,NC\001117=CMEEZ3451\001297=4\0011028=N\0019772=0\0019774=EZ\0019775=A\00110=151\001", - "8=FIX.4.2\0019=165\00135=b\00134=119\001369=58\00152=20150427-19:29:16.425\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-19:29:05.547\001143=US,NC\001117=CME96118\001297=4\0011028=N\0019772=0\0019774=96\0019775=A\00110=011\001", - "8=FIX.4.2\0019=98\00135=0\00134=59\00149=1U7001N\00150=bluestream\00152=20150427-19:29:16.454\00156=CME\00157=G\001142=US,NC\001112=IDi8yfsl3y\00110=003\001", - "8=FIX.4.2\0019=135\00135=4\00134=120\001369=58\00152=20150427-19:29:16.425\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001122=20150427-19:29:16.425\001143=US,NC\00136=122\001123=Y\00110=107\001", - "8=FIX.4.2\0019=116\00135=Z\00134=60\00149=1U7001N\00150=bluestream\00152=20150427-19:29:16.472\00156=CME\00157=G\001142=US,NC\001117=57\001295=1\00155=N/A\001298=4\0011028=N\00110=006\001", - "8=FIX.4.2\0019=126\00135=b\00134=122\001369=60\00152=20150427-19:29:16.562\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=57\001297=4\0011028=N\0019772=0\0019774=T$\00110=167\001", - "8=FIX.4.2\0019=126\00135=b\00134=123\001369=60\00152=20150427-19:29:16.562\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=57\001297=4\0011028=N\0019772=0\0019774=TE\00110=201\001", - "8=FIX.4.2\0019=126\00135=b\00134=124\001369=60\00152=20150427-19:29:16.573\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=57\001297=4\0011028=N\0019772=0\0019774=1V\00110=186\001", - "8=FIX.4.2\0019=126\00135=b\00134=125\001369=60\00152=20150427-19:29:16.573\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=57\001297=4\0011028=N\0019772=0\0019774=EW\00110=208\001", - "8=FIX.4.2\0019=126\00135=b\00134=126\001369=60\00152=20150427-19:29:16.573\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=57\001297=4\0011028=N\0019772=0\0019774=EZ\00110=212\001", - "8=FIX.4.2\0019=126\00135=b\00134=127\001369=60\00152=20150427-19:29:16.582\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=57\001297=4\0011028=N\0019772=0\0019774=96\00110=165\001", - "8=FIX.4.2\0019=234\00135=i\00134=61\00149=1U7001N\00150=bluestream\00152=20150427-19:29:40.610\00156=CME\00157=G\001142=US,NC\001117=58\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25200\001133=25350\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=046\001", - "8=FIX.4.2\0019=147\00135=b\00134=128\001369=61\00152=20150427-19:29:40.640\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=58\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=129\001", - "8=FIX.4.2\0019=234\00135=i\00134=62\00149=1U7001N\00150=bluestream\00152=20150427-19:29:40.767\00156=CME\00157=G\001142=US,NC\001117=59\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25225\001133=25375\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=075\001", - "8=FIX.4.2\0019=147\00135=b\00134=129\001369=62\00152=20150427-19:29:40.791\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=59\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=139\001", - "8=FIX.4.2\0019=234\00135=i\00134=63\00149=1U7001N\00150=bluestream\00152=20150427-19:29:41.039\00156=CME\00157=G\001142=US,NC\001117=60\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25200\001133=25400\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=043\001", - "8=FIX.4.2\0019=147\00135=b\00134=130\001369=63\00152=20150427-19:29:41.074\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=60\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=119\001", - "8=FIX.4.2\0019=234\00135=i\00134=64\00149=1U7001N\00150=bluestream\00152=20150427-19:29:41.303\00156=CME\00157=G\001142=US,NC\001117=61\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25175\001133=25425\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=057\001", - "8=FIX.4.2\0019=147\00135=b\00134=131\001369=64\00152=20150427-19:29:41.350\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=61\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=119\001", - "8=FIX.4.2\0019=234\00135=i\00134=65\00149=1U7001N\00150=bluestream\00152=20150427-19:29:41.567\00156=CME\00157=G\001142=US,NC\001117=62\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25150\001133=25400\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=057\001", - "8=FIX.4.2\0019=147\00135=b\00134=132\001369=65\00152=20150427-19:29:41.593\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=62\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=131\001", - "8=FIX.4.2\0019=234\00135=i\00134=66\00149=1U7001N\00150=bluestream\00152=20150427-19:29:41.831\00156=CME\00157=G\001142=US,NC\001117=63\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25175\001133=25375\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=071\001", - "8=FIX.4.2\0019=147\00135=b\00134=133\001369=66\00152=20150427-19:29:41.856\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=63\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=136\001", - "8=FIX.4.2\0019=234\00135=i\00134=67\00149=1U7001N\00150=bluestream\00152=20150427-19:29:42.095\00156=CME\00157=G\001142=US,NC\001117=64\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25150\001133=25350\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=062\001", - "8=FIX.4.2\0019=147\00135=b\00134=134\001369=67\00152=20150427-19:29:42.120\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=64\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=124\001", - "8=FIX.4.2\0019=234\00135=i\00134=68\00149=1U7001N\00150=bluestream\00152=20150427-19:29:42.359\00156=CME\00157=G\001142=US,NC\001117=65\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25175\001133=25375\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=081\001", - "8=FIX.4.2\0019=147\00135=b\00134=135\001369=68\00152=20150427-19:29:42.386\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=65\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=141\001", - "8=FIX.4.2\0019=234\00135=i\00134=69\00149=1U7001N\00150=bluestream\00152=20150427-19:29:42.622\00156=CME\00157=G\001142=US,NC\001117=66\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25200\001133=25400\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=054\001", - "8=FIX.4.2\0019=147\00135=b\00134=136\001369=69\00152=20150427-19:29:42.661\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=66\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=140\001", - "8=FIX.4.2\0019=234\00135=i\00134=70\00149=1U7001N\00150=bluestream\00152=20150427-19:29:42.886\00156=CME\00157=G\001142=US,NC\001117=67\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25225\001133=25425\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=073\001", - "8=FIX.4.2\0019=147\00135=b\00134=137\001369=70\00152=20150427-19:29:42.912\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=67\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=133\001", - "8=FIX.4.2\0019=234\00135=i\00134=71\00149=1U7001N\00150=bluestream\00152=20150427-19:29:43.150\00156=CME\00157=G\001142=US,NC\001117=68\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25250\001133=25400\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=051\001", - "8=FIX.4.2\0019=147\00135=b\00134=138\001369=71\00152=20150427-19:29:43.186\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=68\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=140\001", - "8=FIX.4.2\0019=234\00135=i\00134=72\00149=1U7001N\00150=bluestream\00152=20150427-19:29:43.414\00156=CME\00157=G\001142=US,NC\001117=69\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25225\001133=25425\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=065\001", - "8=FIX.4.2\0019=147\00135=b\00134=139\001369=72\00152=20150427-19:29:43.441\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=69\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=137\001", - "8=FIX.4.2\0019=234\00135=i\00134=73\00149=1U7001N\00150=bluestream\00152=20150427-19:29:43.677\00156=CME\00157=G\001142=US,NC\001117=70\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25200\001133=25400\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=055\001", - "8=FIX.4.2\0019=147\00135=b\00134=140\001369=73\00152=20150427-19:29:43.715\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=70\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=126\001", - "8=FIX.4.2\0019=234\00135=i\00134=74\00149=1U7001N\00150=bluestream\00152=20150427-19:29:43.941\00156=CME\00157=G\001142=US,NC\001117=71\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25225\001133=25425\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=065\001", - "8=FIX.4.2\0019=147\00135=b\00134=141\001369=74\00152=20150427-19:29:43.964\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=71\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=135\001", - "8=FIX.4.2\0019=234\00135=i\00134=75\00149=1U7001N\00150=bluestream\00152=20150427-19:29:44.205\00156=CME\00157=G\001142=US,NC\001117=72\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25250\001133=25400\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=052\001", - "8=FIX.4.2\0019=147\00135=b\00134=142\001369=75\00152=20150427-19:29:44.232\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=72\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=127\001", - "8=FIX.4.2\0019=234\00135=i\00134=76\00149=1U7001N\00150=bluestream\00152=20150427-19:29:44.468\00156=CME\00157=G\001142=US,NC\001117=73\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25225\001133=25425\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=074\001", - "8=FIX.4.2\0019=147\00135=b\00134=143\001369=76\00152=20150427-19:29:44.510\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=73\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=129\001", - "8=FIX.4.2\0019=234\00135=i\00134=77\00149=1U7001N\00150=bluestream\00152=20150427-19:29:44.730\00156=CME\00157=G\001142=US,NC\001117=74\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25250\001133=25400\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=059\001", - "8=FIX.4.2\0019=147\00135=b\00134=144\001369=77\00152=20150427-19:29:44.755\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=74\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=143\001", - "8=FIX.4.2\0019=234\00135=i\00134=78\00149=1U7001N\00150=bluestream\00152=20150427-19:29:44.992\00156=CME\00157=G\001142=US,NC\001117=75\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25275\001133=25375\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=089\001", - "8=FIX.4.2\0019=147\00135=b\00134=145\001369=78\00152=20150427-19:29:45.015\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=75\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=136\001", - "8=FIX.4.2\0019=218\00135=i\00134=79\00149=1U7001N\00150=bluestream\00152=20150427-19:29:45.255\00156=CME\00157=G\001142=US,NC\001117=76\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001133=25400\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=107\001", - "8=FIX.4.2\0019=147\00135=b\00134=146\001369=79\00152=20150427-19:29:45.281\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=76\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=144\001", - "8=FIX.4.2\0019=218\00135=i\00134=80\00149=1U7001N\00150=bluestream\00152=20150427-19:29:45.518\00156=CME\00157=G\001142=US,NC\001117=77\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001133=25425\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=109\001", - "8=FIX.4.2\0019=147\00135=b\00134=147\001369=80\00152=20150427-19:29:45.561\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=77\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=139\001", - "8=FIX.4.2\0019=218\00135=i\00134=81\00149=1U7001N\00150=bluestream\00152=20150427-19:29:45.780\00156=CME\00157=G\001142=US,NC\001117=78\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001133=25450\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=110\001", - "8=FIX.4.2\0019=147\00135=b\00134=148\001369=81\00152=20150427-19:29:45.828\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=78\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=148\001", - "8=FIX.4.2\0019=234\00135=i\00134=82\00149=1U7001N\00150=bluestream\00152=20150427-19:29:46.042\00156=CME\00157=G\001142=US,NC\001117=79\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25300\001133=25475\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=066\001", - "8=FIX.4.2\0019=147\00135=b\00134=149\001369=82\00152=20150427-19:29:46.071\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=79\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=142\001", - "8=FIX.4.2\0019=234\00135=i\00134=83\00149=1U7001N\00150=bluestream\00152=20150427-19:29:46.304\00156=CME\00157=G\001142=US,NC\001117=80\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25275\001133=25450\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=064\001", - "8=FIX.4.2\0019=147\00135=b\00134=150\001369=83\00152=20150427-19:29:46.332\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=80\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=127\001", - "8=FIX.4.2\0019=218\00135=i\00134=84\00149=1U7001N\00150=bluestream\00152=20150427-19:29:46.567\00156=CME\00157=G\001142=US,NC\001117=81\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001133=25425\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=113\001", - "8=FIX.4.2\0019=147\00135=b\00134=151\001369=84\00152=20150427-19:29:46.593\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=81\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=139\001", - "8=FIX.4.2\0019=218\00135=i\00134=85\00149=1U7001N\00150=bluestream\00152=20150427-19:29:46.829\00156=CME\00157=G\001142=US,NC\001117=82\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001133=25450\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=114\001", - "8=FIX.4.2\0019=147\00135=b\00134=152\001369=85\00152=20150427-19:29:46.856\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=82\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=144\001", - "8=FIX.4.2\0019=234\00135=i\00134=86\00149=1U7001N\00150=bluestream\00152=20150427-19:29:47.092\00156=CME\00157=G\001142=US,NC\001117=83\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25300\001133=25425\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=066\001", - "8=FIX.4.2\0019=147\00135=b\00134=153\001369=86\00152=20150427-19:29:47.116\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=83\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=137\001", - "8=FIX.4.2\0019=234\00135=i\00134=87\00149=1U7001N\00150=bluestream\00152=20150427-19:29:47.354\00156=CME\00157=G\001142=US,NC\001117=84\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25275\001133=25400\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=073\001", - "8=FIX.4.2\0019=147\00135=b\00134=154\001369=87\00152=20150427-19:29:47.383\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=84\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=146\001", - "8=FIX.4.2\0019=218\00135=i\00134=88\00149=1U7001N\00150=bluestream\00152=20150427-19:29:47.616\00156=CME\00157=G\001142=US,NC\001117=85\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001133=25425\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=117\001", - "8=FIX.4.2\0019=147\00135=b\00134=155\001369=88\00152=20150427-19:29:47.643\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=85\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=148\001", - "8=FIX.4.2\0019=234\00135=i\00134=89\00149=1U7001N\00150=bluestream\00152=20150427-19:29:47.879\00156=CME\00157=G\001142=US,NC\001117=86\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25250\001133=25450\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=087\001", - "8=FIX.4.2\0019=147\00135=b\00134=156\001369=89\00152=20150427-19:29:47.906\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=86\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=153\001", - "8=FIX.4.2\0019=234\00135=i\00134=90\00149=1U7001N\00150=bluestream\00152=20150427-19:29:48.141\00156=CME\00157=G\001142=US,NC\001117=87\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25225\001133=25475\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=072\001", - "8=FIX.4.2\0019=147\00135=b\00134=157\001369=90\00152=20150427-19:29:48.163\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=87\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=143\001", - "8=FIX.4.2\0019=234\00135=i\00134=91\00149=1U7001N\00150=bluestream\00152=20150427-19:29:48.403\00156=CME\00157=G\001142=US,NC\001117=88\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25200\001133=25500\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=057\001", - "8=FIX.4.2\0019=147\00135=b\00134=158\001369=91\00152=20150427-19:29:48.423\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=88\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=145\001", - "8=FIX.4.2\0019=234\00135=i\00134=92\00149=1U7001N\00150=bluestream\00152=20150427-19:29:48.666\00156=CME\00157=G\001142=US,NC\001117=89\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25175\001133=25475\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=092\001", - "8=FIX.4.2\0019=147\00135=b\00134=159\001369=92\00152=20150427-19:29:48.691\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=89\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=155\001", - "8=FIX.4.2\0019=234\00135=i\00134=93\00149=1U7001N\00150=bluestream\00152=20150427-19:29:48.928\00156=CME\00157=G\001142=US,NC\001117=90\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25150\001133=25450\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=072\001", - "8=FIX.4.2\0019=147\00135=b\00134=160\001369=93\00152=20150427-19:29:48.948\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=90\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=145\001", - "8=FIX.4.2\0019=234\00135=i\00134=94\00149=1U7001N\00150=bluestream\00152=20150427-19:29:49.191\00156=CME\00157=G\001142=US,NC\001117=91\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25125\001133=25475\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=076\001", - "8=FIX.4.2\0019=147\00135=b\00134=161\001369=94\00152=20150427-19:29:49.213\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=91\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=134\001", - "8=FIX.4.2\0019=234\00135=i\00134=95\00149=1U7001N\00150=bluestream\00152=20150427-19:29:49.454\00156=CME\00157=G\001142=US,NC\001117=92\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25100\001133=25500\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=062\001", - "8=FIX.4.2\0019=147\00135=b\00134=162\001369=95\00152=20150427-19:29:49.484\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=92\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=147\001", - "8=FIX.4.2\0019=234\00135=i\00134=96\00149=1U7001N\00150=bluestream\00152=20150427-19:29:49.718\00156=CME\00157=G\001142=US,NC\001117=93\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25075\001133=25475\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=089\001", - "8=FIX.4.2\0019=147\00135=b\00134=163\001369=96\00152=20150427-19:29:49.739\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=93\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=153\001", - "8=FIX.4.2\0019=234\00135=i\00134=97\00149=1U7001N\00150=bluestream\00152=20150427-19:29:49.982\00156=CME\00157=G\001142=US,NC\001117=94\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25050\001133=25450\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=080\001", - "8=FIX.4.2\0019=147\00135=b\00134=164\001369=97\00152=20150427-19:29:50.008\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=94\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=137\001", - "8=FIX.4.2\0019=234\00135=i\00134=98\00149=1U7001N\00150=bluestream\00152=20150427-19:29:50.246\00156=CME\00157=G\001142=US,NC\001117=95\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25025\001133=25425\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=071\001", - "8=FIX.4.2\0019=147\00135=b\00134=165\001369=98\00152=20150427-19:29:50.275\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=95\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=146\001", - "8=FIX.4.2\0019=234\00135=i\00134=99\00149=1U7001N\00150=bluestream\00152=20150427-19:29:50.510\00156=CME\00157=G\001142=US,NC\001117=96\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25050\001133=25400\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=058\001", - "8=FIX.4.2\0019=147\00135=b\00134=166\001369=99\00152=20150427-19:29:50.537\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=96\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=150\001", - "8=FIX.4.2\0019=235\00135=i\00134=100\00149=1U7001N\00150=bluestream\00152=20150427-19:29:50.774\00156=CME\00157=G\001142=US,NC\001117=97\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25025\001133=25375\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=116\001", - "8=FIX.4.2\0019=148\00135=b\00134=167\001369=100\00152=20150427-19:29:50.840\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=97\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=181\001", - "8=FIX.4.2\0019=235\00135=i\00134=101\00149=1U7001N\00150=bluestream\00152=20150427-19:29:51.037\00156=CME\00157=G\001142=US,NC\001117=98\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25000\001133=25350\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=097\001", - "8=FIX.4.2\0019=148\00135=b\00134=168\001369=101\00152=20150427-19:29:51.063\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=98\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=182\001", - "8=FIX.4.2\0019=219\00135=i\00134=102\00149=1U7001N\00150=bluestream\00152=20150427-19:29:51.301\00156=CME\00157=G\001142=US,NC\001117=99\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001133=25325\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=143\001", - "8=FIX.4.2\0019=148\00135=b\00134=169\001369=102\00152=20150427-19:29:51.325\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=99\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=186\001", - "8=FIX.4.2\0019=220\00135=i\00134=103\00149=1U7001N\00150=bluestream\00152=20150427-19:29:51.563\00156=CME\00157=G\001142=US,NC\001117=100\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001133=25350\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=175\001", - "8=FIX.4.2\0019=149\00135=b\00134=170\001369=103\00152=20150427-19:29:51.584\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=100\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=218\001", - "8=FIX.4.2\0019=220\00135=i\00134=104\00149=1U7001N\00150=bluestream\00152=20150427-19:29:51.825\00156=CME\00157=G\001142=US,NC\001117=101\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001133=25325\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=180\001", - "8=FIX.4.2\0019=149\00135=b\00134=171\001369=104\00152=20150427-19:29:51.851\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=101\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=218\001", - "8=FIX.4.2\0019=236\00135=i\00134=105\00149=1U7001N\00150=bluestream\00152=20150427-19:29:52.087\00156=CME\00157=G\001142=US,NC\001117=102\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25025\001133=25350\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=149\001", - "8=FIX.4.2\0019=149\00135=b\00134=172\001369=105\00152=20150427-19:29:52.111\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=102\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=211\001", - "8=FIX.4.2\0019=236\00135=i\00134=106\00149=1U7001N\00150=bluestream\00152=20150427-19:29:52.350\00156=CME\00157=G\001142=US,NC\001117=103\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25050\001133=25325\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=144\001", - "8=FIX.4.2\0019=149\00135=b\00134=173\001369=106\00152=20150427-19:29:52.380\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=103\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=222\001", - "8=FIX.4.2\0019=236\00135=i\00134=107\00149=1U7001N\00150=bluestream\00152=20150427-19:29:52.612\00156=CME\00157=G\001142=US,NC\001117=104\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25075\001133=25300\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=147\001", - "8=FIX.4.2\0019=149\00135=b\00134=174\001369=107\00152=20150427-19:29:52.640\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=104\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=224\001", - "8=FIX.4.2\0019=236\00135=i\00134=108\00149=1U7001N\00150=bluestream\00152=20150427-19:29:52.874\00156=CME\00157=G\001142=US,NC\001117=105\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25050\001133=25275\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=163\001", - "8=FIX.4.2\0019=149\00135=b\00134=175\001369=108\00152=20150427-19:29:52.897\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=105\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=241\001", - "8=FIX.4.2\0019=236\00135=i\00134=109\00149=1U7001N\00150=bluestream\00152=20150427-19:29:53.137\00156=CME\00157=G\001142=US,NC\001117=106\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25025\001133=25250\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=153\001", - "8=FIX.4.2\0019=149\00135=b\00134=176\001369=109\00152=20150427-19:29:53.162\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=106\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=230\001", - "8=FIX.4.2\0019=236\00135=i\00134=110\00149=1U7001N\00150=bluestream\00152=20150427-19:29:53.400\00156=CME\00157=G\001142=US,NC\001117=107\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25050\001133=25225\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=139\001", - "8=FIX.4.2\0019=149\00135=b\00134=177\001369=110\00152=20150427-19:29:53.422\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=107\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=223\001", - "8=FIX.4.2\0019=236\00135=i\00134=111\00149=1U7001N\00150=bluestream\00152=20150427-19:29:53.663\00156=CME\00157=G\001142=US,NC\001117=108\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25075\001133=25200\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=152\001", - "8=FIX.4.2\0019=149\00135=b\00134=178\001369=111\00152=20150427-19:29:53.691\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=108\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=234\001", - "8=FIX.4.2\0019=220\00135=i\00134=112\00149=1U7001N\00150=bluestream\00152=20150427-19:29:53.927\00156=CME\00157=G\001142=US,NC\001117=109\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001133=25175\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=195\001", - "8=FIX.4.2\0019=149\00135=b\00134=179\001369=112\00152=20150427-19:29:53.952\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=109\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=237\001", - "8=FIX.4.2\0019=236\00135=i\00134=113\00149=1U7001N\00150=bluestream\00152=20150427-19:29:54.191\00156=CME\00157=G\001142=US,NC\001117=110\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25100\001133=25200\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=133\001", - "8=FIX.4.2\0019=149\00135=b\00134=180\001369=113\00152=20150427-19:29:54.215\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=110\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=215\001", - "8=FIX.4.2\0019=236\00135=i\00134=114\00149=1U7001N\00150=bluestream\00152=20150427-19:29:54.455\00156=CME\00157=G\001142=US,NC\001117=111\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25075\001133=25175\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=160\001", - "8=FIX.4.2\0019=149\00135=b\00134=181\001369=114\00152=20150427-19:29:54.481\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=111\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=223\001", - "8=FIX.4.2\0019=236\00135=i\00134=115\00149=1U7001N\00150=bluestream\00152=20150427-19:29:54.718\00156=CME\00157=G\001142=US,NC\001117=112\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25050\001133=25150\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=150\001", - "8=FIX.4.2\0019=149\00135=b\00134=182\001369=115\00152=20150427-19:29:54.748\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=112\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=232\001", - "8=FIX.4.2\0019=236\00135=i\00134=116\00149=1U7001N\00150=bluestream\00152=20150427-19:29:54.982\00156=CME\00157=G\001142=US,NC\001117=113\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25075\001133=25175\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=169\001", - "8=FIX.4.2\0019=149\00135=b\00134=183\001369=116\00152=20150427-19:29:55.014\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=113\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=222\001", - "8=FIX.4.2\0019=236\00135=i\00134=117\00149=1U7001N\00150=bluestream\00152=20150427-19:29:55.245\00156=CME\00157=G\001142=US,NC\001117=114\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25100\001133=25200\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=142\001", - "8=FIX.4.2\0019=149\00135=b\00134=184\001369=117\00152=20150427-19:29:55.275\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=114\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=234\001", - "8=FIX.4.2\0019=236\00135=i\00134=118\00149=1U7001N\00150=bluestream\00152=20150427-19:29:55.509\00156=CME\00157=G\001142=US,NC\001117=115\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25075\001133=25225\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=165\001", - "8=FIX.4.2\0019=149\00135=b\00134=185\001369=118\00152=20150427-19:29:55.533\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=115\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=234\001", - "8=FIX.4.2\0019=236\00135=i\00134=119\00149=1U7001N\00150=bluestream\00152=20150427-19:29:55.773\00156=CME\00157=G\001142=US,NC\001117=116\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25100\001133=25200\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=152\001", - "8=FIX.4.2\0019=149\00135=b\00134=186\001369=119\00152=20150427-19:29:55.797\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=116\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=249\001", - "8=FIX.4.2\0019=236\00135=i\00134=120\00149=1U7001N\00150=bluestream\00152=20150427-19:29:56.036\00156=CME\00157=G\001142=US,NC\001117=117\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25125\001133=25225\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=152\001", - "8=FIX.4.2\0019=149\00135=b\00134=187\001369=120\00152=20150427-19:29:56.061\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=117\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=228\001", - "8=FIX.4.2\0019=236\00135=i\00134=121\00149=1U7001N\00150=bluestream\00152=20150427-19:29:56.300\00156=CME\00157=G\001142=US,NC\001117=118\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25100\001133=25200\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=134\001", - "8=FIX.4.2\0019=149\00135=b\00134=188\001369=121\00152=20150427-19:29:56.326\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=118\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=235\001", - "8=FIX.4.2\0019=236\00135=i\00134=122\00149=1U7001N\00150=bluestream\00152=20150427-19:29:56.564\00156=CME\00157=G\001142=US,NC\001117=119\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25125\001133=25225\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=162\001", - "8=FIX.4.2\0019=149\00135=b\00134=189\001369=122\00152=20150427-19:29:56.584\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=119\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=244\001", - "8=FIX.4.2\0019=236\00135=i\00134=123\00149=1U7001N\00150=bluestream\00152=20150427-19:29:56.827\00156=CME\00157=G\001142=US,NC\001117=120\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25100\001133=25250\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=148\001", - "8=FIX.4.2\0019=149\00135=b\00134=190\001369=123\00152=20150427-19:29:56.856\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=120\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=231\001", - "8=FIX.4.2\0019=236\00135=i\00134=124\00149=1U7001N\00150=bluestream\00152=20150427-19:29:57.091\00156=CME\00157=G\001142=US,NC\001117=121\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25125\001133=25275\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=158\001", - "8=FIX.4.2\0019=149\00135=b\00134=191\001369=124\00152=20150427-19:29:57.116\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=121\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=224\001", - "8=FIX.4.2\0019=236\00135=i\00134=125\00149=1U7001N\00150=bluestream\00152=20150427-19:29:57.354\00156=CME\00157=G\001142=US,NC\001117=122\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25150\001133=25250\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=153\001", - "8=FIX.4.2\0019=149\00135=b\00134=192\001369=125\00152=20150427-19:29:57.379\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=122\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=238\001", - "8=FIX.4.2\0019=236\00135=i\00134=126\00149=1U7001N\00150=bluestream\00152=20150427-19:29:57.618\00156=CME\00157=G\001142=US,NC\001117=123\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25125\001133=25225\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=162\001", - "8=FIX.4.2\0019=149\00135=b\00134=193\001369=126\00152=20150427-19:29:57.648\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=123\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=240\001", - "8=FIX.4.2\0019=236\00135=i\00134=127\00149=1U7001N\00150=bluestream\00152=20150427-19:29:57.882\00156=CME\00157=G\001142=US,NC\001117=124\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25100\001133=25200\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=153\001", - "8=FIX.4.2\0019=149\00135=b\00134=194\001369=127\00152=20150427-19:29:57.911\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=124\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=236\001", - "8=FIX.4.2\0019=236\00135=i\00134=128\00149=1U7001N\00150=bluestream\00152=20150427-19:29:58.145\00156=CME\00157=G\001142=US,NC\001117=125\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25075\001133=25175\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=170\001", - "8=FIX.4.2\0019=149\00135=b\00134=195\001369=128\00152=20150427-19:29:58.174\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=125\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=241\001", - "8=FIX.4.2\0019=236\00135=i\00134=129\00149=1U7001N\00150=bluestream\00152=20150427-19:29:58.409\00156=CME\00157=G\001142=US,NC\001117=126\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25050\001133=25200\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=157\001", - "8=FIX.4.2\0019=149\00135=b\00134=196\001369=129\00152=20150427-19:29:58.439\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=126\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=248\001", - "8=FIX.4.2\0019=236\00135=i\00134=130\00149=1U7001N\00150=bluestream\00152=20150427-19:29:58.673\00156=CME\00157=G\001142=US,NC\001117=127\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25025\001133=25175\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=166\001", - "8=FIX.4.2\0019=149\00135=b\00134=197\001369=130\00152=20150427-19:29:58.696\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=127\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=247\001", - "8=FIX.4.2\0019=236\00135=i\00134=131\00149=1U7001N\00150=bluestream\00152=20150427-19:29:58.936\00156=CME\00157=G\001142=US,NC\001117=128\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25050\001133=25200\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=157\001", - "8=FIX.4.2\0019=149\00135=b\00134=198\001369=131\00152=20150427-19:29:58.957\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=128\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=250\001", - "8=FIX.4.2\0019=236\00135=i\00134=132\00149=1U7001N\00150=bluestream\00152=20150427-19:29:59.200\00156=CME\00157=G\001142=US,NC\001117=129\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25075\001133=25225\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=158\001", - "8=FIX.4.2\0019=149\00135=b\00134=199\001369=132\00152=20150427-19:29:59.223\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=129\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=240\001", - "8=FIX.4.2\0019=236\00135=i\00134=133\00149=1U7001N\00150=bluestream\00152=20150427-19:29:59.464\00156=CME\00157=G\001142=US,NC\001117=130\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25050\001133=25200\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=149\001", - "8=FIX.4.2\0019=149\00135=b\00134=200\001369=133\00152=20150427-19:29:59.493\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=130\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=225\001", - "8=FIX.4.2\0019=236\00135=i\00134=134\00149=1U7001N\00150=bluestream\00152=20150427-19:29:59.727\00156=CME\00157=G\001142=US,NC\001117=131\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25075\001133=25225\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=167\001", - "8=FIX.4.2\0019=149\00135=b\00134=201\001369=134\00152=20150427-19:29:59.749\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=131\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=232\001", - "8=FIX.4.2\0019=236\00135=i\00134=135\00149=1U7001N\00150=bluestream\00152=20150427-19:29:59.991\00156=CME\00157=G\001142=US,NC\001117=132\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25100\001133=25250\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=159\001", - "8=FIX.4.2\0019=149\00135=b\00134=202\001369=135\00152=20150427-19:30:00.040\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=132\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=197\001", - "8=FIX.4.2\0019=236\00135=i\00134=136\00149=1U7001N\00150=bluestream\00152=20150427-19:30:00.255\00156=CME\00157=G\001142=US,NC\001117=133\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25075\001133=25275\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=150\001", - "8=FIX.4.2\0019=149\00135=b\00134=203\001369=136\00152=20150427-19:30:00.284\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=133\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=210\001", - "8=FIX.4.2\0019=236\00135=i\00134=137\00149=1U7001N\00150=bluestream\00152=20150427-19:30:00.519\00156=CME\00157=G\001142=US,NC\001117=134\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25050\001133=25250\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=141\001", - "8=FIX.4.2\0019=149\00135=b\00134=204\001369=137\00152=20150427-19:30:00.540\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=134\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=208\001", - "8=FIX.4.2\0019=236\00135=i\00134=138\00149=1U7001N\00150=bluestream\00152=20150427-19:30:00.782\00156=CME\00157=G\001142=US,NC\001117=135\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25075\001133=25275\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=159\001", - "8=FIX.4.2\0019=149\00135=b\00134=205\001369=138\00152=20150427-19:30:00.813\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=135\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=214\001", - "8=FIX.4.2\0019=236\00135=i\00134=139\00149=1U7001N\00150=bluestream\00152=20150427-19:30:01.046\00156=CME\00157=G\001142=US,NC\001117=136\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25050\001133=25250\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=141\001", - "8=FIX.4.2\0019=149\00135=b\00134=206\001369=139\00152=20150427-19:30:01.078\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=136\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=221\001", - "8=FIX.4.2\0019=236\00135=i\00134=140\00149=1U7001N\00150=bluestream\00152=20150427-19:30:01.310\00156=CME\00157=G\001142=US,NC\001117=137\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25025\001133=25275\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=137\001", - "8=FIX.4.2\0019=149\00135=b\00134=207\001369=140\00152=20150427-19:30:01.340\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=137\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=207\001", - "8=FIX.4.2\0019=236\00135=i\00134=141\00149=1U7001N\00150=bluestream\00152=20150427-19:30:01.573\00156=CME\00157=G\001142=US,NC\001117=138\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25000\001133=25250\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=136\001", - "8=FIX.4.2\0019=149\00135=b\00134=208\001369=141\00152=20150427-19:30:01.598\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=138\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=225\001", - "8=FIX.4.2\0019=220\00135=i\00134=142\00149=1U7001N\00150=bluestream\00152=20150427-19:30:01.837\00156=CME\00157=G\001142=US,NC\001117=139\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001133=25225\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=182\001", - "8=FIX.4.2\0019=149\00135=b\00134=209\001369=142\00152=20150427-19:30:01.867\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=139\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=227\001", - "8=FIX.4.2\0019=220\00135=i\00134=143\00149=1U7001N\00150=bluestream\00152=20150427-19:30:02.100\00156=CME\00157=G\001142=US,NC\001117=140\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001133=25250\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=157\001", - "8=FIX.4.2\0019=149\00135=b\00134=210\001369=143\00152=20150427-19:30:02.136\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=140\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=202\001", - "8=FIX.4.2\0019=236\00135=i\00134=144\00149=1U7001N\00150=bluestream\00152=20150427-19:30:02.364\00156=CME\00157=G\001142=US,NC\001117=141\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25025\001133=25275\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=146\001", - "8=FIX.4.2\0019=149\00135=b\00134=211\001369=144\00152=20150427-19:30:02.387\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=141\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=213\001", - "8=FIX.4.2\0019=236\00135=i\00134=145\00149=1U7001N\00150=bluestream\00152=20150427-19:30:02.628\00156=CME\00157=G\001142=US,NC\001117=142\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25050\001133=25250\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=142\001", - "8=FIX.4.2\0019=149\00135=b\00134=212\001369=145\00152=20150427-19:30:02.667\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=142\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=217\001", - "8=FIX.4.2\0019=236\00135=i\00134=146\00149=1U7001N\00150=bluestream\00152=20150427-19:30:02.891\00156=CME\00157=G\001142=US,NC\001117=143\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25025\001133=25275\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=155\001", - "8=FIX.4.2\0019=149\00135=b\00134=213\001369=146\00152=20150427-19:30:02.917\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=143\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=218\001", - "8=FIX.4.2\0019=236\00135=i\00134=147\00149=1U7001N\00150=bluestream\00152=20150427-19:30:03.155\00156=CME\00157=G\001142=US,NC\001117=144\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25000\001133=25250\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=137\001", - "8=FIX.4.2\0019=149\00135=b\00134=214\001369=147\00152=20150427-19:30:03.179\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=144\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=222\001", - "8=FIX.4.2\0019=236\00135=i\00134=148\00149=1U7001N\00150=bluestream\00152=20150427-19:30:03.421\00156=CME\00157=G\001142=US,NC\001117=145\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25025\001133=25225\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=144\001", - "8=FIX.4.2\0019=149\00135=b\00134=215\001369=148\00152=20150427-19:30:03.448\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=145\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=224\001", - "8=FIX.4.2\0019=236\00135=i\00134=149\00149=1U7001N\00150=bluestream\00152=20150427-19:30:03.688\00156=CME\00157=G\001142=US,NC\001117=146\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25050\001133=25200\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=152\001", - "8=FIX.4.2\0019=149\00135=b\00134=216\001369=149\00152=20150427-19:30:03.717\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=146\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=226\001", - "8=FIX.4.2\0019=236\00135=i\00134=150\00149=1U7001N\00150=bluestream\00152=20150427-19:30:03.952\00156=CME\00157=G\001142=US,NC\001117=147\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25025\001133=25225\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=148\001", - "8=FIX.4.2\0019=149\00135=b\00134=217\001369=150\00152=20150427-19:30:03.975\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=147\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=226\001", - "8=FIX.4.2\0019=236\00135=i\00134=151\00149=1U7001N\00150=bluestream\00152=20150427-19:30:04.216\00156=CME\00157=G\001142=US,NC\001117=148\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25000\001133=25250\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=135\001", - "8=FIX.4.2\0019=149\00135=b\00134=218\001369=151\00152=20150427-19:30:04.268\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=148\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=225\001", - "8=FIX.4.2\0019=220\00135=i\00134=152\00149=1U7001N\00150=bluestream\00152=20150427-19:30:04.479\00156=CME\00157=G\001142=US,NC\001117=149\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001133=25225\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=189\001", - "8=FIX.4.2\0019=149\00135=b\00134=219\001369=152\00152=20150427-19:30:04.507\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=149\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=224\001", - "8=FIX.4.2\0019=236\00135=i\00134=153\00149=1U7001N\00150=bluestream\00152=20150427-19:30:04.743\00156=CME\00157=G\001142=US,NC\001117=150\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25025\001133=25250\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=142\001", - "8=FIX.4.2\0019=149\00135=b\00134=220\001369=153\00152=20150427-19:30:04.764\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=150\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=214\001", - "8=FIX.4.2\0019=236\00135=i\00134=154\00149=1U7001N\00150=bluestream\00152=20150427-19:30:05.007\00156=CME\00157=G\001142=US,NC\001117=151\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25000\001133=25225\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=133\001", - "8=FIX.4.2\0019=149\00135=b\00134=221\001369=154\00152=20150427-19:30:05.039\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=151\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=213\001", - "8=FIX.4.2\0019=236\00135=i\00134=155\00149=1U7001N\00150=bluestream\00152=20150427-19:30:05.271\00156=CME\00157=G\001142=US,NC\001117=152\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25025\001133=25250\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=143\001", - "8=FIX.4.2\0019=149\00135=b\00134=222\001369=155\00152=20150427-19:30:05.301\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=152\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=208\001", - "8=FIX.4.2\0019=236\00135=i\00134=156\00149=1U7001N\00150=bluestream\00152=20150427-19:30:05.535\00156=CME\00157=G\001142=US,NC\001117=153\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25000\001133=25225\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=143\001", - "8=FIX.4.2\0019=149\00135=b\00134=223\001369=156\00152=20150427-19:30:05.569\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=153\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=227\001", - "8=FIX.4.2\0019=236\00135=i\00134=157\00149=1U7001N\00150=bluestream\00152=20150427-19:30:05.799\00156=CME\00157=G\001142=US,NC\001117=154\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25025\001133=25250\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=162\001", - "8=FIX.4.2\0019=149\00135=b\00134=224\001369=157\00152=20150427-19:30:05.823\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=154\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=223\001", - "8=FIX.4.2\0019=236\00135=i\00134=158\00149=1U7001N\00150=bluestream\00152=20150427-19:30:06.063\00156=CME\00157=G\001142=US,NC\001117=155\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25050\001133=25275\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=154\001", - "8=FIX.4.2\0019=149\00135=b\00134=225\001369=158\00152=20150427-19:30:06.090\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=155\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=223\001", - "8=FIX.4.2\0019=236\00135=i\00134=159\00149=1U7001N\00150=bluestream\00152=20150427-19:30:06.327\00156=CME\00157=G\001142=US,NC\001117=156\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25075\001133=25250\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=159\001", - "8=FIX.4.2\0019=149\00135=b\00134=226\001369=159\00152=20150427-19:30:06.350\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=156\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=225\001", - "8=FIX.4.2\0019=236\00135=i\00134=160\00149=1U7001N\00150=bluestream\00152=20150427-19:30:06.590\00156=CME\00157=G\001142=US,NC\001117=157\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25050\001133=25225\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=149\001", - "8=FIX.4.2\0019=149\00135=b\00134=227\001369=160\00152=20150427-19:30:06.620\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=157\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=219\001", - "8=FIX.4.2\0019=236\00135=i\00134=161\00149=1U7001N\00150=bluestream\00152=20150427-19:30:06.854\00156=CME\00157=G\001142=US,NC\001117=158\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25025\001133=25200\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=149\001", - "8=FIX.4.2\0019=149\00135=b\00134=228\001369=161\00152=20150427-19:30:06.882\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=158\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=232\001", - "8=FIX.4.2\0019=236\00135=i\00134=162\00149=1U7001N\00150=bluestream\00152=20150427-19:30:07.118\00156=CME\00157=G\001142=US,NC\001117=159\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25000\001133=25175\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=149\001", - "8=FIX.4.2\0019=149\00135=b\00134=229\001369=162\00152=20150427-19:30:07.141\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=159\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=224\001", - "8=FIX.4.2\0019=220\00135=i\00134=163\00149=1U7001N\00150=bluestream\00152=20150427-19:30:07.382\00156=CME\00157=G\001142=US,NC\001117=160\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001133=25150\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=177\001", - "8=FIX.4.2\0019=149\00135=b\00134=230\001369=163\00152=20150427-19:30:07.404\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=160\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=211\001", - "8=FIX.4.2\0019=220\00135=i\00134=164\00149=1U7001N\00150=bluestream\00152=20150427-19:30:07.909\00156=CME\00157=G\001142=US,NC\001117=161\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001133=25125\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=186\001", - "8=FIX.4.2\0019=149\00135=b\00134=231\001369=164\00152=20150427-19:30:07.936\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=161\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=224\001", - "8=FIX.4.2\0019=236\00135=i\00134=165\00149=1U7001N\00150=bluestream\00152=20150427-19:30:08.437\00156=CME\00157=G\001142=US,NC\001117=162\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25025\001133=25150\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=151\001", - "8=FIX.4.2\0019=149\00135=b\00134=232\001369=165\00152=20150427-19:30:08.482\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=162\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=224\001", - "8=FIX.4.2\0019=220\00135=i\00134=166\00149=1U7001N\00150=bluestream\00152=20150427-19:30:08.700\00156=CME\00157=G\001142=US,NC\001117=163\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25000\001134=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=170\001", - "8=FIX.4.2\0019=149\00135=b\00134=233\001369=166\00152=20150427-19:30:08.728\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=163\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=230\001", - "8=FIX.4.2\0019=236\00135=i\00134=167\00149=1U7001N\00150=bluestream\00152=20150427-19:30:08.964\00156=CME\00157=G\001142=US,NC\001117=164\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25025\001133=25175\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=167\001", - "8=FIX.4.2\0019=149\00135=b\00134=234\001369=167\00152=20150427-19:30:08.988\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=164\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=241\001", - "8=FIX.4.2\0019=236\00135=i\00134=168\00149=1U7001N\00150=bluestream\00152=20150427-19:30:09.228\00156=CME\00157=G\001142=US,NC\001117=165\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25050\001133=25150\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=154\001", - "8=FIX.4.2\0019=149\00135=b\00134=235\001369=168\00152=20150427-19:30:09.255\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=165\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=232\001", - "8=FIX.4.2\0019=220\00135=i\00134=169\00149=1U7001N\00150=bluestream\00152=20150427-19:30:09.492\00156=CME\00157=G\001142=US,NC\001117=166\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25025\001134=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=192\001", - "8=FIX.4.2\0019=149\00135=b\00134=236\001369=169\00152=20150427-19:30:09.520\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=166\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=230\001", - "8=FIX.4.2\0019=236\00135=i\00134=170\00149=1U7001N\00150=bluestream\00152=20150427-19:30:09.755\00156=CME\00157=G\001142=US,NC\001117=167\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25000\001133=25125\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=151\001", - "8=FIX.4.2\0019=149\00135=b\00134=237\001369=170\00152=20150427-19:30:09.787\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=167\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=239\001", - "8=FIX.4.2\0019=220\00135=i\00134=171\00149=1U7001N\00150=bluestream\00152=20150427-19:30:10.547\00156=CME\00157=G\001142=US,NC\001117=168\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001133=25150\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=181\001", - "8=FIX.4.2\0019=149\00135=b\00134=238\001369=171\00152=20150427-19:30:10.570\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=168\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=224\001", - "8=FIX.4.2\0019=220\00135=i\00134=172\00149=1U7001N\00150=bluestream\00152=20150427-19:30:10.810\00156=CME\00157=G\001142=US,NC\001117=169\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001133=25125\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=178\001", - "8=FIX.4.2\0019=149\00135=b\00134=239\001369=172\00152=20150427-19:30:10.850\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=169\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=228\001", - "8=FIX.4.2\0019=220\00135=i\00134=173\00149=1U7001N\00150=bluestream\00152=20150427-19:30:11.344\00156=CME\00157=G\001142=US,NC\001117=170\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001133=25150\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=172\001", - "8=FIX.4.2\0019=149\00135=b\00134=240\001369=173\00152=20150427-19:30:11.373\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=170\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=214\001", - "8=FIX.4.2\0019=220\00135=i\00134=174\00149=1U7001N\00150=bluestream\00152=20150427-19:30:11.608\00156=CME\00157=G\001142=US,NC\001117=171\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001133=25125\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=179\001", - "8=FIX.4.2\0019=149\00135=b\00134=241\001369=174\00152=20150427-19:30:11.631\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=171\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=214\001", - "8=FIX.4.2\0019=220\00135=i\00134=175\00149=1U7001N\00150=bluestream\00152=20150427-19:30:11.872\00156=CME\00157=G\001142=US,NC\001117=172\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001133=25150\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=182\001", - "8=FIX.4.2\0019=149\00135=b\00134=242\001369=175\00152=20150427-19:30:11.897\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=172\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=231\001", - "8=FIX.4.2\0019=220\00135=i\00134=176\00149=1U7001N\00150=bluestream\00152=20150427-19:30:12.136\00156=CME\00157=G\001142=US,NC\001117=173\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25025\001134=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=177\001", - "8=FIX.4.2\0019=149\00135=b\00134=243\001369=176\00152=20150427-19:30:12.161\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=173\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=219\001", - "8=FIX.4.2\0019=220\00135=i\00134=177\00149=1U7001N\00150=bluestream\00152=20150427-19:30:12.400\00156=CME\00157=G\001142=US,NC\001117=174\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25000\001134=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=166\001", - "8=FIX.4.2\0019=149\00135=b\00134=244\001369=177\00152=20150427-19:30:12.428\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=174\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=228\001", - "8=FIX.4.2\0019=220\00135=i\00134=178\00149=1U7001N\00150=bluestream\00152=20150427-19:30:12.663\00156=CME\00157=G\001142=US,NC\001117=175\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001133=25125\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=189\001", - "8=FIX.4.2\0019=149\00135=b\00134=245\001369=178\00152=20150427-19:30:12.691\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=175\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=233\001", - "8=FIX.4.2\0019=236\00135=i\00134=179\00149=1U7001N\00150=bluestream\00152=20150427-19:30:12.927\00156=CME\00157=G\001142=US,NC\001117=176\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25025\001133=25150\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=160\001", - "8=FIX.4.2\0019=149\00135=b\00134=246\001369=179\00152=20150427-19:30:12.956\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=176\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=240\001", - "8=FIX.4.2\0019=236\00135=i\00134=180\00149=1U7001N\00150=bluestream\00152=20150427-19:30:13.191\00156=CME\00157=G\001142=US,NC\001117=177\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25000\001133=25125\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=142\001", - "8=FIX.4.2\0019=149\00135=b\00134=247\001369=180\00152=20150427-19:30:13.220\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=177\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=219\001", - "8=FIX.4.2\0019=236\00135=i\00134=181\00149=1U7001N\00150=bluestream\00152=20150427-19:30:13.718\00156=CME\00157=G\001142=US,NC\001117=178\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25025\001133=25150\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=154\001", - "8=FIX.4.2\0019=149\00135=b\00134=248\001369=181\00152=20150427-19:30:13.742\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=178\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=231\001", - "8=FIX.4.2\0019=220\00135=i\00134=182\00149=1U7001N\00150=bluestream\00152=20150427-19:30:13.982\00156=CME\00157=G\001142=US,NC\001117=179\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25000\001134=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=183\001", - "8=FIX.4.2\0019=149\00135=b\00134=249\001369=182\00152=20150427-19:30:14.008\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=179\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=230\001", - "8=FIX.4.2\0019=220\00135=i\00134=183\00149=1U7001N\00150=bluestream\00152=20150427-19:30:14.246\00156=CME\00157=G\001142=US,NC\001117=180\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25025\001134=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=177\001", - "8=FIX.4.2\0019=149\00135=b\00134=250\001369=183\00152=20150427-19:30:14.270\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=180\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=216\001", - "8=FIX.4.2\0019=220\00135=i\00134=184\00149=1U7001N\00150=bluestream\00152=20150427-19:30:14.509\00156=CME\00157=G\001142=US,NC\001117=181\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25000\001134=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=174\001", - "8=FIX.4.2\0019=149\00135=b\00134=251\001369=184\00152=20150427-19:30:14.545\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=181\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=224\001", - "8=FIX.4.2\0019=220\00135=i\00134=185\00149=1U7001N\00150=bluestream\00152=20150427-19:30:14.773\00156=CME\00157=G\001142=US,NC\001117=182\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25025\001134=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=186\001", - "8=FIX.4.2\0019=149\00135=b\00134=252\001369=185\00152=20150427-19:30:14.798\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=182\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=237\001", - "8=FIX.4.2\0019=220\00135=i\00134=186\00149=1U7001N\00150=bluestream\00152=20150427-19:30:15.037\00156=CME\00157=G\001142=US,NC\001117=183\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25050\001134=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=180\001", - "8=FIX.4.2\0019=149\00135=b\00134=253\001369=186\00152=20150427-19:30:15.062\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=183\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=225\001", - "8=FIX.4.2\0019=236\00135=i\00134=187\00149=1U7001N\00150=bluestream\00152=20150427-19:30:15.301\00156=CME\00157=G\001142=US,NC\001117=184\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25075\001133=25175\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=159\001", - "8=FIX.4.2\0019=149\00135=b\00134=254\001369=187\00152=20150427-19:30:15.327\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=184\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=232\001", - "8=FIX.4.2\0019=236\00135=i\00134=188\00149=1U7001N\00150=bluestream\00152=20150427-19:30:15.564\00156=CME\00157=G\001142=US,NC\001117=185\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25100\001133=25200\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=150\001", - "8=FIX.4.2\0019=149\00135=b\00134=255\001369=188\00152=20150427-19:30:15.591\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=185\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=238\001", - "8=FIX.4.2\0019=134\00135=A\00134=189\00149=1U7001N\00150=bluestream\00152=20150427-19:30:42.013\00156=CME\00157=G\001142=US,NC\00195=3\00196=1U7\00198=0\001108=30\0011603=O2\0011604=1.0\0011605=BTS\00110=105\001", - "8=FIX.4.2\0019=130\00135=A\00134=262\001369=189\00152=20150427-19:30:43.546\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00198=0\001108=30\0011603=O2\0011604=1.0\0011605=BTS\00110=099\001", - "8=FIX.4.2\0019=95\00135=2\00134=190\00149=1U7001N\00150=bluestream\00152=20150427-19:30:43.574\00156=CME\00157=G\001142=US,NC\0017=256\00116=0\00110=166\001", - "8=FIX.4.2\0019=107\00135=1\00134=263\001369=189\00152=20150427-19:30:43.546\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001112=IDi8yfsl3z\00110=150\001", - "8=FIX.4.2\0019=167\00135=b\00134=256\001369=190\00152=20150427-19:30:43.597\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-19:30:16.913\001143=US,NC\001117=CME1V2640\001297=4\0011028=N\0019772=0\0019774=1V\0019775=A\00110=151\001", - "8=FIX.4.2\0019=167\00135=b\00134=257\001369=190\00152=20150427-19:30:43.598\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-19:30:16.913\001143=US,NC\001117=CMEEW3116\001297=4\0011028=N\0019772=0\0019774=EW\0019775=A\00110=194\001", - "8=FIX.4.2\0019=167\00135=b\00134=258\001369=190\00152=20150427-19:30:43.598\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-19:30:16.913\001143=US,NC\001117=CMEEZ3452\001297=4\0011028=N\0019772=1\0019774=EZ\0019775=A\00110=205\001", - "8=FIX.4.2\0019=166\00135=b\00134=259\001369=190\00152=20150427-19:30:43.598\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-19:30:16.913\001143=US,NC\001117=CMET$126\001297=4\0011028=N\0019772=0\0019774=T$\0019775=A\00110=073\001", - "8=FIX.4.2\0019=166\00135=b\00134=260\001369=190\00152=20150427-19:30:43.598\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-19:30:16.913\001143=US,NC\001117=CMETE205\001297=4\0011028=N\0019772=0\0019774=TE\0019775=A\00110=129\001", - "8=FIX.4.2\0019=166\00135=b\00134=261\001369=190\00152=20150427-19:30:43.598\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-19:30:16.913\001143=US,NC\001117=CME96119\001297=4\0011028=N\0019772=0\0019774=96\0019775=A\00110=050\001", - "8=FIX.4.2\0019=99\00135=0\00134=191\00149=1U7001N\00150=bluestream\00152=20150427-19:30:43.626\00156=CME\00157=G\001142=US,NC\001112=IDi8yfsl3z\00110=043\001", - "8=FIX.4.2\0019=136\00135=4\00134=262\001369=190\00152=20150427-19:30:43.598\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001122=20150427-19:30:43.598\001143=US,NC\00136=264\001123=Y\00110=173\001", - "8=FIX.4.2\0019=118\00135=Z\00134=192\00149=1U7001N\00150=bluestream\00152=20150427-19:30:43.668\00156=CME\00157=G\001142=US,NC\001117=189\001295=1\00155=N/A\001298=4\0011028=N\00110=115\001", - "8=FIX.4.2\0019=128\00135=b\00134=264\001369=192\00152=20150427-19:30:43.741\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=189\001297=4\0011028=N\0019772=0\0019774=T$\00110=019\001", - "8=FIX.4.2\0019=128\00135=b\00134=265\001369=192\00152=20150427-19:30:43.741\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=189\001297=4\0011028=N\0019772=0\0019774=TE\00110=053\001", - "8=FIX.4.2\0019=128\00135=b\00134=266\001369=192\00152=20150427-19:30:43.743\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=189\001297=4\0011028=N\0019772=0\0019774=96\00110=014\001", - "8=FIX.4.2\0019=128\00135=b\00134=267\001369=192\00152=20150427-19:30:43.743\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=189\001297=4\0011028=N\0019772=0\0019774=1V\00110=039\001", - "8=FIX.4.2\0019=128\00135=b\00134=268\001369=192\00152=20150427-19:30:43.743\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=189\001297=4\0011028=N\0019772=0\0019774=EW\00110=061\001", - "8=FIX.4.2\0019=128\00135=b\00134=269\001369=192\00152=20150427-19:30:43.743\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=189\001297=4\0011028=N\0019772=0\0019774=EZ\00110=065\001", - "8=FIX.4.2\0019=236\00135=i\00134=193\00149=1U7001N\00150=bluestream\00152=20150427-19:30:51.684\00156=CME\00157=G\001142=US,NC\001117=190\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25025\001133=25150\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=155\001", - "8=FIX.4.2\0019=149\00135=b\00134=270\001369=193\00152=20150427-19:30:51.711\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=190\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=221\001", - "8=FIX.4.2\0019=220\00135=i\00134=194\00149=1U7001N\00150=bluestream\00152=20150427-19:30:51.821\00156=CME\00157=G\001142=US,NC\001117=191\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25050\001134=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=179\001", - "8=FIX.4.2\0019=149\00135=b\00134=271\001369=194\00152=20150427-19:30:51.850\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=191\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=228\001", - "8=FIX.4.2\0019=236\00135=i\00134=195\00149=1U7001N\00150=bluestream\00152=20150427-19:30:51.956\00156=CME\00157=G\001142=US,NC\001117=192\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25075\001133=25175\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=173\001", - "8=FIX.4.2\0019=149\00135=b\00134=272\001369=195\00152=20150427-19:30:51.981\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=192\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=236\001", - "8=FIX.4.2\0019=236\00135=i\00134=196\00149=1U7001N\00150=bluestream\00152=20150427-19:30:52.220\00156=CME\00157=G\001142=US,NC\001117=193\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25100\001133=25200\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=138\001", - "8=FIX.4.2\0019=149\00135=b\00134=273\001369=196\00152=20150427-19:30:52.246\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=193\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=234\001", - "8=FIX.4.2\0019=236\00135=i\00134=197\00149=1U7001N\00150=bluestream\00152=20150427-19:30:52.484\00156=CME\00157=G\001142=US,NC\001117=194\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25075\001133=25225\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=170\001", - "8=FIX.4.2\0019=149\00135=b\00134=274\001369=197\00152=20150427-19:30:52.521\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=194\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=233\001", - "8=FIX.4.2\0019=236\00135=i\00134=198\00149=1U7001N\00150=bluestream\00152=20150427-19:30:52.747\00156=CME\00157=G\001142=US,NC\001117=195\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25100\001133=25200\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=156\001", - "8=FIX.4.2\0019=149\00135=b\00134=275\001369=198\00152=20150427-19:30:52.780\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=195\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=243\001", - "8=FIX.4.2\0019=236\00135=i\00134=199\00149=1U7001N\00150=bluestream\00152=20150427-19:30:53.011\00156=CME\00157=G\001142=US,NC\001117=196\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25075\001133=25175\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=165\001", - "8=FIX.4.2\0019=149\00135=b\00134=276\001369=199\00152=20150427-19:30:53.040\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=196\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=236\001", - "8=FIX.4.2\0019=236\00135=i\00134=200\00149=1U7001N\00150=bluestream\00152=20150427-19:30:53.275\00156=CME\00157=G\001142=US,NC\001117=197\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25100\001133=25200\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=139\001", - "8=FIX.4.2\0019=149\00135=b\00134=277\001369=200\00152=20150427-19:30:53.301\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=197\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=221\001", - "8=FIX.4.2\0019=236\00135=i\00134=201\00149=1U7001N\00150=bluestream\00152=20150427-19:30:53.538\00156=CME\00157=G\001142=US,NC\001117=198\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25125\001133=25225\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=157\001", - "8=FIX.4.2\0019=149\00135=b\00134=278\001369=201\00152=20150427-19:30:53.560\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=198\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=231\001", - "8=FIX.4.2\0019=236\00135=i\00134=202\00149=1U7001N\00150=bluestream\00152=20150427-19:30:53.802\00156=CME\00157=G\001142=US,NC\001117=199\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25100\001133=25250\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=144\001", - "8=FIX.4.2\0019=149\00135=b\00134=279\001369=202\00152=20150427-19:30:53.829\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=199\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=242\001", - "8=FIX.4.2\0019=236\00135=i\00134=203\00149=1U7001N\00150=bluestream\00152=20150427-19:30:54.066\00156=CME\00157=G\001142=US,NC\001117=200\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25075\001133=25225\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=144\001", - "8=FIX.4.2\0019=149\00135=b\00134=280\001369=203\00152=20150427-19:30:54.094\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=200\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=213\001", - "8=FIX.4.2\0019=236\00135=i\00134=204\00149=1U7001N\00150=bluestream\00152=20150427-19:30:54.329\00156=CME\00157=G\001142=US,NC\001117=201\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25100\001133=25250\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=135\001", - "8=FIX.4.2\0019=149\00135=b\00134=281\001369=204\00152=20150427-19:30:54.357\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=201\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=218\001", - "8=FIX.4.2\0019=236\00135=i\00134=205\00149=1U7001N\00150=bluestream\00152=20150427-19:30:54.593\00156=CME\00157=G\001142=US,NC\001117=202\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25125\001133=25225\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=149\001", - "8=FIX.4.2\0019=149\00135=b\00134=282\001369=205\00152=20150427-19:30:54.620\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=202\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=214\001", - "8=FIX.4.2\0019=236\00135=i\00134=206\00149=1U7001N\00150=bluestream\00152=20150427-19:30:54.857\00156=CME\00157=G\001142=US,NC\001117=203\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25100\001133=25250\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=145\001", - "8=FIX.4.2\0019=149\00135=b\00134=283\001369=206\00152=20150427-19:30:54.900\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=203\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=218\001", - "8=FIX.4.2\0019=236\00135=i\00134=207\00149=1U7001N\00150=bluestream\00152=20150427-19:30:55.120\00156=CME\00157=G\001142=US,NC\001117=204\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25075\001133=25225\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=144\001", - "8=FIX.4.2\0019=149\00135=b\00134=284\001369=207\00152=20150427-19:30:55.148\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=204\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=226\001", - "8=FIX.4.2\0019=236\00135=i\00134=208\00149=1U7001N\00150=bluestream\00152=20150427-19:30:55.384\00156=CME\00157=G\001142=US,NC\001117=205\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25050\001133=25200\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=144\001", - "8=FIX.4.2\0019=149\00135=b\00134=285\001369=208\00152=20150427-19:30:55.438\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=205\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=231\001", - "8=FIX.4.2\0019=236\00135=i\00134=209\00149=1U7001N\00150=bluestream\00152=20150427-19:30:55.647\00156=CME\00157=G\001142=US,NC\001117=206\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25025\001133=25175\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=161\001", - "8=FIX.4.2\0019=149\00135=b\00134=286\001369=209\00152=20150427-19:30:55.671\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=206\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=233\001", - "8=FIX.4.2\0019=236\00135=i\00134=210\00149=1U7001N\00150=bluestream\00152=20150427-19:30:55.911\00156=CME\00157=G\001142=US,NC\001117=207\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25000\001133=25150\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=134\001", - "8=FIX.4.2\0019=149\00135=b\00134=287\001369=210\00152=20150427-19:30:55.937\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=207\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=232\001", - "8=FIX.4.2\0019=220\00135=i\00134=211\00149=1U7001N\00150=bluestream\00152=20150427-19:30:56.174\00156=CME\00157=G\001142=US,NC\001117=208\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001133=25175\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=184\001", - "8=FIX.4.2\0019=149\00135=b\00134=288\001369=211\00152=20150427-19:30:56.198\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=208\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=235\001", - "8=FIX.4.2\0019=236\00135=i\00134=212\00149=1U7001N\00150=bluestream\00152=20150427-19:30:56.438\00156=CME\00157=G\001142=US,NC\001117=209\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25025\001133=25200\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=146\001", - "8=FIX.4.2\0019=149\00135=b\00134=289\001369=212\00152=20150427-19:30:56.461\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=209\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=231\001", - "8=FIX.4.2\0019=236\00135=i\00134=213\00149=1U7001N\00150=bluestream\00152=20150427-19:30:56.701\00156=CME\00157=G\001142=US,NC\001117=210\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25050\001133=25225\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=137\001", - "8=FIX.4.2\0019=149\00135=b\00134=290\001369=213\00152=20150427-19:30:56.726\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=210\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=220\001", - "8=FIX.4.2\0019=236\00135=i\00134=214\00149=1U7001N\00150=bluestream\00152=20150427-19:30:56.965\00156=CME\00157=G\001142=US,NC\001117=211\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25075\001133=25250\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=156\001", - "8=FIX.4.2\0019=149\00135=b\00134=291\001369=214\00152=20150427-19:30:56.993\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=211\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=229\001", - "8=FIX.4.2\0019=236\00135=i\00134=215\00149=1U7001N\00150=bluestream\00152=20150427-19:30:57.228\00156=CME\00157=G\001142=US,NC\001117=212\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25100\001133=25225\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=142\001", - "8=FIX.4.2\0019=149\00135=b\00134=292\001369=215\00152=20150427-19:30:57.253\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=212\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=222\001", - "8=FIX.4.2\0019=236\00135=i\00134=216\00149=1U7001N\00150=bluestream\00152=20150427-19:30:57.492\00156=CME\00157=G\001142=US,NC\001117=213\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25075\001133=25200\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=151\001", - "8=FIX.4.2\0019=149\00135=b\00134=293\001369=216\00152=20150427-19:30:57.523\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=213\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=225\001", - "8=FIX.4.2\0019=236\00135=i\00134=217\00149=1U7001N\00150=bluestream\00152=20150427-19:30:57.756\00156=CME\00157=G\001142=US,NC\001117=214\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25050\001133=25225\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=156\001", - "8=FIX.4.2\0019=149\00135=b\00134=294\001369=217\00152=20150427-19:30:57.782\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=214\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=235\001", - "8=FIX.4.2\0019=236\00135=i\00134=218\00149=1U7001N\00150=bluestream\00152=20150427-19:30:58.019\00156=CME\00157=G\001142=US,NC\001117=215\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25075\001133=25250\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=156\001", - "8=FIX.4.2\0019=149\00135=b\00134=295\001369=218\00152=20150427-19:30:58.070\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=215\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=229\001", - "8=FIX.4.2\0019=236\00135=i\00134=219\00149=1U7001N\00150=bluestream\00152=20150427-19:30:58.283\00156=CME\00157=G\001142=US,NC\001117=216\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25100\001133=25275\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=157\001", - "8=FIX.4.2\0019=149\00135=b\00134=296\001369=219\00152=20150427-19:30:58.311\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=216\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=230\001", - "8=FIX.4.2\0019=236\00135=i\00134=220\00149=1U7001N\00150=bluestream\00152=20150427-19:30:58.546\00156=CME\00157=G\001142=US,NC\001117=217\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25075\001133=25250\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=156\001", - "8=FIX.4.2\0019=149\00135=b\00134=297\001369=220\00152=20150427-19:30:58.572\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=217\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=233\001", - "8=FIX.4.2\0019=236\00135=i\00134=221\00149=1U7001N\00150=bluestream\00152=20150427-19:30:58.810\00156=CME\00157=G\001142=US,NC\001117=218\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25100\001133=25225\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=143\001", - "8=FIX.4.2\0019=149\00135=b\00134=298\001369=221\00152=20150427-19:30:58.833\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=218\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=236\001", - "8=FIX.4.2\0019=134\00135=A\00134=222\00149=1U7001N\00150=bluestream\00152=20150427-19:31:09.591\00156=CME\00157=G\001142=US,NC\00195=3\00196=1U7\00198=0\001108=30\0011603=O2\0011604=1.0\0011605=BTS\00110=108\001", - "8=FIX.4.2\0019=130\00135=A\00134=305\001369=222\00152=20150427-19:31:11.204\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00198=0\001108=30\0011603=O2\0011604=1.0\0011605=BTS\00110=072\001", - "8=FIX.4.2\0019=95\00135=2\00134=223\00149=1U7001N\00150=bluestream\00152=20150427-19:31:11.231\00156=CME\00157=G\001142=US,NC\0017=299\00116=0\00110=156\001", - "8=FIX.4.2\0019=107\00135=1\00134=306\001369=222\00152=20150427-19:31:11.204\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001112=IDi8yfsl40\00110=050\001", - "8=FIX.4.2\0019=118\00135=Z\00134=224\00149=1U7001N\00150=bluestream\00152=20150427-19:31:11.248\00156=CME\00157=G\001142=US,NC\001117=222\001295=1\00155=N/A\001298=4\0011028=N\00110=089\001", - "8=FIX.4.2\0019=166\00135=b\00134=299\001369=223\00152=20150427-19:31:11.253\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-19:31:00.082\001143=US,NC\001117=CMET$127\001297=4\0011028=N\0019772=0\0019774=T$\0019775=A\00110=050\001", - "8=FIX.4.2\0019=166\00135=b\00134=300\001369=223\00152=20150427-19:31:11.253\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-19:31:00.082\001143=US,NC\001117=CMETE206\001297=4\0011028=N\0019772=0\0019774=TE\0019775=A\00110=097\001", - "8=FIX.4.2\0019=166\00135=b\00134=301\001369=223\00152=20150427-19:31:11.253\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-19:31:00.090\001143=US,NC\001117=CME96120\001297=4\0011028=N\0019772=0\0019774=96\0019775=A\00110=008\001", - "8=FIX.4.2\0019=167\00135=b\00134=302\001369=223\00152=20150427-19:31:11.253\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-19:31:00.094\001143=US,NC\001117=CME1V2641\001297=4\0011028=N\0019772=0\0019774=1V\0019775=A\00110=120\001", - "8=FIX.4.2\0019=167\00135=b\00134=303\001369=223\00152=20150427-19:31:11.253\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-19:31:00.094\001143=US,NC\001117=CMEEW3117\001297=4\0011028=N\0019772=0\0019774=EW\0019775=A\00110=162\001", - "8=FIX.4.2\0019=167\00135=b\00134=304\001369=223\00152=20150427-19:31:11.253\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-19:31:00.094\001143=US,NC\001117=CMEEZ3453\001297=4\0011028=N\0019772=1\0019774=EZ\0019775=A\00110=173\001", - "8=FIX.4.2\0019=99\00135=0\00134=225\00149=1U7001N\00150=bluestream\00152=20150427-19:31:11.329\00156=CME\00157=G\001142=US,NC\001112=IDi8yfsl40\00110=220\001", - "8=FIX.4.2\0019=136\00135=4\00134=305\001369=223\00152=20150427-19:31:11.253\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001122=20150427-19:31:11.253\001143=US,NC\00136=307\001123=Y\00110=134\001", - "8=FIX.4.2\0019=128\00135=b\00134=307\001369=224\00152=20150427-19:31:11.301\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=222\001297=4\0011028=N\0019772=0\0019774=T$\00110=245\001", - "8=FIX.4.2\0019=128\00135=b\00134=308\001369=224\00152=20150427-19:31:11.301\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=222\001297=4\0011028=N\0019772=0\0019774=TE\00110=023\001", - "8=FIX.4.2\0019=128\00135=b\00134=309\001369=224\00152=20150427-19:31:11.301\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=222\001297=4\0011028=N\0019772=0\0019774=1V\00110=006\001", - "8=FIX.4.2\0019=128\00135=b\00134=310\001369=224\00152=20150427-19:31:11.301\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=222\001297=4\0011028=N\0019772=0\0019774=EW\00110=019\001", - "8=FIX.4.2\0019=128\00135=b\00134=311\001369=224\00152=20150427-19:31:11.301\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=222\001297=4\0011028=N\0019772=0\0019774=EZ\00110=023\001", - "8=FIX.4.2\0019=128\00135=b\00134=312\001369=224\00152=20150427-19:31:11.305\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=222\001297=4\0011028=N\0019772=0\0019774=96\00110=236\001", - "8=FIX.4.2\0019=236\00135=i\00134=226\00149=1U7001N\00150=bluestream\00152=20150427-19:31:17.560\00156=CME\00157=G\001142=US,NC\001117=223\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25050\001133=25300\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=140\001", - "8=FIX.4.2\0019=149\00135=b\00134=313\001369=226\00152=20150427-19:31:17.591\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=223\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=222\001", - "8=FIX.4.2\0019=236\00135=i\00134=227\00149=1U7001N\00150=bluestream\00152=20150427-19:31:17.691\00156=CME\00157=G\001142=US,NC\001117=224\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25075\001133=25325\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=161\001", - "8=FIX.4.2\0019=149\00135=b\00134=314\001369=227\00152=20150427-19:31:17.722\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=224\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=221\001", - "8=FIX.4.2\0019=236\00135=i\00134=228\00149=1U7001N\00150=bluestream\00152=20150427-19:31:17.813\00156=CME\00157=G\001142=US,NC\001117=225\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25100\001133=25300\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=141\001", - "8=FIX.4.2\0019=149\00135=b\00134=315\001369=228\00152=20150427-19:31:17.860\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=225\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=227\001", - "8=FIX.4.2\0019=236\00135=i\00134=229\00149=1U7001N\00150=bluestream\00152=20150427-19:31:18.084\00156=CME\00157=G\001142=US,NC\001117=226\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25075\001133=25325\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=162\001", - "8=FIX.4.2\0019=149\00135=b\00134=316\001369=229\00152=20150427-19:31:18.292\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=226\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=230\001", - "8=FIX.4.2\0019=236\00135=i\00134=230\00149=1U7001N\00150=bluestream\00152=20150427-19:31:18.392\00156=CME\00157=G\001142=US,NC\001117=227\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25050\001133=25350\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=148\001", - "8=FIX.4.2\0019=149\00135=b\00134=317\001369=230\00152=20150427-19:31:18.421\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=227\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=218\001", - "8=FIX.4.2\0019=236\00135=i\00134=231\00149=1U7001N\00150=bluestream\00152=20150427-19:31:18.612\00156=CME\00157=G\001142=US,NC\001117=228\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25025\001133=25325\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=149\001", - "8=FIX.4.2\0019=149\00135=b\00134=318\001369=231\00152=20150427-19:31:18.641\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=228\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=225\001", - "8=FIX.4.2\0019=236\00135=i\00134=232\00149=1U7001N\00150=bluestream\00152=20150427-19:31:18.876\00156=CME\00157=G\001142=US,NC\001117=229\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25050\001133=25350\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=159\001", - "8=FIX.4.2\0019=149\00135=b\00134=319\001369=232\00152=20150427-19:31:18.932\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=229\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=231\001", - "8=FIX.4.2\0019=236\00135=i\00134=233\00149=1U7001N\00150=bluestream\00152=20150427-19:31:19.140\00156=CME\00157=G\001142=US,NC\001117=230\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25025\001133=25325\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=141\001", - "8=FIX.4.2\0019=149\00135=b\00134=320\001369=233\00152=20150427-19:31:19.164\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=230\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=214\001", - "8=FIX.4.2\0019=236\00135=i\00134=234\00149=1U7001N\00150=bluestream\00152=20150427-19:31:19.404\00156=CME\00157=G\001142=US,NC\001117=231\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25000\001133=25300\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=132\001", - "8=FIX.4.2\0019=149\00135=b\00134=321\001369=234\00152=20150427-19:31:19.432\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=231\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=215\001", - "8=FIX.4.2\0019=236\00135=i\00134=235\00149=1U7001N\00150=bluestream\00152=20150427-19:31:19.667\00156=CME\00157=G\001142=US,NC\001117=232\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25025\001133=25275\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=163\001", - "8=FIX.4.2\0019=149\00135=b\00134=322\001369=235\00152=20150427-19:31:19.696\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=232\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=230\001", - "8=FIX.4.2\0019=236\00135=i\00134=236\00149=1U7001N\00150=bluestream\00152=20150427-19:31:19.930\00156=CME\00157=G\001142=US,NC\001117=233\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25050\001133=25300\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=145\001", - "8=FIX.4.2\0019=149\00135=b\00134=323\001369=236\00152=20150427-19:31:19.963\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=233\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=230\001", - "8=FIX.4.2\0019=236\00135=i\00134=237\00149=1U7001N\00150=bluestream\00152=20150427-19:31:20.192\00156=CME\00157=G\001142=US,NC\001117=234\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25025\001133=25275\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=152\001", - "8=FIX.4.2\0019=149\00135=b\00134=324\001369=237\00152=20150427-19:31:20.221\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=234\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=212\001", - "8=FIX.4.2\0019=236\00135=i\00134=238\00149=1U7001N\00150=bluestream\00152=20150427-19:31:20.454\00156=CME\00157=G\001142=US,NC\001117=235\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25050\001133=25300\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=142\001", - "8=FIX.4.2\0019=149\00135=b\00134=325\001369=238\00152=20150427-19:31:20.482\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=235\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=224\001", - "8=FIX.4.2\0019=236\00135=i\00134=239\00149=1U7001N\00150=bluestream\00152=20150427-19:31:20.717\00156=CME\00157=G\001142=US,NC\001117=236\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25025\001133=25325\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=155\001", - "8=FIX.4.2\0019=149\00135=b\00134=326\001369=239\00152=20150427-19:31:20.740\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=236\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=224\001", - "8=FIX.4.2\0019=236\00135=i\00134=240\00149=1U7001N\00150=bluestream\00152=20150427-19:31:20.979\00156=CME\00157=G\001142=US,NC\001117=237\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25050\001133=25300\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=149\001", - "8=FIX.4.2\0019=149\00135=b\00134=327\001369=240\00152=20150427-19:31:21.006\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=237\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=214\001", - "8=FIX.4.2\0019=236\00135=i\00134=241\00149=1U7001N\00150=bluestream\00152=20150427-19:31:21.242\00156=CME\00157=G\001142=US,NC\001117=238\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25025\001133=25325\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=144\001", - "8=FIX.4.2\0019=149\00135=b\00134=328\001369=241\00152=20150427-19:31:21.271\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=238\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=221\001", - "8=FIX.4.2\0019=236\00135=i\00134=242\00149=1U7001N\00150=bluestream\00152=20150427-19:31:21.505\00156=CME\00157=G\001142=US,NC\001117=239\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25050\001133=25300\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=139\001", - "8=FIX.4.2\0019=149\00135=b\00134=329\001369=242\00152=20150427-19:31:21.561\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=239\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=226\001", - "8=FIX.4.2\0019=236\00135=i\00134=243\00149=1U7001N\00150=bluestream\00152=20150427-19:31:21.769\00156=CME\00157=G\001142=US,NC\001117=240\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25075\001133=25275\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=162\001", - "8=FIX.4.2\0019=149\00135=b\00134=330\001369=243\00152=20150427-19:31:21.826\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=240\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=215\001", - "8=FIX.4.2\0019=236\00135=i\00134=244\00149=1U7001N\00150=bluestream\00152=20150427-19:31:22.033\00156=CME\00157=G\001142=US,NC\001117=241\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25100\001133=25250\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=131\001", - "8=FIX.4.2\0019=149\00135=b\00134=331\001369=244\00152=20150427-19:31:22.057\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=241\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=215\001", - "8=FIX.4.2\0019=236\00135=i\00134=245\00149=1U7001N\00150=bluestream\00152=20150427-19:31:22.299\00156=CME\00157=G\001142=US,NC\001117=242\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25125\001133=25225\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=156\001", - "8=FIX.4.2\0019=149\00135=b\00134=332\001369=245\00152=20150427-19:31:22.326\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=242\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=217\001", - "8=FIX.4.2\0019=236\00135=i\00134=246\00149=1U7001N\00150=bluestream\00152=20150427-19:31:22.565\00156=CME\00157=G\001142=US,NC\001117=243\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25100\001133=25250\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=145\001", - "8=FIX.4.2\0019=149\00135=b\00134=333\001369=246\00152=20150427-19:31:22.591\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=243\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=224\001", - "8=FIX.4.2\0019=236\00135=i\00134=247\00149=1U7001N\00150=bluestream\00152=20150427-19:31:22.829\00156=CME\00157=G\001142=US,NC\001117=244\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25075\001133=25275\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=168\001", - "8=FIX.4.2\0019=149\00135=b\00134=334\001369=247\00152=20150427-19:31:22.865\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=244\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=231\001", - "8=FIX.4.2\0019=236\00135=i\00134=248\00149=1U7001N\00150=bluestream\00152=20150427-19:31:23.093\00156=CME\00157=G\001142=US,NC\001117=245\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25050\001133=25250\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=150\001", - "8=FIX.4.2\0019=149\00135=b\00134=335\001369=248\00152=20150427-19:31:23.123\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=245\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=222\001", - "8=FIX.4.2\0019=236\00135=i\00134=249\00149=1U7001N\00150=bluestream\00152=20150427-19:31:23.357\00156=CME\00157=G\001142=US,NC\001117=246\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25075\001133=25275\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=169\001", - "8=FIX.4.2\0019=149\00135=b\00134=336\001369=249\00152=20150427-19:31:23.381\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=246\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=231\001", - "8=FIX.4.2\0019=236\00135=i\00134=250\00149=1U7001N\00150=bluestream\00152=20150427-19:31:23.620\00156=CME\00157=G\001142=US,NC\001117=247\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25050\001133=25300\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=137\001", - "8=FIX.4.2\0019=149\00135=b\00134=337\001369=250\00152=20150427-19:31:23.651\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=247\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=225\001", - "8=FIX.4.2\0019=236\00135=i\00134=251\00149=1U7001N\00150=bluestream\00152=20150427-19:31:23.884\00156=CME\00157=G\001142=US,NC\001117=248\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25025\001133=25325\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=160\001", - "8=FIX.4.2\0019=149\00135=b\00134=338\001369=251\00152=20150427-19:31:23.964\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=248\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=235\001", - "8=FIX.4.2\0019=236\00135=i\00134=252\00149=1U7001N\00150=bluestream\00152=20150427-19:31:24.148\00156=CME\00157=G\001142=US,NC\001117=249\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25050\001133=25350\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=152\001", - "8=FIX.4.2\0019=149\00135=b\00134=339\001369=252\00152=20150427-19:31:24.183\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=249\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=232\001", - "8=FIX.4.2\0019=236\00135=i\00134=253\00149=1U7001N\00150=bluestream\00152=20150427-19:31:24.411\00156=CME\00157=G\001142=US,NC\001117=250\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25025\001133=25325\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=142\001", - "8=FIX.4.2\0019=149\00135=b\00134=340\001369=253\00152=20150427-19:31:24.467\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=250\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=222\001", - "8=FIX.4.2\0019=236\00135=i\00134=254\00149=1U7001N\00150=bluestream\00152=20150427-19:31:24.675\00156=CME\00157=G\001142=US,NC\001117=251\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25000\001133=25300\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=142\001", - "8=FIX.4.2\0019=149\00135=b\00134=341\001369=254\00152=20150427-19:31:24.703\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=251\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=218\001", - "8=FIX.4.2\0019=236\00135=i\00134=255\00149=1U7001N\00150=bluestream\00152=20150427-19:31:24.939\00156=CME\00157=G\001142=US,NC\001117=252\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25025\001133=25325\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=161\001", - "8=FIX.4.2\0019=149\00135=b\00134=342\001369=255\00152=20150427-19:31:24.965\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=252\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=231\001", - "8=FIX.4.2\0019=236\00135=i\00134=256\00149=1U7001N\00150=bluestream\00152=20150427-19:31:25.203\00156=CME\00157=G\001142=US,NC\001117=253\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25050\001133=25300\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=139\001", - "8=FIX.4.2\0019=149\00135=b\00134=343\001369=256\00152=20150427-19:31:25.234\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=253\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=224\001", - "8=FIX.4.2\0019=236\00135=i\00134=257\00149=1U7001N\00150=bluestream\00152=20150427-19:31:25.467\00156=CME\00157=G\001142=US,NC\001117=254\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25025\001133=25325\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=162\001", - "8=FIX.4.2\0019=149\00135=b\00134=344\001369=257\00152=20150427-19:31:25.497\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=254\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=238\001", - "8=FIX.4.2\0019=236\00135=i\00134=258\00149=1U7001N\00150=bluestream\00152=20150427-19:31:25.730\00156=CME\00157=G\001142=US,NC\001117=255\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25000\001133=25300\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=143\001", - "8=FIX.4.2\0019=149\00135=b\00134=345\001369=258\00152=20150427-19:31:25.767\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=255\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=241\001", - "8=FIX.4.2\0019=220\00135=i\00134=259\00149=1U7001N\00150=bluestream\00152=20150427-19:31:25.994\00156=CME\00157=G\001142=US,NC\001117=256\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001133=25325\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=203\001", - "8=FIX.4.2\0019=149\00135=b\00134=346\001369=259\00152=20150427-19:31:26.017\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=256\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=233\001", - "8=FIX.4.2\0019=236\00135=i\00134=260\00149=1U7001N\00150=bluestream\00152=20150427-19:31:26.257\00156=CME\00157=G\001142=US,NC\001117=257\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25025\001133=25300\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=150\001", - "8=FIX.4.2\0019=149\00135=b\00134=347\001369=260\00152=20150427-19:31:26.297\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=257\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=237\001", - "8=FIX.4.2\0019=236\00135=i\00134=261\00149=1U7001N\00150=bluestream\00152=20150427-19:31:26.521\00156=CME\00157=G\001142=US,NC\001117=258\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25000\001133=25325\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=146\001", - "8=FIX.4.2\0019=149\00135=b\00134=348\001369=261\00152=20150427-19:31:26.551\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=258\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=233\001", - "8=FIX.4.2\0019=236\00135=i\00134=262\00149=1U7001N\00150=bluestream\00152=20150427-19:31:26.785\00156=CME\00157=G\001142=US,NC\001117=259\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25025\001133=25350\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=165\001", - "8=FIX.4.2\0019=149\00135=b\00134=349\001369=262\00152=20150427-19:31:26.819\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=259\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=243\001", - "8=FIX.4.2\0019=236\00135=i\00134=263\00149=1U7001N\00150=bluestream\00152=20150427-19:31:27.049\00156=CME\00157=G\001142=US,NC\001117=260\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25000\001133=25375\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=152\001", - "8=FIX.4.2\0019=149\00135=b\00134=350\001369=263\00152=20150427-19:31:27.077\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=260\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=225\001", - "8=FIX.4.2\0019=220\00135=i\00134=264\00149=1U7001N\00150=bluestream\00152=20150427-19:31:27.312\00156=CME\00157=G\001142=US,NC\001117=261\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001133=25400\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=175\001", - "8=FIX.4.2\0019=149\00135=b\00134=351\001369=264\00152=20150427-19:31:27.336\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=261\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=226\001", - "8=FIX.4.2\0019=220\00135=i\00134=265\00149=1U7001N\00150=bluestream\00152=20150427-19:31:27.576\00156=CME\00157=G\001142=US,NC\001117=262\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001133=25375\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=200\001", - "8=FIX.4.2\0019=149\00135=b\00134=352\001369=265\00152=20150427-19:31:27.602\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=262\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=225\001", - "8=FIX.4.2\0019=220\00135=i\00134=266\00149=1U7001N\00150=bluestream\00152=20150427-19:31:27.839\00156=CME\00157=G\001142=US,NC\001117=263\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001133=25400\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=193\001", - "8=FIX.4.2\0019=149\00135=b\00134=353\001369=266\00152=20150427-19:31:27.868\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=263\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=242\001", - "8=FIX.4.2\0019=236\00135=i\00134=267\00149=1U7001N\00150=bluestream\00152=20150427-19:31:28.103\00156=CME\00157=G\001142=US,NC\001117=264\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25025\001133=25425\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=155\001", - "8=FIX.4.2\0019=149\00135=b\00134=354\001369=267\00152=20150427-19:31:28.130\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=264\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=228\001", - "8=FIX.4.2\0019=236\00135=i\00134=268\00149=1U7001N\00150=bluestream\00152=20150427-19:31:28.366\00156=CME\00157=G\001142=US,NC\001117=265\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25050\001133=25450\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=164\001", - "8=FIX.4.2\0019=149\00135=b\00134=355\001369=268\00152=20150427-19:31:28.394\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=265\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=243\001", - "8=FIX.4.2\0019=236\00135=i\00134=269\00149=1U7001N\00150=bluestream\00152=20150427-19:31:28.630\00156=CME\00157=G\001142=US,NC\001117=266\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25075\001133=25425\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=169\001", - "8=FIX.4.2\0019=149\00135=b\00134=356\001369=269\00152=20150427-19:31:28.658\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=266\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=249\001", - "8=FIX.4.2\0019=236\00135=i\00134=270\00149=1U7001N\00150=bluestream\00152=20150427-19:31:28.894\00156=CME\00157=G\001142=US,NC\001117=267\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25100\001133=25450\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=161\001", - "8=FIX.4.2\0019=149\00135=b\00134=357\001369=270\00152=20150427-19:31:28.920\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=267\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=235\001", - "8=FIX.4.2\0019=236\00135=i\00134=271\00149=1U7001N\00150=bluestream\00152=20150427-19:31:29.157\00156=CME\00157=G\001142=US,NC\001117=268\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25125\001133=25425\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=165\001", - "8=FIX.4.2\0019=149\00135=b\00134=358\001369=271\00152=20150427-19:31:29.182\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=268\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=239\001", - "8=FIX.4.2\0019=236\00135=i\00134=272\00149=1U7001N\00150=bluestream\00152=20150427-19:31:29.421\00156=CME\00157=G\001142=US,NC\001117=269\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25100\001133=25400\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=147\001", - "8=FIX.4.2\0019=149\00135=b\00134=359\001369=272\00152=20150427-19:31:29.455\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=269\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=245\001", - "8=FIX.4.2\0019=236\00135=i\00134=273\00149=1U7001N\00150=bluestream\00152=20150427-19:31:29.685\00156=CME\00157=G\001142=US,NC\001117=270\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25075\001133=25425\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=170\001", - "8=FIX.4.2\0019=149\00135=b\00134=360\001369=273\00152=20150427-19:31:29.711\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=270\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=225\001", - "8=FIX.4.2\0019=236\00135=i\00134=274\00149=1U7001N\00150=bluestream\00152=20150427-19:31:29.949\00156=CME\00157=G\001142=US,NC\001117=271\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25050\001133=25400\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=161\001", - "8=FIX.4.2\0019=149\00135=b\00134=361\001369=274\00152=20150427-19:31:29.987\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=271\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=243\001", - "8=FIX.4.2\0019=236\00135=i\00134=275\00149=1U7001N\00150=bluestream\00152=20150427-19:31:30.212\00156=CME\00157=G\001142=US,NC\001117=272\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25025\001133=25375\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=151\001", - "8=FIX.4.2\0019=149\00135=b\00134=362\001369=275\00152=20150427-19:31:30.236\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=272\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=225\001", - "8=FIX.4.2\0019=236\00135=i\00134=276\00149=1U7001N\00150=bluestream\00152=20150427-19:31:30.476\00156=CME\00157=G\001142=US,NC\001117=273\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25050\001133=25350\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=156\001", - "8=FIX.4.2\0019=149\00135=b\00134=363\001369=276\00152=20150427-19:31:30.521\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=273\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=225\001", - "8=FIX.4.2\0019=236\00135=i\00134=277\00149=1U7001N\00150=bluestream\00152=20150427-19:31:30.739\00156=CME\00157=G\001142=US,NC\001117=274\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25025\001133=25325\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=164\001", - "8=FIX.4.2\0019=149\00135=b\00134=364\001369=277\00152=20150427-19:31:30.764\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=274\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=237\001", - "8=FIX.4.2\0019=236\00135=i\00134=278\00149=1U7001N\00150=bluestream\00152=20150427-19:31:31.003\00156=CME\00157=G\001142=US,NC\001117=275\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25050\001133=25300\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=142\001", - "8=FIX.4.2\0019=149\00135=b\00134=365\001369=278\00152=20150427-19:31:31.032\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=275\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=229\001", - "8=FIX.4.2\0019=236\00135=i\00134=279\00149=1U7001N\00150=bluestream\00152=20150427-19:31:31.267\00156=CME\00157=G\001142=US,NC\001117=276\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25025\001133=25325\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=165\001", - "8=FIX.4.2\0019=149\00135=b\00134=366\001369=279\00152=20150427-19:31:31.293\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=276\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=241\001", - "8=FIX.4.2\0019=236\00135=i\00134=280\00149=1U7001N\00150=bluestream\00152=20150427-19:31:31.530\00156=CME\00157=G\001142=US,NC\001117=277\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25000\001133=25350\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=142\001", - "8=FIX.4.2\0019=149\00135=b\00134=367\001369=280\00152=20150427-19:31:31.562\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=277\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=234\001", - "8=FIX.4.2\0019=236\00135=i\00134=281\00149=1U7001N\00150=bluestream\00152=20150427-19:31:31.794\00156=CME\00157=G\001142=US,NC\001117=278\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25025\001133=25375\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=170\001", - "8=FIX.4.2\0019=149\00135=b\00134=368\001369=281\00152=20150427-19:31:31.822\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=278\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=236\001", - "8=FIX.4.2\0019=236\00135=i\00134=282\00149=1U7001N\00150=bluestream\00152=20150427-19:31:32.058\00156=CME\00157=G\001142=US,NC\001117=279\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25050\001133=25400\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=153\001", - "8=FIX.4.2\0019=149\00135=b\00134=369\001369=282\00152=20150427-19:31:32.083\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=279\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=239\001", - "8=FIX.4.2\0019=236\00135=i\00134=283\00149=1U7001N\00150=bluestream\00152=20150427-19:31:32.321\00156=CME\00157=G\001142=US,NC\001117=280\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25075\001133=25425\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=153\001", - "8=FIX.4.2\0019=149\00135=b\00134=370\001369=283\00152=20150427-19:31:32.356\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=280\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=227\001", - "8=FIX.4.2\0019=236\00135=i\00134=284\00149=1U7001N\00150=bluestream\00152=20150427-19:31:32.585\00156=CME\00157=G\001142=US,NC\001117=281\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25050\001133=25450\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=158\001", - "8=FIX.4.2\0019=149\00135=b\00134=371\001369=284\00152=20150427-19:31:32.617\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=281\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=230\001", - "8=FIX.4.2\0019=236\00135=i\00134=285\00149=1U7001N\00150=bluestream\00152=20150427-19:31:32.849\00156=CME\00157=G\001142=US,NC\001117=282\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25025\001133=25475\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=172\001", - "8=FIX.4.2\0019=149\00135=b\00134=372\001369=285\00152=20150427-19:31:32.873\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=282\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=237\001", - "8=FIX.4.2\0019=236\00135=i\00134=286\00149=1U7001N\00150=bluestream\00152=20150427-19:31:33.112\00156=CME\00157=G\001142=US,NC\001117=283\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25000\001133=25500\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=140\001", - "8=FIX.4.2\0019=149\00135=b\00134=373\001369=286\00152=20150427-19:31:33.137\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=283\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=234\001", - "8=FIX.4.2\0019=220\00135=i\00134=287\00149=1U7001N\00150=bluestream\00152=20150427-19:31:33.376\00156=CME\00157=G\001142=US,NC\001117=284\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25025\001134=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=193\001", - "8=FIX.4.2\0019=149\00135=b\00134=374\001369=287\00152=20150427-19:31:33.437\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=284\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=240\001", - "8=FIX.4.2\0019=220\00135=i\00134=288\00149=1U7001N\00150=bluestream\00152=20150427-19:31:33.640\00156=CME\00157=G\001142=US,NC\001117=285\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25050\001134=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=187\001", - "8=FIX.4.2\0019=149\00135=b\00134=375\001369=288\00152=20150427-19:31:33.667\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=285\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=248\001", - "8=FIX.4.2\0019=236\00135=i\00134=289\00149=1U7001N\00150=bluestream\00152=20150427-19:31:33.903\00156=CME\00157=G\001142=US,NC\001117=286\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25025\001133=25475\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=172\001", - "8=FIX.4.2\0019=149\00135=b\00134=376\001369=289\00152=20150427-19:31:33.927\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=286\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=250\001", - "8=FIX.4.2\0019=236\00135=i\00134=290\00149=1U7001N\00150=bluestream\00152=20150427-19:31:34.167\00156=CME\00157=G\001142=US,NC\001117=287\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25000\001133=25500\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=150\001", - "8=FIX.4.2\0019=149\00135=b\00134=377\001369=290\00152=20150427-19:31:34.193\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=287\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=240\001", - "8=FIX.4.2\0019=220\00135=i\00134=291\00149=1U7001N\00150=bluestream\00152=20150427-19:31:34.694\00156=CME\00157=G\001142=US,NC\001117=288\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001133=25525\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=203\001", - "8=FIX.4.2\0019=149\00135=b\00134=378\001369=291\00152=20150427-19:31:34.721\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=288\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=240\001", - "8=FIX.4.2\0019=236\00135=i\00134=292\00149=1U7001N\00150=bluestream\00152=20150427-19:31:34.962\00156=CME\00157=G\001142=US,NC\001117=289\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25025\001133=25550\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=169\001", - "8=FIX.4.2\0019=149\00135=b\00134=379\001369=292\00152=20150427-19:31:34.988\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=289\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=002\001", - "8=FIX.4.2\0019=236\00135=i\00134=293\00149=1U7001N\00150=bluestream\00152=20150427-19:31:35.229\00156=CME\00157=G\001142=US,NC\001117=290\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25000\001133=25575\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=159\001", - "8=FIX.4.2\0019=149\00135=b\00134=380\001369=293\00152=20150427-19:31:35.253\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=290\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=229\001", - "8=FIX.4.2\0019=134\00135=A\00134=294\00149=1U7001N\00150=bluestream\00152=20150427-19:55:10.917\00156=CME\00157=G\001142=US,NC\00195=3\00196=1U7\00198=0\001108=30\0011603=O2\0011604=1.0\0011605=BTS\00110=117\001", - "8=FIX.4.2\0019=130\00135=A\00134=387\001369=294\00152=20150427-19:55:12.438\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00198=0\001108=30\0011603=O2\0011604=1.0\0011605=BTS\00110=107\001", - "8=FIX.4.2\0019=95\00135=2\00134=295\00149=1U7001N\00150=bluestream\00152=20150427-19:55:12.466\00156=CME\00157=G\001142=US,NC\0017=381\00116=0\00110=174\001", - "8=FIX.4.2\0019=107\00135=1\00134=388\001369=294\00152=20150427-19:55:12.439\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001112=IDi8yfsl41\00110=087\001", - "8=FIX.4.2\0019=118\00135=Z\00134=296\00149=1U7001N\00150=bluestream\00152=20150427-19:55:12.472\00156=CME\00157=G\001142=US,NC\001117=294\001295=1\00155=N/A\001298=4\0011028=N\00110=113\001", - "8=FIX.4.2\0019=166\00135=b\00134=381\001369=295\00152=20150427-19:55:12.488\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-19:31:36.468\001143=US,NC\001117=CMET$128\001297=4\0011028=N\0019772=0\0019774=T$\0019775=A\00110=086\001", - "8=FIX.4.2\0019=166\00135=b\00134=382\001369=295\00152=20150427-19:55:12.488\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-19:31:36.468\001143=US,NC\001117=CMETE207\001297=4\0011028=N\0019772=0\0019774=TE\0019775=A\00110=151\001", - "8=FIX.4.2\0019=167\00135=b\00134=383\001369=295\00152=20150427-19:55:12.488\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-19:31:36.469\001143=US,NC\001117=CME1V2644\001297=4\0011028=N\0019772=0\0019774=1V\0019775=A\00110=173\001", - "8=FIX.4.2\0019=167\00135=b\00134=384\001369=295\00152=20150427-19:55:12.488\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-19:31:36.469\001143=US,NC\001117=CMEEW3120\001297=4\0011028=N\0019772=0\0019774=EW\0019775=A\00110=206\001", - "8=FIX.4.2\0019=167\00135=b\00134=385\001369=295\00152=20150427-19:55:12.488\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-19:31:36.470\001143=US,NC\001117=CMEEZ3456\001297=4\0011028=N\0019772=1\0019774=EZ\0019775=A\00110=218\001", - "8=FIX.4.2\0019=166\00135=b\00134=386\001369=295\00152=20150427-19:55:12.488\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-19:31:36.471\001143=US,NC\001117=CME96121\001297=4\0011028=N\0019772=0\0019774=96\0019775=A\00110=060\001", - "8=FIX.4.2\0019=99\00135=0\00134=297\00149=1U7001N\00150=bluestream\00152=20150427-19:55:12.566\00156=CME\00157=G\001142=US,NC\001112=IDi8yfsl41\00110=240\001", - "8=FIX.4.2\0019=136\00135=4\00134=387\001369=295\00152=20150427-19:55:12.488\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001122=20150427-19:55:12.488\001143=US,NC\00136=389\001123=Y\00110=197\001", - "8=FIX.4.2\0019=128\00135=b\00134=389\001369=296\00152=20150427-19:55:12.533\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=294\001297=4\0011028=N\0019772=0\0019774=T$\00110=031\001", - "8=FIX.4.2\0019=128\00135=b\00134=390\001369=296\00152=20150427-19:55:12.533\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=294\001297=4\0011028=N\0019772=0\0019774=TE\00110=056\001", - "8=FIX.4.2\0019=128\00135=b\00134=391\001369=296\00152=20150427-19:55:12.538\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=294\001297=4\0011028=N\0019772=0\0019774=1V\00110=044\001", - "8=FIX.4.2\0019=128\00135=b\00134=392\001369=296\00152=20150427-19:55:12.538\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=294\001297=4\0011028=N\0019772=0\0019774=EW\00110=066\001", - "8=FIX.4.2\0019=128\00135=b\00134=393\001369=296\00152=20150427-19:55:12.538\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=294\001297=4\0011028=N\0019772=0\0019774=EZ\00110=070\001", - "8=FIX.4.2\0019=128\00135=b\00134=394\001369=296\00152=20150427-19:55:12.545\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=294\001297=4\0011028=N\0019772=0\0019774=96\00110=021\001", - "8=FIX.4.2\0019=92\00135=0\00134=395\001369=297\00152=20150427-19:55:42.582\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=009\001", - "8=FIX.4.2\0019=84\00135=0\00134=298\00149=1U7001N\00150=bluestream\00152=20150427-19:55:42.609\00156=CME\00157=G\001142=US,NC\00110=201\001", - "8=FIX.4.2\0019=236\00135=i\00134=299\00149=1U7001N\00150=bluestream\00152=20150427-19:56:08.053\00156=CME\00157=G\001142=US,NC\001117=295\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25125\001133=25500\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=168\001", - "8=FIX.4.2\0019=149\00135=b\00134=396\001369=299\00152=20150427-19:56:08.082\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=295\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=254\001", - "8=FIX.4.2\0019=236\00135=i\00134=300\00149=1U7001N\00150=bluestream\00152=20150427-19:56:08.179\00156=CME\00157=G\001142=US,NC\001117=296\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25150\001133=25525\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=166\001", - "8=FIX.4.2\0019=149\00135=b\00134=397\001369=300\00152=20150427-19:56:08.208\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=296\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=239\001", - "8=FIX.4.2\0019=236\00135=i\00134=301\00149=1U7001N\00150=bluestream\00152=20150427-19:56:08.279\00156=CME\00157=G\001142=US,NC\001117=297\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25125\001133=25500\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=164\001", - "8=FIX.4.2\0019=149\00135=b\00134=398\001369=301\00152=20150427-19:56:08.307\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=297\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=242\001", - "8=FIX.4.2\0019=236\00135=i\00134=302\00149=1U7001N\00150=bluestream\00152=20150427-19:56:08.487\00156=CME\00157=G\001142=US,NC\001117=298\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25100\001133=25525\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=167\001", - "8=FIX.4.2\0019=149\00135=b\00134=399\001369=302\00152=20150427-19:56:08.511\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=298\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=242\001", - "8=FIX.4.2\0019=236\00135=i\00134=303\00149=1U7001N\00150=bluestream\00152=20150427-19:56:08.751\00156=CME\00157=G\001142=US,NC\001117=299\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25075\001133=25550\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=172\001", - "8=FIX.4.2\0019=149\00135=b\00134=400\001369=303\00152=20150427-19:56:08.784\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=299\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=239\001", - "8=FIX.4.2\0019=236\00135=i\00134=304\00149=1U7001N\00150=bluestream\00152=20150427-19:56:09.014\00156=CME\00157=G\001142=US,NC\001117=300\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25100\001133=25575\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=145\001", - "8=FIX.4.2\0019=149\00135=b\00134=401\001369=304\00152=20150427-19:56:09.049\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=300\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=219\001", - "8=FIX.4.2\0019=236\00135=i\00134=305\00149=1U7001N\00150=bluestream\00152=20150427-19:56:09.278\00156=CME\00157=G\001142=US,NC\001117=301\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25075\001133=25550\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=163\001", - "8=FIX.4.2\0019=149\00135=b\00134=402\001369=305\00152=20150427-19:56:09.306\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=301\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=218\001", - "8=FIX.4.2\0019=236\00135=i\00134=306\00149=1U7001N\00150=bluestream\00152=20150427-19:56:09.542\00156=CME\00157=G\001142=US,NC\001117=302\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25050\001133=25575\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=159\001", - "8=FIX.4.2\0019=149\00135=b\00134=403\001369=306\00152=20150427-19:56:09.564\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=302\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=227\001", - "8=FIX.4.2\0019=236\00135=i\00134=307\00149=1U7001N\00150=bluestream\00152=20150427-19:56:09.805\00156=CME\00157=G\001142=US,NC\001117=303\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25075\001133=25550\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=163\001", - "8=FIX.4.2\0019=149\00135=b\00134=404\001369=307\00152=20150427-19:56:09.833\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=303\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=229\001", - "8=FIX.4.2\0019=236\00135=i\00134=308\00149=1U7001N\00150=bluestream\00152=20150427-19:56:10.069\00156=CME\00157=G\001142=US,NC\001117=304\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25050\001133=25575\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=159\001", - "8=FIX.4.2\0019=149\00135=b\00134=405\001369=308\00152=20150427-19:56:10.097\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=304\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=226\001", - "8=FIX.4.2\0019=236\00135=i\00134=309\00149=1U7001N\00150=bluestream\00152=20150427-19:56:10.332\00156=CME\00157=G\001142=US,NC\001117=305\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25025\001133=25600\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=145\001", - "8=FIX.4.2\0019=149\00135=b\00134=406\001369=309\00152=20150427-19:56:10.358\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=305\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=229\001", - "8=FIX.4.2\0019=236\00135=i\00134=310\00149=1U7001N\00150=bluestream\00152=20150427-19:56:10.595\00156=CME\00157=G\001142=US,NC\001117=306\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25000\001133=25625\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=149\001", - "8=FIX.4.2\0019=149\00135=b\00134=407\001369=310\00152=20150427-19:56:10.622\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=306\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=217\001", - "8=FIX.4.2\0019=220\00135=i\00134=311\00149=1U7001N\00150=bluestream\00152=20150427-19:56:10.859\00156=CME\00157=G\001142=US,NC\001117=307\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001133=25600\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=186\001", - "8=FIX.4.2\0019=149\00135=b\00134=408\001369=311\00152=20150427-19:56:10.886\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=307\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=232\001", - "8=FIX.4.2\0019=220\00135=i\00134=312\00149=1U7001N\00150=bluestream\00152=20150427-19:56:11.123\00156=CME\00157=G\001142=US,NC\001117=308\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001133=25575\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=184\001", - "8=FIX.4.2\0019=149\00135=b\00134=409\001369=312\00152=20150427-19:56:11.160\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=308\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=221\001", - "8=FIX.4.2\0019=236\00135=i\00134=313\00149=1U7001N\00150=bluestream\00152=20150427-19:56:11.386\00156=CME\00157=G\001142=US,NC\001117=309\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25025\001133=25550\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=158\001", - "8=FIX.4.2\0019=149\00135=b\00134=410\001369=313\00152=20150427-19:56:11.409\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=309\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=221\001", - "8=FIX.4.2\0019=236\00135=i\00134=314\00149=1U7001N\00150=bluestream\00152=20150427-19:56:11.650\00156=CME\00157=G\001142=US,NC\001117=310\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25000\001133=25525\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=140\001", - "8=FIX.4.2\0019=149\00135=b\00134=411\001369=314\00152=20150427-19:56:11.690\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=310\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=217\001", - "8=FIX.4.2\0019=220\00135=i\00134=315\00149=1U7001N\00150=bluestream\00152=20150427-19:56:11.914\00156=CME\00157=G\001142=US,NC\001117=311\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001133=25550\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=182\001", - "8=FIX.4.2\0019=149\00135=b\00134=412\001369=315\00152=20150427-19:56:11.936\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=311\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=223\001", - "8=FIX.4.2\0019=236\00135=i\00134=316\00149=1U7001N\00150=bluestream\00152=20150427-19:56:12.177\00156=CME\00157=G\001142=US,NC\001117=312\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25025\001133=25525\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=156\001", - "8=FIX.4.2\0019=149\00135=b\00134=413\001369=316\00152=20150427-19:56:12.213\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=312\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=215\001", - "8=FIX.4.2\0019=236\00135=i\00134=317\00149=1U7001N\00150=bluestream\00152=20150427-19:56:12.441\00156=CME\00157=G\001142=US,NC\001117=313\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25050\001133=25500\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=143\001", - "8=FIX.4.2\0019=149\00135=b\00134=414\001369=317\00152=20150427-19:56:12.468\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=313\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=230\001", - "8=FIX.4.2\0019=236\00135=i\00134=318\00149=1U7001N\00150=bluestream\00152=20150427-19:56:12.705\00156=CME\00157=G\001142=US,NC\001117=314\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25025\001133=25525\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=157\001", - "8=FIX.4.2\0019=149\00135=b\00134=415\001369=318\00152=20150427-19:56:12.736\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=314\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=231\001", - "8=FIX.4.2\0019=236\00135=i\00134=319\00149=1U7001N\00150=bluestream\00152=20150427-19:56:12.968\00156=CME\00157=G\001142=US,NC\001117=315\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25050\001133=25550\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=166\001", - "8=FIX.4.2\0019=149\00135=b\00134=416\001369=319\00152=20150427-19:56:12.992\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=315\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=238\001", - "8=FIX.4.2\0019=236\00135=i\00134=320\00149=1U7001N\00150=bluestream\00152=20150427-19:56:13.232\00156=CME\00157=G\001142=US,NC\001117=316\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25025\001133=25575\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=153\001", - "8=FIX.4.2\0019=149\00135=b\00134=417\001369=320\00152=20150427-19:56:13.268\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=316\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=229\001", - "8=FIX.4.2\0019=236\00135=i\00134=321\00149=1U7001N\00150=bluestream\00152=20150427-19:56:13.496\00156=CME\00157=G\001142=US,NC\001117=317\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25050\001133=25550\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=158\001", - "8=FIX.4.2\0019=149\00135=b\00134=418\001369=321\00152=20150427-19:56:13.538\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=317\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=232\001", - "8=FIX.4.2\0019=236\00135=i\00134=322\00149=1U7001N\00150=bluestream\00152=20150427-19:56:13.759\00156=CME\00157=G\001142=US,NC\001117=318\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25025\001133=25525\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=166\001", - "8=FIX.4.2\0019=149\00135=b\00134=419\001369=322\00152=20150427-19:56:13.787\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=318\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=241\001", - "8=FIX.4.2\0019=236\00135=i\00134=323\00149=1U7001N\00150=bluestream\00152=20150427-19:56:14.021\00156=CME\00157=G\001142=US,NC\001117=319\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25000\001133=25550\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=142\001", - "8=FIX.4.2\0019=149\00135=b\00134=420\001369=323\00152=20150427-19:56:14.059\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=319\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=228\001", - "8=FIX.4.2\0019=220\00135=i\00134=324\00149=1U7001N\00150=bluestream\00152=20150427-19:56:14.284\00156=CME\00157=G\001142=US,NC\001117=320\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001133=25575\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=192\001", - "8=FIX.4.2\0019=149\00135=b\00134=421\001369=324\00152=20150427-19:56:14.312\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=320\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=214\001", - "8=FIX.4.2\0019=220\00135=i\00134=325\00149=1U7001N\00150=bluestream\00152=20150427-19:56:14.548\00156=CME\00157=G\001142=US,NC\001117=321\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001133=25550\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=190\001", - "8=FIX.4.2\0019=149\00135=b\00134=422\001369=325\00152=20150427-19:56:14.573\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=321\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=226\001", - "8=FIX.4.2\0019=220\00135=i\00134=326\00149=1U7001N\00150=bluestream\00152=20150427-19:56:14.811\00156=CME\00157=G\001142=US,NC\001117=322\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001133=25575\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=192\001", - "8=FIX.4.2\0019=149\00135=b\00134=423\001369=326\00152=20150427-19:56:14.839\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=322\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=234\001", - "8=FIX.4.2\0019=220\00135=i\00134=327\00149=1U7001N\00150=bluestream\00152=20150427-19:56:15.075\00156=CME\00157=G\001142=US,NC\001117=323\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001133=25600\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=186\001", - "8=FIX.4.2\0019=149\00135=b\00134=424\001369=327\00152=20150427-19:56:15.123\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=323\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=224\001", - "8=FIX.4.2\0019=236\00135=i\00134=328\00149=1U7001N\00150=bluestream\00152=20150427-19:56:15.339\00156=CME\00157=G\001142=US,NC\001117=324\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25025\001133=25575\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=170\001", - "8=FIX.4.2\0019=149\00135=b\00134=425\001369=328\00152=20150427-19:56:15.358\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=324\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=237\001", - "8=FIX.4.2\0019=236\00135=i\00134=329\00149=1U7001N\00150=bluestream\00152=20150427-19:56:15.603\00156=CME\00157=G\001142=US,NC\001117=325\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25050\001133=25550\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=157\001", - "8=FIX.4.2\0019=149\00135=b\00134=426\001369=329\00152=20150427-19:56:15.623\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=325\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=235\001", - "8=FIX.4.2\0019=236\00135=i\00134=330\00149=1U7001N\00150=bluestream\00152=20150427-19:56:15.866\00156=CME\00157=G\001142=US,NC\001117=326\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25025\001133=25525\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=165\001", - "8=FIX.4.2\0019=149\00135=b\00134=427\001369=330\00152=20150427-19:56:15.896\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=326\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=241\001", - "8=FIX.4.2\0019=236\00135=i\00134=331\00149=1U7001N\00150=bluestream\00152=20150427-19:56:16.130\00156=CME\00157=G\001142=US,NC\001117=327\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25050\001133=25500\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=143\001", - "8=FIX.4.2\0019=149\00135=b\00134=428\001369=331\00152=20150427-19:56:16.153\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=327\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=231\001", - "8=FIX.4.2\0019=220\00135=i\00134=332\00149=1U7001N\00150=bluestream\00152=20150427-19:56:16.393\00156=CME\00157=G\001142=US,NC\001117=328\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25075\001134=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=195\001", - "8=FIX.4.2\0019=149\00135=b\00134=429\001369=332\00152=20150427-19:56:16.418\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=328\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=238\001", - "8=FIX.4.2\0019=236\00135=i\00134=333\00149=1U7001N\00150=bluestream\00152=20150427-19:56:16.657\00156=CME\00157=G\001142=US,NC\001117=329\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25100\001133=25475\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=168\001", - "8=FIX.4.2\0019=149\00135=b\00134=430\001369=333\00152=20150427-19:56:16.687\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=329\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=240\001", - "8=FIX.4.2\0019=236\00135=i\00134=334\00149=1U7001N\00150=bluestream\00152=20150427-19:56:16.921\00156=CME\00157=G\001142=US,NC\001117=330\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25075\001133=25500\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=155\001", - "8=FIX.4.2\0019=149\00135=b\00134=431\001369=334\00152=20150427-19:56:16.943\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=330\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=229\001", - "8=FIX.4.2\0019=236\00135=i\00134=335\00149=1U7001N\00150=bluestream\00152=20150427-19:56:17.185\00156=CME\00157=G\001142=US,NC\001117=331\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25050\001133=25475\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=164\001", - "8=FIX.4.2\0019=149\00135=b\00134=432\001369=335\00152=20150427-19:56:17.209\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=331\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=228\001", - "8=FIX.4.2\0019=236\00135=i\00134=336\00149=1U7001N\00150=bluestream\00152=20150427-19:56:17.448\00156=CME\00157=G\001142=US,NC\001117=332\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25025\001133=25450\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=163\001", - "8=FIX.4.2\0019=149\00135=b\00134=433\001369=336\00152=20150427-19:56:17.477\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=332\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=238\001", - "8=FIX.4.2\0019=236\00135=i\00134=337\00149=1U7001N\00150=bluestream\00152=20150427-19:56:17.712\00156=CME\00157=G\001142=US,NC\001117=333\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25000\001133=25425\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=154\001", - "8=FIX.4.2\0019=149\00135=b\00134=434\001369=337\00152=20150427-19:56:17.737\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=333\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=240\001", - "8=FIX.4.2\0019=220\00135=i\00134=338\00149=1U7001N\00150=bluestream\00152=20150427-19:56:17.976\00156=CME\00157=G\001142=US,NC\001117=334\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001133=25400\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=200\001", - "8=FIX.4.2\0019=149\00135=b\00134=435\001369=338\00152=20150427-19:56:18.029\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=334\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=238\001", - "8=FIX.4.2\0019=236\00135=i\00134=339\00149=1U7001N\00150=bluestream\00152=20150427-19:56:18.239\00156=CME\00157=G\001142=US,NC\001117=335\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25025\001133=25375\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=174\001", - "8=FIX.4.2\0019=149\00135=b\00134=436\001369=339\00152=20150427-19:56:18.267\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=335\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=245\001", - "8=FIX.4.2\0019=236\00135=i\00134=340\00149=1U7001N\00150=bluestream\00152=20150427-19:56:18.503\00156=CME\00157=G\001142=US,NC\001117=336\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25050\001133=25400\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=148\001", - "8=FIX.4.2\0019=149\00135=b\00134=437\001369=340\00152=20150427-19:56:18.527\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=336\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=238\001", - "8=FIX.4.2\0019=236\00135=i\00134=341\00149=1U7001N\00150=bluestream\00152=20150427-19:56:18.767\00156=CME\00157=G\001142=US,NC\001117=337\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25025\001133=25375\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=175\001", - "8=FIX.4.2\0019=149\00135=b\00134=438\001369=341\00152=20150427-19:56:18.790\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=337\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=243\001", - "8=FIX.4.2\0019=236\00135=i\00134=342\00149=1U7001N\00150=bluestream\00152=20150427-19:56:19.029\00156=CME\00157=G\001142=US,NC\001117=338\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25050\001133=25350\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=160\001", - "8=FIX.4.2\0019=149\00135=b\00134=439\001369=342\00152=20150427-19:56:19.052\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=338\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=238\001", - "8=FIX.4.2\0019=236\00135=i\00134=343\00149=1U7001N\00150=bluestream\00152=20150427-19:56:19.291\00156=CME\00157=G\001142=US,NC\001117=339\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25075\001133=25375\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=177\001", - "8=FIX.4.2\0019=149\00135=b\00134=440\001369=343\00152=20150427-19:56:19.318\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=339\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=237\001", - "8=FIX.4.2\0019=236\00135=i\00134=344\00149=1U7001N\00150=bluestream\00152=20150427-19:56:19.553\00156=CME\00157=G\001142=US,NC\001117=340\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25100\001133=25400\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=149\001", - "8=FIX.4.2\0019=149\00135=b\00134=441\001369=344\00152=20150427-19:56:19.573\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=340\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=234\001", - "8=FIX.4.2\0019=236\00135=i\00134=345\00149=1U7001N\00150=bluestream\00152=20150427-19:56:19.815\00156=CME\00157=G\001142=US,NC\001117=341\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25125\001133=25375\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=170\001", - "8=FIX.4.2\0019=149\00135=b\00134=442\001369=345\00152=20150427-19:56:19.846\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=341\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=240\001", - "8=FIX.4.2\0019=236\00135=i\00134=346\00149=1U7001N\00150=bluestream\00152=20150427-19:56:20.078\00156=CME\00157=G\001142=US,NC\001117=342\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25150\001133=25350\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=156\001", - "8=FIX.4.2\0019=149\00135=b\00134=443\001369=346\00152=20150427-19:56:20.109\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=342\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=227\001", - "8=FIX.4.2\0019=236\00135=i\00134=347\00149=1U7001N\00150=bluestream\00152=20150427-19:56:20.342\00156=CME\00157=G\001142=US,NC\001117=343\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25175\001133=25325\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=161\001", - "8=FIX.4.2\0019=149\00135=b\00134=444\001369=347\00152=20150427-19:56:20.363\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=343\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=232\001", - "8=FIX.4.2\0019=236\00135=i\00134=348\00149=1U7001N\00150=bluestream\00152=20150427-19:56:20.606\00156=CME\00157=G\001142=US,NC\001117=344\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25150\001133=25350\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=157\001", - "8=FIX.4.2\0019=149\00135=b\00134=445\001369=348\00152=20150427-19:56:20.634\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=344\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=236\001", - "8=FIX.4.2\0019=236\00135=i\00134=349\00149=1U7001N\00150=bluestream\00152=20150427-19:56:20.869\00156=CME\00157=G\001142=US,NC\001117=345\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25175\001133=25375\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=184\001", - "8=FIX.4.2\0019=149\00135=b\00134=446\001369=349\00152=20150427-19:56:20.897\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=345\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=250\001", - "8=FIX.4.2\0019=236\00135=i\00134=350\00149=1U7001N\00150=bluestream\00152=20150427-19:56:21.133\00156=CME\00157=G\001142=US,NC\001117=346\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25150\001133=25400\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=144\001", - "8=FIX.4.2\0019=149\00135=b\00134=447\001369=350\00152=20150427-19:56:21.153\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=346\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=230\001", - "8=FIX.4.2\0019=236\00135=i\00134=351\00149=1U7001N\00150=bluestream\00152=20150427-19:56:21.397\00156=CME\00157=G\001142=US,NC\001117=347\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25125\001133=25425\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=167\001", - "8=FIX.4.2\0019=149\00135=b\00134=448\001369=351\00152=20150427-19:56:21.419\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=347\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=238\001", - "8=FIX.4.2\0019=236\00135=i\00134=352\00149=1U7001N\00150=bluestream\00152=20150427-19:56:21.661\00156=CME\00157=G\001142=US,NC\001117=348\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25100\001133=25450\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=154\001", - "8=FIX.4.2\0019=149\00135=b\00134=449\001369=352\00152=20150427-19:56:21.694\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=348\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=246\001", - "8=FIX.4.2\0019=236\00135=i\00134=353\00149=1U7001N\00150=bluestream\00152=20150427-19:56:21.926\00156=CME\00157=G\001142=US,NC\001117=349\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25075\001133=25425\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=173\001", - "8=FIX.4.2\0019=149\00135=b\00134=450\001369=353\00152=20150427-19:56:21.953\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=349\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=238\001", - "8=FIX.4.2\0019=236\00135=i\00134=354\00149=1U7001N\00150=bluestream\00152=20150427-19:56:22.191\00156=CME\00157=G\001142=US,NC\001117=350\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25100\001133=25400\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=143\001", - "8=FIX.4.2\0019=149\00135=b\00134=451\001369=354\00152=20150427-19:56:22.213\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=350\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=222\001", - "8=FIX.4.2\0019=236\00135=i\00134=355\00149=1U7001N\00150=bluestream\00152=20150427-19:56:22.456\00156=CME\00157=G\001142=US,NC\001117=351\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25075\001133=25425\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=167\001", - "8=FIX.4.2\0019=149\00135=b\00134=452\001369=355\00152=20150427-19:56:22.487\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=351\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=238\001", - "8=FIX.4.2\0019=236\00135=i\00134=356\00149=1U7001N\00150=bluestream\00152=20150427-19:56:22.721\00156=CME\00157=G\001142=US,NC\001117=352\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25100\001133=25450\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=151\001", - "8=FIX.4.2\0019=149\00135=b\00134=453\001369=356\00152=20150427-19:56:22.744\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=352\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=237\001", - "8=FIX.4.2\0019=236\00135=i\00134=357\00149=1U7001N\00150=bluestream\00152=20150427-19:56:22.986\00156=CME\00157=G\001142=US,NC\001117=353\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25075\001133=25475\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=184\001", - "8=FIX.4.2\0019=149\00135=b\00134=454\001369=357\00152=20150427-19:56:23.042\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=353\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=232\001", - "8=FIX.4.2\0019=236\00135=i\00134=358\00149=1U7001N\00150=bluestream\00152=20150427-19:56:23.250\00156=CME\00157=G\001142=US,NC\001117=354\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25050\001133=25450\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=157\001", - "8=FIX.4.2\0019=149\00135=b\00134=455\001369=358\00152=20150427-19:56:23.290\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=354\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=240\001", - "8=FIX.4.2\0019=236\00135=i\00134=359\00149=1U7001N\00150=bluestream\00152=20150427-19:56:23.515\00156=CME\00157=G\001142=US,NC\001117=355\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25075\001133=25475\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=177\001", - "8=FIX.4.2\0019=149\00135=b\00134=456\001369=359\00152=20150427-19:56:23.540\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=355\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=241\001", - "8=FIX.4.2\0019=236\00135=i\00134=360\00149=1U7001N\00150=bluestream\00152=20150427-19:56:23.779\00156=CME\00157=G\001142=US,NC\001117=356\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25050\001133=25450\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=168\001", - "8=FIX.4.2\0019=149\00135=b\00134=457\001369=360\00152=20150427-19:56:23.809\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=356\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=243\001", - "8=FIX.4.2\0019=236\00135=i\00134=361\00149=1U7001N\00150=bluestream\00152=20150427-19:56:24.044\00156=CME\00157=G\001142=US,NC\001117=357\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25025\001133=25475\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=165\001", - "8=FIX.4.2\0019=149\00135=b\00134=458\001369=361\00152=20150427-19:56:24.072\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=357\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=239\001", - "8=FIX.4.2\0019=236\00135=i\00134=362\00149=1U7001N\00150=bluestream\00152=20150427-19:56:24.309\00156=CME\00157=G\001142=US,NC\001117=358\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25000\001133=25500\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=153\001", - "8=FIX.4.2\0019=149\00135=b\00134=459\001369=362\00152=20150427-19:56:24.332\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=358\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=241\001", - "8=FIX.4.2\0019=220\00135=i\00134=363\00149=1U7001N\00150=bluestream\00152=20150427-19:56:24.573\00156=CME\00157=G\001142=US,NC\001117=359\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25025\001134=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=197\001", - "8=FIX.4.2\0019=149\00135=b\00134=460\001369=363\00152=20150427-19:56:24.612\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=359\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=236\001", - "8=FIX.4.2\0019=236\00135=i\00134=364\00149=1U7001N\00150=bluestream\00152=20150427-19:56:24.838\00156=CME\00157=G\001142=US,NC\001117=360\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25000\001133=25525\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=162\001", - "8=FIX.4.2\0019=149\00135=b\00134=461\001369=364\00152=20150427-19:56:24.870\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=360\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=236\001", - "8=FIX.4.2\0019=220\00135=i\00134=365\00149=1U7001N\00150=bluestream\00152=20150427-19:56:25.102\00156=CME\00157=G\001142=US,NC\001117=361\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001133=25500\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=181\001", - "8=FIX.4.2\0019=149\00135=b\00134=462\001369=365\00152=20150427-19:56:25.139\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=361\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=238\001", - "8=FIX.4.2\0019=220\00135=i\00134=366\00149=1U7001N\00150=bluestream\00152=20150427-19:56:25.632\00156=CME\00157=G\001142=US,NC\001117=362\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25025\001134=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=191\001", - "8=FIX.4.2\0019=149\00135=b\00134=463\001369=366\00152=20150427-19:56:25.654\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=362\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=243\001", - "8=FIX.4.2\0019=220\00135=i\00134=367\00149=1U7001N\00150=bluestream\00152=20150427-19:56:25.896\00156=CME\00157=G\001142=US,NC\001117=363\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25050\001134=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=203\001", - "8=FIX.4.2\0019=149\00135=b\00134=464\001369=367\00152=20150427-19:56:25.924\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=363\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=246\001", - "8=FIX.4.2\0019=236\00135=i\00134=368\00149=1U7001N\00150=bluestream\00152=20150427-19:56:26.160\00156=CME\00157=G\001142=US,NC\001117=364\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25075\001133=25475\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=176\001", - "8=FIX.4.2\0019=149\00135=b\00134=465\001369=368\00152=20150427-19:56:26.183\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=364\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=247\001", - "8=FIX.4.2\0019=236\00135=i\00134=369\00149=1U7001N\00150=bluestream\00152=20150427-19:56:26.425\00156=CME\00157=G\001142=US,NC\001117=365\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25100\001133=25500\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=160\001", - "8=FIX.4.2\0019=149\00135=b\00134=466\001369=369\00152=20150427-19:56:26.455\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=365\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=252\001", - "8=FIX.4.2\0019=220\00135=i\00134=370\00149=1U7001N\00150=bluestream\00152=20150427-19:56:26.689\00156=CME\00157=G\001142=US,NC\001117=366\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25075\001134=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=208\001", - "8=FIX.4.2\0019=149\00135=b\00134=467\001369=370\00152=20150427-19:56:26.716\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=366\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=246\001", - "8=FIX.4.2\0019=220\00135=i\00134=371\00149=1U7001N\00150=bluestream\00152=20150427-19:56:26.954\00156=CME\00157=G\001142=US,NC\001117=367\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25050\001134=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=198\001", - "8=FIX.4.2\0019=149\00135=b\00134=468\001369=371\00152=20150427-19:56:26.980\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=367\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=252\001", - "8=FIX.4.2\0019=236\00135=i\00134=372\00149=1U7001N\00150=bluestream\00152=20150427-19:56:27.219\00156=CME\00157=G\001142=US,NC\001117=368\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25075\001133=25475\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=181\001", - "8=FIX.4.2\0019=149\00135=b\00134=469\001369=372\00152=20150427-19:56:27.241\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=368\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=246\001", - "8=FIX.4.2\0019=236\00135=i\00134=373\00149=1U7001N\00150=bluestream\00152=20150427-19:56:27.483\00156=CME\00157=G\001142=US,NC\001117=369\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25100\001133=25450\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=168\001", - "8=FIX.4.2\0019=149\00135=b\00134=470\001369=373\00152=20150427-19:56:27.510\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=369\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=239\001", - "8=FIX.4.2\0019=236\00135=i\00134=374\00149=1U7001N\00150=bluestream\00152=20150427-19:56:27.748\00156=CME\00157=G\001142=US,NC\001117=370\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25075\001133=25475\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=183\001", - "8=FIX.4.2\0019=149\00135=b\00134=471\001369=374\00152=20150427-19:56:27.773\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=370\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=244\001", - "8=FIX.4.2\0019=236\00135=i\00134=375\00149=1U7001N\00150=bluestream\00152=20150427-19:56:28.013\00156=CME\00157=G\001142=US,NC\001117=371\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25050\001133=25450\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=157\001", - "8=FIX.4.2\0019=149\00135=b\00134=472\001369=375\00152=20150427-19:56:28.034\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=371\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=238\001", - "8=FIX.4.2\0019=236\00135=i\00134=376\00149=1U7001N\00150=bluestream\00152=20150427-19:56:28.278\00156=CME\00157=G\001142=US,NC\001117=372\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25075\001133=25475\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=186\001", - "8=FIX.4.2\0019=149\00135=b\00134=473\001369=376\00152=20150427-19:56:28.311\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=372\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=239\001", - "8=FIX.4.2\0019=236\00135=i\00134=377\00149=1U7001N\00150=bluestream\00152=20150427-19:56:28.543\00156=CME\00157=G\001142=US,NC\001117=373\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25100\001133=25500\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=161\001", - "8=FIX.4.2\0019=149\00135=b\00134=474\001369=377\00152=20150427-19:56:28.563\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=373\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=251\001", - "8=FIX.4.2\0019=236\00135=i\00134=378\00149=1U7001N\00150=bluestream\00152=20150427-19:56:28.808\00156=CME\00157=G\001142=US,NC\001117=374\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25075\001133=25475\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=189\001", - "8=FIX.4.2\0019=149\00135=b\00134=475\001369=378\00152=20150427-19:56:28.841\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=374\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=253\001", - "8=FIX.4.2\0019=236\00135=i\00134=379\00149=1U7001N\00150=bluestream\00152=20150427-19:56:29.072\00156=CME\00157=G\001142=US,NC\001117=375\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25050\001133=25450\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=171\001", - "8=FIX.4.2\0019=149\00135=b\00134=476\001369=379\00152=20150427-19:56:29.101\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=375\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=246\001", - "8=FIX.4.2\0019=236\00135=i\00134=380\00149=1U7001N\00150=bluestream\00152=20150427-19:56:29.337\00156=CME\00157=G\001142=US,NC\001117=376\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25025\001133=25425\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=172\001", - "8=FIX.4.2\0019=149\00135=b\00134=477\001369=380\00152=20150427-19:56:29.358\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=376\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=254\001", - "8=FIX.4.2\0019=236\00135=i\00134=381\00149=1U7001N\00150=bluestream\00152=20150427-19:56:29.602\00156=CME\00157=G\001142=US,NC\001117=377\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25000\001133=25400\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=155\001", - "8=FIX.4.2\0019=149\00135=b\00134=478\001369=381\00152=20150427-19:56:29.625\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=377\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=254\001", - "8=FIX.4.2\0019=220\00135=i\00134=382\00149=1U7001N\00150=bluestream\00152=20150427-19:56:29.866\00156=CME\00157=G\001142=US,NC\001117=378\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001133=25425\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=215\001", - "8=FIX.4.2\0019=149\00135=b\00134=479\001369=382\00152=20150427-19:56:29.896\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=378\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=011\001", - "8=FIX.4.2\0019=236\00135=i\00134=383\00149=1U7001N\00150=bluestream\00152=20150427-19:56:30.131\00156=CME\00157=G\001142=US,NC\001117=379\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25025\001133=25400\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=155\001", - "8=FIX.4.2\0019=149\00135=b\00134=480\001369=383\00152=20150427-19:56:30.158\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=379\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=244\001", - "8=FIX.4.2\0019=236\00135=i\00134=384\00149=1U7001N\00150=bluestream\00152=20150427-19:56:30.395\00156=CME\00157=G\001142=US,NC\001117=380\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25050\001133=25375\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=169\001", - "8=FIX.4.2\0019=149\00135=b\00134=481\001369=384\00152=20150427-19:56:30.424\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=380\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=234\001", - "8=FIX.4.2\0019=236\00135=i\00134=385\00149=1U7001N\00150=bluestream\00152=20150427-19:56:30.660\00156=CME\00157=G\001142=US,NC\001117=381\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25075\001133=25350\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=166\001", - "8=FIX.4.2\0019=149\00135=b\00134=482\001369=385\00152=20150427-19:56:30.687\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=381\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=248\001", - "8=FIX.4.2\0019=236\00135=i\00134=386\00149=1U7001N\00150=bluestream\00152=20150427-19:56:30.925\00156=CME\00157=G\001142=US,NC\001117=382\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25100\001133=25325\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=163\001", - "8=FIX.4.2\0019=149\00135=b\00134=483\001369=386\00152=20150427-19:56:30.948\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=382\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=251\001", - "8=FIX.4.2\0019=236\00135=i\00134=387\00149=1U7001N\00150=bluestream\00152=20150427-19:56:31.189\00156=CME\00157=G\001142=US,NC\001117=383\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25125\001133=25300\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=168\001", - "8=FIX.4.2\0019=149\00135=b\00134=484\001369=387\00152=20150427-19:56:31.212\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=383\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=239\001", - "8=FIX.4.2\0019=236\00135=i\00134=388\00149=1U7001N\00150=bluestream\00152=20150427-19:56:31.454\00156=CME\00157=G\001142=US,NC\001117=384\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25150\001133=25275\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=174\001", - "8=FIX.4.2\0019=149\00135=b\00134=485\001369=388\00152=20150427-19:56:31.480\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=384\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=249\001", - "8=FIX.4.2\0019=220\00135=i\00134=389\00149=1U7001N\00150=bluestream\00152=20150427-19:56:31.719\00156=CME\00157=G\001142=US,NC\001117=385\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001133=25250\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=206\001", - "8=FIX.4.2\0019=149\00135=b\00134=486\001369=389\00152=20150427-19:56:31.741\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=385\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=252\001", - "8=FIX.4.2\0019=236\00135=i\00134=390\00149=1U7001N\00150=bluestream\00152=20150427-19:56:31.983\00156=CME\00157=G\001142=US,NC\001117=386\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25125\001133=25275\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=178\001", - "8=FIX.4.2\0019=149\00135=b\00134=487\001369=390\00152=20150427-19:56:32.007\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=386\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=242\001", - "8=FIX.4.2\0019=236\00135=i\00134=391\00149=1U7001N\00150=bluestream\00152=20150427-19:56:32.248\00156=CME\00157=G\001142=US,NC\001117=387\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25150\001133=25250\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=166\001", - "8=FIX.4.2\0019=149\00135=b\00134=488\001369=391\00152=20150427-19:56:32.271\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=387\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=248\001", - "8=FIX.4.2\0019=236\00135=i\00134=392\00149=1U7001N\00150=bluestream\00152=20150427-19:56:32.512\00156=CME\00157=G\001142=US,NC\001117=388\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25175\001133=25275\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=176\001", - "8=FIX.4.2\0019=149\00135=b\00134=489\001369=392\00152=20150427-19:56:32.538\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=388\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=001\001", - "8=FIX.4.2\0019=236\00135=i\00134=393\00149=1U7001N\00150=bluestream\00152=20150427-19:56:32.777\00156=CME\00157=G\001142=US,NC\001117=389\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25200\001133=25300\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=169\001", - "8=FIX.4.2\0019=149\00135=b\00134=490\001369=393\00152=20150427-19:56:32.799\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=389\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=004\001", - "8=FIX.4.2\0019=236\00135=i\00134=394\00149=1U7001N\00150=bluestream\00152=20150427-19:56:33.042\00156=CME\00157=G\001142=US,NC\001117=390\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25175\001133=25275\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=170\001", - "8=FIX.4.2\0019=149\00135=b\00134=491\001369=394\00152=20150427-19:56:33.067\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=390\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=243\001", - "8=FIX.4.2\0019=236\00135=i\00134=395\00149=1U7001N\00150=bluestream\00152=20150427-19:56:33.306\00156=CME\00157=G\001142=US,NC\001117=391\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25150\001133=25250\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=161\001", - "8=FIX.4.2\0019=149\00135=b\00134=492\001369=395\00152=20150427-19:56:33.332\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=391\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=241\001", - "8=FIX.4.2\0019=236\00135=i\00134=396\00149=1U7001N\00150=bluestream\00152=20150427-19:56:33.571\00156=CME\00157=G\001142=US,NC\001117=392\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25175\001133=25275\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=181\001", - "8=FIX.4.2\0019=149\00135=b\00134=493\001369=396\00152=20150427-19:56:33.593\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=392\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=253\001", - "8=FIX.4.2\0019=236\00135=i\00134=397\00149=1U7001N\00150=bluestream\00152=20150427-19:56:33.835\00156=CME\00157=G\001142=US,NC\001117=393\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25200\001133=25300\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=164\001", - "8=FIX.4.2\0019=149\00135=b\00134=494\001369=397\00152=20150427-19:56:33.871\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=393\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=255\001", - "8=FIX.4.2\0019=236\00135=i\00134=398\00149=1U7001N\00150=bluestream\00152=20150427-19:56:34.100\00156=CME\00157=G\001142=US,NC\001117=394\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25175\001133=25325\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=170\001", - "8=FIX.4.2\0019=149\00135=b\00134=495\001369=398\00152=20150427-19:56:34.130\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=394\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=247\001", - "8=FIX.4.2\0019=236\00135=i\00134=399\00149=1U7001N\00150=bluestream\00152=20150427-19:56:34.365\00156=CME\00157=G\001142=US,NC\001117=395\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25200\001133=25300\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=167\001", - "8=FIX.4.2\0019=149\00135=b\00134=496\001369=399\00152=20150427-19:56:34.394\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=395\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=006\001", - "8=FIX.4.2\0019=236\00135=i\00134=400\00149=1U7001N\00150=bluestream\00152=20150427-19:56:34.630\00156=CME\00157=G\001142=US,NC\001117=396\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25175\001133=25275\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=168\001", - "8=FIX.4.2\0019=149\00135=b\00134=497\001369=400\00152=20150427-19:56:34.656\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=396\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=248\001", - "8=FIX.4.2\0019=236\00135=i\00134=401\00149=1U7001N\00150=bluestream\00152=20150427-19:56:34.894\00156=CME\00157=G\001142=US,NC\001117=397\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25200\001133=25300\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=160\001", - "8=FIX.4.2\0019=149\00135=b\00134=498\001369=401\00152=20150427-19:56:34.927\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=397\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=252\001", - "8=FIX.4.2\0019=236\00135=i\00134=402\00149=1U7001N\00150=bluestream\00152=20150427-19:56:35.160\00156=CME\00157=G\001142=US,NC\001117=398\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25225\001133=25325\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=163\001", - "8=FIX.4.2\0019=149\00135=b\00134=499\001369=402\00152=20150427-19:56:35.182\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=398\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=249\001", - "8=FIX.4.2\0019=236\00135=i\00134=403\00149=1U7001N\00150=bluestream\00152=20150427-19:56:35.424\00156=CME\00157=G\001142=US,NC\001117=399\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25250\001133=25350\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=164\001", - "8=FIX.4.2\0019=149\00135=b\00134=500\001369=403\00152=20150427-19:56:35.450\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=399\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=232\001", - "8=FIX.4.2\0019=236\00135=i\00134=404\00149=1U7001N\00150=bluestream\00152=20150427-19:56:35.689\00156=CME\00157=G\001142=US,NC\001117=400\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25275\001133=25375\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=175\001", - "8=FIX.4.2\0019=149\00135=b\00134=501\001369=404\00152=20150427-19:56:35.715\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=400\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=221\001", - "8=FIX.4.2\0019=236\00135=i\00134=405\00149=1U7001N\00150=bluestream\00152=20150427-19:56:35.954\00156=CME\00157=G\001142=US,NC\001117=401\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25250\001133=25350\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=158\001", - "8=FIX.4.2\0019=149\00135=b\00134=502\001369=405\00152=20150427-19:56:35.974\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=401\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=231\001", - "8=FIX.4.2\0019=236\00135=i\00134=406\00149=1U7001N\00150=bluestream\00152=20150427-19:56:36.218\00156=CME\00157=G\001142=US,NC\001117=402\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25225\001133=25325\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=158\001", - "8=FIX.4.2\0019=149\00135=b\00134=503\001369=406\00152=20150427-19:56:36.244\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=402\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=225\001", - "8=FIX.4.2\0019=236\00135=i\00134=407\00149=1U7001N\00150=bluestream\00152=20150427-19:56:36.483\00156=CME\00157=G\001142=US,NC\001117=403\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25250\001133=25350\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=160\001", - "8=FIX.4.2\0019=149\00135=b\00134=504\001369=407\00152=20150427-19:56:36.513\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=403\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=227\001", - "8=FIX.4.2\0019=236\00135=i\00134=408\00149=1U7001N\00150=bluestream\00152=20150427-19:56:36.748\00156=CME\00157=G\001142=US,NC\001117=404\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25225\001133=25375\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=175\001", - "8=FIX.4.2\0019=149\00135=b\00134=505\001369=408\00152=20150427-19:56:36.772\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=404\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=237\001", - "8=FIX.4.2\0019=236\00135=i\00134=409\00149=1U7001N\00150=bluestream\00152=20150427-19:56:37.013\00156=CME\00157=G\001142=US,NC\001117=405\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25250\001133=25400\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=150\001", - "8=FIX.4.2\0019=149\00135=b\00134=506\001369=409\00152=20150427-19:56:37.034\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=405\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=232\001", - "8=FIX.4.2\0019=236\00135=i\00134=410\00149=1U7001N\00150=bluestream\00152=20150427-19:56:37.278\00156=CME\00157=G\001142=US,NC\001117=406\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25225\001133=25375\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=169\001", - "8=FIX.4.2\0019=149\00135=b\00134=507\001369=410\00152=20150427-19:56:37.305\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=406\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=227\001", - "8=FIX.4.2\0019=236\00135=i\00134=411\00149=1U7001N\00150=bluestream\00152=20150427-19:56:37.544\00156=CME\00157=G\001142=US,NC\001117=407\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25200\001133=25350\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=153\001", - "8=FIX.4.2\0019=149\00135=b\00134=508\001369=411\00152=20150427-19:56:37.567\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=407\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=240\001", - "8=FIX.4.2\0019=236\00135=i\00134=412\00149=1U7001N\00150=bluestream\00152=20150427-19:56:37.809\00156=CME\00157=G\001142=US,NC\001117=408\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25225\001133=25325\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=168\001", - "8=FIX.4.2\0019=149\00135=b\00134=509\001369=412\00152=20150427-19:56:37.834\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=408\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=240\001", - "8=FIX.4.2\0019=236\00135=i\00134=413\00149=1U7001N\00150=bluestream\00152=20150427-19:56:38.073\00156=CME\00157=G\001142=US,NC\001117=409\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25200\001133=25350\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=155\001", - "8=FIX.4.2\0019=149\00135=b\00134=510\001369=413\00152=20150427-19:56:38.102\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=409\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=223\001", - "8=FIX.4.2\0019=236\00135=i\00134=414\00149=1U7001N\00150=bluestream\00152=20150427-19:56:38.338\00156=CME\00157=G\001142=US,NC\001117=410\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25175\001133=25375\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=170\001", - "8=FIX.4.2\0019=149\00135=b\00134=511\001369=414\00152=20150427-19:56:38.358\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=410\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=230\001", - "8=FIX.4.2\0019=236\00135=i\00134=415\00149=1U7001N\00150=bluestream\00152=20150427-19:56:38.607\00156=CME\00157=G\001142=US,NC\001117=411\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25200\001133=25400\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=149\001", - "8=FIX.4.2\0019=149\00135=b\00134=512\001369=415\00152=20150427-19:56:38.634\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=411\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=230\001", - "8=FIX.4.2\0019=236\00135=i\00134=416\00149=1U7001N\00150=bluestream\00152=20150427-19:56:38.877\00156=CME\00157=G\001142=US,NC\001117=412\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25225\001133=25425\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=174\001", - "8=FIX.4.2\0019=149\00135=b\00134=513\001369=416\00152=20150427-19:56:38.906\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=412\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=235\001", - "8=FIX.4.2\0019=236\00135=i\00134=417\00149=1U7001N\00150=bluestream\00152=20150427-19:56:39.143\00156=CME\00157=G\001142=US,NC\001117=413\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25250\001133=25400\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=154\001", - "8=FIX.4.2\0019=149\00135=b\00134=514\001369=417\00152=20150427-19:56:39.170\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=413\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=232\001", - "8=FIX.4.2\0019=236\00135=i\00134=418\00149=1U7001N\00150=bluestream\00152=20150427-19:56:39.408\00156=CME\00157=G\001142=US,NC\001117=414\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25275\001133=25375\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=178\001", - "8=FIX.4.2\0019=149\00135=b\00134=515\001369=418\00152=20150427-19:56:39.431\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=414\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=235\001", - "8=FIX.4.2\0019=220\00135=i\00134=419\00149=1U7001N\00150=bluestream\00152=20150427-19:56:39.673\00156=CME\00157=G\001142=US,NC\001117=415\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001133=25400\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=198\001", - "8=FIX.4.2\0019=149\00135=b\00134=516\001369=419\00152=20150427-19:56:39.701\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=415\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=238\001", - "8=FIX.4.2\0019=236\00135=i\00134=420\00149=1U7001N\00150=bluestream\00152=20150427-19:56:39.936\00156=CME\00157=G\001142=US,NC\001117=416\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25300\001133=25425\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=164\001", - "8=FIX.4.2\0019=149\00135=b\00134=517\001369=420\00152=20150427-19:56:39.964\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=416\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=243\001", - "8=FIX.4.2\0019=236\00135=i\00134=421\00149=1U7001N\00150=bluestream\00152=20150427-19:56:40.200\00156=CME\00157=G\001142=US,NC\001117=417\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25325\001133=25450\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=147\001", - "8=FIX.4.2\0019=149\00135=b\00134=518\001369=421\00152=20150427-19:56:40.229\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=417\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=232\001", - "8=FIX.4.2\0019=236\00135=i\00134=422\00149=1U7001N\00150=bluestream\00152=20150427-19:56:40.464\00156=CME\00157=G\001142=US,NC\001117=418\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25300\001133=25425\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=156\001", - "8=FIX.4.2\0019=149\00135=b\00134=519\001369=422\00152=20150427-19:56:40.494\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=418\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=239\001", - "8=FIX.4.2\0019=236\00135=i\00134=423\00149=1U7001N\00150=bluestream\00152=20150427-19:56:40.728\00156=CME\00157=G\001142=US,NC\001117=419\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25325\001133=25450\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=166\001", - "8=FIX.4.2\0019=149\00135=b\00134=520\001369=423\00152=20150427-19:56:40.748\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=419\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=235\001", - "8=FIX.4.2\0019=236\00135=i\00134=424\00149=1U7001N\00150=bluestream\00152=20150427-19:56:40.991\00156=CME\00157=G\001142=US,NC\001117=420\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25350\001133=25475\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=166\001", - "8=FIX.4.2\0019=149\00135=b\00134=521\001369=424\00152=20150427-19:56:41.014\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=420\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=216\001", - "8=FIX.4.2\0019=236\00135=i\00134=425\00149=1U7001N\00150=bluestream\00152=20150427-19:56:41.255\00156=CME\00157=G\001142=US,NC\001117=421\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25325\001133=25450\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=157\001", - "8=FIX.4.2\0019=149\00135=b\00134=522\001369=425\00152=20150427-19:56:41.281\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=421\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=225\001", - "8=FIX.4.2\0019=236\00135=i\00134=426\00149=1U7001N\00150=bluestream\00152=20150427-19:56:41.519\00156=CME\00157=G\001142=US,NC\001117=422\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25350\001133=25475\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=167\001", - "8=FIX.4.2\0019=149\00135=b\00134=523\001369=426\00152=20150427-19:56:41.544\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=422\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=230\001", - "8=FIX.4.2\0019=236\00135=i\00134=427\00149=1U7001N\00150=bluestream\00152=20150427-19:56:41.782\00156=CME\00157=G\001142=US,NC\001117=423\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25375\001133=25500\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=167\001", - "8=FIX.4.2\0019=149\00135=b\00134=524\001369=427\00152=20150427-19:56:41.803\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=423\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=231\001", - "8=FIX.4.2\0019=236\00135=i\00134=428\00149=1U7001N\00150=bluestream\00152=20150427-19:56:42.046\00156=CME\00157=G\001142=US,NC\001117=424\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25350\001133=25475\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=167\001", - "8=FIX.4.2\0019=149\00135=b\00134=525\001369=428\00152=20150427-19:56:42.080\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=424\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=232\001", - "8=FIX.4.2\0019=236\00135=i\00134=429\00149=1U7001N\00150=bluestream\00152=20150427-19:56:42.309\00156=CME\00157=G\001142=US,NC\001117=425\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25325\001133=25450\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=166\001", - "8=FIX.4.2\0019=149\00135=b\00134=526\001369=429\00152=20150427-19:56:42.336\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=425\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=239\001", - "8=FIX.4.2\0019=236\00135=i\00134=430\00149=1U7001N\00150=bluestream\00152=20150427-19:56:42.573\00156=CME\00157=G\001142=US,NC\001117=426\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25350\001133=25475\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=167\001", - "8=FIX.4.2\0019=149\00135=b\00134=527\001369=430\00152=20150427-19:56:42.593\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=426\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=238\001", - "8=FIX.4.2\0019=236\00135=i\00134=431\00149=1U7001N\00150=bluestream\00152=20150427-19:56:42.837\00156=CME\00157=G\001142=US,NC\001117=427\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25325\001133=25450\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=167\001", - "8=FIX.4.2\0019=149\00135=b\00134=528\001369=431\00152=20150427-19:56:42.862\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=427\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=240\001", - "8=FIX.4.2\0019=236\00135=i\00134=432\00149=1U7001N\00150=bluestream\00152=20150427-19:56:43.100\00156=CME\00157=G\001142=US,NC\001117=428\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25300\001133=25425\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=148\001", - "8=FIX.4.2\0019=149\00135=b\00134=529\001369=432\00152=20150427-19:56:43.131\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=428\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=233\001", - "8=FIX.4.2\0019=236\00135=i\00134=433\00149=1U7001N\00150=bluestream\00152=20150427-19:56:43.364\00156=CME\00157=G\001142=US,NC\001117=429\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25325\001133=25450\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=167\001", - "8=FIX.4.2\0019=149\00135=b\00134=530\001369=433\00152=20150427-19:56:43.392\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=429\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=236\001", - "8=FIX.4.2\0019=236\00135=i\00134=434\00149=1U7001N\00150=bluestream\00152=20150427-19:56:43.627\00156=CME\00157=G\001142=US,NC\001117=430\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25300\001133=25425\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=157\001", - "8=FIX.4.2\0019=149\00135=b\00134=531\001369=434\00152=20150427-19:56:43.652\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=430\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=229\001", - "8=FIX.4.2\0019=236\00135=i\00134=435\00149=1U7001N\00150=bluestream\00152=20150427-19:56:43.891\00156=CME\00157=G\001142=US,NC\001117=431\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25325\001133=25450\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=167\001", - "8=FIX.4.2\0019=149\00135=b\00134=532\001369=435\00152=20150427-19:56:43.936\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=431\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=237\001", - "8=FIX.4.2\0019=236\00135=i\00134=436\00149=1U7001N\00150=bluestream\00152=20150427-19:56:44.155\00156=CME\00157=G\001142=US,NC\001117=432\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25350\001133=25475\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=168\001", - "8=FIX.4.2\0019=149\00135=b\00134=533\001369=436\00152=20150427-19:56:44.202\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=432\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=227\001", - "8=FIX.4.2\0019=236\00135=i\00134=437\00149=1U7001N\00150=bluestream\00152=20150427-19:56:44.418\00156=CME\00157=G\001142=US,NC\001117=433\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25325\001133=25500\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=163\001", - "8=FIX.4.2\0019=149\00135=b\00134=534\001369=437\00152=20150427-19:56:44.447\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=433\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=241\001", - "8=FIX.4.2\0019=220\00135=i\00134=438\00149=1U7001N\00150=bluestream\00152=20150427-19:56:44.682\00156=CME\00157=G\001142=US,NC\001117=434\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25350\001134=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=198\001", - "8=FIX.4.2\0019=149\00135=b\00134=535\001369=438\00152=20150427-19:56:44.712\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=434\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=239\001", - "8=FIX.4.2\0019=236\00135=i\00134=439\00149=1U7001N\00150=bluestream\00152=20150427-19:56:44.946\00156=CME\00157=G\001142=US,NC\001117=435\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25325\001133=25525\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=180\001", - "8=FIX.4.2\0019=149\00135=b\00134=536\001369=439\00152=20150427-19:56:44.973\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=435\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=251\001", - "8=FIX.4.2\0019=236\00135=i\00134=440\00149=1U7001N\00150=bluestream\00152=20150427-19:56:45.209\00156=CME\00157=G\001142=US,NC\001117=436\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25350\001133=25500\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=157\001", - "8=FIX.4.2\0019=149\00135=b\00134=537\001369=440\00152=20150427-19:56:45.239\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=436\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=241\001", - "8=FIX.4.2\0019=220\00135=i\00134=441\00149=1U7001N\00150=bluestream\00152=20150427-19:56:45.473\00156=CME\00157=G\001142=US,NC\001117=437\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25325\001134=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=196\001", - "8=FIX.4.2\0019=149\00135=b\00134=538\001369=441\00152=20150427-19:56:45.511\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=437\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=237\001", - "8=FIX.4.2\0019=220\00135=i\00134=442\00149=1U7001N\00150=bluestream\00152=20150427-19:56:45.736\00156=CME\00157=G\001142=US,NC\001117=438\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25350\001134=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=198\001", - "8=FIX.4.2\0019=149\00135=b\00134=539\001369=442\00152=20150427-19:56:45.768\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=438\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=254\001", - "8=FIX.4.2\0019=236\00135=i\00134=443\00149=1U7001N\00150=bluestream\00152=20150427-19:56:46.000\00156=CME\00157=G\001142=US,NC\001117=439\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25375\001133=25525\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=167\001", - "8=FIX.4.2\0019=149\00135=b\00134=540\001369=443\00152=20150427-19:56:46.023\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=439\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=233\001", - "8=FIX.4.2\0019=236\00135=i\00134=444\00149=1U7001N\00150=bluestream\00152=20150427-19:56:46.264\00156=CME\00157=G\001142=US,NC\001117=440\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25350\001133=25500\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=158\001", - "8=FIX.4.2\0019=149\00135=b\00134=541\001369=444\00152=20150427-19:56:46.286\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=440\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=238\001", - "8=FIX.4.2\0019=236\00135=i\00134=445\00149=1U7001N\00150=bluestream\00152=20150427-19:56:46.528\00156=CME\00157=G\001142=US,NC\001117=441\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25325\001133=25525\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=172\001", - "8=FIX.4.2\0019=149\00135=b\00134=542\001369=445\00152=20150427-19:56:46.553\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=441\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=238\001", - "8=FIX.4.2\0019=236\00135=i\00134=446\00149=1U7001N\00150=bluestream\00152=20150427-19:56:46.791\00156=CME\00157=G\001142=US,NC\001117=442\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25300\001133=25500\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=162\001", - "8=FIX.4.2\0019=149\00135=b\00134=543\001369=446\00152=20150427-19:56:46.813\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=442\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=240\001", - "8=FIX.4.2\0019=220\00135=i\00134=447\00149=1U7001N\00150=bluestream\00152=20150427-19:56:47.055\00156=CME\00157=G\001142=US,NC\001117=443\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25325\001134=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=197\001", - "8=FIX.4.2\0019=149\00135=b\00134=544\001369=447\00152=20150427-19:56:47.087\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=443\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=247\001", - "8=FIX.4.2\0019=236\00135=i\00134=448\00149=1U7001N\00150=bluestream\00152=20150427-19:56:47.319\00156=CME\00157=G\001142=US,NC\001117=444\001204=1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=OPT\001107=ESK5 C1855\001132=25300\001133=25475\001134=1\001135=1\0011028=N\0017928=bluestream\0019702=1\0019771=TESTACC\00110=174\001" -}; +const char *data[] = { + "8=FIX.4.2\0019=132\00135=A\00134=1\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:05:17.032\00156=CME\00157=G\001142=US,NC\00195=3\00196=" + "1U7\00198=0\001108=30\0011603=O2\0011604=1.0\0011605=BTS\00110=251\001", + "8=FIX.4.2\0019=127\00135=A\00134=25\001369=1\00152=20150427-19:05:18." + "922\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00198=" + "0\001108=30\0011603=O2\0011604=1.0\0011605=BTS\00110=199\001", + "8=FIX.4.2\0019=91\00135=2\00134=2\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:05:18.951\00156=CME\00157=G\001142=US,NC\0017=1\00116=0\00110=" + "209\001", + "8=FIX.4.2\0019=104\00135=1\00134=26\001369=1\00152=20150427-19:05:18." + "923\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001112=" + "IDi8yfsl3t\00110=236\001", + "8=FIX.4.2\0019=114\00135=Z\00134=3\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:05:18.995\00156=CME\00157=G\001142=US,NC\001117=1\001295=" + "1\00155=N/A\001298=4\0011028=N\00110=156\001", + "8=FIX.4.2\0019=136\00135=b\00134=1\001369=2\00152=20150427-19:05:18." + "974\00143=Y\00149=CME\00150=G\00156=1U7001N\001122=20150427-05:32:56." + "995\001117=CMEEW719\001297=3\0019772=0\0019774=EW\0019775=E\00110=028\001", + "8=FIX.4.2\0019=136\00135=b\00134=2\001369=2\00152=20150427-19:05:18." + "974\00143=Y\00149=CME\00150=G\00156=1U7001N\001122=20150427-05:32:57." + "021\001117=CME1V415\001297=3\0019772=0\0019774=1V\0019775=E\00110=217\001", + "8=FIX.4.2\0019=136\00135=b\00134=3\001369=2\00152=20150427-19:05:18." + "974\00143=Y\00149=CME\00150=G\00156=1U7001N\001122=20150427-05:32:57." + "068\001117=CMEEZ522\001297=3\0019772=0\0019774=EZ\0019775=E\00110=020\001", + "8=FIX.4.2\0019=136\00135=b\00134=4\001369=2\00152=20150427-19:05:18." + "974\00143=Y\00149=CME\00150=G\00156=1U7001N\001122=20150427-05:38:15." + "601\001117=CMEEW979\001297=3\0019772=0\0019774=EW\0019775=E\00110=024\001", + "8=FIX.4.2\0019=136\00135=b\00134=5\001369=2\00152=20150427-19:05:18." + "974\00143=Y\00149=CME\00150=G\00156=1U7001N\001122=20150427-05:38:15." + "629\001117=CME1V656\001297=3\0019772=0\0019774=1V\0019775=E\00110=241\001", + "8=FIX.4.2\0019=136\00135=b\00134=6\001369=2\00152=20150427-19:05:18." + "974\00143=Y\00149=CME\00150=G\00156=1U7001N\001122=20150427-05:38:15." + "765\001117=CMEEZ848\001297=3\0019772=0\0019774=EZ\0019775=E\00110=038\001", + "8=FIX.4.2\0019=137\00135=b\00134=7\001369=2\00152=20150427-19:05:18." + "974\00143=Y\00149=CME\00150=G\00156=1U7001N\001122=20150427-06:01:56." + "206\001117=CMEEW1242\001297=3\0019772=0\0019774=EW\0019775=E\00110=" + "057\001", + "8=FIX.4.2\0019=136\00135=b\00134=8\001369=2\00152=20150427-19:05:18." + "974\00143=Y\00149=CME\00150=G\00156=1U7001N\001122=20150427-06:01:56." + "298\001117=CME1V902\001297=3\0019772=0\0019774=1V\0019775=E\00110=236\001", + "8=FIX.4.2\0019=137\00135=b\00134=9\001369=2\00152=20150427-19:05:18." + "974\00143=Y\00149=CME\00150=G\00156=1U7001N\001122=20150427-06:01:56." + "350\001117=CMEEZ1179\001297=3\0019772=0\0019774=EZ\0019775=E\00110=" + "074\001", + "8=FIX.4.2\0019=138\00135=b\00134=10\001369=2\00152=20150427-19:05:18." + "974\00143=Y\00149=CME\00150=G\00156=1U7001N\001122=20150427-12:29:44." + "126\001117=CMEEW1619\001297=3\0019772=0\0019774=EW\0019775=E\00110=" + "113\001", + "8=FIX.4.2\0019=138\00135=b\00134=11\001369=2\00152=20150427-19:05:18." + "975\00143=Y\00149=CME\00150=G\00156=1U7001N\001122=20150427-12:29:44." + "213\001117=CME1V1265\001297=3\0019772=0\0019774=1V\0019775=E\00110=" + "067\001", + "8=FIX.4.2\0019=138\00135=b\00134=12\001369=2\00152=20150427-19:05:18." + "975\00143=Y\00149=CME\00150=G\00156=1U7001N\001122=20150427-12:29:44." + "238\001117=CMEEZ1627\001297=3\0019772=0\0019774=EZ\0019775=E\00110=" + "125\001", + "8=FIX.4.2\0019=138\00135=b\00134=13\001369=2\00152=20150427-19:05:18." + "975\00143=Y\00149=CME\00150=G\00156=1U7001N\001122=20150427-13:42:19." + "772\001117=CMEEW1911\001297=3\0019772=0\0019774=EW\0019775=E\00110=" + "117\001", + "8=FIX.4.2\0019=138\00135=b\00134=14\001369=2\00152=20150427-19:05:18." + "975\00143=Y\00149=CME\00150=G\00156=1U7001N\001122=20150427-13:42:19." + "861\001117=CME1V1529\001297=3\0019772=0\0019774=1V\0019775=E\00110=" + "080\001", + "8=FIX.4.2\0019=138\00135=b\00134=15\001369=2\00152=20150427-19:05:18." + "975\00143=Y\00149=CME\00150=G\00156=1U7001N\001122=20150427-13:42:19." + "881\001117=CMEEZ1986\001297=3\0019772=0\0019774=EZ\0019775=E\00110=" + "138\001", + "8=FIX.4.2\0019=138\00135=b\00134=16\001369=2\00152=20150427-19:05:18." + "975\00143=Y\00149=CME\00150=G\00156=1U7001N\001122=20150427-13:43:28." + "781\001117=CMEEW2172\001297=3\0019772=0\0019774=EW\0019775=E\00110=" + "121\001", + "8=FIX.4.2\0019=138\00135=b\00134=17\001369=2\00152=20150427-19:05:18." + "975\00143=Y\00149=CME\00150=G\00156=1U7001N\001122=20150427-13:43:28." + "816\001117=CME1V1771\001297=3\0019772=0\0019774=1V\0019775=E\00110=" + "083\001", + "8=FIX.4.2\0019=138\00135=b\00134=18\001369=2\00152=20150427-19:05:18." + "975\00143=Y\00149=CME\00150=G\00156=1U7001N\001122=20150427-13:43:28." + "975\001117=CMEEZ2313\001297=3\0019772=0\0019774=EZ\0019775=E\00110=" + "131\001", + "8=FIX.4.2\0019=138\00135=b\00134=19\001369=2\00152=20150427-19:05:18." + "975\00143=Y\00149=CME\00150=G\00156=1U7001N\001122=20150427-16:41:14." + "395\001117=CMEEW2518\001297=3\0019772=0\0019774=EW\0019775=E\00110=" + "125\001", + "8=FIX.4.2\0019=138\00135=b\00134=20\001369=2\00152=20150427-19:05:18." + "975\00143=Y\00149=CME\00150=G\00156=1U7001N\001122=20150427-16:41:14." + "421\001117=CME1V2089\001297=3\0019772=0\0019774=1V\0019775=E\00110=" + "068\001", + "8=FIX.4.2\0019=138\00135=b\00134=21\001369=2\00152=20150427-19:05:18." + "975\00143=Y\00149=CME\00150=G\00156=1U7001N\001122=20150427-16:41:14." + "618\001117=CMEEZ2730\001297=3\0019772=0\0019774=EZ\0019775=E\00110=" + "118\001", + "8=FIX.4.2\0019=138\00135=b\00134=22\001369=2\00152=20150427-19:05:18." + "975\00143=Y\00149=CME\00150=G\00156=1U7001N\001122=20150427-18:03:09." + "895\001117=CMEEW2822\001297=3\0019772=0\0019774=EW\0019775=E\00110=" + "126\001", + "8=FIX.4.2\0019=138\00135=b\00134=23\001369=2\00152=20150427-19:05:18." + "975\00143=Y\00149=CME\00150=G\00156=1U7001N\001122=20150427-18:03:09." + "967\001117=CME1V2364\001297=3\0019772=0\0019774=1V\0019775=E\00110=" + "086\001", + "8=FIX.4.2\0019=138\00135=b\00134=24\001369=2\00152=20150427-19:05:18." + "975\00143=Y\00149=CME\00150=G\00156=1U7001N\001122=20150427-18:03:10." + "251\001117=CMEEZ3102\001297=3\0019772=0\0019774=EZ\0019775=E\00110=" + "104\001", + "8=FIX.4.2\0019=97\00135=0\00134=4\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:05:19.053\00156=CME\00157=G\001142=US,NC\001112=" + "IDi8yfsl3t\00110=187\001", + "8=FIX.4.2\0019=132\00135=4\00134=25\001369=2\00152=20150427-19:05:18." + "975\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001122=" + "20150427-19:05:18.975\001143=US,NC\00136=27\001123=Y\00110=225\001", + "8=FIX.4.2\0019=123\00135=b\00134=27\001369=3\00152=20150427-19:05:19." + "026\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "1\001297=4\0011028=N\0019772=0\0019774=1V\00110=017\001", + "8=FIX.4.2\0019=123\00135=b\00134=28\001369=3\00152=20150427-19:05:19." + "026\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "1\001297=4\0011028=N\0019772=0\0019774=96\00110=250\001", + "8=FIX.4.2\0019=123\00135=b\00134=29\001369=3\00152=20150427-19:05:19." + "026\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "1\001297=4\0011028=N\0019772=0\0019774=EW\00110=040\001", + "8=FIX.4.2\0019=123\00135=b\00134=30\001369=3\00152=20150427-19:05:19." + "026\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "1\001297=4\0011028=N\0019772=0\0019774=EZ\00110=035\001", + "8=FIX.4.2\0019=123\00135=b\00134=31\001369=3\00152=20150427-19:05:19." + "026\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "1\001297=4\0011028=N\0019772=0\0019774=T$\00110=253\001", + "8=FIX.4.2\0019=123\00135=b\00134=32\001369=3\00152=20150427-19:05:19." + "026\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "1\001297=4\0011028=N\0019772=0\0019774=TE\00110=031\001", + "8=FIX.4.2\0019=132\00135=A\00134=5\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:06:35.838\00156=CME\00157=G\001142=US,NC\00195=3\00196=" + "1U7\00198=0\001108=30\0011603=O2\0011604=1.0\0011605=BTS\00110=014\001", + "8=FIX.4.2\0019=127\00135=A\00134=39\001369=5\00152=20150427-19:06:37." + "384\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00198=" + "0\001108=30\0011603=O2\0011604=1.0\0011605=BTS\00110=212\001", + "8=FIX.4.2\0019=92\00135=2\00134=6\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:06:37.412\00156=CME\00157=G\001142=US,NC\0017=33\00116=" + "0\00110=005\001", + "8=FIX.4.2\0019=104\00135=1\00134=40\001369=5\00152=20150427-19:06:37." + "384\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001112=" + "IDi8yfsl3u\00110=240\001", + "8=FIX.4.2\0019=164\00135=b\00134=33\001369=6\00152=20150427-19:06:37." + "437\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-" + "19:05:25.280\001143=US,NC\001117=CME1V2624\001297=4\0011028=N\0019772=" + "0\0019774=1V\0019775=A\00110=249\001", + "8=FIX.4.2\0019=164\00135=b\00134=34\001369=6\00152=20150427-19:06:37." + "437\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-" + "19:05:25.280\001143=US,NC\001117=CMEEW3099\001297=4\0011028=N\0019772=" + "0\0019774=EW\0019775=A\00110=043\001", + "8=FIX.4.2\0019=163\00135=b\00134=35\001369=6\00152=20150427-19:06:37." + "437\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-" + "19:05:25.280\001143=US,NC\001117=CMET$121\001297=4\0011028=N\0019772=" + "0\0019774=T$\0019775=A\00110=162\001", + "8=FIX.4.2\0019=164\00135=b\00134=36\001369=6\00152=20150427-19:06:37." + "437\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-" + "19:05:25.280\001143=US,NC\001117=CMEEZ3435\001297=4\0011028=N\0019772=" + "0\0019774=EZ\0019775=A\00110=045\001", + "8=FIX.4.2\0019=163\00135=b\00134=37\001369=6\00152=20150427-19:06:37." + "437\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-" + "19:05:25.280\001143=US,NC\001117=CMETE200\001297=4\0011028=N\0019772=" + "0\0019774=TE\0019775=A\00110=228\001", + "8=FIX.4.2\0019=114\00135=Z\00134=7\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:06:37.493\00156=CME\00157=G\001142=US,NC\001117=5\001295=" + "1\00155=N/A\001298=4\0011028=N\00110=159\001", + "8=FIX.4.2\0019=163\00135=b\00134=38\001369=6\00152=20150427-19:06:37." + "437\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-" + "19:05:25.282\001143=US,NC\001117=CME96114\001297=4\0011028=N\0019772=" + "0\0019774=96\0019775=A\00110=151\001", + "8=FIX.4.2\0019=97\00135=0\00134=8\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:06:37.538\00156=CME\00157=G\001142=US,NC\001112=" + "IDi8yfsl3u\00110=201\001", + "8=FIX.4.2\0019=132\00135=4\00134=39\001369=6\00152=20150427-19:06:37." + "437\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001122=" + "20150427-19:06:37.437\001143=US,NC\00136=41\001123=Y\00110=220\001", + "8=FIX.4.2\0019=123\00135=b\00134=41\001369=7\00152=20150427-19:06:37." + "518\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "5\001297=4\0011028=N\0019772=0\0019774=96\00110=004\001", + "8=FIX.4.2\0019=123\00135=b\00134=42\001369=7\00152=20150427-19:06:37." + "524\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "5\001297=4\0011028=N\0019772=0\0019774=1V\00110=026\001", + "8=FIX.4.2\0019=123\00135=b\00134=43\001369=7\00152=20150427-19:06:37." + "524\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "5\001297=4\0011028=N\0019772=0\0019774=EW\00110=048\001", + "8=FIX.4.2\0019=123\00135=b\00134=44\001369=7\00152=20150427-19:06:37." + "524\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "5\001297=4\0011028=N\0019772=0\0019774=EZ\00110=052\001", + "8=FIX.4.2\0019=123\00135=b\00134=45\001369=7\00152=20150427-19:06:37." + "530\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "5\001297=4\0011028=N\0019772=0\0019774=T$\00110=011\001", + "8=FIX.4.2\0019=123\00135=b\00134=46\001369=7\00152=20150427-19:06:37." + "530\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "5\001297=4\0011028=N\0019772=0\0019774=TE\00110=045\001", + "8=FIX.4.2\0019=82\00135=0\00134=9\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:07:07.873\00156=CME\00157=G\001142=US,NC\00110=094\001", + "8=FIX.4.2\0019=89\00135=0\00134=47\001369=9\00152=20150427-19:07:08." + "078\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=" + "111\001", + "8=FIX.4.2\0019=83\00135=0\00134=10\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:07:37.905\00156=CME\00157=G\001142=US,NC\00110=134\001", + "8=FIX.4.2\0019=90\00135=0\00134=48\001369=10\00152=20150427-19:07:39." + "084\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=" + "145\001", + "8=FIX.4.2\0019=83\00135=0\00134=11\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:08:07.937\00156=CME\00157=G\001142=US,NC\00110=138\001", + "8=FIX.4.2\0019=90\00135=0\00134=49\001369=11\00152=20150427-19:08:10." + "088\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=" + "141\001", + "8=FIX.4.2\0019=83\00135=0\00134=12\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:08:37.968\00156=CME\00157=G\001142=US,NC\00110=146\001", + "8=FIX.4.2\0019=90\00135=0\00134=50\001369=12\00152=20150427-19:08:41." + "093\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=" + "134\001", + "8=FIX.4.2\0019=83\00135=0\00134=13\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:09:07.000\00156=CME\00157=G\001142=US,NC\00110=122\001", + "8=FIX.4.2\0019=90\00135=0\00134=51\001369=13\00152=20150427-19:09:12." + "098\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=" + "140\001", + "8=FIX.4.2\0019=83\00135=0\00134=14\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:09:37.031\00156=CME\00157=G\001142=US,NC\00110=130\001", + "8=FIX.4.2\0019=90\00135=0\00134=52\001369=14\00152=20150427-19:09:43." + "106\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=" + "136\001", + "8=FIX.4.2\0019=133\00135=A\00134=15\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:11:24.357\00156=CME\00157=G\001142=US,NC\00195=3\00196=" + "1U7\00198=0\001108=30\0011603=O2\0011604=1.0\0011605=BTS\00110=054\001", + "8=FIX.4.2\0019=128\00135=A\00134=59\001369=15\00152=20150427-19:11:25." + "963\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00198=" + "0\001108=30\0011603=O2\0011604=1.0\0011605=BTS\00110=004\001", + "8=FIX.4.2\0019=93\00135=2\00134=16\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:11:25.992\00156=CME\00157=G\001142=US,NC\0017=53\00116=" + "0\00110=063\001", + "8=FIX.4.2\0019=105\00135=1\00134=60\001369=15\00152=20150427-19:11:25." + "963\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001112=" + "IDi8yfsl3v\00110=033\001", + "8=FIX.4.2\0019=116\00135=Z\00134=17\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:11:26.014\00156=CME\00157=G\001142=US,NC\001117=15\001295=" + "1\00155=N/A\001298=4\0011028=N\00110=242\001", + "8=FIX.4.2\0019=165\00135=b\00134=53\001369=16\00152=20150427-19:11:26." + "018\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-" + "19:09:54.204\001143=US,NC\001117=CME1V2628\001297=4\0011028=N\0019772=" + "0\0019774=1V\0019775=A\00110=040\001", + "8=FIX.4.2\0019=165\00135=b\00134=54\001369=16\00152=20150427-19:11:26." + "018\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-" + "19:09:54.204\001143=US,NC\001117=CMEEW3103\001297=4\0011028=N\0019772=" + "0\0019774=EW\0019775=A\00110=072\001", + "8=FIX.4.2\0019=165\00135=b\00134=55\001369=16\00152=20150427-19:11:26." + "019\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-" + "19:09:54.204\001143=US,NC\001117=CMEEZ3439\001297=4\0011028=N\0019772=" + "0\0019774=EZ\0019775=A\00110=092\001", + "8=FIX.4.2\0019=164\00135=b\00134=56\001369=16\00152=20150427-19:11:26." + "019\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-" + "19:09:54.207\001143=US,NC\001117=CME96115\001297=4\0011028=N\0019772=" + "0\0019774=96\0019775=A\00110=195\001", + "8=FIX.4.2\0019=164\00135=b\00134=57\001369=16\00152=20150427-19:11:26." + "019\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-" + "19:09:54.207\001143=US,NC\001117=CMET$122\001297=4\0011028=N\0019772=" + "0\0019774=T$\0019775=A\00110=212\001", + "8=FIX.4.2\0019=164\00135=b\00134=58\001369=16\00152=20150427-19:11:26." + "019\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-" + "19:09:54.207\001143=US,NC\001117=CMETE201\001297=4\0011028=N\0019772=" + "0\0019774=TE\0019775=A\00110=021\001", + "8=FIX.4.2\0019=98\00135=0\00134=18\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:11:26.100\00156=CME\00157=G\001142=US,NC\001112=" + "IDi8yfsl3v\00110=231\001", + "8=FIX.4.2\0019=133\00135=4\00134=59\001369=16\00152=20150427-19:11:26." + "019\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001122=" + "20150427-19:11:26.019\001143=US,NC\00136=61\001123=Y\00110=254\001", + "8=FIX.4.2\0019=125\00135=b\00134=61\001369=17\00152=20150427-19:11:26." + "070\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "15\001297=4\0011028=N\0019772=0\0019774=T$\00110=102\001", + "8=FIX.4.2\0019=125\00135=b\00134=62\001369=17\00152=20150427-19:11:26." + "070\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "15\001297=4\0011028=N\0019772=0\0019774=TE\00110=136\001", + "8=FIX.4.2\0019=125\00135=b\00134=63\001369=17\00152=20150427-19:11:26." + "072\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "15\001297=4\0011028=N\0019772=0\0019774=96\00110=097\001", + "8=FIX.4.2\0019=125\00135=b\00134=64\001369=17\00152=20150427-19:11:26." + "076\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "15\001297=4\0011028=N\0019772=0\0019774=1V\00110=126\001", + "8=FIX.4.2\0019=125\00135=b\00134=65\001369=17\00152=20150427-19:11:26." + "076\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "15\001297=4\0011028=N\0019772=0\0019774=EW\00110=148\001", + "8=FIX.4.2\0019=125\00135=b\00134=66\001369=17\00152=20150427-19:11:26." + "076\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "15\001297=4\0011028=N\0019772=0\0019774=EZ\00110=152\001", + "8=FIX.4.2\0019=105\00135=1\00134=67\001369=18\00152=20150427-19:11:56." + "129\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001112=" + "IDi8yfsl3w\00110=042\001", + "8=FIX.4.2\0019=98\00135=0\00134=19\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:11:56.156\00156=CME\00157=G\001142=US,NC\001112=" + "IDi8yfsl3w\00110=247\001", + "8=FIX.4.2\0019=83\00135=0\00134=20\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:12:26.423\00156=CME\00157=G\001142=US,NC\00110=124\001", + "8=FIX.4.2\0019=90\00135=0\00134=68\001369=20\00152=20150427-19:12:27." + "135\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=" + "138\001", + "8=FIX.4.2\0019=83\00135=0\00134=21\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:12:56.454\00156=CME\00157=G\001142=US,NC\00110=132\001", + "8=FIX.4.2\0019=90\00135=0\00134=69\001369=21\00152=20150427-19:12:58." + "140\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=" + "140\001", + "8=FIX.4.2\0019=83\00135=0\00134=22\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:13:26.485\00156=CME\00157=G\001142=US,NC\00110=135\001", + "8=FIX.4.2\0019=90\00135=0\00134=70\001369=22\00152=20150427-19:13:29." + "146\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=" + "138\001", + "8=FIX.4.2\0019=83\00135=0\00134=23\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:13:56.517\00156=CME\00157=G\001142=US,NC\00110=135\001", + "8=FIX.4.2\0019=90\00135=0\00134=71\001369=23\00152=20150427-19:14:00." + "150\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=" + "125\001", + "8=FIX.4.2\0019=83\00135=0\00134=24\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:14:26.549\00156=CME\00157=G\001142=US,NC\00110=139\001", + "8=FIX.4.2\0019=90\00135=0\00134=72\001369=24\00152=20150427-19:14:31." + "157\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=" + "138\001", + "8=FIX.4.2\0019=83\00135=0\00134=25\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:14:56.581\00156=CME\00157=G\001142=US,NC\00110=139\001", + "8=FIX.4.2\0019=90\00135=0\00134=73\001369=25\00152=20150427-19:15:02." + "164\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=" + "137\001", + "8=FIX.4.2\0019=83\00135=0\00134=26\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:15:26.611\00156=CME\00157=G\001142=US,NC\00110=132\001", + "8=FIX.4.2\0019=90\00135=0\00134=74\001369=26\00152=20150427-19:15:33." + "169\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=" + "148\001", + "8=FIX.4.2\0019=83\00135=0\00134=27\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:15:56.642\00156=CME\00157=G\001142=US,NC\00110=140\001", + "8=FIX.4.2\0019=90\00135=0\00134=75\001369=27\00152=20150427-19:16:04." + "174\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=" + "145\001", + "8=FIX.4.2\0019=83\00135=0\00134=28\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:16:26.672\00156=CME\00157=G\001142=US,NC\00110=142\001", + "8=FIX.4.2\0019=90\00135=0\00134=76\001369=28\00152=20150427-19:16:35." + "180\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=" + "148\001", + "8=FIX.4.2\0019=83\00135=0\00134=29\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:16:56.703\00156=CME\00157=G\001142=US,NC\00110=141\001", + "8=FIX.4.2\0019=90\00135=0\00134=77\001369=29\00152=20150427-19:17:06." + "186\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=" + "155\001", + "8=FIX.4.2\0019=83\00135=0\00134=30\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:17:26.734\00156=CME\00157=G\001142=US,NC\00110=135\001", + "8=FIX.4.2\0019=90\00135=0\00134=78\001369=30\00152=20150427-19:17:37." + "191\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=" + "148\001", + "8=FIX.4.2\0019=83\00135=0\00134=31\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:17:56.765\00156=CME\00157=G\001142=US,NC\00110=143\001", + "8=FIX.4.2\0019=90\00135=0\00134=79\001369=31\00152=20150427-19:18:08." + "196\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=" + "154\001", + "8=FIX.4.2\0019=83\00135=0\00134=32\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:18:26.797\00156=CME\00157=G\001142=US,NC\00110=147\001", + "8=FIX.4.2\0019=90\00135=0\00134=80\001369=32\00152=20150427-19:18:39." + "203\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=" + "140\001", + "8=FIX.4.2\0019=83\00135=0\00134=33\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:18:56.830\00156=CME\00157=G\001142=US,NC\00110=139\001", + "8=FIX.4.2\0019=90\00135=0\00134=81\001369=33\00152=20150427-19:19:10." + "207\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=" + "136\001", + "8=FIX.4.2\0019=83\00135=0\00134=34\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:19:26.862\00156=CME\00157=G\001142=US,NC\00110=143\001", + "8=FIX.4.2\0019=90\00135=0\00134=82\001369=34\00152=20150427-19:19:41." + "212\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=" + "138\001", + "8=FIX.4.2\0019=83\00135=0\00134=35\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:19:56.893\00156=CME\00157=G\001142=US,NC\00110=151\001", + "8=FIX.4.2\0019=90\00135=0\00134=83\001369=35\00152=20150427-19:20:12." + "217\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=" + "135\001", + "8=FIX.4.2\0019=83\00135=0\00134=36\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:20:26.925\00156=CME\00157=G\001142=US,NC\00110=137\001", + "8=FIX.4.2\0019=90\00135=0\00134=84\001369=36\00152=20150427-19:20:43." + "222\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=" + "137\001", + "8=FIX.4.2\0019=83\00135=0\00134=37\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:20:56.955\00156=CME\00157=G\001142=US,NC\00110=144\001", + "8=FIX.4.2\0019=90\00135=0\00134=85\001369=37\00152=20150427-19:21:14." + "227\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=" + "143\001", + "8=FIX.4.2\0019=83\00135=0\00134=38\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:21:26.987\00156=CME\00157=G\001142=US,NC\00110=148\001", + "8=FIX.4.2\0019=90\00135=0\00134=86\001369=38\00152=20150427-19:21:45." + "232\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=" + "145\001", + "8=FIX.4.2\0019=133\00135=A\00134=39\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:22:00.231\00156=CME\00157=G\001142=US,NC\00195=3\00196=" + "1U7\00198=0\001108=30\0011603=O2\0011604=1.0\0011605=BTS\00110=047\001", + "8=FIX.4.2\0019=128\00135=A\00134=93\001369=39\00152=20150427-19:22:01." + "752\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00198=" + "0\001108=30\0011603=O2\0011604=1.0\0011605=BTS\00110=000\001", + "8=FIX.4.2\0019=93\00135=2\00134=40\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:22:01.780\00156=CME\00157=G\001142=US,NC\0017=87\00116=" + "0\00110=058\001", + "8=FIX.4.2\0019=105\00135=1\00134=94\001369=39\00152=20150427-19:22:01." + "752\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001112=" + "IDi8yfsl3x\00110=040\001", + "8=FIX.4.2\0019=116\00135=Z\00134=41\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:22:01.784\00156=CME\00157=G\001142=US,NC\001117=39\001295=" + "1\00155=N/A\001298=4\0011028=N\00110=254\001", + "8=FIX.4.2\0019=165\00135=b\00134=87\001369=40\00152=20150427-19:22:01." + "802\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-" + "19:21:56.933\001143=US,NC\001117=CME1V2635\001297=4\0011028=N\0019772=" + "0\0019774=1V\0019775=A\00110=043\001", + "8=FIX.4.2\0019=165\00135=b\00134=88\001369=40\00152=20150427-19:22:01." + "802\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-" + "19:21:56.933\001143=US,NC\001117=CMEEW3111\001297=4\0011028=N\0019772=" + "0\0019774=EW\0019775=A\00110=076\001", + "8=FIX.4.2\0019=165\00135=b\00134=89\001369=40\00152=20150427-19:22:01." + "802\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-" + "19:21:56.934\001143=US,NC\001117=CMEEZ3447\001297=4\0011028=N\0019772=" + "0\0019774=EZ\0019775=A\00110=096\001", + "8=FIX.4.2\0019=164\00135=b\00134=90\001369=40\00152=20150427-19:22:01." + "802\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-" + "19:21:56.934\001143=US,NC\001117=CME96117\001297=4\0011028=N\0019772=" + "0\0019774=96\0019775=A\00110=190\001", + "8=FIX.4.2\0019=164\00135=b\00134=91\001369=40\00152=20150427-19:22:01." + "802\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-" + "19:21:56.935\001143=US,NC\001117=CMET$124\001297=4\0011028=N\0019772=" + "0\0019774=T$\0019775=A\00110=208\001", + "8=FIX.4.2\0019=164\00135=b\00134=92\001369=40\00152=20150427-19:22:01." + "802\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-" + "19:21:56.935\001143=US,NC\001117=CMETE203\001297=4\0011028=N\0019772=" + "0\0019774=TE\0019775=A\00110=017\001", + "8=FIX.4.2\0019=98\00135=0\00134=42\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:22:01.889\00156=CME\00157=G\001142=US,NC\001112=" + "IDi8yfsl3x\00110=249\001", + "8=FIX.4.2\0019=133\00135=4\00134=93\001369=40\00152=20150427-19:22:01." + "802\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001122=" + "20150427-19:22:01.802\001143=US,NC\00136=95\001123=Y\00110=246\001", + "8=FIX.4.2\0019=125\00135=b\00134=95\001369=41\00152=20150427-19:22:01." + "852\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "39\001297=4\0011028=N\0019772=0\0019774=96\00110=106\001", + "8=FIX.4.2\0019=125\00135=b\00134=96\001369=41\00152=20150427-19:22:01." + "855\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "39\001297=4\0011028=N\0019772=0\0019774=1V\00110=134\001", + "8=FIX.4.2\0019=125\00135=b\00134=97\001369=41\00152=20150427-19:22:01." + "855\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "39\001297=4\0011028=N\0019772=0\0019774=EW\00110=156\001", + "8=FIX.4.2\0019=125\00135=b\00134=98\001369=41\00152=20150427-19:22:01." + "855\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "39\001297=4\0011028=N\0019772=0\0019774=EZ\00110=160\001", + "8=FIX.4.2\0019=125\00135=b\00134=99\001369=41\00152=20150427-19:22:01." + "861\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "39\001297=4\0011028=N\0019772=0\0019774=T$\00110=119\001", + "8=FIX.4.2\0019=126\00135=b\00134=100\001369=41\00152=20150427-19:22:01." + "861\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "39\001297=4\0011028=N\0019772=0\0019774=TE\00110=184\001", + "8=FIX.4.2\0019=83\00135=0\00134=43\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:22:31.264\00156=CME\00157=G\001142=US,NC\00110=129\001", + "8=FIX.4.2\0019=91\00135=0\00134=101\001369=43\00152=20150427-19:22:32." + "240\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=" + "174\001", + "8=FIX.4.2\0019=83\00135=0\00134=44\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:23:01.296\00156=CME\00157=G\001142=US,NC\00110=133\001", + "8=FIX.4.2\0019=91\00135=0\00134=102\001369=44\00152=20150427-19:23:03." + "245\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=" + "180\001", + "8=FIX.4.2\0019=83\00135=0\00134=45\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:23:31.328\00156=CME\00157=G\001142=US,NC\00110=133\001", + "8=FIX.4.2\0019=91\00135=0\00134=103\001369=45\00152=20150427-19:23:34." + "250\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=" + "182\001", + "8=FIX.4.2\0019=83\00135=0\00134=46\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:24:01.360\00156=CME\00157=G\001142=US,NC\00110=128\001", + "8=FIX.4.2\0019=91\00135=0\00134=104\001369=46\00152=20150427-19:24:05." + "255\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=" + "188\001", + "8=FIX.4.2\0019=83\00135=0\00134=47\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:24:31.390\00156=CME\00157=G\001142=US,NC\00110=135\001", + "8=FIX.4.2\0019=91\00135=0\00134=105\001369=47\00152=20150427-19:24:36." + "260\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=" + "190\001", + "8=FIX.4.2\0019=83\00135=0\00134=48\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:25:01.421\00156=CME\00157=G\001142=US,NC\00110=129\001", + "8=FIX.4.2\0019=91\00135=0\00134=106\001369=48\00152=20150427-19:25:07." + "265\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=" + "196\001", + "8=FIX.4.2\0019=83\00135=0\00134=49\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:25:31.450\00156=CME\00157=G\001142=US,NC\00110=135\001", + "8=FIX.4.2\0019=91\00135=0\00134=107\001369=49\00152=20150427-19:25:38." + "269\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=" + "206\001", + "8=FIX.4.2\0019=83\00135=0\00134=50\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:26:01.480\00156=CME\00157=G\001142=US,NC\00110=128\001", + "8=FIX.4.2\0019=91\00135=0\00134=108\001369=50\00152=20150427-19:26:09." + "274\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=" + "194\001", + "8=FIX.4.2\0019=83\00135=0\00134=51\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:26:31.511\00156=CME\00157=G\001142=US,NC\00110=127\001", + "8=FIX.4.2\0019=91\00135=0\00134=109\001369=51\00152=20150427-19:26:40." + "279\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=" + "196\001", + "8=FIX.4.2\0019=83\00135=0\00134=52\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:27:01.542\00156=CME\00157=G\001142=US,NC\00110=130\001", + "8=FIX.4.2\0019=91\00135=0\00134=110\001369=52\00152=20150427-19:27:11." + "283\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=" + "183\001", + "8=FIX.4.2\0019=83\00135=0\00134=53\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:27:31.573\00156=CME\00157=G\001142=US,NC\00110=138\001", + "8=FIX.4.2\0019=91\00135=0\00134=111\001369=53\00152=20150427-19:27:42." + "291\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=" + "188\001", + "8=FIX.4.2\0019=83\00135=0\00134=54\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:28:01.603\00156=CME\00157=G\001142=US,NC\00110=131\001", + "8=FIX.4.2\0019=91\00135=0\00134=112\001369=54\00152=20150427-19:28:13." + "298\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=" + "196\001", + "8=FIX.4.2\0019=83\00135=0\00134=55\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:28:31.633\00156=CME\00157=G\001142=US,NC\00110=138\001", + "8=FIX.4.2\0019=91\00135=0\00134=113\001369=55\00152=20150427-19:28:44." + "303\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=" + "189\001", + "8=FIX.4.2\0019=83\00135=0\00134=56\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:01.665\00156=CME\00157=G\001142=US,NC\00110=142\001", + "8=FIX.4.2\0019=133\00135=A\00134=57\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:14.817\00156=CME\00157=G\001142=US,NC\00195=3\00196=" + "1U7\00198=0\001108=30\0011603=O2\0011604=1.0\0011605=BTS\00110=069\001", + "8=FIX.4.2\0019=129\00135=A\00134=120\001369=57\00152=20150427-19:29:16." + "376\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00198=" + "0\001108=30\0011603=O2\0011604=1.0\0011605=BTS\00110=055\001", + "8=FIX.4.2\0019=94\00135=2\00134=58\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:16.404\00156=CME\00157=G\001142=US,NC\0017=114\00116=" + "0\00110=113\001", + "8=FIX.4.2\0019=106\00135=1\00134=121\001369=57\00152=20150427-19:29:16." + "376\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001112=" + "IDi8yfsl3y\00110=096\001", + "8=FIX.4.2\0019=165\00135=b\00134=114\001369=58\00152=20150427-19:29:16." + "424\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-" + "19:29:05.528\001143=US,NC\001117=CMET$125\001297=4\0011028=N\0019772=" + "0\0019774=T$\0019775=A\00110=020\001", + "8=FIX.4.2\0019=165\00135=b\00134=115\001369=58\00152=20150427-19:29:16." + "424\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-" + "19:29:05.528\001143=US,NC\001117=CMETE204\001297=4\0011028=N\0019772=" + "0\0019774=TE\0019775=A\00110=085\001", + "8=FIX.4.2\0019=166\00135=b\00134=116\001369=58\00152=20150427-19:29:16." + "424\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-" + "19:29:05.531\001143=US,NC\001117=CME1V2639\001297=4\0011028=N\0019772=" + "0\0019774=1V\0019775=A\00110=107\001", + "8=FIX.4.2\0019=166\00135=b\00134=117\001369=58\00152=20150427-19:29:16." + "425\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-" + "19:29:05.531\001143=US,NC\001117=CMEEW3115\001297=4\0011028=N\0019772=" + "0\0019774=EW\0019775=A\00110=141\001", + "8=FIX.4.2\0019=166\00135=b\00134=118\001369=58\00152=20150427-19:29:16." + "425\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-" + "19:29:05.531\001143=US,NC\001117=CMEEZ3451\001297=4\0011028=N\0019772=" + "0\0019774=EZ\0019775=A\00110=151\001", + "8=FIX.4.2\0019=165\00135=b\00134=119\001369=58\00152=20150427-19:29:16." + "425\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-" + "19:29:05.547\001143=US,NC\001117=CME96118\001297=4\0011028=N\0019772=" + "0\0019774=96\0019775=A\00110=011\001", + "8=FIX.4.2\0019=98\00135=0\00134=59\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:16.454\00156=CME\00157=G\001142=US,NC\001112=" + "IDi8yfsl3y\00110=003\001", + "8=FIX.4.2\0019=135\00135=4\00134=120\001369=58\00152=20150427-19:29:16." + "425\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001122=" + "20150427-19:29:16.425\001143=US,NC\00136=122\001123=Y\00110=107\001", + "8=FIX.4.2\0019=116\00135=Z\00134=60\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:16.472\00156=CME\00157=G\001142=US,NC\001117=57\001295=" + "1\00155=N/A\001298=4\0011028=N\00110=006\001", + "8=FIX.4.2\0019=126\00135=b\00134=122\001369=60\00152=20150427-19:29:16." + "562\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "57\001297=4\0011028=N\0019772=0\0019774=T$\00110=167\001", + "8=FIX.4.2\0019=126\00135=b\00134=123\001369=60\00152=20150427-19:29:16." + "562\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "57\001297=4\0011028=N\0019772=0\0019774=TE\00110=201\001", + "8=FIX.4.2\0019=126\00135=b\00134=124\001369=60\00152=20150427-19:29:16." + "573\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "57\001297=4\0011028=N\0019772=0\0019774=1V\00110=186\001", + "8=FIX.4.2\0019=126\00135=b\00134=125\001369=60\00152=20150427-19:29:16." + "573\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "57\001297=4\0011028=N\0019772=0\0019774=EW\00110=208\001", + "8=FIX.4.2\0019=126\00135=b\00134=126\001369=60\00152=20150427-19:29:16." + "573\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "57\001297=4\0011028=N\0019772=0\0019774=EZ\00110=212\001", + "8=FIX.4.2\0019=126\00135=b\00134=127\001369=60\00152=20150427-19:29:16." + "582\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "57\001297=4\0011028=N\0019772=0\0019774=96\00110=165\001", + "8=FIX.4.2\0019=234\00135=i\00134=61\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:40.610\00156=CME\00157=G\001142=US,NC\001117=58\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25200\001133=25350\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=046\001", + "8=FIX.4.2\0019=147\00135=b\00134=128\001369=61\00152=20150427-19:29:40." + "640\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "58\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "129\001", + "8=FIX.4.2\0019=234\00135=i\00134=62\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:40.767\00156=CME\00157=G\001142=US,NC\001117=59\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25225\001133=25375\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=075\001", + "8=FIX.4.2\0019=147\00135=b\00134=129\001369=62\00152=20150427-19:29:40." + "791\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "59\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "139\001", + "8=FIX.4.2\0019=234\00135=i\00134=63\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:41.039\00156=CME\00157=G\001142=US,NC\001117=60\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25200\001133=25400\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=043\001", + "8=FIX.4.2\0019=147\00135=b\00134=130\001369=63\00152=20150427-19:29:41." + "074\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "60\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "119\001", + "8=FIX.4.2\0019=234\00135=i\00134=64\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:41.303\00156=CME\00157=G\001142=US,NC\001117=61\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25175\001133=25425\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=057\001", + "8=FIX.4.2\0019=147\00135=b\00134=131\001369=64\00152=20150427-19:29:41." + "350\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "61\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "119\001", + "8=FIX.4.2\0019=234\00135=i\00134=65\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:41.567\00156=CME\00157=G\001142=US,NC\001117=62\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25150\001133=25400\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=057\001", + "8=FIX.4.2\0019=147\00135=b\00134=132\001369=65\00152=20150427-19:29:41." + "593\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "62\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "131\001", + "8=FIX.4.2\0019=234\00135=i\00134=66\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:41.831\00156=CME\00157=G\001142=US,NC\001117=63\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25175\001133=25375\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=071\001", + "8=FIX.4.2\0019=147\00135=b\00134=133\001369=66\00152=20150427-19:29:41." + "856\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "63\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "136\001", + "8=FIX.4.2\0019=234\00135=i\00134=67\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:42.095\00156=CME\00157=G\001142=US,NC\001117=64\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25150\001133=25350\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=062\001", + "8=FIX.4.2\0019=147\00135=b\00134=134\001369=67\00152=20150427-19:29:42." + "120\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "64\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "124\001", + "8=FIX.4.2\0019=234\00135=i\00134=68\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:42.359\00156=CME\00157=G\001142=US,NC\001117=65\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25175\001133=25375\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=081\001", + "8=FIX.4.2\0019=147\00135=b\00134=135\001369=68\00152=20150427-19:29:42." + "386\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "65\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "141\001", + "8=FIX.4.2\0019=234\00135=i\00134=69\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:42.622\00156=CME\00157=G\001142=US,NC\001117=66\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25200\001133=25400\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=054\001", + "8=FIX.4.2\0019=147\00135=b\00134=136\001369=69\00152=20150427-19:29:42." + "661\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "66\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "140\001", + "8=FIX.4.2\0019=234\00135=i\00134=70\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:42.886\00156=CME\00157=G\001142=US,NC\001117=67\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25225\001133=25425\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=073\001", + "8=FIX.4.2\0019=147\00135=b\00134=137\001369=70\00152=20150427-19:29:42." + "912\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "67\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "133\001", + "8=FIX.4.2\0019=234\00135=i\00134=71\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:43.150\00156=CME\00157=G\001142=US,NC\001117=68\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25250\001133=25400\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=051\001", + "8=FIX.4.2\0019=147\00135=b\00134=138\001369=71\00152=20150427-19:29:43." + "186\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "68\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "140\001", + "8=FIX.4.2\0019=234\00135=i\00134=72\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:43.414\00156=CME\00157=G\001142=US,NC\001117=69\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25225\001133=25425\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=065\001", + "8=FIX.4.2\0019=147\00135=b\00134=139\001369=72\00152=20150427-19:29:43." + "441\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "69\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "137\001", + "8=FIX.4.2\0019=234\00135=i\00134=73\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:43.677\00156=CME\00157=G\001142=US,NC\001117=70\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25200\001133=25400\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=055\001", + "8=FIX.4.2\0019=147\00135=b\00134=140\001369=73\00152=20150427-19:29:43." + "715\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "70\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "126\001", + "8=FIX.4.2\0019=234\00135=i\00134=74\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:43.941\00156=CME\00157=G\001142=US,NC\001117=71\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25225\001133=25425\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=065\001", + "8=FIX.4.2\0019=147\00135=b\00134=141\001369=74\00152=20150427-19:29:43." + "964\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "71\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "135\001", + "8=FIX.4.2\0019=234\00135=i\00134=75\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:44.205\00156=CME\00157=G\001142=US,NC\001117=72\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25250\001133=25400\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=052\001", + "8=FIX.4.2\0019=147\00135=b\00134=142\001369=75\00152=20150427-19:29:44." + "232\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "72\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "127\001", + "8=FIX.4.2\0019=234\00135=i\00134=76\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:44.468\00156=CME\00157=G\001142=US,NC\001117=73\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25225\001133=25425\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=074\001", + "8=FIX.4.2\0019=147\00135=b\00134=143\001369=76\00152=20150427-19:29:44." + "510\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "73\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "129\001", + "8=FIX.4.2\0019=234\00135=i\00134=77\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:44.730\00156=CME\00157=G\001142=US,NC\001117=74\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25250\001133=25400\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=059\001", + "8=FIX.4.2\0019=147\00135=b\00134=144\001369=77\00152=20150427-19:29:44." + "755\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "74\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "143\001", + "8=FIX.4.2\0019=234\00135=i\00134=78\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:44.992\00156=CME\00157=G\001142=US,NC\001117=75\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25275\001133=25375\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=089\001", + "8=FIX.4.2\0019=147\00135=b\00134=145\001369=78\00152=20150427-19:29:45." + "015\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "75\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "136\001", + "8=FIX.4.2\0019=218\00135=i\00134=79\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:45.255\00156=CME\00157=G\001142=US,NC\001117=76\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001133=25400\001135=1\0011028=N\0017928=bluestream\0019702=" + "1\0019771=TESTACC\00110=107\001", + "8=FIX.4.2\0019=147\00135=b\00134=146\001369=79\00152=20150427-19:29:45." + "281\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "76\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "144\001", + "8=FIX.4.2\0019=218\00135=i\00134=80\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:45.518\00156=CME\00157=G\001142=US,NC\001117=77\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001133=25425\001135=1\0011028=N\0017928=bluestream\0019702=" + "1\0019771=TESTACC\00110=109\001", + "8=FIX.4.2\0019=147\00135=b\00134=147\001369=80\00152=20150427-19:29:45." + "561\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "77\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "139\001", + "8=FIX.4.2\0019=218\00135=i\00134=81\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:45.780\00156=CME\00157=G\001142=US,NC\001117=78\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001133=25450\001135=1\0011028=N\0017928=bluestream\0019702=" + "1\0019771=TESTACC\00110=110\001", + "8=FIX.4.2\0019=147\00135=b\00134=148\001369=81\00152=20150427-19:29:45." + "828\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "78\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "148\001", + "8=FIX.4.2\0019=234\00135=i\00134=82\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:46.042\00156=CME\00157=G\001142=US,NC\001117=79\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25300\001133=25475\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=066\001", + "8=FIX.4.2\0019=147\00135=b\00134=149\001369=82\00152=20150427-19:29:46." + "071\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "79\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "142\001", + "8=FIX.4.2\0019=234\00135=i\00134=83\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:46.304\00156=CME\00157=G\001142=US,NC\001117=80\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25275\001133=25450\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=064\001", + "8=FIX.4.2\0019=147\00135=b\00134=150\001369=83\00152=20150427-19:29:46." + "332\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "80\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "127\001", + "8=FIX.4.2\0019=218\00135=i\00134=84\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:46.567\00156=CME\00157=G\001142=US,NC\001117=81\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001133=25425\001135=1\0011028=N\0017928=bluestream\0019702=" + "1\0019771=TESTACC\00110=113\001", + "8=FIX.4.2\0019=147\00135=b\00134=151\001369=84\00152=20150427-19:29:46." + "593\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "81\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "139\001", + "8=FIX.4.2\0019=218\00135=i\00134=85\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:46.829\00156=CME\00157=G\001142=US,NC\001117=82\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001133=25450\001135=1\0011028=N\0017928=bluestream\0019702=" + "1\0019771=TESTACC\00110=114\001", + "8=FIX.4.2\0019=147\00135=b\00134=152\001369=85\00152=20150427-19:29:46." + "856\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "82\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "144\001", + "8=FIX.4.2\0019=234\00135=i\00134=86\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:47.092\00156=CME\00157=G\001142=US,NC\001117=83\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25300\001133=25425\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=066\001", + "8=FIX.4.2\0019=147\00135=b\00134=153\001369=86\00152=20150427-19:29:47." + "116\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "83\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "137\001", + "8=FIX.4.2\0019=234\00135=i\00134=87\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:47.354\00156=CME\00157=G\001142=US,NC\001117=84\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25275\001133=25400\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=073\001", + "8=FIX.4.2\0019=147\00135=b\00134=154\001369=87\00152=20150427-19:29:47." + "383\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "84\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "146\001", + "8=FIX.4.2\0019=218\00135=i\00134=88\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:47.616\00156=CME\00157=G\001142=US,NC\001117=85\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001133=25425\001135=1\0011028=N\0017928=bluestream\0019702=" + "1\0019771=TESTACC\00110=117\001", + "8=FIX.4.2\0019=147\00135=b\00134=155\001369=88\00152=20150427-19:29:47." + "643\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "85\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "148\001", + "8=FIX.4.2\0019=234\00135=i\00134=89\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:47.879\00156=CME\00157=G\001142=US,NC\001117=86\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25250\001133=25450\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=087\001", + "8=FIX.4.2\0019=147\00135=b\00134=156\001369=89\00152=20150427-19:29:47." + "906\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "86\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "153\001", + "8=FIX.4.2\0019=234\00135=i\00134=90\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:48.141\00156=CME\00157=G\001142=US,NC\001117=87\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25225\001133=25475\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=072\001", + "8=FIX.4.2\0019=147\00135=b\00134=157\001369=90\00152=20150427-19:29:48." + "163\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "87\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "143\001", + "8=FIX.4.2\0019=234\00135=i\00134=91\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:48.403\00156=CME\00157=G\001142=US,NC\001117=88\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25200\001133=25500\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=057\001", + "8=FIX.4.2\0019=147\00135=b\00134=158\001369=91\00152=20150427-19:29:48." + "423\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "88\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "145\001", + "8=FIX.4.2\0019=234\00135=i\00134=92\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:48.666\00156=CME\00157=G\001142=US,NC\001117=89\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25175\001133=25475\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=092\001", + "8=FIX.4.2\0019=147\00135=b\00134=159\001369=92\00152=20150427-19:29:48." + "691\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "89\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "155\001", + "8=FIX.4.2\0019=234\00135=i\00134=93\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:48.928\00156=CME\00157=G\001142=US,NC\001117=90\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25150\001133=25450\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=072\001", + "8=FIX.4.2\0019=147\00135=b\00134=160\001369=93\00152=20150427-19:29:48." + "948\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "90\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "145\001", + "8=FIX.4.2\0019=234\00135=i\00134=94\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:49.191\00156=CME\00157=G\001142=US,NC\001117=91\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25125\001133=25475\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=076\001", + "8=FIX.4.2\0019=147\00135=b\00134=161\001369=94\00152=20150427-19:29:49." + "213\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "91\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "134\001", + "8=FIX.4.2\0019=234\00135=i\00134=95\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:49.454\00156=CME\00157=G\001142=US,NC\001117=92\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25100\001133=25500\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=062\001", + "8=FIX.4.2\0019=147\00135=b\00134=162\001369=95\00152=20150427-19:29:49." + "484\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "92\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "147\001", + "8=FIX.4.2\0019=234\00135=i\00134=96\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:49.718\00156=CME\00157=G\001142=US,NC\001117=93\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25075\001133=25475\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=089\001", + "8=FIX.4.2\0019=147\00135=b\00134=163\001369=96\00152=20150427-19:29:49." + "739\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "93\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "153\001", + "8=FIX.4.2\0019=234\00135=i\00134=97\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:49.982\00156=CME\00157=G\001142=US,NC\001117=94\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25050\001133=25450\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=080\001", + "8=FIX.4.2\0019=147\00135=b\00134=164\001369=97\00152=20150427-19:29:50." + "008\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "94\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "137\001", + "8=FIX.4.2\0019=234\00135=i\00134=98\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:50.246\00156=CME\00157=G\001142=US,NC\001117=95\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25025\001133=25425\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=071\001", + "8=FIX.4.2\0019=147\00135=b\00134=165\001369=98\00152=20150427-19:29:50." + "275\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "95\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "146\001", + "8=FIX.4.2\0019=234\00135=i\00134=99\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:50.510\00156=CME\00157=G\001142=US,NC\001117=96\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25050\001133=25400\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=058\001", + "8=FIX.4.2\0019=147\00135=b\00134=166\001369=99\00152=20150427-19:29:50." + "537\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "96\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "150\001", + "8=FIX.4.2\0019=235\00135=i\00134=100\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:50.774\00156=CME\00157=G\001142=US,NC\001117=97\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25025\001133=25375\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=116\001", + "8=FIX.4.2\0019=148\00135=b\00134=167\001369=100\00152=20150427-19:29:50." + "840\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "97\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "181\001", + "8=FIX.4.2\0019=235\00135=i\00134=101\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:51.037\00156=CME\00157=G\001142=US,NC\001117=98\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25000\001133=25350\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=097\001", + "8=FIX.4.2\0019=148\00135=b\00134=168\001369=101\00152=20150427-19:29:51." + "063\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "98\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "182\001", + "8=FIX.4.2\0019=219\00135=i\00134=102\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:51.301\00156=CME\00157=G\001142=US,NC\001117=99\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001133=25325\001135=1\0011028=N\0017928=bluestream\0019702=" + "1\0019771=TESTACC\00110=143\001", + "8=FIX.4.2\0019=148\00135=b\00134=169\001369=102\00152=20150427-19:29:51." + "325\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "99\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "186\001", + "8=FIX.4.2\0019=220\00135=i\00134=103\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:51.563\00156=CME\00157=G\001142=US,NC\001117=100\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001133=25350\001135=1\0011028=N\0017928=bluestream\0019702=" + "1\0019771=TESTACC\00110=175\001", + "8=FIX.4.2\0019=149\00135=b\00134=170\001369=103\00152=20150427-19:29:51." + "584\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "100\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "218\001", + "8=FIX.4.2\0019=220\00135=i\00134=104\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:51.825\00156=CME\00157=G\001142=US,NC\001117=101\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001133=25325\001135=1\0011028=N\0017928=bluestream\0019702=" + "1\0019771=TESTACC\00110=180\001", + "8=FIX.4.2\0019=149\00135=b\00134=171\001369=104\00152=20150427-19:29:51." + "851\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "101\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "218\001", + "8=FIX.4.2\0019=236\00135=i\00134=105\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:52.087\00156=CME\00157=G\001142=US,NC\001117=102\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25025\001133=25350\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=149\001", + "8=FIX.4.2\0019=149\00135=b\00134=172\001369=105\00152=20150427-19:29:52." + "111\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "102\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "211\001", + "8=FIX.4.2\0019=236\00135=i\00134=106\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:52.350\00156=CME\00157=G\001142=US,NC\001117=103\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25050\001133=25325\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=144\001", + "8=FIX.4.2\0019=149\00135=b\00134=173\001369=106\00152=20150427-19:29:52." + "380\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "103\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "222\001", + "8=FIX.4.2\0019=236\00135=i\00134=107\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:52.612\00156=CME\00157=G\001142=US,NC\001117=104\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25075\001133=25300\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=147\001", + "8=FIX.4.2\0019=149\00135=b\00134=174\001369=107\00152=20150427-19:29:52." + "640\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "104\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "224\001", + "8=FIX.4.2\0019=236\00135=i\00134=108\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:52.874\00156=CME\00157=G\001142=US,NC\001117=105\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25050\001133=25275\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=163\001", + "8=FIX.4.2\0019=149\00135=b\00134=175\001369=108\00152=20150427-19:29:52." + "897\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "105\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "241\001", + "8=FIX.4.2\0019=236\00135=i\00134=109\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:53.137\00156=CME\00157=G\001142=US,NC\001117=106\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25025\001133=25250\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=153\001", + "8=FIX.4.2\0019=149\00135=b\00134=176\001369=109\00152=20150427-19:29:53." + "162\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "106\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "230\001", + "8=FIX.4.2\0019=236\00135=i\00134=110\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:53.400\00156=CME\00157=G\001142=US,NC\001117=107\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25050\001133=25225\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=139\001", + "8=FIX.4.2\0019=149\00135=b\00134=177\001369=110\00152=20150427-19:29:53." + "422\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "107\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "223\001", + "8=FIX.4.2\0019=236\00135=i\00134=111\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:53.663\00156=CME\00157=G\001142=US,NC\001117=108\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25075\001133=25200\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=152\001", + "8=FIX.4.2\0019=149\00135=b\00134=178\001369=111\00152=20150427-19:29:53." + "691\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "108\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "234\001", + "8=FIX.4.2\0019=220\00135=i\00134=112\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:53.927\00156=CME\00157=G\001142=US,NC\001117=109\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001133=25175\001135=1\0011028=N\0017928=bluestream\0019702=" + "1\0019771=TESTACC\00110=195\001", + "8=FIX.4.2\0019=149\00135=b\00134=179\001369=112\00152=20150427-19:29:53." + "952\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "109\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "237\001", + "8=FIX.4.2\0019=236\00135=i\00134=113\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:54.191\00156=CME\00157=G\001142=US,NC\001117=110\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25100\001133=25200\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=133\001", + "8=FIX.4.2\0019=149\00135=b\00134=180\001369=113\00152=20150427-19:29:54." + "215\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "110\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "215\001", + "8=FIX.4.2\0019=236\00135=i\00134=114\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:54.455\00156=CME\00157=G\001142=US,NC\001117=111\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25075\001133=25175\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=160\001", + "8=FIX.4.2\0019=149\00135=b\00134=181\001369=114\00152=20150427-19:29:54." + "481\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "111\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "223\001", + "8=FIX.4.2\0019=236\00135=i\00134=115\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:54.718\00156=CME\00157=G\001142=US,NC\001117=112\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25050\001133=25150\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=150\001", + "8=FIX.4.2\0019=149\00135=b\00134=182\001369=115\00152=20150427-19:29:54." + "748\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "112\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "232\001", + "8=FIX.4.2\0019=236\00135=i\00134=116\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:54.982\00156=CME\00157=G\001142=US,NC\001117=113\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25075\001133=25175\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=169\001", + "8=FIX.4.2\0019=149\00135=b\00134=183\001369=116\00152=20150427-19:29:55." + "014\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "113\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "222\001", + "8=FIX.4.2\0019=236\00135=i\00134=117\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:55.245\00156=CME\00157=G\001142=US,NC\001117=114\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25100\001133=25200\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=142\001", + "8=FIX.4.2\0019=149\00135=b\00134=184\001369=117\00152=20150427-19:29:55." + "275\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "114\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "234\001", + "8=FIX.4.2\0019=236\00135=i\00134=118\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:55.509\00156=CME\00157=G\001142=US,NC\001117=115\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25075\001133=25225\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=165\001", + "8=FIX.4.2\0019=149\00135=b\00134=185\001369=118\00152=20150427-19:29:55." + "533\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "115\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "234\001", + "8=FIX.4.2\0019=236\00135=i\00134=119\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:55.773\00156=CME\00157=G\001142=US,NC\001117=116\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25100\001133=25200\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=152\001", + "8=FIX.4.2\0019=149\00135=b\00134=186\001369=119\00152=20150427-19:29:55." + "797\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "116\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "249\001", + "8=FIX.4.2\0019=236\00135=i\00134=120\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:56.036\00156=CME\00157=G\001142=US,NC\001117=117\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25125\001133=25225\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=152\001", + "8=FIX.4.2\0019=149\00135=b\00134=187\001369=120\00152=20150427-19:29:56." + "061\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "117\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "228\001", + "8=FIX.4.2\0019=236\00135=i\00134=121\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:56.300\00156=CME\00157=G\001142=US,NC\001117=118\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25100\001133=25200\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=134\001", + "8=FIX.4.2\0019=149\00135=b\00134=188\001369=121\00152=20150427-19:29:56." + "326\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "118\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "235\001", + "8=FIX.4.2\0019=236\00135=i\00134=122\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:56.564\00156=CME\00157=G\001142=US,NC\001117=119\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25125\001133=25225\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=162\001", + "8=FIX.4.2\0019=149\00135=b\00134=189\001369=122\00152=20150427-19:29:56." + "584\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "119\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "244\001", + "8=FIX.4.2\0019=236\00135=i\00134=123\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:56.827\00156=CME\00157=G\001142=US,NC\001117=120\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25100\001133=25250\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=148\001", + "8=FIX.4.2\0019=149\00135=b\00134=190\001369=123\00152=20150427-19:29:56." + "856\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "120\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "231\001", + "8=FIX.4.2\0019=236\00135=i\00134=124\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:57.091\00156=CME\00157=G\001142=US,NC\001117=121\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25125\001133=25275\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=158\001", + "8=FIX.4.2\0019=149\00135=b\00134=191\001369=124\00152=20150427-19:29:57." + "116\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "121\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "224\001", + "8=FIX.4.2\0019=236\00135=i\00134=125\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:57.354\00156=CME\00157=G\001142=US,NC\001117=122\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25150\001133=25250\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=153\001", + "8=FIX.4.2\0019=149\00135=b\00134=192\001369=125\00152=20150427-19:29:57." + "379\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "122\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "238\001", + "8=FIX.4.2\0019=236\00135=i\00134=126\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:57.618\00156=CME\00157=G\001142=US,NC\001117=123\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25125\001133=25225\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=162\001", + "8=FIX.4.2\0019=149\00135=b\00134=193\001369=126\00152=20150427-19:29:57." + "648\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "123\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "240\001", + "8=FIX.4.2\0019=236\00135=i\00134=127\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:57.882\00156=CME\00157=G\001142=US,NC\001117=124\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25100\001133=25200\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=153\001", + "8=FIX.4.2\0019=149\00135=b\00134=194\001369=127\00152=20150427-19:29:57." + "911\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "124\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "236\001", + "8=FIX.4.2\0019=236\00135=i\00134=128\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:58.145\00156=CME\00157=G\001142=US,NC\001117=125\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25075\001133=25175\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=170\001", + "8=FIX.4.2\0019=149\00135=b\00134=195\001369=128\00152=20150427-19:29:58." + "174\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "125\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "241\001", + "8=FIX.4.2\0019=236\00135=i\00134=129\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:58.409\00156=CME\00157=G\001142=US,NC\001117=126\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25050\001133=25200\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=157\001", + "8=FIX.4.2\0019=149\00135=b\00134=196\001369=129\00152=20150427-19:29:58." + "439\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "126\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "248\001", + "8=FIX.4.2\0019=236\00135=i\00134=130\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:58.673\00156=CME\00157=G\001142=US,NC\001117=127\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25025\001133=25175\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=166\001", + "8=FIX.4.2\0019=149\00135=b\00134=197\001369=130\00152=20150427-19:29:58." + "696\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "127\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "247\001", + "8=FIX.4.2\0019=236\00135=i\00134=131\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:58.936\00156=CME\00157=G\001142=US,NC\001117=128\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25050\001133=25200\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=157\001", + "8=FIX.4.2\0019=149\00135=b\00134=198\001369=131\00152=20150427-19:29:58." + "957\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "128\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "250\001", + "8=FIX.4.2\0019=236\00135=i\00134=132\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:59.200\00156=CME\00157=G\001142=US,NC\001117=129\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25075\001133=25225\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=158\001", + "8=FIX.4.2\0019=149\00135=b\00134=199\001369=132\00152=20150427-19:29:59." + "223\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "129\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "240\001", + "8=FIX.4.2\0019=236\00135=i\00134=133\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:59.464\00156=CME\00157=G\001142=US,NC\001117=130\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25050\001133=25200\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=149\001", + "8=FIX.4.2\0019=149\00135=b\00134=200\001369=133\00152=20150427-19:29:59." + "493\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "130\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "225\001", + "8=FIX.4.2\0019=236\00135=i\00134=134\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:59.727\00156=CME\00157=G\001142=US,NC\001117=131\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25075\001133=25225\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=167\001", + "8=FIX.4.2\0019=149\00135=b\00134=201\001369=134\00152=20150427-19:29:59." + "749\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "131\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "232\001", + "8=FIX.4.2\0019=236\00135=i\00134=135\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:29:59.991\00156=CME\00157=G\001142=US,NC\001117=132\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25100\001133=25250\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=159\001", + "8=FIX.4.2\0019=149\00135=b\00134=202\001369=135\00152=20150427-19:30:00." + "040\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "132\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "197\001", + "8=FIX.4.2\0019=236\00135=i\00134=136\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:00.255\00156=CME\00157=G\001142=US,NC\001117=133\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25075\001133=25275\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=150\001", + "8=FIX.4.2\0019=149\00135=b\00134=203\001369=136\00152=20150427-19:30:00." + "284\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "133\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "210\001", + "8=FIX.4.2\0019=236\00135=i\00134=137\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:00.519\00156=CME\00157=G\001142=US,NC\001117=134\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25050\001133=25250\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=141\001", + "8=FIX.4.2\0019=149\00135=b\00134=204\001369=137\00152=20150427-19:30:00." + "540\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "134\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "208\001", + "8=FIX.4.2\0019=236\00135=i\00134=138\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:00.782\00156=CME\00157=G\001142=US,NC\001117=135\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25075\001133=25275\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=159\001", + "8=FIX.4.2\0019=149\00135=b\00134=205\001369=138\00152=20150427-19:30:00." + "813\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "135\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "214\001", + "8=FIX.4.2\0019=236\00135=i\00134=139\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:01.046\00156=CME\00157=G\001142=US,NC\001117=136\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25050\001133=25250\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=141\001", + "8=FIX.4.2\0019=149\00135=b\00134=206\001369=139\00152=20150427-19:30:01." + "078\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "136\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "221\001", + "8=FIX.4.2\0019=236\00135=i\00134=140\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:01.310\00156=CME\00157=G\001142=US,NC\001117=137\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25025\001133=25275\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=137\001", + "8=FIX.4.2\0019=149\00135=b\00134=207\001369=140\00152=20150427-19:30:01." + "340\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "137\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "207\001", + "8=FIX.4.2\0019=236\00135=i\00134=141\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:01.573\00156=CME\00157=G\001142=US,NC\001117=138\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25000\001133=25250\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=136\001", + "8=FIX.4.2\0019=149\00135=b\00134=208\001369=141\00152=20150427-19:30:01." + "598\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "138\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "225\001", + "8=FIX.4.2\0019=220\00135=i\00134=142\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:01.837\00156=CME\00157=G\001142=US,NC\001117=139\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001133=25225\001135=1\0011028=N\0017928=bluestream\0019702=" + "1\0019771=TESTACC\00110=182\001", + "8=FIX.4.2\0019=149\00135=b\00134=209\001369=142\00152=20150427-19:30:01." + "867\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "139\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "227\001", + "8=FIX.4.2\0019=220\00135=i\00134=143\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:02.100\00156=CME\00157=G\001142=US,NC\001117=140\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001133=25250\001135=1\0011028=N\0017928=bluestream\0019702=" + "1\0019771=TESTACC\00110=157\001", + "8=FIX.4.2\0019=149\00135=b\00134=210\001369=143\00152=20150427-19:30:02." + "136\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "140\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "202\001", + "8=FIX.4.2\0019=236\00135=i\00134=144\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:02.364\00156=CME\00157=G\001142=US,NC\001117=141\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25025\001133=25275\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=146\001", + "8=FIX.4.2\0019=149\00135=b\00134=211\001369=144\00152=20150427-19:30:02." + "387\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "141\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "213\001", + "8=FIX.4.2\0019=236\00135=i\00134=145\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:02.628\00156=CME\00157=G\001142=US,NC\001117=142\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25050\001133=25250\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=142\001", + "8=FIX.4.2\0019=149\00135=b\00134=212\001369=145\00152=20150427-19:30:02." + "667\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "142\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "217\001", + "8=FIX.4.2\0019=236\00135=i\00134=146\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:02.891\00156=CME\00157=G\001142=US,NC\001117=143\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25025\001133=25275\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=155\001", + "8=FIX.4.2\0019=149\00135=b\00134=213\001369=146\00152=20150427-19:30:02." + "917\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "143\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "218\001", + "8=FIX.4.2\0019=236\00135=i\00134=147\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:03.155\00156=CME\00157=G\001142=US,NC\001117=144\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25000\001133=25250\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=137\001", + "8=FIX.4.2\0019=149\00135=b\00134=214\001369=147\00152=20150427-19:30:03." + "179\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "144\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "222\001", + "8=FIX.4.2\0019=236\00135=i\00134=148\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:03.421\00156=CME\00157=G\001142=US,NC\001117=145\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25025\001133=25225\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=144\001", + "8=FIX.4.2\0019=149\00135=b\00134=215\001369=148\00152=20150427-19:30:03." + "448\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "145\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "224\001", + "8=FIX.4.2\0019=236\00135=i\00134=149\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:03.688\00156=CME\00157=G\001142=US,NC\001117=146\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25050\001133=25200\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=152\001", + "8=FIX.4.2\0019=149\00135=b\00134=216\001369=149\00152=20150427-19:30:03." + "717\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "146\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "226\001", + "8=FIX.4.2\0019=236\00135=i\00134=150\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:03.952\00156=CME\00157=G\001142=US,NC\001117=147\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25025\001133=25225\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=148\001", + "8=FIX.4.2\0019=149\00135=b\00134=217\001369=150\00152=20150427-19:30:03." + "975\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "147\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "226\001", + "8=FIX.4.2\0019=236\00135=i\00134=151\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:04.216\00156=CME\00157=G\001142=US,NC\001117=148\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25000\001133=25250\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=135\001", + "8=FIX.4.2\0019=149\00135=b\00134=218\001369=151\00152=20150427-19:30:04." + "268\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "148\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "225\001", + "8=FIX.4.2\0019=220\00135=i\00134=152\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:04.479\00156=CME\00157=G\001142=US,NC\001117=149\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001133=25225\001135=1\0011028=N\0017928=bluestream\0019702=" + "1\0019771=TESTACC\00110=189\001", + "8=FIX.4.2\0019=149\00135=b\00134=219\001369=152\00152=20150427-19:30:04." + "507\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "149\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "224\001", + "8=FIX.4.2\0019=236\00135=i\00134=153\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:04.743\00156=CME\00157=G\001142=US,NC\001117=150\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25025\001133=25250\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=142\001", + "8=FIX.4.2\0019=149\00135=b\00134=220\001369=153\00152=20150427-19:30:04." + "764\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "150\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "214\001", + "8=FIX.4.2\0019=236\00135=i\00134=154\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:05.007\00156=CME\00157=G\001142=US,NC\001117=151\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25000\001133=25225\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=133\001", + "8=FIX.4.2\0019=149\00135=b\00134=221\001369=154\00152=20150427-19:30:05." + "039\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "151\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "213\001", + "8=FIX.4.2\0019=236\00135=i\00134=155\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:05.271\00156=CME\00157=G\001142=US,NC\001117=152\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25025\001133=25250\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=143\001", + "8=FIX.4.2\0019=149\00135=b\00134=222\001369=155\00152=20150427-19:30:05." + "301\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "152\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "208\001", + "8=FIX.4.2\0019=236\00135=i\00134=156\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:05.535\00156=CME\00157=G\001142=US,NC\001117=153\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25000\001133=25225\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=143\001", + "8=FIX.4.2\0019=149\00135=b\00134=223\001369=156\00152=20150427-19:30:05." + "569\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "153\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "227\001", + "8=FIX.4.2\0019=236\00135=i\00134=157\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:05.799\00156=CME\00157=G\001142=US,NC\001117=154\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25025\001133=25250\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=162\001", + "8=FIX.4.2\0019=149\00135=b\00134=224\001369=157\00152=20150427-19:30:05." + "823\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "154\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "223\001", + "8=FIX.4.2\0019=236\00135=i\00134=158\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:06.063\00156=CME\00157=G\001142=US,NC\001117=155\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25050\001133=25275\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=154\001", + "8=FIX.4.2\0019=149\00135=b\00134=225\001369=158\00152=20150427-19:30:06." + "090\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "155\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "223\001", + "8=FIX.4.2\0019=236\00135=i\00134=159\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:06.327\00156=CME\00157=G\001142=US,NC\001117=156\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25075\001133=25250\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=159\001", + "8=FIX.4.2\0019=149\00135=b\00134=226\001369=159\00152=20150427-19:30:06." + "350\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "156\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "225\001", + "8=FIX.4.2\0019=236\00135=i\00134=160\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:06.590\00156=CME\00157=G\001142=US,NC\001117=157\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25050\001133=25225\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=149\001", + "8=FIX.4.2\0019=149\00135=b\00134=227\001369=160\00152=20150427-19:30:06." + "620\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "157\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "219\001", + "8=FIX.4.2\0019=236\00135=i\00134=161\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:06.854\00156=CME\00157=G\001142=US,NC\001117=158\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25025\001133=25200\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=149\001", + "8=FIX.4.2\0019=149\00135=b\00134=228\001369=161\00152=20150427-19:30:06." + "882\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "158\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "232\001", + "8=FIX.4.2\0019=236\00135=i\00134=162\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:07.118\00156=CME\00157=G\001142=US,NC\001117=159\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25000\001133=25175\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=149\001", + "8=FIX.4.2\0019=149\00135=b\00134=229\001369=162\00152=20150427-19:30:07." + "141\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "159\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "224\001", + "8=FIX.4.2\0019=220\00135=i\00134=163\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:07.382\00156=CME\00157=G\001142=US,NC\001117=160\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001133=25150\001135=1\0011028=N\0017928=bluestream\0019702=" + "1\0019771=TESTACC\00110=177\001", + "8=FIX.4.2\0019=149\00135=b\00134=230\001369=163\00152=20150427-19:30:07." + "404\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "160\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "211\001", + "8=FIX.4.2\0019=220\00135=i\00134=164\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:07.909\00156=CME\00157=G\001142=US,NC\001117=161\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001133=25125\001135=1\0011028=N\0017928=bluestream\0019702=" + "1\0019771=TESTACC\00110=186\001", + "8=FIX.4.2\0019=149\00135=b\00134=231\001369=164\00152=20150427-19:30:07." + "936\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "161\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "224\001", + "8=FIX.4.2\0019=236\00135=i\00134=165\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:08.437\00156=CME\00157=G\001142=US,NC\001117=162\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25025\001133=25150\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=151\001", + "8=FIX.4.2\0019=149\00135=b\00134=232\001369=165\00152=20150427-19:30:08." + "482\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "162\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "224\001", + "8=FIX.4.2\0019=220\00135=i\00134=166\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:08.700\00156=CME\00157=G\001142=US,NC\001117=163\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25000\001134=1\0011028=N\0017928=bluestream\0019702=" + "1\0019771=TESTACC\00110=170\001", + "8=FIX.4.2\0019=149\00135=b\00134=233\001369=166\00152=20150427-19:30:08." + "728\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "163\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "230\001", + "8=FIX.4.2\0019=236\00135=i\00134=167\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:08.964\00156=CME\00157=G\001142=US,NC\001117=164\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25025\001133=25175\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=167\001", + "8=FIX.4.2\0019=149\00135=b\00134=234\001369=167\00152=20150427-19:30:08." + "988\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "164\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "241\001", + "8=FIX.4.2\0019=236\00135=i\00134=168\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:09.228\00156=CME\00157=G\001142=US,NC\001117=165\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25050\001133=25150\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=154\001", + "8=FIX.4.2\0019=149\00135=b\00134=235\001369=168\00152=20150427-19:30:09." + "255\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "165\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "232\001", + "8=FIX.4.2\0019=220\00135=i\00134=169\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:09.492\00156=CME\00157=G\001142=US,NC\001117=166\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25025\001134=1\0011028=N\0017928=bluestream\0019702=" + "1\0019771=TESTACC\00110=192\001", + "8=FIX.4.2\0019=149\00135=b\00134=236\001369=169\00152=20150427-19:30:09." + "520\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "166\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "230\001", + "8=FIX.4.2\0019=236\00135=i\00134=170\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:09.755\00156=CME\00157=G\001142=US,NC\001117=167\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25000\001133=25125\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=151\001", + "8=FIX.4.2\0019=149\00135=b\00134=237\001369=170\00152=20150427-19:30:09." + "787\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "167\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "239\001", + "8=FIX.4.2\0019=220\00135=i\00134=171\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:10.547\00156=CME\00157=G\001142=US,NC\001117=168\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001133=25150\001135=1\0011028=N\0017928=bluestream\0019702=" + "1\0019771=TESTACC\00110=181\001", + "8=FIX.4.2\0019=149\00135=b\00134=238\001369=171\00152=20150427-19:30:10." + "570\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "168\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "224\001", + "8=FIX.4.2\0019=220\00135=i\00134=172\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:10.810\00156=CME\00157=G\001142=US,NC\001117=169\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001133=25125\001135=1\0011028=N\0017928=bluestream\0019702=" + "1\0019771=TESTACC\00110=178\001", + "8=FIX.4.2\0019=149\00135=b\00134=239\001369=172\00152=20150427-19:30:10." + "850\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "169\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "228\001", + "8=FIX.4.2\0019=220\00135=i\00134=173\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:11.344\00156=CME\00157=G\001142=US,NC\001117=170\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001133=25150\001135=1\0011028=N\0017928=bluestream\0019702=" + "1\0019771=TESTACC\00110=172\001", + "8=FIX.4.2\0019=149\00135=b\00134=240\001369=173\00152=20150427-19:30:11." + "373\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "170\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "214\001", + "8=FIX.4.2\0019=220\00135=i\00134=174\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:11.608\00156=CME\00157=G\001142=US,NC\001117=171\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001133=25125\001135=1\0011028=N\0017928=bluestream\0019702=" + "1\0019771=TESTACC\00110=179\001", + "8=FIX.4.2\0019=149\00135=b\00134=241\001369=174\00152=20150427-19:30:11." + "631\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "171\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "214\001", + "8=FIX.4.2\0019=220\00135=i\00134=175\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:11.872\00156=CME\00157=G\001142=US,NC\001117=172\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001133=25150\001135=1\0011028=N\0017928=bluestream\0019702=" + "1\0019771=TESTACC\00110=182\001", + "8=FIX.4.2\0019=149\00135=b\00134=242\001369=175\00152=20150427-19:30:11." + "897\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "172\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "231\001", + "8=FIX.4.2\0019=220\00135=i\00134=176\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:12.136\00156=CME\00157=G\001142=US,NC\001117=173\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25025\001134=1\0011028=N\0017928=bluestream\0019702=" + "1\0019771=TESTACC\00110=177\001", + "8=FIX.4.2\0019=149\00135=b\00134=243\001369=176\00152=20150427-19:30:12." + "161\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "173\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "219\001", + "8=FIX.4.2\0019=220\00135=i\00134=177\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:12.400\00156=CME\00157=G\001142=US,NC\001117=174\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25000\001134=1\0011028=N\0017928=bluestream\0019702=" + "1\0019771=TESTACC\00110=166\001", + "8=FIX.4.2\0019=149\00135=b\00134=244\001369=177\00152=20150427-19:30:12." + "428\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "174\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "228\001", + "8=FIX.4.2\0019=220\00135=i\00134=178\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:12.663\00156=CME\00157=G\001142=US,NC\001117=175\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001133=25125\001135=1\0011028=N\0017928=bluestream\0019702=" + "1\0019771=TESTACC\00110=189\001", + "8=FIX.4.2\0019=149\00135=b\00134=245\001369=178\00152=20150427-19:30:12." + "691\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "175\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "233\001", + "8=FIX.4.2\0019=236\00135=i\00134=179\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:12.927\00156=CME\00157=G\001142=US,NC\001117=176\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25025\001133=25150\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=160\001", + "8=FIX.4.2\0019=149\00135=b\00134=246\001369=179\00152=20150427-19:30:12." + "956\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "176\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "240\001", + "8=FIX.4.2\0019=236\00135=i\00134=180\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:13.191\00156=CME\00157=G\001142=US,NC\001117=177\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25000\001133=25125\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=142\001", + "8=FIX.4.2\0019=149\00135=b\00134=247\001369=180\00152=20150427-19:30:13." + "220\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "177\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "219\001", + "8=FIX.4.2\0019=236\00135=i\00134=181\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:13.718\00156=CME\00157=G\001142=US,NC\001117=178\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25025\001133=25150\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=154\001", + "8=FIX.4.2\0019=149\00135=b\00134=248\001369=181\00152=20150427-19:30:13." + "742\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "178\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "231\001", + "8=FIX.4.2\0019=220\00135=i\00134=182\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:13.982\00156=CME\00157=G\001142=US,NC\001117=179\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25000\001134=1\0011028=N\0017928=bluestream\0019702=" + "1\0019771=TESTACC\00110=183\001", + "8=FIX.4.2\0019=149\00135=b\00134=249\001369=182\00152=20150427-19:30:14." + "008\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "179\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "230\001", + "8=FIX.4.2\0019=220\00135=i\00134=183\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:14.246\00156=CME\00157=G\001142=US,NC\001117=180\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25025\001134=1\0011028=N\0017928=bluestream\0019702=" + "1\0019771=TESTACC\00110=177\001", + "8=FIX.4.2\0019=149\00135=b\00134=250\001369=183\00152=20150427-19:30:14." + "270\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "180\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "216\001", + "8=FIX.4.2\0019=220\00135=i\00134=184\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:14.509\00156=CME\00157=G\001142=US,NC\001117=181\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25000\001134=1\0011028=N\0017928=bluestream\0019702=" + "1\0019771=TESTACC\00110=174\001", + "8=FIX.4.2\0019=149\00135=b\00134=251\001369=184\00152=20150427-19:30:14." + "545\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "181\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "224\001", + "8=FIX.4.2\0019=220\00135=i\00134=185\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:14.773\00156=CME\00157=G\001142=US,NC\001117=182\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25025\001134=1\0011028=N\0017928=bluestream\0019702=" + "1\0019771=TESTACC\00110=186\001", + "8=FIX.4.2\0019=149\00135=b\00134=252\001369=185\00152=20150427-19:30:14." + "798\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "182\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "237\001", + "8=FIX.4.2\0019=220\00135=i\00134=186\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:15.037\00156=CME\00157=G\001142=US,NC\001117=183\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25050\001134=1\0011028=N\0017928=bluestream\0019702=" + "1\0019771=TESTACC\00110=180\001", + "8=FIX.4.2\0019=149\00135=b\00134=253\001369=186\00152=20150427-19:30:15." + "062\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "183\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "225\001", + "8=FIX.4.2\0019=236\00135=i\00134=187\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:15.301\00156=CME\00157=G\001142=US,NC\001117=184\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25075\001133=25175\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=159\001", + "8=FIX.4.2\0019=149\00135=b\00134=254\001369=187\00152=20150427-19:30:15." + "327\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "184\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "232\001", + "8=FIX.4.2\0019=236\00135=i\00134=188\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:15.564\00156=CME\00157=G\001142=US,NC\001117=185\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25100\001133=25200\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=150\001", + "8=FIX.4.2\0019=149\00135=b\00134=255\001369=188\00152=20150427-19:30:15." + "591\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "185\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "238\001", + "8=FIX.4.2\0019=134\00135=A\00134=189\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:42.013\00156=CME\00157=G\001142=US,NC\00195=3\00196=" + "1U7\00198=0\001108=30\0011603=O2\0011604=1.0\0011605=BTS\00110=105\001", + "8=FIX.4.2\0019=130\00135=A\00134=262\001369=189\00152=20150427-19:30:43." + "546\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00198=" + "0\001108=30\0011603=O2\0011604=1.0\0011605=BTS\00110=099\001", + "8=FIX.4.2\0019=95\00135=2\00134=190\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:43.574\00156=CME\00157=G\001142=US,NC\0017=256\00116=" + "0\00110=166\001", + "8=FIX.4.2\0019=107\00135=1\00134=263\001369=189\00152=20150427-19:30:43." + "546\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001112=" + "IDi8yfsl3z\00110=150\001", + "8=FIX.4.2\0019=167\00135=b\00134=256\001369=190\00152=20150427-19:30:43." + "597\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-" + "19:30:16.913\001143=US,NC\001117=CME1V2640\001297=4\0011028=N\0019772=" + "0\0019774=1V\0019775=A\00110=151\001", + "8=FIX.4.2\0019=167\00135=b\00134=257\001369=190\00152=20150427-19:30:43." + "598\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-" + "19:30:16.913\001143=US,NC\001117=CMEEW3116\001297=4\0011028=N\0019772=" + "0\0019774=EW\0019775=A\00110=194\001", + "8=FIX.4.2\0019=167\00135=b\00134=258\001369=190\00152=20150427-19:30:43." + "598\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-" + "19:30:16.913\001143=US,NC\001117=CMEEZ3452\001297=4\0011028=N\0019772=" + "1\0019774=EZ\0019775=A\00110=205\001", + "8=FIX.4.2\0019=166\00135=b\00134=259\001369=190\00152=20150427-19:30:43." + "598\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-" + "19:30:16.913\001143=US,NC\001117=CMET$126\001297=4\0011028=N\0019772=" + "0\0019774=T$\0019775=A\00110=073\001", + "8=FIX.4.2\0019=166\00135=b\00134=260\001369=190\00152=20150427-19:30:43." + "598\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-" + "19:30:16.913\001143=US,NC\001117=CMETE205\001297=4\0011028=N\0019772=" + "0\0019774=TE\0019775=A\00110=129\001", + "8=FIX.4.2\0019=166\00135=b\00134=261\001369=190\00152=20150427-19:30:43." + "598\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-" + "19:30:16.913\001143=US,NC\001117=CME96119\001297=4\0011028=N\0019772=" + "0\0019774=96\0019775=A\00110=050\001", + "8=FIX.4.2\0019=99\00135=0\00134=191\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:43.626\00156=CME\00157=G\001142=US,NC\001112=" + "IDi8yfsl3z\00110=043\001", + "8=FIX.4.2\0019=136\00135=4\00134=262\001369=190\00152=20150427-19:30:43." + "598\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001122=" + "20150427-19:30:43.598\001143=US,NC\00136=264\001123=Y\00110=173\001", + "8=FIX.4.2\0019=118\00135=Z\00134=192\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:43.668\00156=CME\00157=G\001142=US,NC\001117=189\001295=" + "1\00155=N/A\001298=4\0011028=N\00110=115\001", + "8=FIX.4.2\0019=128\00135=b\00134=264\001369=192\00152=20150427-19:30:43." + "741\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "189\001297=4\0011028=N\0019772=0\0019774=T$\00110=019\001", + "8=FIX.4.2\0019=128\00135=b\00134=265\001369=192\00152=20150427-19:30:43." + "741\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "189\001297=4\0011028=N\0019772=0\0019774=TE\00110=053\001", + "8=FIX.4.2\0019=128\00135=b\00134=266\001369=192\00152=20150427-19:30:43." + "743\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "189\001297=4\0011028=N\0019772=0\0019774=96\00110=014\001", + "8=FIX.4.2\0019=128\00135=b\00134=267\001369=192\00152=20150427-19:30:43." + "743\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "189\001297=4\0011028=N\0019772=0\0019774=1V\00110=039\001", + "8=FIX.4.2\0019=128\00135=b\00134=268\001369=192\00152=20150427-19:30:43." + "743\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "189\001297=4\0011028=N\0019772=0\0019774=EW\00110=061\001", + "8=FIX.4.2\0019=128\00135=b\00134=269\001369=192\00152=20150427-19:30:43." + "743\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "189\001297=4\0011028=N\0019772=0\0019774=EZ\00110=065\001", + "8=FIX.4.2\0019=236\00135=i\00134=193\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:51.684\00156=CME\00157=G\001142=US,NC\001117=190\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25025\001133=25150\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=155\001", + "8=FIX.4.2\0019=149\00135=b\00134=270\001369=193\00152=20150427-19:30:51." + "711\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "190\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "221\001", + "8=FIX.4.2\0019=220\00135=i\00134=194\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:51.821\00156=CME\00157=G\001142=US,NC\001117=191\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25050\001134=1\0011028=N\0017928=bluestream\0019702=" + "1\0019771=TESTACC\00110=179\001", + "8=FIX.4.2\0019=149\00135=b\00134=271\001369=194\00152=20150427-19:30:51." + "850\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "191\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "228\001", + "8=FIX.4.2\0019=236\00135=i\00134=195\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:51.956\00156=CME\00157=G\001142=US,NC\001117=192\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25075\001133=25175\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=173\001", + "8=FIX.4.2\0019=149\00135=b\00134=272\001369=195\00152=20150427-19:30:51." + "981\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "192\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "236\001", + "8=FIX.4.2\0019=236\00135=i\00134=196\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:52.220\00156=CME\00157=G\001142=US,NC\001117=193\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25100\001133=25200\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=138\001", + "8=FIX.4.2\0019=149\00135=b\00134=273\001369=196\00152=20150427-19:30:52." + "246\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "193\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "234\001", + "8=FIX.4.2\0019=236\00135=i\00134=197\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:52.484\00156=CME\00157=G\001142=US,NC\001117=194\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25075\001133=25225\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=170\001", + "8=FIX.4.2\0019=149\00135=b\00134=274\001369=197\00152=20150427-19:30:52." + "521\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "194\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "233\001", + "8=FIX.4.2\0019=236\00135=i\00134=198\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:52.747\00156=CME\00157=G\001142=US,NC\001117=195\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25100\001133=25200\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=156\001", + "8=FIX.4.2\0019=149\00135=b\00134=275\001369=198\00152=20150427-19:30:52." + "780\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "195\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "243\001", + "8=FIX.4.2\0019=236\00135=i\00134=199\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:53.011\00156=CME\00157=G\001142=US,NC\001117=196\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25075\001133=25175\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=165\001", + "8=FIX.4.2\0019=149\00135=b\00134=276\001369=199\00152=20150427-19:30:53." + "040\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "196\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "236\001", + "8=FIX.4.2\0019=236\00135=i\00134=200\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:53.275\00156=CME\00157=G\001142=US,NC\001117=197\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25100\001133=25200\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=139\001", + "8=FIX.4.2\0019=149\00135=b\00134=277\001369=200\00152=20150427-19:30:53." + "301\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "197\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "221\001", + "8=FIX.4.2\0019=236\00135=i\00134=201\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:53.538\00156=CME\00157=G\001142=US,NC\001117=198\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25125\001133=25225\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=157\001", + "8=FIX.4.2\0019=149\00135=b\00134=278\001369=201\00152=20150427-19:30:53." + "560\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "198\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "231\001", + "8=FIX.4.2\0019=236\00135=i\00134=202\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:53.802\00156=CME\00157=G\001142=US,NC\001117=199\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25100\001133=25250\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=144\001", + "8=FIX.4.2\0019=149\00135=b\00134=279\001369=202\00152=20150427-19:30:53." + "829\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "199\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "242\001", + "8=FIX.4.2\0019=236\00135=i\00134=203\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:54.066\00156=CME\00157=G\001142=US,NC\001117=200\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25075\001133=25225\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=144\001", + "8=FIX.4.2\0019=149\00135=b\00134=280\001369=203\00152=20150427-19:30:54." + "094\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "200\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "213\001", + "8=FIX.4.2\0019=236\00135=i\00134=204\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:54.329\00156=CME\00157=G\001142=US,NC\001117=201\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25100\001133=25250\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=135\001", + "8=FIX.4.2\0019=149\00135=b\00134=281\001369=204\00152=20150427-19:30:54." + "357\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "201\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "218\001", + "8=FIX.4.2\0019=236\00135=i\00134=205\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:54.593\00156=CME\00157=G\001142=US,NC\001117=202\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25125\001133=25225\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=149\001", + "8=FIX.4.2\0019=149\00135=b\00134=282\001369=205\00152=20150427-19:30:54." + "620\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "202\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "214\001", + "8=FIX.4.2\0019=236\00135=i\00134=206\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:54.857\00156=CME\00157=G\001142=US,NC\001117=203\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25100\001133=25250\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=145\001", + "8=FIX.4.2\0019=149\00135=b\00134=283\001369=206\00152=20150427-19:30:54." + "900\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "203\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "218\001", + "8=FIX.4.2\0019=236\00135=i\00134=207\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:55.120\00156=CME\00157=G\001142=US,NC\001117=204\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25075\001133=25225\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=144\001", + "8=FIX.4.2\0019=149\00135=b\00134=284\001369=207\00152=20150427-19:30:55." + "148\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "204\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "226\001", + "8=FIX.4.2\0019=236\00135=i\00134=208\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:55.384\00156=CME\00157=G\001142=US,NC\001117=205\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25050\001133=25200\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=144\001", + "8=FIX.4.2\0019=149\00135=b\00134=285\001369=208\00152=20150427-19:30:55." + "438\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "205\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "231\001", + "8=FIX.4.2\0019=236\00135=i\00134=209\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:55.647\00156=CME\00157=G\001142=US,NC\001117=206\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25025\001133=25175\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=161\001", + "8=FIX.4.2\0019=149\00135=b\00134=286\001369=209\00152=20150427-19:30:55." + "671\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "206\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "233\001", + "8=FIX.4.2\0019=236\00135=i\00134=210\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:55.911\00156=CME\00157=G\001142=US,NC\001117=207\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25000\001133=25150\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=134\001", + "8=FIX.4.2\0019=149\00135=b\00134=287\001369=210\00152=20150427-19:30:55." + "937\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "207\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "232\001", + "8=FIX.4.2\0019=220\00135=i\00134=211\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:56.174\00156=CME\00157=G\001142=US,NC\001117=208\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001133=25175\001135=1\0011028=N\0017928=bluestream\0019702=" + "1\0019771=TESTACC\00110=184\001", + "8=FIX.4.2\0019=149\00135=b\00134=288\001369=211\00152=20150427-19:30:56." + "198\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "208\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "235\001", + "8=FIX.4.2\0019=236\00135=i\00134=212\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:56.438\00156=CME\00157=G\001142=US,NC\001117=209\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25025\001133=25200\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=146\001", + "8=FIX.4.2\0019=149\00135=b\00134=289\001369=212\00152=20150427-19:30:56." + "461\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "209\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "231\001", + "8=FIX.4.2\0019=236\00135=i\00134=213\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:56.701\00156=CME\00157=G\001142=US,NC\001117=210\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25050\001133=25225\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=137\001", + "8=FIX.4.2\0019=149\00135=b\00134=290\001369=213\00152=20150427-19:30:56." + "726\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "210\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "220\001", + "8=FIX.4.2\0019=236\00135=i\00134=214\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:56.965\00156=CME\00157=G\001142=US,NC\001117=211\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25075\001133=25250\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=156\001", + "8=FIX.4.2\0019=149\00135=b\00134=291\001369=214\00152=20150427-19:30:56." + "993\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "211\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "229\001", + "8=FIX.4.2\0019=236\00135=i\00134=215\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:57.228\00156=CME\00157=G\001142=US,NC\001117=212\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25100\001133=25225\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=142\001", + "8=FIX.4.2\0019=149\00135=b\00134=292\001369=215\00152=20150427-19:30:57." + "253\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "212\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "222\001", + "8=FIX.4.2\0019=236\00135=i\00134=216\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:57.492\00156=CME\00157=G\001142=US,NC\001117=213\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25075\001133=25200\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=151\001", + "8=FIX.4.2\0019=149\00135=b\00134=293\001369=216\00152=20150427-19:30:57." + "523\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "213\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "225\001", + "8=FIX.4.2\0019=236\00135=i\00134=217\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:57.756\00156=CME\00157=G\001142=US,NC\001117=214\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25050\001133=25225\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=156\001", + "8=FIX.4.2\0019=149\00135=b\00134=294\001369=217\00152=20150427-19:30:57." + "782\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "214\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "235\001", + "8=FIX.4.2\0019=236\00135=i\00134=218\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:58.019\00156=CME\00157=G\001142=US,NC\001117=215\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25075\001133=25250\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=156\001", + "8=FIX.4.2\0019=149\00135=b\00134=295\001369=218\00152=20150427-19:30:58." + "070\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "215\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "229\001", + "8=FIX.4.2\0019=236\00135=i\00134=219\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:58.283\00156=CME\00157=G\001142=US,NC\001117=216\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25100\001133=25275\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=157\001", + "8=FIX.4.2\0019=149\00135=b\00134=296\001369=219\00152=20150427-19:30:58." + "311\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "216\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "230\001", + "8=FIX.4.2\0019=236\00135=i\00134=220\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:58.546\00156=CME\00157=G\001142=US,NC\001117=217\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25075\001133=25250\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=156\001", + "8=FIX.4.2\0019=149\00135=b\00134=297\001369=220\00152=20150427-19:30:58." + "572\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "217\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "233\001", + "8=FIX.4.2\0019=236\00135=i\00134=221\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:30:58.810\00156=CME\00157=G\001142=US,NC\001117=218\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25100\001133=25225\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=143\001", + "8=FIX.4.2\0019=149\00135=b\00134=298\001369=221\00152=20150427-19:30:58." + "833\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "218\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "236\001", + "8=FIX.4.2\0019=134\00135=A\00134=222\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:09.591\00156=CME\00157=G\001142=US,NC\00195=3\00196=" + "1U7\00198=0\001108=30\0011603=O2\0011604=1.0\0011605=BTS\00110=108\001", + "8=FIX.4.2\0019=130\00135=A\00134=305\001369=222\00152=20150427-19:31:11." + "204\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00198=" + "0\001108=30\0011603=O2\0011604=1.0\0011605=BTS\00110=072\001", + "8=FIX.4.2\0019=95\00135=2\00134=223\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:11.231\00156=CME\00157=G\001142=US,NC\0017=299\00116=" + "0\00110=156\001", + "8=FIX.4.2\0019=107\00135=1\00134=306\001369=222\00152=20150427-19:31:11." + "204\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001112=" + "IDi8yfsl40\00110=050\001", + "8=FIX.4.2\0019=118\00135=Z\00134=224\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:11.248\00156=CME\00157=G\001142=US,NC\001117=222\001295=" + "1\00155=N/A\001298=4\0011028=N\00110=089\001", + "8=FIX.4.2\0019=166\00135=b\00134=299\001369=223\00152=20150427-19:31:11." + "253\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-" + "19:31:00.082\001143=US,NC\001117=CMET$127\001297=4\0011028=N\0019772=" + "0\0019774=T$\0019775=A\00110=050\001", + "8=FIX.4.2\0019=166\00135=b\00134=300\001369=223\00152=20150427-19:31:11." + "253\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-" + "19:31:00.082\001143=US,NC\001117=CMETE206\001297=4\0011028=N\0019772=" + "0\0019774=TE\0019775=A\00110=097\001", + "8=FIX.4.2\0019=166\00135=b\00134=301\001369=223\00152=20150427-19:31:11." + "253\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-" + "19:31:00.090\001143=US,NC\001117=CME96120\001297=4\0011028=N\0019772=" + "0\0019774=96\0019775=A\00110=008\001", + "8=FIX.4.2\0019=167\00135=b\00134=302\001369=223\00152=20150427-19:31:11." + "253\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-" + "19:31:00.094\001143=US,NC\001117=CME1V2641\001297=4\0011028=N\0019772=" + "0\0019774=1V\0019775=A\00110=120\001", + "8=FIX.4.2\0019=167\00135=b\00134=303\001369=223\00152=20150427-19:31:11." + "253\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-" + "19:31:00.094\001143=US,NC\001117=CMEEW3117\001297=4\0011028=N\0019772=" + "0\0019774=EW\0019775=A\00110=162\001", + "8=FIX.4.2\0019=167\00135=b\00134=304\001369=223\00152=20150427-19:31:11." + "253\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-" + "19:31:00.094\001143=US,NC\001117=CMEEZ3453\001297=4\0011028=N\0019772=" + "1\0019774=EZ\0019775=A\00110=173\001", + "8=FIX.4.2\0019=99\00135=0\00134=225\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:11.329\00156=CME\00157=G\001142=US,NC\001112=" + "IDi8yfsl40\00110=220\001", + "8=FIX.4.2\0019=136\00135=4\00134=305\001369=223\00152=20150427-19:31:11." + "253\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001122=" + "20150427-19:31:11.253\001143=US,NC\00136=307\001123=Y\00110=134\001", + "8=FIX.4.2\0019=128\00135=b\00134=307\001369=224\00152=20150427-19:31:11." + "301\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "222\001297=4\0011028=N\0019772=0\0019774=T$\00110=245\001", + "8=FIX.4.2\0019=128\00135=b\00134=308\001369=224\00152=20150427-19:31:11." + "301\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "222\001297=4\0011028=N\0019772=0\0019774=TE\00110=023\001", + "8=FIX.4.2\0019=128\00135=b\00134=309\001369=224\00152=20150427-19:31:11." + "301\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "222\001297=4\0011028=N\0019772=0\0019774=1V\00110=006\001", + "8=FIX.4.2\0019=128\00135=b\00134=310\001369=224\00152=20150427-19:31:11." + "301\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "222\001297=4\0011028=N\0019772=0\0019774=EW\00110=019\001", + "8=FIX.4.2\0019=128\00135=b\00134=311\001369=224\00152=20150427-19:31:11." + "301\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "222\001297=4\0011028=N\0019772=0\0019774=EZ\00110=023\001", + "8=FIX.4.2\0019=128\00135=b\00134=312\001369=224\00152=20150427-19:31:11." + "305\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "222\001297=4\0011028=N\0019772=0\0019774=96\00110=236\001", + "8=FIX.4.2\0019=236\00135=i\00134=226\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:17.560\00156=CME\00157=G\001142=US,NC\001117=223\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25050\001133=25300\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=140\001", + "8=FIX.4.2\0019=149\00135=b\00134=313\001369=226\00152=20150427-19:31:17." + "591\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "223\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "222\001", + "8=FIX.4.2\0019=236\00135=i\00134=227\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:17.691\00156=CME\00157=G\001142=US,NC\001117=224\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25075\001133=25325\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=161\001", + "8=FIX.4.2\0019=149\00135=b\00134=314\001369=227\00152=20150427-19:31:17." + "722\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "224\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "221\001", + "8=FIX.4.2\0019=236\00135=i\00134=228\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:17.813\00156=CME\00157=G\001142=US,NC\001117=225\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25100\001133=25300\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=141\001", + "8=FIX.4.2\0019=149\00135=b\00134=315\001369=228\00152=20150427-19:31:17." + "860\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "225\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "227\001", + "8=FIX.4.2\0019=236\00135=i\00134=229\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:18.084\00156=CME\00157=G\001142=US,NC\001117=226\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25075\001133=25325\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=162\001", + "8=FIX.4.2\0019=149\00135=b\00134=316\001369=229\00152=20150427-19:31:18." + "292\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "226\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "230\001", + "8=FIX.4.2\0019=236\00135=i\00134=230\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:18.392\00156=CME\00157=G\001142=US,NC\001117=227\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25050\001133=25350\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=148\001", + "8=FIX.4.2\0019=149\00135=b\00134=317\001369=230\00152=20150427-19:31:18." + "421\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "227\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "218\001", + "8=FIX.4.2\0019=236\00135=i\00134=231\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:18.612\00156=CME\00157=G\001142=US,NC\001117=228\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25025\001133=25325\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=149\001", + "8=FIX.4.2\0019=149\00135=b\00134=318\001369=231\00152=20150427-19:31:18." + "641\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "228\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "225\001", + "8=FIX.4.2\0019=236\00135=i\00134=232\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:18.876\00156=CME\00157=G\001142=US,NC\001117=229\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25050\001133=25350\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=159\001", + "8=FIX.4.2\0019=149\00135=b\00134=319\001369=232\00152=20150427-19:31:18." + "932\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "229\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "231\001", + "8=FIX.4.2\0019=236\00135=i\00134=233\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:19.140\00156=CME\00157=G\001142=US,NC\001117=230\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25025\001133=25325\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=141\001", + "8=FIX.4.2\0019=149\00135=b\00134=320\001369=233\00152=20150427-19:31:19." + "164\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "230\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "214\001", + "8=FIX.4.2\0019=236\00135=i\00134=234\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:19.404\00156=CME\00157=G\001142=US,NC\001117=231\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25000\001133=25300\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=132\001", + "8=FIX.4.2\0019=149\00135=b\00134=321\001369=234\00152=20150427-19:31:19." + "432\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "231\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "215\001", + "8=FIX.4.2\0019=236\00135=i\00134=235\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:19.667\00156=CME\00157=G\001142=US,NC\001117=232\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25025\001133=25275\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=163\001", + "8=FIX.4.2\0019=149\00135=b\00134=322\001369=235\00152=20150427-19:31:19." + "696\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "232\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "230\001", + "8=FIX.4.2\0019=236\00135=i\00134=236\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:19.930\00156=CME\00157=G\001142=US,NC\001117=233\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25050\001133=25300\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=145\001", + "8=FIX.4.2\0019=149\00135=b\00134=323\001369=236\00152=20150427-19:31:19." + "963\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "233\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "230\001", + "8=FIX.4.2\0019=236\00135=i\00134=237\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:20.192\00156=CME\00157=G\001142=US,NC\001117=234\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25025\001133=25275\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=152\001", + "8=FIX.4.2\0019=149\00135=b\00134=324\001369=237\00152=20150427-19:31:20." + "221\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "234\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "212\001", + "8=FIX.4.2\0019=236\00135=i\00134=238\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:20.454\00156=CME\00157=G\001142=US,NC\001117=235\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25050\001133=25300\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=142\001", + "8=FIX.4.2\0019=149\00135=b\00134=325\001369=238\00152=20150427-19:31:20." + "482\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "235\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "224\001", + "8=FIX.4.2\0019=236\00135=i\00134=239\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:20.717\00156=CME\00157=G\001142=US,NC\001117=236\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25025\001133=25325\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=155\001", + "8=FIX.4.2\0019=149\00135=b\00134=326\001369=239\00152=20150427-19:31:20." + "740\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "236\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "224\001", + "8=FIX.4.2\0019=236\00135=i\00134=240\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:20.979\00156=CME\00157=G\001142=US,NC\001117=237\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25050\001133=25300\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=149\001", + "8=FIX.4.2\0019=149\00135=b\00134=327\001369=240\00152=20150427-19:31:21." + "006\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "237\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "214\001", + "8=FIX.4.2\0019=236\00135=i\00134=241\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:21.242\00156=CME\00157=G\001142=US,NC\001117=238\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25025\001133=25325\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=144\001", + "8=FIX.4.2\0019=149\00135=b\00134=328\001369=241\00152=20150427-19:31:21." + "271\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "238\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "221\001", + "8=FIX.4.2\0019=236\00135=i\00134=242\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:21.505\00156=CME\00157=G\001142=US,NC\001117=239\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25050\001133=25300\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=139\001", + "8=FIX.4.2\0019=149\00135=b\00134=329\001369=242\00152=20150427-19:31:21." + "561\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "239\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "226\001", + "8=FIX.4.2\0019=236\00135=i\00134=243\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:21.769\00156=CME\00157=G\001142=US,NC\001117=240\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25075\001133=25275\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=162\001", + "8=FIX.4.2\0019=149\00135=b\00134=330\001369=243\00152=20150427-19:31:21." + "826\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "240\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "215\001", + "8=FIX.4.2\0019=236\00135=i\00134=244\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:22.033\00156=CME\00157=G\001142=US,NC\001117=241\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25100\001133=25250\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=131\001", + "8=FIX.4.2\0019=149\00135=b\00134=331\001369=244\00152=20150427-19:31:22." + "057\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "241\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "215\001", + "8=FIX.4.2\0019=236\00135=i\00134=245\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:22.299\00156=CME\00157=G\001142=US,NC\001117=242\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25125\001133=25225\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=156\001", + "8=FIX.4.2\0019=149\00135=b\00134=332\001369=245\00152=20150427-19:31:22." + "326\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "242\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "217\001", + "8=FIX.4.2\0019=236\00135=i\00134=246\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:22.565\00156=CME\00157=G\001142=US,NC\001117=243\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25100\001133=25250\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=145\001", + "8=FIX.4.2\0019=149\00135=b\00134=333\001369=246\00152=20150427-19:31:22." + "591\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "243\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "224\001", + "8=FIX.4.2\0019=236\00135=i\00134=247\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:22.829\00156=CME\00157=G\001142=US,NC\001117=244\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25075\001133=25275\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=168\001", + "8=FIX.4.2\0019=149\00135=b\00134=334\001369=247\00152=20150427-19:31:22." + "865\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "244\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "231\001", + "8=FIX.4.2\0019=236\00135=i\00134=248\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:23.093\00156=CME\00157=G\001142=US,NC\001117=245\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25050\001133=25250\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=150\001", + "8=FIX.4.2\0019=149\00135=b\00134=335\001369=248\00152=20150427-19:31:23." + "123\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "245\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "222\001", + "8=FIX.4.2\0019=236\00135=i\00134=249\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:23.357\00156=CME\00157=G\001142=US,NC\001117=246\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25075\001133=25275\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=169\001", + "8=FIX.4.2\0019=149\00135=b\00134=336\001369=249\00152=20150427-19:31:23." + "381\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "246\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "231\001", + "8=FIX.4.2\0019=236\00135=i\00134=250\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:23.620\00156=CME\00157=G\001142=US,NC\001117=247\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25050\001133=25300\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=137\001", + "8=FIX.4.2\0019=149\00135=b\00134=337\001369=250\00152=20150427-19:31:23." + "651\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "247\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "225\001", + "8=FIX.4.2\0019=236\00135=i\00134=251\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:23.884\00156=CME\00157=G\001142=US,NC\001117=248\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25025\001133=25325\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=160\001", + "8=FIX.4.2\0019=149\00135=b\00134=338\001369=251\00152=20150427-19:31:23." + "964\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "248\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "235\001", + "8=FIX.4.2\0019=236\00135=i\00134=252\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:24.148\00156=CME\00157=G\001142=US,NC\001117=249\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25050\001133=25350\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=152\001", + "8=FIX.4.2\0019=149\00135=b\00134=339\001369=252\00152=20150427-19:31:24." + "183\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "249\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "232\001", + "8=FIX.4.2\0019=236\00135=i\00134=253\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:24.411\00156=CME\00157=G\001142=US,NC\001117=250\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25025\001133=25325\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=142\001", + "8=FIX.4.2\0019=149\00135=b\00134=340\001369=253\00152=20150427-19:31:24." + "467\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "250\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "222\001", + "8=FIX.4.2\0019=236\00135=i\00134=254\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:24.675\00156=CME\00157=G\001142=US,NC\001117=251\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25000\001133=25300\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=142\001", + "8=FIX.4.2\0019=149\00135=b\00134=341\001369=254\00152=20150427-19:31:24." + "703\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "251\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "218\001", + "8=FIX.4.2\0019=236\00135=i\00134=255\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:24.939\00156=CME\00157=G\001142=US,NC\001117=252\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25025\001133=25325\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=161\001", + "8=FIX.4.2\0019=149\00135=b\00134=342\001369=255\00152=20150427-19:31:24." + "965\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "252\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "231\001", + "8=FIX.4.2\0019=236\00135=i\00134=256\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:25.203\00156=CME\00157=G\001142=US,NC\001117=253\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25050\001133=25300\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=139\001", + "8=FIX.4.2\0019=149\00135=b\00134=343\001369=256\00152=20150427-19:31:25." + "234\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "253\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "224\001", + "8=FIX.4.2\0019=236\00135=i\00134=257\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:25.467\00156=CME\00157=G\001142=US,NC\001117=254\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25025\001133=25325\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=162\001", + "8=FIX.4.2\0019=149\00135=b\00134=344\001369=257\00152=20150427-19:31:25." + "497\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "254\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "238\001", + "8=FIX.4.2\0019=236\00135=i\00134=258\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:25.730\00156=CME\00157=G\001142=US,NC\001117=255\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25000\001133=25300\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=143\001", + "8=FIX.4.2\0019=149\00135=b\00134=345\001369=258\00152=20150427-19:31:25." + "767\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "255\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "241\001", + "8=FIX.4.2\0019=220\00135=i\00134=259\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:25.994\00156=CME\00157=G\001142=US,NC\001117=256\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001133=25325\001135=1\0011028=N\0017928=bluestream\0019702=" + "1\0019771=TESTACC\00110=203\001", + "8=FIX.4.2\0019=149\00135=b\00134=346\001369=259\00152=20150427-19:31:26." + "017\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "256\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "233\001", + "8=FIX.4.2\0019=236\00135=i\00134=260\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:26.257\00156=CME\00157=G\001142=US,NC\001117=257\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25025\001133=25300\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=150\001", + "8=FIX.4.2\0019=149\00135=b\00134=347\001369=260\00152=20150427-19:31:26." + "297\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "257\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "237\001", + "8=FIX.4.2\0019=236\00135=i\00134=261\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:26.521\00156=CME\00157=G\001142=US,NC\001117=258\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25000\001133=25325\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=146\001", + "8=FIX.4.2\0019=149\00135=b\00134=348\001369=261\00152=20150427-19:31:26." + "551\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "258\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "233\001", + "8=FIX.4.2\0019=236\00135=i\00134=262\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:26.785\00156=CME\00157=G\001142=US,NC\001117=259\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25025\001133=25350\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=165\001", + "8=FIX.4.2\0019=149\00135=b\00134=349\001369=262\00152=20150427-19:31:26." + "819\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "259\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "243\001", + "8=FIX.4.2\0019=236\00135=i\00134=263\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:27.049\00156=CME\00157=G\001142=US,NC\001117=260\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25000\001133=25375\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=152\001", + "8=FIX.4.2\0019=149\00135=b\00134=350\001369=263\00152=20150427-19:31:27." + "077\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "260\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "225\001", + "8=FIX.4.2\0019=220\00135=i\00134=264\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:27.312\00156=CME\00157=G\001142=US,NC\001117=261\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001133=25400\001135=1\0011028=N\0017928=bluestream\0019702=" + "1\0019771=TESTACC\00110=175\001", + "8=FIX.4.2\0019=149\00135=b\00134=351\001369=264\00152=20150427-19:31:27." + "336\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "261\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "226\001", + "8=FIX.4.2\0019=220\00135=i\00134=265\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:27.576\00156=CME\00157=G\001142=US,NC\001117=262\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001133=25375\001135=1\0011028=N\0017928=bluestream\0019702=" + "1\0019771=TESTACC\00110=200\001", + "8=FIX.4.2\0019=149\00135=b\00134=352\001369=265\00152=20150427-19:31:27." + "602\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "262\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "225\001", + "8=FIX.4.2\0019=220\00135=i\00134=266\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:27.839\00156=CME\00157=G\001142=US,NC\001117=263\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001133=25400\001135=1\0011028=N\0017928=bluestream\0019702=" + "1\0019771=TESTACC\00110=193\001", + "8=FIX.4.2\0019=149\00135=b\00134=353\001369=266\00152=20150427-19:31:27." + "868\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "263\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "242\001", + "8=FIX.4.2\0019=236\00135=i\00134=267\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:28.103\00156=CME\00157=G\001142=US,NC\001117=264\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25025\001133=25425\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=155\001", + "8=FIX.4.2\0019=149\00135=b\00134=354\001369=267\00152=20150427-19:31:28." + "130\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "264\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "228\001", + "8=FIX.4.2\0019=236\00135=i\00134=268\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:28.366\00156=CME\00157=G\001142=US,NC\001117=265\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25050\001133=25450\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=164\001", + "8=FIX.4.2\0019=149\00135=b\00134=355\001369=268\00152=20150427-19:31:28." + "394\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "265\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "243\001", + "8=FIX.4.2\0019=236\00135=i\00134=269\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:28.630\00156=CME\00157=G\001142=US,NC\001117=266\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25075\001133=25425\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=169\001", + "8=FIX.4.2\0019=149\00135=b\00134=356\001369=269\00152=20150427-19:31:28." + "658\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "266\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "249\001", + "8=FIX.4.2\0019=236\00135=i\00134=270\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:28.894\00156=CME\00157=G\001142=US,NC\001117=267\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25100\001133=25450\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=161\001", + "8=FIX.4.2\0019=149\00135=b\00134=357\001369=270\00152=20150427-19:31:28." + "920\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "267\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "235\001", + "8=FIX.4.2\0019=236\00135=i\00134=271\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:29.157\00156=CME\00157=G\001142=US,NC\001117=268\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25125\001133=25425\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=165\001", + "8=FIX.4.2\0019=149\00135=b\00134=358\001369=271\00152=20150427-19:31:29." + "182\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "268\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "239\001", + "8=FIX.4.2\0019=236\00135=i\00134=272\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:29.421\00156=CME\00157=G\001142=US,NC\001117=269\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25100\001133=25400\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=147\001", + "8=FIX.4.2\0019=149\00135=b\00134=359\001369=272\00152=20150427-19:31:29." + "455\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "269\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "245\001", + "8=FIX.4.2\0019=236\00135=i\00134=273\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:29.685\00156=CME\00157=G\001142=US,NC\001117=270\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25075\001133=25425\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=170\001", + "8=FIX.4.2\0019=149\00135=b\00134=360\001369=273\00152=20150427-19:31:29." + "711\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "270\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "225\001", + "8=FIX.4.2\0019=236\00135=i\00134=274\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:29.949\00156=CME\00157=G\001142=US,NC\001117=271\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25050\001133=25400\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=161\001", + "8=FIX.4.2\0019=149\00135=b\00134=361\001369=274\00152=20150427-19:31:29." + "987\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "271\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "243\001", + "8=FIX.4.2\0019=236\00135=i\00134=275\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:30.212\00156=CME\00157=G\001142=US,NC\001117=272\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25025\001133=25375\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=151\001", + "8=FIX.4.2\0019=149\00135=b\00134=362\001369=275\00152=20150427-19:31:30." + "236\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "272\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "225\001", + "8=FIX.4.2\0019=236\00135=i\00134=276\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:30.476\00156=CME\00157=G\001142=US,NC\001117=273\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25050\001133=25350\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=156\001", + "8=FIX.4.2\0019=149\00135=b\00134=363\001369=276\00152=20150427-19:31:30." + "521\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "273\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "225\001", + "8=FIX.4.2\0019=236\00135=i\00134=277\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:30.739\00156=CME\00157=G\001142=US,NC\001117=274\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25025\001133=25325\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=164\001", + "8=FIX.4.2\0019=149\00135=b\00134=364\001369=277\00152=20150427-19:31:30." + "764\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "274\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "237\001", + "8=FIX.4.2\0019=236\00135=i\00134=278\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:31.003\00156=CME\00157=G\001142=US,NC\001117=275\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25050\001133=25300\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=142\001", + "8=FIX.4.2\0019=149\00135=b\00134=365\001369=278\00152=20150427-19:31:31." + "032\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "275\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "229\001", + "8=FIX.4.2\0019=236\00135=i\00134=279\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:31.267\00156=CME\00157=G\001142=US,NC\001117=276\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25025\001133=25325\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=165\001", + "8=FIX.4.2\0019=149\00135=b\00134=366\001369=279\00152=20150427-19:31:31." + "293\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "276\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "241\001", + "8=FIX.4.2\0019=236\00135=i\00134=280\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:31.530\00156=CME\00157=G\001142=US,NC\001117=277\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25000\001133=25350\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=142\001", + "8=FIX.4.2\0019=149\00135=b\00134=367\001369=280\00152=20150427-19:31:31." + "562\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "277\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "234\001", + "8=FIX.4.2\0019=236\00135=i\00134=281\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:31.794\00156=CME\00157=G\001142=US,NC\001117=278\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25025\001133=25375\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=170\001", + "8=FIX.4.2\0019=149\00135=b\00134=368\001369=281\00152=20150427-19:31:31." + "822\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "278\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "236\001", + "8=FIX.4.2\0019=236\00135=i\00134=282\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:32.058\00156=CME\00157=G\001142=US,NC\001117=279\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25050\001133=25400\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=153\001", + "8=FIX.4.2\0019=149\00135=b\00134=369\001369=282\00152=20150427-19:31:32." + "083\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "279\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "239\001", + "8=FIX.4.2\0019=236\00135=i\00134=283\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:32.321\00156=CME\00157=G\001142=US,NC\001117=280\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25075\001133=25425\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=153\001", + "8=FIX.4.2\0019=149\00135=b\00134=370\001369=283\00152=20150427-19:31:32." + "356\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "280\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "227\001", + "8=FIX.4.2\0019=236\00135=i\00134=284\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:32.585\00156=CME\00157=G\001142=US,NC\001117=281\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25050\001133=25450\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=158\001", + "8=FIX.4.2\0019=149\00135=b\00134=371\001369=284\00152=20150427-19:31:32." + "617\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "281\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "230\001", + "8=FIX.4.2\0019=236\00135=i\00134=285\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:32.849\00156=CME\00157=G\001142=US,NC\001117=282\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25025\001133=25475\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=172\001", + "8=FIX.4.2\0019=149\00135=b\00134=372\001369=285\00152=20150427-19:31:32." + "873\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "282\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "237\001", + "8=FIX.4.2\0019=236\00135=i\00134=286\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:33.112\00156=CME\00157=G\001142=US,NC\001117=283\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25000\001133=25500\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=140\001", + "8=FIX.4.2\0019=149\00135=b\00134=373\001369=286\00152=20150427-19:31:33." + "137\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "283\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "234\001", + "8=FIX.4.2\0019=220\00135=i\00134=287\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:33.376\00156=CME\00157=G\001142=US,NC\001117=284\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25025\001134=1\0011028=N\0017928=bluestream\0019702=" + "1\0019771=TESTACC\00110=193\001", + "8=FIX.4.2\0019=149\00135=b\00134=374\001369=287\00152=20150427-19:31:33." + "437\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "284\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "240\001", + "8=FIX.4.2\0019=220\00135=i\00134=288\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:33.640\00156=CME\00157=G\001142=US,NC\001117=285\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25050\001134=1\0011028=N\0017928=bluestream\0019702=" + "1\0019771=TESTACC\00110=187\001", + "8=FIX.4.2\0019=149\00135=b\00134=375\001369=288\00152=20150427-19:31:33." + "667\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "285\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "248\001", + "8=FIX.4.2\0019=236\00135=i\00134=289\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:33.903\00156=CME\00157=G\001142=US,NC\001117=286\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25025\001133=25475\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=172\001", + "8=FIX.4.2\0019=149\00135=b\00134=376\001369=289\00152=20150427-19:31:33." + "927\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "286\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "250\001", + "8=FIX.4.2\0019=236\00135=i\00134=290\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:34.167\00156=CME\00157=G\001142=US,NC\001117=287\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25000\001133=25500\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=150\001", + "8=FIX.4.2\0019=149\00135=b\00134=377\001369=290\00152=20150427-19:31:34." + "193\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "287\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "240\001", + "8=FIX.4.2\0019=220\00135=i\00134=291\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:34.694\00156=CME\00157=G\001142=US,NC\001117=288\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001133=25525\001135=1\0011028=N\0017928=bluestream\0019702=" + "1\0019771=TESTACC\00110=203\001", + "8=FIX.4.2\0019=149\00135=b\00134=378\001369=291\00152=20150427-19:31:34." + "721\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "288\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "240\001", + "8=FIX.4.2\0019=236\00135=i\00134=292\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:34.962\00156=CME\00157=G\001142=US,NC\001117=289\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25025\001133=25550\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=169\001", + "8=FIX.4.2\0019=149\00135=b\00134=379\001369=292\00152=20150427-19:31:34." + "988\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "289\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "002\001", + "8=FIX.4.2\0019=236\00135=i\00134=293\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:31:35.229\00156=CME\00157=G\001142=US,NC\001117=290\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25000\001133=25575\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=159\001", + "8=FIX.4.2\0019=149\00135=b\00134=380\001369=293\00152=20150427-19:31:35." + "253\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "290\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "229\001", + "8=FIX.4.2\0019=134\00135=A\00134=294\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:55:10.917\00156=CME\00157=G\001142=US,NC\00195=3\00196=" + "1U7\00198=0\001108=30\0011603=O2\0011604=1.0\0011605=BTS\00110=117\001", + "8=FIX.4.2\0019=130\00135=A\00134=387\001369=294\00152=20150427-19:55:12." + "438\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00198=" + "0\001108=30\0011603=O2\0011604=1.0\0011605=BTS\00110=107\001", + "8=FIX.4.2\0019=95\00135=2\00134=295\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:55:12.466\00156=CME\00157=G\001142=US,NC\0017=381\00116=" + "0\00110=174\001", + "8=FIX.4.2\0019=107\00135=1\00134=388\001369=294\00152=20150427-19:55:12." + "439\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001112=" + "IDi8yfsl41\00110=087\001", + "8=FIX.4.2\0019=118\00135=Z\00134=296\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:55:12.472\00156=CME\00157=G\001142=US,NC\001117=294\001295=" + "1\00155=N/A\001298=4\0011028=N\00110=113\001", + "8=FIX.4.2\0019=166\00135=b\00134=381\001369=295\00152=20150427-19:55:12." + "488\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-" + "19:31:36.468\001143=US,NC\001117=CMET$128\001297=4\0011028=N\0019772=" + "0\0019774=T$\0019775=A\00110=086\001", + "8=FIX.4.2\0019=166\00135=b\00134=382\001369=295\00152=20150427-19:55:12." + "488\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-" + "19:31:36.468\001143=US,NC\001117=CMETE207\001297=4\0011028=N\0019772=" + "0\0019774=TE\0019775=A\00110=151\001", + "8=FIX.4.2\0019=167\00135=b\00134=383\001369=295\00152=20150427-19:55:12." + "488\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-" + "19:31:36.469\001143=US,NC\001117=CME1V2644\001297=4\0011028=N\0019772=" + "0\0019774=1V\0019775=A\00110=173\001", + "8=FIX.4.2\0019=167\00135=b\00134=384\001369=295\00152=20150427-19:55:12." + "488\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-" + "19:31:36.469\001143=US,NC\001117=CMEEW3120\001297=4\0011028=N\0019772=" + "0\0019774=EW\0019775=A\00110=206\001", + "8=FIX.4.2\0019=167\00135=b\00134=385\001369=295\00152=20150427-19:55:12." + "488\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-" + "19:31:36.470\001143=US,NC\001117=CMEEZ3456\001297=4\0011028=N\0019772=" + "1\0019774=EZ\0019775=A\00110=218\001", + "8=FIX.4.2\0019=166\00135=b\00134=386\001369=295\00152=20150427-19:55:12." + "488\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=ILINK\001122=20150427-" + "19:31:36.471\001143=US,NC\001117=CME96121\001297=4\0011028=N\0019772=" + "0\0019774=96\0019775=A\00110=060\001", + "8=FIX.4.2\0019=99\00135=0\00134=297\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:55:12.566\00156=CME\00157=G\001142=US,NC\001112=" + "IDi8yfsl41\00110=240\001", + "8=FIX.4.2\0019=136\00135=4\00134=387\001369=295\00152=20150427-19:55:12." + "488\00143=Y\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001122=" + "20150427-19:55:12.488\001143=US,NC\00136=389\001123=Y\00110=197\001", + "8=FIX.4.2\0019=128\00135=b\00134=389\001369=296\00152=20150427-19:55:12." + "533\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "294\001297=4\0011028=N\0019772=0\0019774=T$\00110=031\001", + "8=FIX.4.2\0019=128\00135=b\00134=390\001369=296\00152=20150427-19:55:12." + "533\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "294\001297=4\0011028=N\0019772=0\0019774=TE\00110=056\001", + "8=FIX.4.2\0019=128\00135=b\00134=391\001369=296\00152=20150427-19:55:12." + "538\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "294\001297=4\0011028=N\0019772=0\0019774=1V\00110=044\001", + "8=FIX.4.2\0019=128\00135=b\00134=392\001369=296\00152=20150427-19:55:12." + "538\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "294\001297=4\0011028=N\0019772=0\0019774=EW\00110=066\001", + "8=FIX.4.2\0019=128\00135=b\00134=393\001369=296\00152=20150427-19:55:12." + "538\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "294\001297=4\0011028=N\0019772=0\0019774=EZ\00110=070\001", + "8=FIX.4.2\0019=128\00135=b\00134=394\001369=296\00152=20150427-19:55:12." + "545\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "294\001297=4\0011028=N\0019772=0\0019774=96\00110=021\001", + "8=FIX.4.2\0019=92\00135=0\00134=395\001369=297\00152=20150427-19:55:42." + "582\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\00110=" + "009\001", + "8=FIX.4.2\0019=84\00135=0\00134=298\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:55:42.609\00156=CME\00157=G\001142=US,NC\00110=201\001", + "8=FIX.4.2\0019=236\00135=i\00134=299\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:08.053\00156=CME\00157=G\001142=US,NC\001117=295\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25125\001133=25500\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=168\001", + "8=FIX.4.2\0019=149\00135=b\00134=396\001369=299\00152=20150427-19:56:08." + "082\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "295\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "254\001", + "8=FIX.4.2\0019=236\00135=i\00134=300\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:08.179\00156=CME\00157=G\001142=US,NC\001117=296\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25150\001133=25525\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=166\001", + "8=FIX.4.2\0019=149\00135=b\00134=397\001369=300\00152=20150427-19:56:08." + "208\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "296\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "239\001", + "8=FIX.4.2\0019=236\00135=i\00134=301\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:08.279\00156=CME\00157=G\001142=US,NC\001117=297\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25125\001133=25500\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=164\001", + "8=FIX.4.2\0019=149\00135=b\00134=398\001369=301\00152=20150427-19:56:08." + "307\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "297\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "242\001", + "8=FIX.4.2\0019=236\00135=i\00134=302\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:08.487\00156=CME\00157=G\001142=US,NC\001117=298\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25100\001133=25525\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=167\001", + "8=FIX.4.2\0019=149\00135=b\00134=399\001369=302\00152=20150427-19:56:08." + "511\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "298\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "242\001", + "8=FIX.4.2\0019=236\00135=i\00134=303\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:08.751\00156=CME\00157=G\001142=US,NC\001117=299\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25075\001133=25550\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=172\001", + "8=FIX.4.2\0019=149\00135=b\00134=400\001369=303\00152=20150427-19:56:08." + "784\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "299\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "239\001", + "8=FIX.4.2\0019=236\00135=i\00134=304\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:09.014\00156=CME\00157=G\001142=US,NC\001117=300\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25100\001133=25575\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=145\001", + "8=FIX.4.2\0019=149\00135=b\00134=401\001369=304\00152=20150427-19:56:09." + "049\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "300\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "219\001", + "8=FIX.4.2\0019=236\00135=i\00134=305\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:09.278\00156=CME\00157=G\001142=US,NC\001117=301\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25075\001133=25550\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=163\001", + "8=FIX.4.2\0019=149\00135=b\00134=402\001369=305\00152=20150427-19:56:09." + "306\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "301\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "218\001", + "8=FIX.4.2\0019=236\00135=i\00134=306\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:09.542\00156=CME\00157=G\001142=US,NC\001117=302\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25050\001133=25575\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=159\001", + "8=FIX.4.2\0019=149\00135=b\00134=403\001369=306\00152=20150427-19:56:09." + "564\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "302\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "227\001", + "8=FIX.4.2\0019=236\00135=i\00134=307\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:09.805\00156=CME\00157=G\001142=US,NC\001117=303\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25075\001133=25550\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=163\001", + "8=FIX.4.2\0019=149\00135=b\00134=404\001369=307\00152=20150427-19:56:09." + "833\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "303\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "229\001", + "8=FIX.4.2\0019=236\00135=i\00134=308\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:10.069\00156=CME\00157=G\001142=US,NC\001117=304\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25050\001133=25575\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=159\001", + "8=FIX.4.2\0019=149\00135=b\00134=405\001369=308\00152=20150427-19:56:10." + "097\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "304\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "226\001", + "8=FIX.4.2\0019=236\00135=i\00134=309\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:10.332\00156=CME\00157=G\001142=US,NC\001117=305\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25025\001133=25600\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=145\001", + "8=FIX.4.2\0019=149\00135=b\00134=406\001369=309\00152=20150427-19:56:10." + "358\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "305\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "229\001", + "8=FIX.4.2\0019=236\00135=i\00134=310\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:10.595\00156=CME\00157=G\001142=US,NC\001117=306\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25000\001133=25625\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=149\001", + "8=FIX.4.2\0019=149\00135=b\00134=407\001369=310\00152=20150427-19:56:10." + "622\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "306\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "217\001", + "8=FIX.4.2\0019=220\00135=i\00134=311\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:10.859\00156=CME\00157=G\001142=US,NC\001117=307\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001133=25600\001135=1\0011028=N\0017928=bluestream\0019702=" + "1\0019771=TESTACC\00110=186\001", + "8=FIX.4.2\0019=149\00135=b\00134=408\001369=311\00152=20150427-19:56:10." + "886\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "307\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "232\001", + "8=FIX.4.2\0019=220\00135=i\00134=312\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:11.123\00156=CME\00157=G\001142=US,NC\001117=308\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001133=25575\001135=1\0011028=N\0017928=bluestream\0019702=" + "1\0019771=TESTACC\00110=184\001", + "8=FIX.4.2\0019=149\00135=b\00134=409\001369=312\00152=20150427-19:56:11." + "160\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "308\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "221\001", + "8=FIX.4.2\0019=236\00135=i\00134=313\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:11.386\00156=CME\00157=G\001142=US,NC\001117=309\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25025\001133=25550\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=158\001", + "8=FIX.4.2\0019=149\00135=b\00134=410\001369=313\00152=20150427-19:56:11." + "409\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "309\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "221\001", + "8=FIX.4.2\0019=236\00135=i\00134=314\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:11.650\00156=CME\00157=G\001142=US,NC\001117=310\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25000\001133=25525\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=140\001", + "8=FIX.4.2\0019=149\00135=b\00134=411\001369=314\00152=20150427-19:56:11." + "690\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "310\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "217\001", + "8=FIX.4.2\0019=220\00135=i\00134=315\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:11.914\00156=CME\00157=G\001142=US,NC\001117=311\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001133=25550\001135=1\0011028=N\0017928=bluestream\0019702=" + "1\0019771=TESTACC\00110=182\001", + "8=FIX.4.2\0019=149\00135=b\00134=412\001369=315\00152=20150427-19:56:11." + "936\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "311\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "223\001", + "8=FIX.4.2\0019=236\00135=i\00134=316\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:12.177\00156=CME\00157=G\001142=US,NC\001117=312\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25025\001133=25525\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=156\001", + "8=FIX.4.2\0019=149\00135=b\00134=413\001369=316\00152=20150427-19:56:12." + "213\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "312\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "215\001", + "8=FIX.4.2\0019=236\00135=i\00134=317\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:12.441\00156=CME\00157=G\001142=US,NC\001117=313\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25050\001133=25500\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=143\001", + "8=FIX.4.2\0019=149\00135=b\00134=414\001369=317\00152=20150427-19:56:12." + "468\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "313\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "230\001", + "8=FIX.4.2\0019=236\00135=i\00134=318\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:12.705\00156=CME\00157=G\001142=US,NC\001117=314\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25025\001133=25525\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=157\001", + "8=FIX.4.2\0019=149\00135=b\00134=415\001369=318\00152=20150427-19:56:12." + "736\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "314\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "231\001", + "8=FIX.4.2\0019=236\00135=i\00134=319\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:12.968\00156=CME\00157=G\001142=US,NC\001117=315\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25050\001133=25550\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=166\001", + "8=FIX.4.2\0019=149\00135=b\00134=416\001369=319\00152=20150427-19:56:12." + "992\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "315\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "238\001", + "8=FIX.4.2\0019=236\00135=i\00134=320\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:13.232\00156=CME\00157=G\001142=US,NC\001117=316\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25025\001133=25575\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=153\001", + "8=FIX.4.2\0019=149\00135=b\00134=417\001369=320\00152=20150427-19:56:13." + "268\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "316\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "229\001", + "8=FIX.4.2\0019=236\00135=i\00134=321\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:13.496\00156=CME\00157=G\001142=US,NC\001117=317\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25050\001133=25550\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=158\001", + "8=FIX.4.2\0019=149\00135=b\00134=418\001369=321\00152=20150427-19:56:13." + "538\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "317\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "232\001", + "8=FIX.4.2\0019=236\00135=i\00134=322\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:13.759\00156=CME\00157=G\001142=US,NC\001117=318\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25025\001133=25525\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=166\001", + "8=FIX.4.2\0019=149\00135=b\00134=419\001369=322\00152=20150427-19:56:13." + "787\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "318\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "241\001", + "8=FIX.4.2\0019=236\00135=i\00134=323\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:14.021\00156=CME\00157=G\001142=US,NC\001117=319\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25000\001133=25550\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=142\001", + "8=FIX.4.2\0019=149\00135=b\00134=420\001369=323\00152=20150427-19:56:14." + "059\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "319\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "228\001", + "8=FIX.4.2\0019=220\00135=i\00134=324\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:14.284\00156=CME\00157=G\001142=US,NC\001117=320\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001133=25575\001135=1\0011028=N\0017928=bluestream\0019702=" + "1\0019771=TESTACC\00110=192\001", + "8=FIX.4.2\0019=149\00135=b\00134=421\001369=324\00152=20150427-19:56:14." + "312\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "320\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "214\001", + "8=FIX.4.2\0019=220\00135=i\00134=325\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:14.548\00156=CME\00157=G\001142=US,NC\001117=321\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001133=25550\001135=1\0011028=N\0017928=bluestream\0019702=" + "1\0019771=TESTACC\00110=190\001", + "8=FIX.4.2\0019=149\00135=b\00134=422\001369=325\00152=20150427-19:56:14." + "573\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "321\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "226\001", + "8=FIX.4.2\0019=220\00135=i\00134=326\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:14.811\00156=CME\00157=G\001142=US,NC\001117=322\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001133=25575\001135=1\0011028=N\0017928=bluestream\0019702=" + "1\0019771=TESTACC\00110=192\001", + "8=FIX.4.2\0019=149\00135=b\00134=423\001369=326\00152=20150427-19:56:14." + "839\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "322\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "234\001", + "8=FIX.4.2\0019=220\00135=i\00134=327\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:15.075\00156=CME\00157=G\001142=US,NC\001117=323\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001133=25600\001135=1\0011028=N\0017928=bluestream\0019702=" + "1\0019771=TESTACC\00110=186\001", + "8=FIX.4.2\0019=149\00135=b\00134=424\001369=327\00152=20150427-19:56:15." + "123\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "323\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "224\001", + "8=FIX.4.2\0019=236\00135=i\00134=328\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:15.339\00156=CME\00157=G\001142=US,NC\001117=324\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25025\001133=25575\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=170\001", + "8=FIX.4.2\0019=149\00135=b\00134=425\001369=328\00152=20150427-19:56:15." + "358\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "324\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "237\001", + "8=FIX.4.2\0019=236\00135=i\00134=329\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:15.603\00156=CME\00157=G\001142=US,NC\001117=325\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25050\001133=25550\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=157\001", + "8=FIX.4.2\0019=149\00135=b\00134=426\001369=329\00152=20150427-19:56:15." + "623\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "325\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "235\001", + "8=FIX.4.2\0019=236\00135=i\00134=330\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:15.866\00156=CME\00157=G\001142=US,NC\001117=326\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25025\001133=25525\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=165\001", + "8=FIX.4.2\0019=149\00135=b\00134=427\001369=330\00152=20150427-19:56:15." + "896\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "326\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "241\001", + "8=FIX.4.2\0019=236\00135=i\00134=331\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:16.130\00156=CME\00157=G\001142=US,NC\001117=327\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25050\001133=25500\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=143\001", + "8=FIX.4.2\0019=149\00135=b\00134=428\001369=331\00152=20150427-19:56:16." + "153\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "327\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "231\001", + "8=FIX.4.2\0019=220\00135=i\00134=332\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:16.393\00156=CME\00157=G\001142=US,NC\001117=328\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25075\001134=1\0011028=N\0017928=bluestream\0019702=" + "1\0019771=TESTACC\00110=195\001", + "8=FIX.4.2\0019=149\00135=b\00134=429\001369=332\00152=20150427-19:56:16." + "418\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "328\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "238\001", + "8=FIX.4.2\0019=236\00135=i\00134=333\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:16.657\00156=CME\00157=G\001142=US,NC\001117=329\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25100\001133=25475\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=168\001", + "8=FIX.4.2\0019=149\00135=b\00134=430\001369=333\00152=20150427-19:56:16." + "687\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "329\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "240\001", + "8=FIX.4.2\0019=236\00135=i\00134=334\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:16.921\00156=CME\00157=G\001142=US,NC\001117=330\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25075\001133=25500\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=155\001", + "8=FIX.4.2\0019=149\00135=b\00134=431\001369=334\00152=20150427-19:56:16." + "943\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "330\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "229\001", + "8=FIX.4.2\0019=236\00135=i\00134=335\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:17.185\00156=CME\00157=G\001142=US,NC\001117=331\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25050\001133=25475\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=164\001", + "8=FIX.4.2\0019=149\00135=b\00134=432\001369=335\00152=20150427-19:56:17." + "209\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "331\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "228\001", + "8=FIX.4.2\0019=236\00135=i\00134=336\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:17.448\00156=CME\00157=G\001142=US,NC\001117=332\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25025\001133=25450\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=163\001", + "8=FIX.4.2\0019=149\00135=b\00134=433\001369=336\00152=20150427-19:56:17." + "477\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "332\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "238\001", + "8=FIX.4.2\0019=236\00135=i\00134=337\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:17.712\00156=CME\00157=G\001142=US,NC\001117=333\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25000\001133=25425\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=154\001", + "8=FIX.4.2\0019=149\00135=b\00134=434\001369=337\00152=20150427-19:56:17." + "737\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "333\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "240\001", + "8=FIX.4.2\0019=220\00135=i\00134=338\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:17.976\00156=CME\00157=G\001142=US,NC\001117=334\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001133=25400\001135=1\0011028=N\0017928=bluestream\0019702=" + "1\0019771=TESTACC\00110=200\001", + "8=FIX.4.2\0019=149\00135=b\00134=435\001369=338\00152=20150427-19:56:18." + "029\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "334\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "238\001", + "8=FIX.4.2\0019=236\00135=i\00134=339\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:18.239\00156=CME\00157=G\001142=US,NC\001117=335\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25025\001133=25375\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=174\001", + "8=FIX.4.2\0019=149\00135=b\00134=436\001369=339\00152=20150427-19:56:18." + "267\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "335\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "245\001", + "8=FIX.4.2\0019=236\00135=i\00134=340\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:18.503\00156=CME\00157=G\001142=US,NC\001117=336\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25050\001133=25400\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=148\001", + "8=FIX.4.2\0019=149\00135=b\00134=437\001369=340\00152=20150427-19:56:18." + "527\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "336\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "238\001", + "8=FIX.4.2\0019=236\00135=i\00134=341\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:18.767\00156=CME\00157=G\001142=US,NC\001117=337\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25025\001133=25375\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=175\001", + "8=FIX.4.2\0019=149\00135=b\00134=438\001369=341\00152=20150427-19:56:18." + "790\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "337\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "243\001", + "8=FIX.4.2\0019=236\00135=i\00134=342\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:19.029\00156=CME\00157=G\001142=US,NC\001117=338\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25050\001133=25350\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=160\001", + "8=FIX.4.2\0019=149\00135=b\00134=439\001369=342\00152=20150427-19:56:19." + "052\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "338\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "238\001", + "8=FIX.4.2\0019=236\00135=i\00134=343\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:19.291\00156=CME\00157=G\001142=US,NC\001117=339\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25075\001133=25375\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=177\001", + "8=FIX.4.2\0019=149\00135=b\00134=440\001369=343\00152=20150427-19:56:19." + "318\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "339\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "237\001", + "8=FIX.4.2\0019=236\00135=i\00134=344\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:19.553\00156=CME\00157=G\001142=US,NC\001117=340\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25100\001133=25400\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=149\001", + "8=FIX.4.2\0019=149\00135=b\00134=441\001369=344\00152=20150427-19:56:19." + "573\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "340\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "234\001", + "8=FIX.4.2\0019=236\00135=i\00134=345\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:19.815\00156=CME\00157=G\001142=US,NC\001117=341\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25125\001133=25375\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=170\001", + "8=FIX.4.2\0019=149\00135=b\00134=442\001369=345\00152=20150427-19:56:19." + "846\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "341\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "240\001", + "8=FIX.4.2\0019=236\00135=i\00134=346\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:20.078\00156=CME\00157=G\001142=US,NC\001117=342\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25150\001133=25350\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=156\001", + "8=FIX.4.2\0019=149\00135=b\00134=443\001369=346\00152=20150427-19:56:20." + "109\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "342\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "227\001", + "8=FIX.4.2\0019=236\00135=i\00134=347\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:20.342\00156=CME\00157=G\001142=US,NC\001117=343\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25175\001133=25325\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=161\001", + "8=FIX.4.2\0019=149\00135=b\00134=444\001369=347\00152=20150427-19:56:20." + "363\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "343\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "232\001", + "8=FIX.4.2\0019=236\00135=i\00134=348\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:20.606\00156=CME\00157=G\001142=US,NC\001117=344\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25150\001133=25350\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=157\001", + "8=FIX.4.2\0019=149\00135=b\00134=445\001369=348\00152=20150427-19:56:20." + "634\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "344\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "236\001", + "8=FIX.4.2\0019=236\00135=i\00134=349\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:20.869\00156=CME\00157=G\001142=US,NC\001117=345\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25175\001133=25375\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=184\001", + "8=FIX.4.2\0019=149\00135=b\00134=446\001369=349\00152=20150427-19:56:20." + "897\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "345\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "250\001", + "8=FIX.4.2\0019=236\00135=i\00134=350\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:21.133\00156=CME\00157=G\001142=US,NC\001117=346\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25150\001133=25400\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=144\001", + "8=FIX.4.2\0019=149\00135=b\00134=447\001369=350\00152=20150427-19:56:21." + "153\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "346\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "230\001", + "8=FIX.4.2\0019=236\00135=i\00134=351\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:21.397\00156=CME\00157=G\001142=US,NC\001117=347\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25125\001133=25425\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=167\001", + "8=FIX.4.2\0019=149\00135=b\00134=448\001369=351\00152=20150427-19:56:21." + "419\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "347\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "238\001", + "8=FIX.4.2\0019=236\00135=i\00134=352\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:21.661\00156=CME\00157=G\001142=US,NC\001117=348\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25100\001133=25450\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=154\001", + "8=FIX.4.2\0019=149\00135=b\00134=449\001369=352\00152=20150427-19:56:21." + "694\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "348\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "246\001", + "8=FIX.4.2\0019=236\00135=i\00134=353\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:21.926\00156=CME\00157=G\001142=US,NC\001117=349\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25075\001133=25425\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=173\001", + "8=FIX.4.2\0019=149\00135=b\00134=450\001369=353\00152=20150427-19:56:21." + "953\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "349\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "238\001", + "8=FIX.4.2\0019=236\00135=i\00134=354\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:22.191\00156=CME\00157=G\001142=US,NC\001117=350\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25100\001133=25400\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=143\001", + "8=FIX.4.2\0019=149\00135=b\00134=451\001369=354\00152=20150427-19:56:22." + "213\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "350\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "222\001", + "8=FIX.4.2\0019=236\00135=i\00134=355\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:22.456\00156=CME\00157=G\001142=US,NC\001117=351\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25075\001133=25425\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=167\001", + "8=FIX.4.2\0019=149\00135=b\00134=452\001369=355\00152=20150427-19:56:22." + "487\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "351\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "238\001", + "8=FIX.4.2\0019=236\00135=i\00134=356\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:22.721\00156=CME\00157=G\001142=US,NC\001117=352\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25100\001133=25450\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=151\001", + "8=FIX.4.2\0019=149\00135=b\00134=453\001369=356\00152=20150427-19:56:22." + "744\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "352\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "237\001", + "8=FIX.4.2\0019=236\00135=i\00134=357\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:22.986\00156=CME\00157=G\001142=US,NC\001117=353\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25075\001133=25475\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=184\001", + "8=FIX.4.2\0019=149\00135=b\00134=454\001369=357\00152=20150427-19:56:23." + "042\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "353\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "232\001", + "8=FIX.4.2\0019=236\00135=i\00134=358\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:23.250\00156=CME\00157=G\001142=US,NC\001117=354\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25050\001133=25450\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=157\001", + "8=FIX.4.2\0019=149\00135=b\00134=455\001369=358\00152=20150427-19:56:23." + "290\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "354\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "240\001", + "8=FIX.4.2\0019=236\00135=i\00134=359\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:23.515\00156=CME\00157=G\001142=US,NC\001117=355\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25075\001133=25475\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=177\001", + "8=FIX.4.2\0019=149\00135=b\00134=456\001369=359\00152=20150427-19:56:23." + "540\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "355\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "241\001", + "8=FIX.4.2\0019=236\00135=i\00134=360\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:23.779\00156=CME\00157=G\001142=US,NC\001117=356\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25050\001133=25450\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=168\001", + "8=FIX.4.2\0019=149\00135=b\00134=457\001369=360\00152=20150427-19:56:23." + "809\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "356\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "243\001", + "8=FIX.4.2\0019=236\00135=i\00134=361\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:24.044\00156=CME\00157=G\001142=US,NC\001117=357\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25025\001133=25475\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=165\001", + "8=FIX.4.2\0019=149\00135=b\00134=458\001369=361\00152=20150427-19:56:24." + "072\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "357\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "239\001", + "8=FIX.4.2\0019=236\00135=i\00134=362\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:24.309\00156=CME\00157=G\001142=US,NC\001117=358\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25000\001133=25500\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=153\001", + "8=FIX.4.2\0019=149\00135=b\00134=459\001369=362\00152=20150427-19:56:24." + "332\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "358\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "241\001", + "8=FIX.4.2\0019=220\00135=i\00134=363\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:24.573\00156=CME\00157=G\001142=US,NC\001117=359\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25025\001134=1\0011028=N\0017928=bluestream\0019702=" + "1\0019771=TESTACC\00110=197\001", + "8=FIX.4.2\0019=149\00135=b\00134=460\001369=363\00152=20150427-19:56:24." + "612\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "359\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "236\001", + "8=FIX.4.2\0019=236\00135=i\00134=364\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:24.838\00156=CME\00157=G\001142=US,NC\001117=360\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25000\001133=25525\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=162\001", + "8=FIX.4.2\0019=149\00135=b\00134=461\001369=364\00152=20150427-19:56:24." + "870\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "360\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "236\001", + "8=FIX.4.2\0019=220\00135=i\00134=365\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:25.102\00156=CME\00157=G\001142=US,NC\001117=361\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001133=25500\001135=1\0011028=N\0017928=bluestream\0019702=" + "1\0019771=TESTACC\00110=181\001", + "8=FIX.4.2\0019=149\00135=b\00134=462\001369=365\00152=20150427-19:56:25." + "139\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "361\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "238\001", + "8=FIX.4.2\0019=220\00135=i\00134=366\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:25.632\00156=CME\00157=G\001142=US,NC\001117=362\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25025\001134=1\0011028=N\0017928=bluestream\0019702=" + "1\0019771=TESTACC\00110=191\001", + "8=FIX.4.2\0019=149\00135=b\00134=463\001369=366\00152=20150427-19:56:25." + "654\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "362\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "243\001", + "8=FIX.4.2\0019=220\00135=i\00134=367\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:25.896\00156=CME\00157=G\001142=US,NC\001117=363\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25050\001134=1\0011028=N\0017928=bluestream\0019702=" + "1\0019771=TESTACC\00110=203\001", + "8=FIX.4.2\0019=149\00135=b\00134=464\001369=367\00152=20150427-19:56:25." + "924\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "363\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "246\001", + "8=FIX.4.2\0019=236\00135=i\00134=368\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:26.160\00156=CME\00157=G\001142=US,NC\001117=364\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25075\001133=25475\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=176\001", + "8=FIX.4.2\0019=149\00135=b\00134=465\001369=368\00152=20150427-19:56:26." + "183\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "364\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "247\001", + "8=FIX.4.2\0019=236\00135=i\00134=369\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:26.425\00156=CME\00157=G\001142=US,NC\001117=365\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25100\001133=25500\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=160\001", + "8=FIX.4.2\0019=149\00135=b\00134=466\001369=369\00152=20150427-19:56:26." + "455\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "365\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "252\001", + "8=FIX.4.2\0019=220\00135=i\00134=370\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:26.689\00156=CME\00157=G\001142=US,NC\001117=366\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25075\001134=1\0011028=N\0017928=bluestream\0019702=" + "1\0019771=TESTACC\00110=208\001", + "8=FIX.4.2\0019=149\00135=b\00134=467\001369=370\00152=20150427-19:56:26." + "716\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "366\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "246\001", + "8=FIX.4.2\0019=220\00135=i\00134=371\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:26.954\00156=CME\00157=G\001142=US,NC\001117=367\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25050\001134=1\0011028=N\0017928=bluestream\0019702=" + "1\0019771=TESTACC\00110=198\001", + "8=FIX.4.2\0019=149\00135=b\00134=468\001369=371\00152=20150427-19:56:26." + "980\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "367\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "252\001", + "8=FIX.4.2\0019=236\00135=i\00134=372\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:27.219\00156=CME\00157=G\001142=US,NC\001117=368\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25075\001133=25475\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=181\001", + "8=FIX.4.2\0019=149\00135=b\00134=469\001369=372\00152=20150427-19:56:27." + "241\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "368\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "246\001", + "8=FIX.4.2\0019=236\00135=i\00134=373\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:27.483\00156=CME\00157=G\001142=US,NC\001117=369\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25100\001133=25450\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=168\001", + "8=FIX.4.2\0019=149\00135=b\00134=470\001369=373\00152=20150427-19:56:27." + "510\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "369\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "239\001", + "8=FIX.4.2\0019=236\00135=i\00134=374\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:27.748\00156=CME\00157=G\001142=US,NC\001117=370\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25075\001133=25475\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=183\001", + "8=FIX.4.2\0019=149\00135=b\00134=471\001369=374\00152=20150427-19:56:27." + "773\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "370\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "244\001", + "8=FIX.4.2\0019=236\00135=i\00134=375\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:28.013\00156=CME\00157=G\001142=US,NC\001117=371\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25050\001133=25450\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=157\001", + "8=FIX.4.2\0019=149\00135=b\00134=472\001369=375\00152=20150427-19:56:28." + "034\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "371\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "238\001", + "8=FIX.4.2\0019=236\00135=i\00134=376\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:28.278\00156=CME\00157=G\001142=US,NC\001117=372\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25075\001133=25475\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=186\001", + "8=FIX.4.2\0019=149\00135=b\00134=473\001369=376\00152=20150427-19:56:28." + "311\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "372\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "239\001", + "8=FIX.4.2\0019=236\00135=i\00134=377\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:28.543\00156=CME\00157=G\001142=US,NC\001117=373\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25100\001133=25500\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=161\001", + "8=FIX.4.2\0019=149\00135=b\00134=474\001369=377\00152=20150427-19:56:28." + "563\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "373\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "251\001", + "8=FIX.4.2\0019=236\00135=i\00134=378\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:28.808\00156=CME\00157=G\001142=US,NC\001117=374\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25075\001133=25475\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=189\001", + "8=FIX.4.2\0019=149\00135=b\00134=475\001369=378\00152=20150427-19:56:28." + "841\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "374\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "253\001", + "8=FIX.4.2\0019=236\00135=i\00134=379\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:29.072\00156=CME\00157=G\001142=US,NC\001117=375\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25050\001133=25450\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=171\001", + "8=FIX.4.2\0019=149\00135=b\00134=476\001369=379\00152=20150427-19:56:29." + "101\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "375\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "246\001", + "8=FIX.4.2\0019=236\00135=i\00134=380\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:29.337\00156=CME\00157=G\001142=US,NC\001117=376\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25025\001133=25425\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=172\001", + "8=FIX.4.2\0019=149\00135=b\00134=477\001369=380\00152=20150427-19:56:29." + "358\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "376\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "254\001", + "8=FIX.4.2\0019=236\00135=i\00134=381\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:29.602\00156=CME\00157=G\001142=US,NC\001117=377\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25000\001133=25400\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=155\001", + "8=FIX.4.2\0019=149\00135=b\00134=478\001369=381\00152=20150427-19:56:29." + "625\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "377\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "254\001", + "8=FIX.4.2\0019=220\00135=i\00134=382\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:29.866\00156=CME\00157=G\001142=US,NC\001117=378\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001133=25425\001135=1\0011028=N\0017928=bluestream\0019702=" + "1\0019771=TESTACC\00110=215\001", + "8=FIX.4.2\0019=149\00135=b\00134=479\001369=382\00152=20150427-19:56:29." + "896\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "378\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "011\001", + "8=FIX.4.2\0019=236\00135=i\00134=383\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:30.131\00156=CME\00157=G\001142=US,NC\001117=379\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25025\001133=25400\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=155\001", + "8=FIX.4.2\0019=149\00135=b\00134=480\001369=383\00152=20150427-19:56:30." + "158\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "379\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "244\001", + "8=FIX.4.2\0019=236\00135=i\00134=384\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:30.395\00156=CME\00157=G\001142=US,NC\001117=380\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25050\001133=25375\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=169\001", + "8=FIX.4.2\0019=149\00135=b\00134=481\001369=384\00152=20150427-19:56:30." + "424\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "380\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "234\001", + "8=FIX.4.2\0019=236\00135=i\00134=385\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:30.660\00156=CME\00157=G\001142=US,NC\001117=381\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25075\001133=25350\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=166\001", + "8=FIX.4.2\0019=149\00135=b\00134=482\001369=385\00152=20150427-19:56:30." + "687\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "381\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "248\001", + "8=FIX.4.2\0019=236\00135=i\00134=386\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:30.925\00156=CME\00157=G\001142=US,NC\001117=382\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25100\001133=25325\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=163\001", + "8=FIX.4.2\0019=149\00135=b\00134=483\001369=386\00152=20150427-19:56:30." + "948\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "382\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "251\001", + "8=FIX.4.2\0019=236\00135=i\00134=387\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:31.189\00156=CME\00157=G\001142=US,NC\001117=383\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25125\001133=25300\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=168\001", + "8=FIX.4.2\0019=149\00135=b\00134=484\001369=387\00152=20150427-19:56:31." + "212\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "383\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "239\001", + "8=FIX.4.2\0019=236\00135=i\00134=388\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:31.454\00156=CME\00157=G\001142=US,NC\001117=384\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25150\001133=25275\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=174\001", + "8=FIX.4.2\0019=149\00135=b\00134=485\001369=388\00152=20150427-19:56:31." + "480\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "384\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "249\001", + "8=FIX.4.2\0019=220\00135=i\00134=389\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:31.719\00156=CME\00157=G\001142=US,NC\001117=385\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001133=25250\001135=1\0011028=N\0017928=bluestream\0019702=" + "1\0019771=TESTACC\00110=206\001", + "8=FIX.4.2\0019=149\00135=b\00134=486\001369=389\00152=20150427-19:56:31." + "741\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "385\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "252\001", + "8=FIX.4.2\0019=236\00135=i\00134=390\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:31.983\00156=CME\00157=G\001142=US,NC\001117=386\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25125\001133=25275\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=178\001", + "8=FIX.4.2\0019=149\00135=b\00134=487\001369=390\00152=20150427-19:56:32." + "007\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "386\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "242\001", + "8=FIX.4.2\0019=236\00135=i\00134=391\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:32.248\00156=CME\00157=G\001142=US,NC\001117=387\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25150\001133=25250\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=166\001", + "8=FIX.4.2\0019=149\00135=b\00134=488\001369=391\00152=20150427-19:56:32." + "271\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "387\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "248\001", + "8=FIX.4.2\0019=236\00135=i\00134=392\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:32.512\00156=CME\00157=G\001142=US,NC\001117=388\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25175\001133=25275\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=176\001", + "8=FIX.4.2\0019=149\00135=b\00134=489\001369=392\00152=20150427-19:56:32." + "538\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "388\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "001\001", + "8=FIX.4.2\0019=236\00135=i\00134=393\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:32.777\00156=CME\00157=G\001142=US,NC\001117=389\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25200\001133=25300\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=169\001", + "8=FIX.4.2\0019=149\00135=b\00134=490\001369=393\00152=20150427-19:56:32." + "799\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "389\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "004\001", + "8=FIX.4.2\0019=236\00135=i\00134=394\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:33.042\00156=CME\00157=G\001142=US,NC\001117=390\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25175\001133=25275\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=170\001", + "8=FIX.4.2\0019=149\00135=b\00134=491\001369=394\00152=20150427-19:56:33." + "067\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "390\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "243\001", + "8=FIX.4.2\0019=236\00135=i\00134=395\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:33.306\00156=CME\00157=G\001142=US,NC\001117=391\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25150\001133=25250\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=161\001", + "8=FIX.4.2\0019=149\00135=b\00134=492\001369=395\00152=20150427-19:56:33." + "332\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "391\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "241\001", + "8=FIX.4.2\0019=236\00135=i\00134=396\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:33.571\00156=CME\00157=G\001142=US,NC\001117=392\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25175\001133=25275\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=181\001", + "8=FIX.4.2\0019=149\00135=b\00134=493\001369=396\00152=20150427-19:56:33." + "593\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "392\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "253\001", + "8=FIX.4.2\0019=236\00135=i\00134=397\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:33.835\00156=CME\00157=G\001142=US,NC\001117=393\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25200\001133=25300\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=164\001", + "8=FIX.4.2\0019=149\00135=b\00134=494\001369=397\00152=20150427-19:56:33." + "871\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "393\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "255\001", + "8=FIX.4.2\0019=236\00135=i\00134=398\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:34.100\00156=CME\00157=G\001142=US,NC\001117=394\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25175\001133=25325\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=170\001", + "8=FIX.4.2\0019=149\00135=b\00134=495\001369=398\00152=20150427-19:56:34." + "130\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "394\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "247\001", + "8=FIX.4.2\0019=236\00135=i\00134=399\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:34.365\00156=CME\00157=G\001142=US,NC\001117=395\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25200\001133=25300\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=167\001", + "8=FIX.4.2\0019=149\00135=b\00134=496\001369=399\00152=20150427-19:56:34." + "394\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "395\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "006\001", + "8=FIX.4.2\0019=236\00135=i\00134=400\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:34.630\00156=CME\00157=G\001142=US,NC\001117=396\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25175\001133=25275\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=168\001", + "8=FIX.4.2\0019=149\00135=b\00134=497\001369=400\00152=20150427-19:56:34." + "656\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "396\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "248\001", + "8=FIX.4.2\0019=236\00135=i\00134=401\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:34.894\00156=CME\00157=G\001142=US,NC\001117=397\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25200\001133=25300\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=160\001", + "8=FIX.4.2\0019=149\00135=b\00134=498\001369=401\00152=20150427-19:56:34." + "927\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "397\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "252\001", + "8=FIX.4.2\0019=236\00135=i\00134=402\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:35.160\00156=CME\00157=G\001142=US,NC\001117=398\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25225\001133=25325\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=163\001", + "8=FIX.4.2\0019=149\00135=b\00134=499\001369=402\00152=20150427-19:56:35." + "182\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "398\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "249\001", + "8=FIX.4.2\0019=236\00135=i\00134=403\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:35.424\00156=CME\00157=G\001142=US,NC\001117=399\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25250\001133=25350\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=164\001", + "8=FIX.4.2\0019=149\00135=b\00134=500\001369=403\00152=20150427-19:56:35." + "450\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "399\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "232\001", + "8=FIX.4.2\0019=236\00135=i\00134=404\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:35.689\00156=CME\00157=G\001142=US,NC\001117=400\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25275\001133=25375\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=175\001", + "8=FIX.4.2\0019=149\00135=b\00134=501\001369=404\00152=20150427-19:56:35." + "715\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "400\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "221\001", + "8=FIX.4.2\0019=236\00135=i\00134=405\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:35.954\00156=CME\00157=G\001142=US,NC\001117=401\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25250\001133=25350\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=158\001", + "8=FIX.4.2\0019=149\00135=b\00134=502\001369=405\00152=20150427-19:56:35." + "974\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "401\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "231\001", + "8=FIX.4.2\0019=236\00135=i\00134=406\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:36.218\00156=CME\00157=G\001142=US,NC\001117=402\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25225\001133=25325\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=158\001", + "8=FIX.4.2\0019=149\00135=b\00134=503\001369=406\00152=20150427-19:56:36." + "244\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "402\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "225\001", + "8=FIX.4.2\0019=236\00135=i\00134=407\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:36.483\00156=CME\00157=G\001142=US,NC\001117=403\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25250\001133=25350\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=160\001", + "8=FIX.4.2\0019=149\00135=b\00134=504\001369=407\00152=20150427-19:56:36." + "513\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "403\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "227\001", + "8=FIX.4.2\0019=236\00135=i\00134=408\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:36.748\00156=CME\00157=G\001142=US,NC\001117=404\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25225\001133=25375\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=175\001", + "8=FIX.4.2\0019=149\00135=b\00134=505\001369=408\00152=20150427-19:56:36." + "772\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "404\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "237\001", + "8=FIX.4.2\0019=236\00135=i\00134=409\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:37.013\00156=CME\00157=G\001142=US,NC\001117=405\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25250\001133=25400\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=150\001", + "8=FIX.4.2\0019=149\00135=b\00134=506\001369=409\00152=20150427-19:56:37." + "034\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "405\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "232\001", + "8=FIX.4.2\0019=236\00135=i\00134=410\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:37.278\00156=CME\00157=G\001142=US,NC\001117=406\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25225\001133=25375\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=169\001", + "8=FIX.4.2\0019=149\00135=b\00134=507\001369=410\00152=20150427-19:56:37." + "305\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "406\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "227\001", + "8=FIX.4.2\0019=236\00135=i\00134=411\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:37.544\00156=CME\00157=G\001142=US,NC\001117=407\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25200\001133=25350\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=153\001", + "8=FIX.4.2\0019=149\00135=b\00134=508\001369=411\00152=20150427-19:56:37." + "567\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "407\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "240\001", + "8=FIX.4.2\0019=236\00135=i\00134=412\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:37.809\00156=CME\00157=G\001142=US,NC\001117=408\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25225\001133=25325\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=168\001", + "8=FIX.4.2\0019=149\00135=b\00134=509\001369=412\00152=20150427-19:56:37." + "834\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "408\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "240\001", + "8=FIX.4.2\0019=236\00135=i\00134=413\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:38.073\00156=CME\00157=G\001142=US,NC\001117=409\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25200\001133=25350\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=155\001", + "8=FIX.4.2\0019=149\00135=b\00134=510\001369=413\00152=20150427-19:56:38." + "102\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "409\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "223\001", + "8=FIX.4.2\0019=236\00135=i\00134=414\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:38.338\00156=CME\00157=G\001142=US,NC\001117=410\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25175\001133=25375\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=170\001", + "8=FIX.4.2\0019=149\00135=b\00134=511\001369=414\00152=20150427-19:56:38." + "358\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "410\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "230\001", + "8=FIX.4.2\0019=236\00135=i\00134=415\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:38.607\00156=CME\00157=G\001142=US,NC\001117=411\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25200\001133=25400\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=149\001", + "8=FIX.4.2\0019=149\00135=b\00134=512\001369=415\00152=20150427-19:56:38." + "634\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "411\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "230\001", + "8=FIX.4.2\0019=236\00135=i\00134=416\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:38.877\00156=CME\00157=G\001142=US,NC\001117=412\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25225\001133=25425\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=174\001", + "8=FIX.4.2\0019=149\00135=b\00134=513\001369=416\00152=20150427-19:56:38." + "906\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "412\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "235\001", + "8=FIX.4.2\0019=236\00135=i\00134=417\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:39.143\00156=CME\00157=G\001142=US,NC\001117=413\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25250\001133=25400\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=154\001", + "8=FIX.4.2\0019=149\00135=b\00134=514\001369=417\00152=20150427-19:56:39." + "170\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "413\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "232\001", + "8=FIX.4.2\0019=236\00135=i\00134=418\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:39.408\00156=CME\00157=G\001142=US,NC\001117=414\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25275\001133=25375\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=178\001", + "8=FIX.4.2\0019=149\00135=b\00134=515\001369=418\00152=20150427-19:56:39." + "431\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "414\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "235\001", + "8=FIX.4.2\0019=220\00135=i\00134=419\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:39.673\00156=CME\00157=G\001142=US,NC\001117=415\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001133=25400\001135=1\0011028=N\0017928=bluestream\0019702=" + "1\0019771=TESTACC\00110=198\001", + "8=FIX.4.2\0019=149\00135=b\00134=516\001369=419\00152=20150427-19:56:39." + "701\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "415\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "238\001", + "8=FIX.4.2\0019=236\00135=i\00134=420\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:39.936\00156=CME\00157=G\001142=US,NC\001117=416\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25300\001133=25425\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=164\001", + "8=FIX.4.2\0019=149\00135=b\00134=517\001369=420\00152=20150427-19:56:39." + "964\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "416\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "243\001", + "8=FIX.4.2\0019=236\00135=i\00134=421\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:40.200\00156=CME\00157=G\001142=US,NC\001117=417\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25325\001133=25450\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=147\001", + "8=FIX.4.2\0019=149\00135=b\00134=518\001369=421\00152=20150427-19:56:40." + "229\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "417\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "232\001", + "8=FIX.4.2\0019=236\00135=i\00134=422\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:40.464\00156=CME\00157=G\001142=US,NC\001117=418\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25300\001133=25425\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=156\001", + "8=FIX.4.2\0019=149\00135=b\00134=519\001369=422\00152=20150427-19:56:40." + "494\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "418\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "239\001", + "8=FIX.4.2\0019=236\00135=i\00134=423\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:40.728\00156=CME\00157=G\001142=US,NC\001117=419\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25325\001133=25450\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=166\001", + "8=FIX.4.2\0019=149\00135=b\00134=520\001369=423\00152=20150427-19:56:40." + "748\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "419\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "235\001", + "8=FIX.4.2\0019=236\00135=i\00134=424\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:40.991\00156=CME\00157=G\001142=US,NC\001117=420\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25350\001133=25475\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=166\001", + "8=FIX.4.2\0019=149\00135=b\00134=521\001369=424\00152=20150427-19:56:41." + "014\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "420\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "216\001", + "8=FIX.4.2\0019=236\00135=i\00134=425\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:41.255\00156=CME\00157=G\001142=US,NC\001117=421\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25325\001133=25450\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=157\001", + "8=FIX.4.2\0019=149\00135=b\00134=522\001369=425\00152=20150427-19:56:41." + "281\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "421\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "225\001", + "8=FIX.4.2\0019=236\00135=i\00134=426\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:41.519\00156=CME\00157=G\001142=US,NC\001117=422\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25350\001133=25475\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=167\001", + "8=FIX.4.2\0019=149\00135=b\00134=523\001369=426\00152=20150427-19:56:41." + "544\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "422\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "230\001", + "8=FIX.4.2\0019=236\00135=i\00134=427\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:41.782\00156=CME\00157=G\001142=US,NC\001117=423\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25375\001133=25500\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=167\001", + "8=FIX.4.2\0019=149\00135=b\00134=524\001369=427\00152=20150427-19:56:41." + "803\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "423\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "231\001", + "8=FIX.4.2\0019=236\00135=i\00134=428\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:42.046\00156=CME\00157=G\001142=US,NC\001117=424\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25350\001133=25475\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=167\001", + "8=FIX.4.2\0019=149\00135=b\00134=525\001369=428\00152=20150427-19:56:42." + "080\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "424\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "232\001", + "8=FIX.4.2\0019=236\00135=i\00134=429\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:42.309\00156=CME\00157=G\001142=US,NC\001117=425\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25325\001133=25450\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=166\001", + "8=FIX.4.2\0019=149\00135=b\00134=526\001369=429\00152=20150427-19:56:42." + "336\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "425\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "239\001", + "8=FIX.4.2\0019=236\00135=i\00134=430\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:42.573\00156=CME\00157=G\001142=US,NC\001117=426\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25350\001133=25475\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=167\001", + "8=FIX.4.2\0019=149\00135=b\00134=527\001369=430\00152=20150427-19:56:42." + "593\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "426\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "238\001", + "8=FIX.4.2\0019=236\00135=i\00134=431\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:42.837\00156=CME\00157=G\001142=US,NC\001117=427\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25325\001133=25450\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=167\001", + "8=FIX.4.2\0019=149\00135=b\00134=528\001369=431\00152=20150427-19:56:42." + "862\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "427\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "240\001", + "8=FIX.4.2\0019=236\00135=i\00134=432\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:43.100\00156=CME\00157=G\001142=US,NC\001117=428\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25300\001133=25425\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=148\001", + "8=FIX.4.2\0019=149\00135=b\00134=529\001369=432\00152=20150427-19:56:43." + "131\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "428\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "233\001", + "8=FIX.4.2\0019=236\00135=i\00134=433\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:43.364\00156=CME\00157=G\001142=US,NC\001117=429\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25325\001133=25450\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=167\001", + "8=FIX.4.2\0019=149\00135=b\00134=530\001369=433\00152=20150427-19:56:43." + "392\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "429\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "236\001", + "8=FIX.4.2\0019=236\00135=i\00134=434\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:43.627\00156=CME\00157=G\001142=US,NC\001117=430\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25300\001133=25425\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=157\001", + "8=FIX.4.2\0019=149\00135=b\00134=531\001369=434\00152=20150427-19:56:43." + "652\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "430\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "229\001", + "8=FIX.4.2\0019=236\00135=i\00134=435\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:43.891\00156=CME\00157=G\001142=US,NC\001117=431\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25325\001133=25450\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=167\001", + "8=FIX.4.2\0019=149\00135=b\00134=532\001369=435\00152=20150427-19:56:43." + "936\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "431\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "237\001", + "8=FIX.4.2\0019=236\00135=i\00134=436\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:44.155\00156=CME\00157=G\001142=US,NC\001117=432\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25350\001133=25475\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=168\001", + "8=FIX.4.2\0019=149\00135=b\00134=533\001369=436\00152=20150427-19:56:44." + "202\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "432\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "227\001", + "8=FIX.4.2\0019=236\00135=i\00134=437\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:44.418\00156=CME\00157=G\001142=US,NC\001117=433\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25325\001133=25500\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=163\001", + "8=FIX.4.2\0019=149\00135=b\00134=534\001369=437\00152=20150427-19:56:44." + "447\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "433\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "241\001", + "8=FIX.4.2\0019=220\00135=i\00134=438\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:44.682\00156=CME\00157=G\001142=US,NC\001117=434\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25350\001134=1\0011028=N\0017928=bluestream\0019702=" + "1\0019771=TESTACC\00110=198\001", + "8=FIX.4.2\0019=149\00135=b\00134=535\001369=438\00152=20150427-19:56:44." + "712\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "434\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "239\001", + "8=FIX.4.2\0019=236\00135=i\00134=439\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:44.946\00156=CME\00157=G\001142=US,NC\001117=435\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25325\001133=25525\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=180\001", + "8=FIX.4.2\0019=149\00135=b\00134=536\001369=439\00152=20150427-19:56:44." + "973\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "435\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "251\001", + "8=FIX.4.2\0019=236\00135=i\00134=440\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:45.209\00156=CME\00157=G\001142=US,NC\001117=436\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25350\001133=25500\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=157\001", + "8=FIX.4.2\0019=149\00135=b\00134=537\001369=440\00152=20150427-19:56:45." + "239\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "436\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "241\001", + "8=FIX.4.2\0019=220\00135=i\00134=441\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:45.473\00156=CME\00157=G\001142=US,NC\001117=437\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25325\001134=1\0011028=N\0017928=bluestream\0019702=" + "1\0019771=TESTACC\00110=196\001", + "8=FIX.4.2\0019=149\00135=b\00134=538\001369=441\00152=20150427-19:56:45." + "511\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "437\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "237\001", + "8=FIX.4.2\0019=220\00135=i\00134=442\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:45.736\00156=CME\00157=G\001142=US,NC\001117=438\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25350\001134=1\0011028=N\0017928=bluestream\0019702=" + "1\0019771=TESTACC\00110=198\001", + "8=FIX.4.2\0019=149\00135=b\00134=539\001369=442\00152=20150427-19:56:45." + "768\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "438\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "254\001", + "8=FIX.4.2\0019=236\00135=i\00134=443\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:46.000\00156=CME\00157=G\001142=US,NC\001117=439\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25375\001133=25525\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=167\001", + "8=FIX.4.2\0019=149\00135=b\00134=540\001369=443\00152=20150427-19:56:46." + "023\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "439\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "233\001", + "8=FIX.4.2\0019=236\00135=i\00134=444\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:46.264\00156=CME\00157=G\001142=US,NC\001117=440\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25350\001133=25500\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=158\001", + "8=FIX.4.2\0019=149\00135=b\00134=541\001369=444\00152=20150427-19:56:46." + "286\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "440\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "238\001", + "8=FIX.4.2\0019=236\00135=i\00134=445\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:46.528\00156=CME\00157=G\001142=US,NC\001117=441\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25325\001133=25525\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=172\001", + "8=FIX.4.2\0019=149\00135=b\00134=542\001369=445\00152=20150427-19:56:46." + "553\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "441\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "238\001", + "8=FIX.4.2\0019=236\00135=i\00134=446\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:46.791\00156=CME\00157=G\001142=US,NC\001117=442\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25300\001133=25500\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=162\001", + "8=FIX.4.2\0019=149\00135=b\00134=543\001369=446\00152=20150427-19:56:46." + "813\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "442\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "240\001", + "8=FIX.4.2\0019=220\00135=i\00134=447\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:47.055\00156=CME\00157=G\001142=US,NC\001117=443\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25325\001134=1\0011028=N\0017928=bluestream\0019702=" + "1\0019771=TESTACC\00110=197\001", + "8=FIX.4.2\0019=149\00135=b\00134=544\001369=447\00152=20150427-19:56:47." + "087\00149=CME\00150=G\00156=1U7001N\00157=BLUESTREAM\001143=US,NC\001117=" + "443\001297=0\0011028=N\0017928=bluestream\0019771=TESTACC\0019772=1\00110=" + "247\001", + "8=FIX.4.2\0019=236\00135=i\00134=448\00149=1U7001N\00150=bluestream\00152=" + "20150427-19:56:47.319\00156=CME\00157=G\001142=US,NC\001117=444\001204=" + "1\001296=1\001302=1\001304=1\001295=1\001299=10857\00155=EZ\001167=" + "OPT\001107=ESK5 " + "C1855\001132=25300\001133=25475\001134=1\001135=1\0011028=N\0017928=" + "bluestream\0019702=1\0019771=TESTACC\00110=174\001"}; -std::string sample_fix() -{ +std::string sample_fix() { std::ostringstream str; for (auto s : data) str << s; return str.str(); } -}} - +} // namespace jetfix +} // namespace bts diff --git a/src/lib/jetfix/tests/sample_fix.h b/src/lib/jetfix/tests/sample_fix.h index 0c74dcf95..80ea2777d 100644 --- a/src/lib/jetfix/tests/sample_fix.h +++ b/src/lib/jetfix/tests/sample_fix.h @@ -7,4 +7,5 @@ namespace jetfix { std::string sample_fix(); -}} +} +} // namespace bts diff --git a/src/lib/jetfix/tests/store_tests.cpp b/src/lib/jetfix/tests/store_tests.cpp index 661a6d006..7d676ab0f 100644 --- a/src/lib/jetfix/tests/store_tests.cpp +++ b/src/lib/jetfix/tests/store_tests.cpp @@ -29,104 +29,131 @@ TEST_CASE("JetFIX SessionNameTests", "[jetfix]") { } SECTION("closest_before_works") { - auto same_day_before = - closest_before(datetime::make_ptime(2015, 7, 17, 17, 0, 0, 0), - boost::gregorian::Friday, - boost::posix_time::time_duration(16, 59, 59)); - REQUIRE(datetime::FIX_date_time_string(same_day_before) == - "20150717-16:59:59"); + auto same_day_before = closest_before( + datetime::make_ptime(2015, 7, 17, 17, 0, 0, 0), + boost::gregorian::Friday, + boost::posix_time::time_duration(16, 59, 59)); + REQUIRE( + datetime::FIX_date_time_string(same_day_before) == + "20150717-16:59:59"); auto same_day_after = closest_before( datetime::make_ptime(2015, 7, 17, 17, 0, 0, 0), boost::gregorian::Friday, boost::posix_time::time_duration(17, 0, 1)); - REQUIRE(datetime::FIX_date_time_string(same_day_after) == - "20150710-17:00:01"); + REQUIRE( + datetime::FIX_date_time_string(same_day_after) == + "20150710-17:00:01"); - auto another_day_same_week = - closest_before(datetime::make_ptime(2015, 7, 17, 17, 0, 0, 0), - boost::gregorian::Thursday, - boost::posix_time::time_duration(16, 59, 59)); - REQUIRE(datetime::FIX_date_time_string(another_day_same_week) == - "20150716-16:59:59"); + auto another_day_same_week = closest_before( + datetime::make_ptime(2015, 7, 17, 17, 0, 0, 0), + boost::gregorian::Thursday, + boost::posix_time::time_duration(16, 59, 59)); + REQUIRE( + datetime::FIX_date_time_string(another_day_same_week) == + "20150716-16:59:59"); - auto another_day_previous_week = - closest_before(datetime::make_ptime(2015, 7, 17, 17, 0, 0, 0), - boost::gregorian::Saturday, - boost::posix_time::time_duration(16, 59, 59)); - REQUIRE(datetime::FIX_date_time_string(another_day_previous_week) == - "20150711-16:59:59"); + auto another_day_previous_week = closest_before( + datetime::make_ptime(2015, 7, 17, 17, 0, 0, 0), + boost::gregorian::Saturday, + boost::posix_time::time_duration(16, 59, 59)); + REQUIRE( + datetime::FIX_date_time_string(another_day_previous_week) == + "20150711-16:59:59"); } SECTION("in_session_works") { - REQUIRE(in_session(datetime::make_ptime(2015, 7, 17, 17, 0, 0, 0), - boost::gregorian::Sunday, - boost::posix_time::time_duration(16, 59, 59), + REQUIRE(in_session( + datetime::make_ptime(2015, 7, 17, 17, 0, 0, 0), + boost::gregorian::Sunday, + boost::posix_time::time_duration(16, 59, 59), - boost::gregorian::Friday, - boost::posix_time::time_duration(17, 0, 1))); + boost::gregorian::Friday, + boost::posix_time::time_duration(17, 0, 1))); - REQUIRE(!in_session(datetime::make_ptime(2015, 7, 17, 17, 0, 0, 0), - boost::gregorian::Sunday, - boost::posix_time::time_duration(16, 59, 59), + REQUIRE(!in_session( + datetime::make_ptime(2015, 7, 17, 17, 0, 0, 0), + boost::gregorian::Sunday, + boost::posix_time::time_duration(16, 59, 59), - boost::gregorian::Friday, - boost::posix_time::time_duration(16, 59, 59))); + boost::gregorian::Friday, + boost::posix_time::time_duration(16, 59, 59))); - REQUIRE(in_session(datetime::make_ptime(2015, 7, 17, 17, 0, 0, 0), - boost::posix_time::time_duration(16, 59, 59), - boost::posix_time::time_duration(17, 59, 59))); + REQUIRE(in_session( + datetime::make_ptime(2015, 7, 17, 17, 0, 0, 0), + boost::posix_time::time_duration(16, 59, 59), + boost::posix_time::time_duration(17, 59, 59))); - REQUIRE(!in_session(datetime::make_ptime(2015, 7, 17, 17, 0, 0, 0), - boost::posix_time::time_duration(0, 0, 0), - boost::posix_time::time_duration(16, 0, 0))); + REQUIRE(!in_session( + datetime::make_ptime(2015, 7, 17, 17, 0, 0, 0), + boost::posix_time::time_duration(0, 0, 0), + boost::posix_time::time_duration(16, 0, 0))); - REQUIRE(in_session(datetime::make_ptime(2015, 7, 17, 17, 0, 0, 0), - boost::posix_time::time_duration(17, 50, 59), - boost::posix_time::time_duration(17, 45, 59))); + REQUIRE(in_session( + datetime::make_ptime(2015, 7, 17, 17, 0, 0, 0), + boost::posix_time::time_duration(17, 50, 59), + boost::posix_time::time_duration(17, 45, 59))); - REQUIRE(!in_session(datetime::make_ptime(2015, 7, 17, 17, 47, 0, 0), - boost::posix_time::time_duration(17, 50, 59), - boost::posix_time::time_duration(17, 45, 59))); + REQUIRE(!in_session( + datetime::make_ptime(2015, 7, 17, 17, 47, 0, 0), + boost::posix_time::time_duration(17, 50, 59), + boost::posix_time::time_duration(17, 45, 59))); } SECTION("session_name_works") { - REQUIRE(session_name(datetime::make_ptime(2015, 7, 17, 17, 0, 0, 0), - boost::gregorian::Sunday, - boost::posix_time::time_duration(16, 59, 59), + REQUIRE( + session_name( + datetime::make_ptime(2015, 7, 17, 17, 0, 0, 0), + boost::gregorian::Sunday, + boost::posix_time::time_duration(16, 59, 59), - boost::gregorian::Friday, - boost::posix_time::time_duration(17, 0, 1)).as_string == - "2015-07-12"); + boost::gregorian::Friday, + boost::posix_time::time_duration(17, 0, 1)) + .as_string == "2015-07-12"); - REQUIRE(session_name(datetime::make_ptime(2015, 7, 17, 17, 0, 0, 0), - boost::gregorian::Sunday, - boost::posix_time::time_duration(16, 59, 59), + REQUIRE( + session_name( + datetime::make_ptime(2015, 7, 17, 17, 0, 0, 0), + boost::gregorian::Sunday, + boost::posix_time::time_duration(16, 59, 59), - boost::gregorian::Friday, - boost::posix_time::time_duration(16, 59, 59)).as_string == ""); + boost::gregorian::Friday, + boost::posix_time::time_duration(16, 59, 59)) + .as_string == ""); - REQUIRE(session_name(datetime::make_ptime(2015, 7, 17, 17, 0, 0, 0), - boost::posix_time::time_duration(16, 59, 59), - boost::posix_time::time_duration(17, 59, 59)).as_string == - "2015-07-17"); + REQUIRE( + session_name( + datetime::make_ptime(2015, 7, 17, 17, 0, 0, 0), + boost::posix_time::time_duration(16, 59, 59), + boost::posix_time::time_duration(17, 59, 59)) + .as_string == "2015-07-17"); - REQUIRE(session_name(datetime::make_ptime(2015, 7, 17, 18, 0, 0, 0), - boost::posix_time::time_duration(16, 59, 59), - boost::posix_time::time_duration(17, 59, 59)).as_string == ""); + REQUIRE( + session_name( + datetime::make_ptime(2015, 7, 17, 18, 0, 0, 0), + boost::posix_time::time_duration(16, 59, 59), + boost::posix_time::time_duration(17, 59, 59)) + .as_string == ""); - REQUIRE(session_name(datetime::make_ptime(2015, 7, 17, 17, 0, 0, 0), - boost::posix_time::time_duration(17, 50, 59), - boost::posix_time::time_duration(17, 45, 59)).as_string == - "2015-07-16"); + REQUIRE( + session_name( + datetime::make_ptime(2015, 7, 17, 17, 0, 0, 0), + boost::posix_time::time_duration(17, 50, 59), + boost::posix_time::time_duration(17, 45, 59)) + .as_string == "2015-07-16"); - REQUIRE(session_name(datetime::make_ptime(2015, 7, 17, 17, 51, 0, 0), - boost::posix_time::time_duration(17, 50, 59), - boost::posix_time::time_duration(17, 45, 59)).as_string == - "2015-07-17"); + REQUIRE( + session_name( + datetime::make_ptime(2015, 7, 17, 17, 51, 0, 0), + boost::posix_time::time_duration(17, 50, 59), + boost::posix_time::time_duration(17, 45, 59)) + .as_string == "2015-07-17"); - REQUIRE(session_name(datetime::make_ptime(2015, 7, 17, 17, 47, 0, 0), - boost::posix_time::time_duration(17, 50, 59), - boost::posix_time::time_duration(17, 45, 59)).as_string == ""); + REQUIRE( + session_name( + datetime::make_ptime(2015, 7, 17, 17, 47, 0, 0), + boost::posix_time::time_duration(17, 50, 59), + boost::posix_time::time_duration(17, 45, 59)) + .as_string == ""); } } @@ -253,9 +280,10 @@ TEST_CASE("JetFIX FileStoreTests", "[jetfix]") { buf.add(std::string_view{"1.0"}); buf.add(std::string_view{"BTS"}); stream.close(); - stream.stamp(i, 3, - datetime::FIX_timestamp(datetime::now() - - boost::gregorian::days(1))); + stream.stamp( + i, 3, + datetime::FIX_timestamp( + datetime::now() - boost::gregorian::days(1))); fs.store(InMsgBuffer(stream.to_str())); } } diff --git a/src/lib/logging/Common.h b/src/lib/logging/Common.h index 19679a294..6804a4ed5 100644 --- a/src/lib/logging/Common.h +++ b/src/lib/logging/Common.h @@ -2,9 +2,9 @@ #include "lib/utils/windows_wrapper.h" -#include #include #include +#include #include namespace bts { @@ -14,19 +14,19 @@ struct Level { using Rep = uint8_t; constexpr static auto Max = std::numeric_limits::max(); Rep ordinal; - bool operator<(const Level &rhs) const {return ordinal < rhs.ordinal;} + bool operator<(const Level &rhs) const { return ordinal < rhs.ordinal; } }; struct Subsystem { using Rep = uint8_t; constexpr static auto Max = std::numeric_limits::max(); Rep ordinal; - bool operator<(const Subsystem &rhs) const {return ordinal < rhs.ordinal;} + bool operator<(const Subsystem &rhs) const { return ordinal < rhs.ordinal; } }; -using ArgBuffer = std::array; -using MsgFormatter = std::string(*) (ArgBuffer const&,const char*); -using Filter = std::array; +using ArgBuffer = std::array; +using MsgFormatter = std::string (*)(ArgBuffer const &, const char *); +using Filter = std::array; inline uint64_t log_ts() { uint64_t result; @@ -36,13 +36,13 @@ inline uint64_t log_ts() { result = qpcnt.QuadPart; #else struct timespec ts; - clock_gettime( CLOCK_MONOTONIC, &ts ); + clock_gettime(CLOCK_MONOTONIC, &ts); result = - static_cast(1000000000UL)* - static_cast(ts.tv_sec) + - static_cast(ts.tv_nsec); + static_cast(1000000000UL) * static_cast(ts.tv_sec) + + static_cast(ts.tv_nsec); #endif return result; } -}} +} // namespace log +} // namespace bts diff --git a/src/lib/logging/LogRec.h b/src/lib/logging/LogRec.h index 82779679d..d95ce2460 100644 --- a/src/lib/logging/LogRec.h +++ b/src/lib/logging/LogRec.h @@ -1,13 +1,14 @@ #pragma once -#include "lib/utils/warn_ctrl.h" #include "Common.h" #include "MsgPacking.h" +#include "lib/utils/warn_ctrl.h" namespace bts { namespace log { -using ArgUnpacker = std::string (*) (ArgBuffer const&b, const char*msg_template); +using ArgUnpacker = + std::string (*)(ArgBuffer const &b, const char *msg_template); GCC_DIAG_OFF("-Weffc++") struct LogRec { @@ -19,25 +20,23 @@ struct LogRec { Level level; Subsystem subsystem; ArgBuffer args; - + template - void pack_msg (const char *msg_t, Args&&... msg_args) { + void pack_msg(const char *msg_t, Args &&... msg_args) { msg_template = msg_t; - unpacker = unpack_msg_args::type...>; - pack_msg_args(args,std::forward(msg_args)...); + unpacker = unpack_msg_args< + sizeof(ArgBuffer), typename std::remove_reference::type...>; + pack_msg_args(args, std::forward(msg_args)...); } - std::string unpack_msg() - { - return unpacker(args,msg_template); - } + std::string unpack_msg() { return unpacker(args, msg_template); } }; GCC_DIAG_RESTORE() #ifndef WIN32 -//static_assert(sizeof(LogRec) == 256, "LogRec should be 128 bytes"); +// static_assert(sizeof(LogRec) == 256, "LogRec should be 128 bytes"); #endif -}} - +} // namespace log +} // namespace bts diff --git a/src/lib/logging/Logger.h b/src/lib/logging/Logger.h index 9a6aa5083..ea184f1be 100644 --- a/src/lib/logging/Logger.h +++ b/src/lib/logging/Logger.h @@ -1,42 +1,33 @@ #pragma once -#include "MsgPacking.h" #include "LogRec.h" +#include "MsgPacking.h" #include "lib/os/os.h" -#include #include #include +#include namespace bts { namespace log { class Logger { -public: - Logger(const Logger&) = delete; - Logger&operator=(const Logger&) = delete; + public: + Logger(const Logger &) = delete; + Logger &operator=(const Logger &) = delete; - Logger(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), - _queue_b(initial_queue_size), - _tid(tid), - _active(true), - _max_queue_size(initial_queue_size*max_queue_growth), - _thread_name() - { + Logger( + 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), + _queue_b(initial_queue_size), _tid(tid), _active(true), + _max_queue_size(initial_queue_size * max_queue_growth), + _thread_name() { os::get_thread_name(&_thread_name); } - bool is_loggable(Subsystem subsystem,Level lv) { + bool is_loggable(Subsystem subsystem, Level lv) { lock(); bool result = lv.ordinal >= _filter[subsystem.ordinal].ordinal; unlock(); @@ -44,119 +35,118 @@ public: } template - bool enqueue (uint64_t ts,Subsystem subsystem,Level lv, const char*file, int line, - const char *msg_template, Args&&... msg_args) - { + bool enqueue( + 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()) + if (_wcursor == _write_q->size()) _drop_count++; else { - auto &lrec = (*_write_q) [_wcursor++]; + auto &lrec = (*_write_q)[_wcursor++]; lrec.ts = ts; lrec.file = file; lrec.line = line; lrec.level = lv; lrec.subsystem = subsystem; - lrec.pack_msg(msg_template, std::forward(msg_args)...); + lrec.pack_msg(msg_template, std::forward(msg_args)...); } unlock(); return true; } size_t aggregate_hash() { return 0; } - template - size_t aggregate_hash(Arg1& arg1, Args&&... args2) { - return - std::hash()(arg1) + - aggregate_hash(args2...); + template + size_t aggregate_hash(Arg1 &arg1, Args &&... args2) { + return std::hash()(arg1) + aggregate_hash(args2...); } template - bool enqueue_once_maybe(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 + bool enqueue_once_maybe( + 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...); - size_t hash = (arg_hash + std::hash()(msg_template)) % filter_size; + size_t hash = + (arg_hash + std::hash()(msg_template)) % filter_size; if (s_bloom[hash]) return false; else - enqueue (ts,subsystem,lv,file,line,msg_template,std::forward(msg_args)...); + enqueue( + ts, subsystem, lv, file, line, msg_template, + std::forward(msg_args)...); s_bloom[hash] = true; return true; } - template - void unqueue(S const&s) { + template void unqueue(S const &s) { size_t logged_msg_count = 0; size_t dropped_msg_count = 0; bool active = true; - + lock(); - std::swap(_read_q,_write_q); + std::swap(_read_q, _write_q); logged_msg_count = _wcursor; dropped_msg_count = _drop_count; active = _active; _wcursor = 0; - _drop_count = 0; + _drop_count = 0; unlock(); - s(_tid,_thread_name,active,dropped_msg_count,logged_msg_count,*_read_q); + s(_tid, _thread_name, active, dropped_msg_count, logged_msg_count, + *_read_q); if ((logged_msg_count > _read_q->size() / 2) && - _read_q->size() < _max_queue_size) - _read_q->resize(_read_q->size()*2); + _read_q->size() < _max_queue_size) + _read_q->resize(_read_q->size() * 2); } - void update_filter(Filter const&new_filter) - { + void update_filter(Filter const &new_filter) { lock(); _filter = new_filter; unlock(); } - void update_queue_limits(size_t initial_queue_size, - size_t max_queue_growth) { + void + update_queue_limits(size_t initial_queue_size, size_t max_queue_growth) { lock(); if (_wcursor == 0) { // we can only do this if the queue is empty because each log // record contains a tuple with possibly non trivially - // constructuable objects and cannot be moved + // constructuable objects and cannot be moved _write_q->resize(initial_queue_size); } _read_q->resize(initial_queue_size); - _max_queue_size = initial_queue_size*max_queue_growth; + _max_queue_size = initial_queue_size * max_queue_growth; unlock(); } - void mark_inactive() - { + void mark_inactive() { lock(); assert(_active); - _active=false; + _active = false; unlock(); } - ~Logger() - { -#ifdef false //This breaks .net core and windows + ~Logger() { +#ifdef false // This breaks .net core and windows assert(!_active); assert(_wcursor == 0); #endif } - - -private: - void lock () - {while (_mutex.test_and_set(std::memory_order_acquire));} - void unlock () - {_mutex.clear(std::memory_order_release);} + private: + void lock() { + while (_mutex.test_and_set(std::memory_order_acquire)) + ; + } + + void unlock() { _mutex.clear(std::memory_order_release); } std::atomic_flag _mutex = ATOMIC_FLAG_INIT; - std::vector* _read_q; - std::vector* _write_q; + std::vector *_read_q; + std::vector *_write_q; size_t _wcursor; Filter _filter; size_t _drop_count; @@ -167,4 +157,5 @@ private: size_t _max_queue_size; std::string _thread_name; }; -}} +} // namespace log +} // namespace bts diff --git a/src/lib/logging/LoggerHub.cpp b/src/lib/logging/LoggerHub.cpp index 799771d7f..9f32b526b 100644 --- a/src/lib/logging/LoggerHub.cpp +++ b/src/lib/logging/LoggerHub.cpp @@ -80,9 +80,9 @@ void LoggerHub::config(const LoggingConfig &cfg) { void LoggerHub::start() { bts_assert(!me->worker); - me->worker = std::make_unique( - threading::make_thread(me->logger_name.c_str(), - std::bind(&LoggerHub::do_work, this),me->thread_cfg)); + me->worker = std::make_unique(threading::make_thread( + me->logger_name.c_str(), std::bind(&LoggerHub::do_work, this), + me->thread_cfg)); } LoggerHub::~LoggerHub() { @@ -132,10 +132,10 @@ size_t LoggerHub::consume_log_recs() { size_t consumed = 0; for (size_t i = 0; i < me->loggers.size(); i++) { auto &l = me->loggers[i]; - l->unqueue([&l, &to_keep, &consumed, - this](size_t tid, std::string const &thread_name, bool active, - size_t dropped_msg_count, size_t logged_msg_count, - std::vector &msgs) { + l->unqueue([&l, &to_keep, &consumed, this]( + size_t tid, std::string const &thread_name, bool active, + size_t dropped_msg_count, size_t logged_msg_count, + std::vector &msgs) { consumed += (dropped_msg_count + logged_msg_count); if (dropped_msg_count) { LogRec lrec; @@ -144,8 +144,9 @@ size_t LoggerHub::consume_log_recs() { lrec.line = __LINE__; lrec.level = Level{Level::Max}; lrec.subsystem = Subsystem{Subsystem::Max}; - lrec.pack_msg("Dropped {} messages. Increase logging buffer size.", - dropped_msg_count); + lrec.pack_msg( + "Dropped {} messages. Increase logging buffer size.", + dropped_msg_count); dispatch_to_sinks(tid, thread_name, lrec); } @@ -160,19 +161,14 @@ size_t LoggerHub::consume_log_recs() { return consumed; } -void LoggerHub::dispatch_to_sinks(size_t tid, std::string const &thread_name, - LogRec &lr) { +void LoggerHub::dispatch_to_sinks( + size_t tid, std::string const &thread_name, LogRec &lr) { auto msg = lr.unpack_msg(); - auto lm = LogMsg{lr.ts, - msg, - lr.file, - lr.line, - lr.level, - me->level_names[lr.level.ordinal], - lr.subsystem, - me->subsystem_names[lr.subsystem.ordinal], - tid, - thread_name}; + auto lm = LogMsg{lr.ts, msg, + lr.file, lr.line, + lr.level, me->level_names[lr.level.ordinal], + lr.subsystem, me->subsystem_names[lr.subsystem.ordinal], + tid, thread_name}; for (auto &s : me->sinks) if (lr.level.ordinal >= s.filter[lr.subsystem.ordinal].ordinal) @@ -198,8 +194,8 @@ Filter LoggerHub::get_base_filter() const { void LoggerHub::update_logger_queue_limits() { for (auto &l : me->loggers) - l->update_queue_limits(me->logger_initial_queue_size, - me->logger_max_queue_growth); -} -} + l->update_queue_limits( + me->logger_initial_queue_size, me->logger_max_queue_growth); } +} // namespace log +} // namespace bts diff --git a/src/lib/logging/LoggerHub.h b/src/lib/logging/LoggerHub.h index 5b39b3ba7..a46fd257f 100644 --- a/src/lib/logging/LoggerHub.h +++ b/src/lib/logging/LoggerHub.h @@ -1,8 +1,8 @@ #pragma once #include "Common.h" -#include "Sink.h" #include "LoggingConfig.h" +#include "Sink.h" #include @@ -13,14 +13,14 @@ class Logger; struct LogRec; class LoggerHub { -public: - LoggerHub(std::string const& ); + public: + LoggerHub(std::string const &); ~LoggerHub(); void config(const LoggingConfig &cfg); void start(); Logger &make_logger(); -private: + private: struct SinkRec; struct PImpl; std::unique_ptr me; @@ -29,8 +29,9 @@ private: void update_logger_queue_limits(); size_t consume_log_recs(); void rebuild_logger_filters(); - void dispatch_to_sinks(size_t tid,std::string const&thread_name,LogRec&); + void dispatch_to_sinks(size_t tid, std::string const &thread_name, LogRec &); Filter get_base_filter() const; }; -}} +} // namespace log +} // namespace bts diff --git a/src/lib/logging/LoggingConfig.h b/src/lib/logging/LoggingConfig.h index 6c2bafc3e..fa8324f7f 100644 --- a/src/lib/logging/LoggingConfig.h +++ b/src/lib/logging/LoggingConfig.h @@ -1,33 +1,28 @@ #pragma once -#include "Sink.h" #include "Common.h" -#include -#include +#include "Sink.h" #include "lib/config/protos/threads.pb.h" +#include +#include namespace bts { namespace log { struct LoggingConfig { - LoggingConfig() : - logger_initial_queue_size(120000), - logger_max_queue_growth(4), - sinks(), - level_names(), - subsystem_names(), - deployment_type("dev"), - thread_cfg() - { - } + LoggingConfig() + : logger_initial_queue_size(120000), logger_max_queue_growth(4), sinks(), + level_names(), subsystem_names(), deployment_type("dev"), + thread_cfg() {} size_t logger_initial_queue_size = 0; size_t logger_max_queue_growth = 0; - std::map> sinks; - std::map level_names; - std::map subsystem_names; + std::map> sinks; + std::map level_names; + std::map subsystem_names; std::string deployment_type; config::ThreadGroupCfg thread_cfg; }; -}} +} // namespace log +} // namespace bts diff --git a/src/lib/logging/MsgPacking.h b/src/lib/logging/MsgPacking.h index f83d52319..6cbe4d7dd 100644 --- a/src/lib/logging/MsgPacking.h +++ b/src/lib/logging/MsgPacking.h @@ -1,65 +1,64 @@ #pragma once -#include #include -#include +#include #include +#include namespace bts { namespace log { template -std::string format_tuple(const char*msg_template, Tuple const &t,std::index_sequence) -{ +std::string format_tuple( + const char *msg_template, Tuple const &t, std::index_sequence) { try { - return fmt::format(msg_template,std::get(t)...); + return fmt::format(msg_template, std::get(t)...); + } catch (fmt::FormatError const &e) { + return fmt::format( + "Bad log message template: '{}' Error: '{}'", msg_template, e.what()); } - catch (fmt::FormatError const &e) - { - return fmt::format("Bad log message template: '{}' Error: '{}'", - msg_template,e.what()); - } - } template -std::string unpack_msg_args(std::array const&buffer, const char*msg_template) -{ +std::string unpack_msg_args( + std::array const &buffer, const char *msg_template) { std::string result; using Store = std::tuple; if (sizeof(Store) <= SZ) { - auto args = (Store*) &buffer[0]; - result = format_tuple(msg_template,*args,std::index_sequence_for{}); + auto args = (Store *)&buffer[0]; + result = + format_tuple(msg_template, *args, std::index_sequence_for{}); args->~Store(); - } - else { - auto indirect_store = (Store**) &buffer[0]; - auto args = *indirect_store; - result = format_tuple(msg_template,*args,std::index_sequence_for{}); + } else { + auto indirect_store = (Store **)&buffer[0]; + auto args = *indirect_store; + result = + format_tuple(msg_template, *args, std::index_sequence_for{}); delete args; } - return result; + return result; } -template struct CheckPtr { - const static auto value = true; -}; +template struct CheckPtr { const static auto value = true; }; template -struct CheckPtr : public CheckPtr { - static_assert(!std::is_pointer::value,"Pointers cannot be logged"); +struct CheckPtr : public CheckPtr { + static_assert(!std::is_pointer::value, "Pointers cannot be logged"); }; template -void pack_msg_args(std::array &buffer,Args&&...args) { +void pack_msg_args(std::array &buffer, Args &&... args) { using Store = std::tuple::type...>; - static_assert(CheckPtr::type...>::value,"Illegal type logged"); - if(sizeof(Store) <= SZ) + static_assert( + CheckPtr::type...>::value, + "Illegal type logged"); + if (sizeof(Store) <= SZ) new (&buffer[0]) Store(std::forward(args)...); else { auto indirect_store = new Store(std::forward(args)...); - *((Store**) &buffer[0]) = indirect_store; + *((Store **)&buffer[0]) = indirect_store; } } -}} +} // namespace log +} // namespace bts diff --git a/src/lib/logging/Sink.cpp b/src/lib/logging/Sink.cpp index 1896126f7..4b8152fbc 100644 --- a/src/lib/logging/Sink.cpp +++ b/src/lib/logging/Sink.cpp @@ -38,18 +38,18 @@ auto formatter(LoggingConfig const &cfg) { m.subsystem_name, m.level_name, m.tid, // m.thread_name, os::process_id(), - fmt::format("{}:{}", - boost::filesystem::path(m.file).filename().string(), - m.line), + fmt::format( + "{}:{}", boost::filesystem::path(m.file).filename().string(), + m.line), cfg.deployment_type, m.msg); #else return fmt::format( "{}|{}|{:<8}|{:<5}|{:<3}|{:<16}|{:<4}|{:<35}|{}|{} ", iso_date, m.ts, m.subsystem_name, m.level_name, m.tid, m.thread_name, os::process_id(), - fmt::format("{}:{}", - boost::filesystem::path(m.file).filename().string(), - m.line), + fmt::format( + "{}:{}", boost::filesystem::path(m.file).filename().string(), + m.line), cfg.deployment_type, m.msg); #endif }; diff --git a/src/lib/logging/Sink.h b/src/lib/logging/Sink.h index 33be1d6d9..2423c8bac 100644 --- a/src/lib/logging/Sink.h +++ b/src/lib/logging/Sink.h @@ -1,20 +1,20 @@ #pragma once -#include "lib/utils/warn_ctrl.h" #include "Common.h" +#include "lib/utils/warn_ctrl.h" +#include #include #include -#include namespace bts { namespace log { struct LoggingConfig; GCC_DIAG_OFF("-Weffc++") struct LogMsg { - const uint64_t ts ; + const uint64_t ts; const std::string &msg; - + const char *file; const uint16_t line; @@ -28,9 +28,10 @@ struct LogMsg { }; GCC_DIAG_RESTORE() -using Sink = std::function ; -Sink console_sink(LoggingConfig const&cfg); -Sink syslog_sink(LoggingConfig const&cfg); -Sink file_sink(LoggingConfig const&cfg); +using Sink = std::function; +Sink console_sink(LoggingConfig const &cfg); +Sink syslog_sink(LoggingConfig const &cfg); +Sink file_sink(LoggingConfig const &cfg); Sink null_sink(); -}} +} // namespace log +} // namespace bts diff --git a/src/lib/logging/logging.cpp b/src/lib/logging/logging.cpp index eb8729ba3..e224b2c7a 100644 --- a/src/lib/logging/logging.cpp +++ b/src/lib/logging/logging.cpp @@ -2,23 +2,23 @@ #include "LoggerHub.h" #include "lib/config/config.h" +#include "lib/config/protos/logging.pb.h" +#include "lib/config/protos/system.pb.h" #include "lib/os/os.h" +#include "lib/utils/Dispatcher.h" #include "lib/utils/bts_assert.h" #include "lib/utils/bts_chrono.h" -#include "lib/config/protos/logging.pb.h" #include "lib/utils/file_utils.h" -#include "lib/utils/Dispatcher.h" -#include "lib/config/protos/system.pb.h" #include "lib/utils/thread_manager.h" -#include -#include -#include -#include +#include #include #include -#include +#include #include +#include +#include +#include #include namespace bts { @@ -27,58 +27,50 @@ namespace log { static LoggerHub _default_logger_hub("logger"); thread_local LoggerHandle _thread_logger(_default_logger_hub.make_logger()); - template -typename M::const_iterator find_key(M const&m, typename M::mapped_type const &v) -{ - for (auto it = m.begin(); it != m.end();it++) +typename M::const_iterator +find_key(M const &m, typename M::mapped_type const &v) { + for (auto it = m.begin(); it != m.end(); it++) if (it->second == v) return it; return m.end(); } - -boost::filesystem::path log_path () -{ + +boost::filesystem::path log_path() { auto store_root = os::bts_data_path(); - std::string base_path = store_root; - boost::filesystem::path result = utils::normalize_data_path (base_path); + std::string base_path = store_root; + boost::filesystem::path result = utils::normalize_data_path(base_path); result /= "logging"; return result; } -void start_default_logging_thread() -{ - _default_logger_hub.start(); -} +void start_default_logging_thread() { _default_logger_hub.start(); } -Filter get_filter (LoggingConfig &cfg, - config::Logging::SinkConfig const&scfg) -{ +Filter get_filter(LoggingConfig &cfg, config::Logging::SinkConfig const &scfg) { Filter result; for (auto &l : result) l = Info; - - auto it = find_key(cfg.level_names,scfg.default_level()); + auto it = find_key(cfg.level_names, scfg.default_level()); if (it == cfg.level_names.end()) return result; - + auto default_level = it->first; for (auto &l : result) l = default_level; - + for (auto const &sub_system : scfg.subsystem()) { - auto ss_it = find_key(cfg.subsystem_names,sub_system.name()); + auto ss_it = find_key(cfg.subsystem_names, sub_system.name()); if (ss_it == cfg.subsystem_names.end()) continue; - + auto ss = ss_it->first; - auto level_it = find_key(cfg.level_names,sub_system.level()); + auto level_it = find_key(cfg.level_names, sub_system.level()); if (level_it == cfg.level_names.end()) continue; - + auto level = level_it->first; result[ss.ordinal] = level; @@ -86,146 +78,141 @@ Filter get_filter (LoggingConfig &cfg, return result; } -void configure_logging(LoggingConfig const&cfg) {_default_logger_hub.config(cfg);} -void configure_logging(bts::config::Logging const&cfg) {configure_logging(cfg,bts::config::ThreadGroupCfg ());} -void configure_logging(bts::config::Logging const&cfg, bts::config::ThreadGroupCfg const&thread_cfg) -{ +void configure_logging(LoggingConfig const &cfg) { + _default_logger_hub.config(cfg); +} +void configure_logging(bts::config::Logging const &cfg) { + configure_logging(cfg, bts::config::ThreadGroupCfg()); +} +void configure_logging( + bts::config::Logging const &cfg, + bts::config::ThreadGroupCfg const &thread_cfg) { LoggingConfig real_cfg; real_cfg.deployment_type = config::get().type(); real_cfg.logger_initial_queue_size = cfg.initial_queue_size(); real_cfg.logger_max_queue_growth = cfg.max_queue_growth(); - real_cfg.level_names = { {NoLog,"NoLog"},{Diag,"Diag"},{Info,"Info"}, - {Warn,"Warn"},{Error,"Error"}, - {Fatal,"Fatal"},{Sys,"Sys"} }; + real_cfg.level_names = {{NoLog, "NoLog"}, {Diag, "Diag"}, {Info, "Info"}, + {Warn, "Warn"}, {Error, "Error"}, {Fatal, "Fatal"}, + {Sys, "Sys"}}; - real_cfg.subsystem_names = { {log::Gen,"Gen"}, - {log::Cfg,"Cfg"}, - {log::QBus,"QBus"}, - {log::Log,"Log"}, - {log::Jetfix,"Jetfix"}, - {log::md,"md"}, - {log::Api,"Api"}, - {log::persist,"persist"}, - {log::User,"User"}, - {log::OrderMan,"OrderMan"}, - {log::Assert,"Assert"}, - {log::Engine,"Engine"}, - {log::Ui,"UI"}, - {log::ExSim,"ExSim"}, - {log::Mercury,"Mercury"}, - {log::Testing,"Testing"}, - {log::Latency,"Latency"}, - {log::DataFlow,"DataFlow"}, - {log::Plugin,"Plugin"}, - {log::Sdk,"Sdk"}, - {log::Http,"Http"}, - {log::Spartan,"Spartan"}, - {log::iLink3,"iLink3"}, + real_cfg.subsystem_names = { + {log::Gen, "Gen"}, {log::Cfg, "Cfg"}, + {log::QBus, "QBus"}, {log::Log, "Log"}, + {log::Jetfix, "Jetfix"}, {log::md, "md"}, + {log::Api, "Api"}, {log::persist, "persist"}, + {log::User, "User"}, {log::OrderMan, "OrderMan"}, + {log::Assert, "Assert"}, {log::Engine, "Engine"}, + {log::Ui, "UI"}, {log::ExSim, "ExSim"}, + {log::Mercury, "Mercury"}, {log::Testing, "Testing"}, + {log::Latency, "Latency"}, {log::DataFlow, "DataFlow"}, + {log::Plugin, "Plugin"}, {log::Sdk, "Sdk"}, + {log::Http, "Http"}, {log::Spartan, "Spartan"}, + {log::iLink3, "iLink3"}, }; - real_cfg.sinks["console"] = - std::make_pair (console_sink(real_cfg),get_filter(real_cfg,cfg.console())); - real_cfg.sinks["syslog"] = - std::make_pair (syslog_sink(real_cfg),get_filter(real_cfg,cfg.syslog())); + real_cfg.sinks["console"] = std::make_pair( + console_sink(real_cfg), get_filter(real_cfg, cfg.console())); + real_cfg.sinks["syslog"] = std::make_pair( + syslog_sink(real_cfg), get_filter(real_cfg, cfg.syslog())); real_cfg.sinks["file"] = - std::make_pair (file_sink(real_cfg),get_filter(real_cfg,cfg.file())); + std::make_pair(file_sink(real_cfg), get_filter(real_cfg, cfg.file())); real_cfg.thread_cfg = thread_cfg; configure_logging(real_cfg); } -boost::filesystem::path log_cache_file_path () -{ +boost::filesystem::path log_cache_file_path() { auto store_root = os::bts_data_path(); - boost::filesystem::path result = utils::normalize_data_path (store_root); + boost::filesystem::path result = utils::normalize_data_path(store_root); result /= "logging"; result /= "log_control"; return result; } -LoggingConfigPoller::LoggingConfigPoller (bts::config::Logging const&cfg, bts::config::ThreadGroupCfg const&thread_cfg) - : _poller(utils::Dispatcher::background(), 1000, [=]() { poll_once(); }), - _last_ts(std::time(nullptr)), - _log_cache_file(log_cache_file_path()), - _done(false) -{ - init(cfg,thread_cfg); +LoggingConfigPoller::LoggingConfigPoller( + bts::config::Logging const &cfg, + bts::config::ThreadGroupCfg const &thread_cfg) + : _poller(utils::Dispatcher::background(), 1000, [=]() { poll_once(); }), + _last_ts(std::time(nullptr)), _log_cache_file(log_cache_file_path()), + _done(false) { + init(cfg, thread_cfg); } -LoggingConfigPoller::LoggingConfigPoller () : LoggingConfigPoller(config::get(), - threading::get_thread_cfg("logger")) -{ } +LoggingConfigPoller::LoggingConfigPoller() + : LoggingConfigPoller( + config::get(), threading::get_thread_cfg("logger")) { +} -void LoggingConfigPoller::init (bts::config::Logging const&cfg,bts::config::ThreadGroupCfg const&thread_cfg) -{ +void LoggingConfigPoller::init( + bts::config::Logging const &cfg, + bts::config::ThreadGroupCfg const &thread_cfg) { auto parent = _log_cache_file.parent_path(); - if (!boost::filesystem::is_directory(parent)) + if (!boost::filesystem::is_directory(parent)) bts_assert(boost::filesystem::create_directories(parent)); - std::ofstream fs (_log_cache_file.string()); - google::protobuf::io::OstreamOutputStream gs (&fs); - google::protobuf::TextFormat::Print (cfg,&gs); - + std::ofstream fs(_log_cache_file.string()); + google::protobuf::io::OstreamOutputStream gs(&fs); + google::protobuf::TextFormat::Print(cfg, &gs); // initialize logging - configure_logging(cfg,thread_cfg); + configure_logging(cfg, thread_cfg); _poller.start(); } void LoggingConfigPoller::poll_once() { - if (_done) return; - auto current_ts = - boost::filesystem::last_write_time(_log_cache_file) ; + if (_done) + return; + auto current_ts = boost::filesystem::last_write_time(_log_cache_file); if (current_ts != _last_ts) { _last_ts = current_ts; bts::config::Logging cfg; - std::ifstream fs (_log_cache_file.string()); - google::protobuf::io::IstreamInputStream gs (&fs); - if (google::protobuf::TextFormat::Parse (&gs,&cfg)) { - LOG(Log,Info,"Detected logging configuration change. Reconfiguring logging."); + std::ifstream fs(_log_cache_file.string()); + google::protobuf::io::IstreamInputStream gs(&fs); + if (google::protobuf::TextFormat::Parse(&gs, &cfg)) { + LOG(Log, Info, + "Detected logging configuration change. Reconfiguring logging."); configure_logging(cfg); - } - else - LOG(Log,Error,"Detected invalid logging configuration. Ignoring."); + } else + LOG(Log, Error, "Detected invalid logging configuration. Ignoring."); } } -LoggingConfigPoller::~LoggingConfigPoller () -{ +LoggingConfigPoller::~LoggingConfigPoller() { _done = true; _poller.stop(); } - namespace interop { -const char* intern(const char* str) { +const char *intern(const char *str) { static std::mutex mutex; - static boost::container::flat_set set; + static boost::container::flat_set set; std::lock_guard lock(mutex); const auto iter = set.find(str); if (iter != set.end()) { return *iter; - } - else { -#ifdef _WIN32 - const char* v = _strdup(str); -#else - const char* v = strdup(str); + } else { +#ifdef _WIN32 + const char *v = _strdup(str); +#else + const char *v = strdup(str); #endif set.insert(v); return v; } } -extern "C" BTS_EXPORT void Logger_log (int level, int subsystem, const char *message, const char *file, int line) -{ +extern "C" BTS_EXPORT void Logger_log( + int level, int subsystem, const char *message, const char *file, int line) { if (bts::log::_thread_logger.logger != nullptr) { - bts::log::_thread_logger.logger->enqueue(log::log_ts(), log::Subsystem{ (uint8_t)subsystem }, log::Level{ (uint8_t)level }, intern(file), line, "{}", std::string(message)); + bts::log::_thread_logger.logger->enqueue( + log::log_ts(), log::Subsystem{(uint8_t)subsystem}, + log::Level{(uint8_t)level}, intern(file), line, "{}", + std::string(message)); } } -} +} // namespace interop - -}} +} // namespace log +} // namespace bts diff --git a/src/lib/logging/logging.h b/src/lib/logging/logging.h index 8afbdb8ca..a93eae472 100644 --- a/src/lib/logging/logging.h +++ b/src/lib/logging/logging.h @@ -1,87 +1,97 @@ #pragma once -#include -#include +#include "lib/utils/bts_chrono.h" #include "Common.h" #include "Logger.h" #include "LoggerHub.h" #include "lib/utils/Dispatcher.h" +#include #include - +#include namespace bts { -namespace config {class Logging; class ThreadGroupCfg;} +namespace config { +class Logging; +class ThreadGroupCfg; +} // namespace config // Please keep this list in sync with Log.cs -constexpr log::Level NoLog {0}; -constexpr log::Level Diag {NoLog.ordinal+1}; -constexpr log::Level Info {Diag.ordinal+1}; -constexpr log::Level Warn {Info.ordinal+1}; -constexpr log::Level Error {Warn.ordinal+1}; -constexpr log::Level Fatal {Error.ordinal+1}; -constexpr log::Level Sys {log::Level::Max-1}; - +constexpr log::Level NoLog{0}; +constexpr log::Level Diag{NoLog.ordinal + 1}; +constexpr log::Level Info{Diag.ordinal + 1}; +constexpr log::Level Warn{Info.ordinal + 1}; +constexpr log::Level Error{Warn.ordinal + 1}; +constexpr log::Level Fatal{Error.ordinal + 1}; +constexpr log::Level Sys{log::Level::Max - 1}; namespace log { // Please keep this list in sync with Log.cs -constexpr log::Subsystem Gen {0 }; -constexpr log::Subsystem Cfg {Gen.ordinal+1 }; -constexpr log::Subsystem QBus {Cfg.ordinal+1 }; -constexpr log::Subsystem Log {QBus.ordinal+1 }; -constexpr log::Subsystem Jetfix {Log.ordinal+1 }; -constexpr log::Subsystem md {Jetfix.ordinal+1 }; -constexpr log::Subsystem Api {md.ordinal+1 }; -constexpr log::Subsystem persist {Api.ordinal+1 }; -constexpr log::Subsystem User {persist.ordinal+1 }; -constexpr log::Subsystem OrderMan {User.ordinal+1 }; -constexpr log::Subsystem Assert {OrderMan.ordinal+1 }; -constexpr log::Subsystem Engine {Assert.ordinal+1 }; -constexpr log::Subsystem Ui {Engine.ordinal+1 }; -constexpr log::Subsystem ExSim {Ui.ordinal+1 }; -constexpr log::Subsystem Mercury {ExSim.ordinal+1 }; -constexpr log::Subsystem Testing {Mercury.ordinal+1 }; -constexpr log::Subsystem Latency {Testing.ordinal+1 }; -constexpr log::Subsystem DataFlow {Latency.ordinal+1 }; -constexpr log::Subsystem Plugin {DataFlow.ordinal+1 }; -constexpr log::Subsystem Sdk {Plugin.ordinal+1 }; -constexpr log::Subsystem Http {Sdk.ordinal+1 }; -constexpr log::Subsystem Spartan {Http.ordinal+1 }; -constexpr log::Subsystem iLink3 {Spartan.ordinal+1 }; +constexpr log::Subsystem Gen{0}; +constexpr log::Subsystem Cfg{Gen.ordinal + 1}; +constexpr log::Subsystem QBus{Cfg.ordinal + 1}; +constexpr log::Subsystem Log{QBus.ordinal + 1}; +constexpr log::Subsystem Jetfix{Log.ordinal + 1}; +constexpr log::Subsystem md{Jetfix.ordinal + 1}; +constexpr log::Subsystem Api{md.ordinal + 1}; +constexpr log::Subsystem persist{Api.ordinal + 1}; +constexpr log::Subsystem User{persist.ordinal + 1}; +constexpr log::Subsystem OrderMan{User.ordinal + 1}; +constexpr log::Subsystem Assert{OrderMan.ordinal + 1}; +constexpr log::Subsystem Engine{Assert.ordinal + 1}; +constexpr log::Subsystem Ui{Engine.ordinal + 1}; +constexpr log::Subsystem ExSim{Ui.ordinal + 1}; +constexpr log::Subsystem Mercury{ExSim.ordinal + 1}; +constexpr log::Subsystem Testing{Mercury.ordinal + 1}; +constexpr log::Subsystem Latency{Testing.ordinal + 1}; +constexpr log::Subsystem DataFlow{Latency.ordinal + 1}; +constexpr log::Subsystem Plugin{DataFlow.ordinal + 1}; +constexpr log::Subsystem Sdk{Plugin.ordinal + 1}; +constexpr log::Subsystem Http{Sdk.ordinal + 1}; +constexpr log::Subsystem Spartan{Http.ordinal + 1}; +constexpr log::Subsystem iLink3{Spartan.ordinal + 1}; struct LoggerHandle { - LoggerHandle(LoggerHandle const&) = delete; - LoggerHandle& operator=(LoggerHandle const&) = delete; - + LoggerHandle(LoggerHandle const &) = delete; + LoggerHandle &operator=(LoggerHandle const &) = delete; + LoggerHandle() : logger(nullptr) {} - LoggerHandle (Logger &l) : logger(&l) {} - ~LoggerHandle() { if (logger) logger->mark_inactive();} + LoggerHandle(Logger &l) : logger(&l) {} + ~LoggerHandle() { + if (logger) + logger->mark_inactive(); + } Logger *logger; }; -struct CharPtrWrapper -{const char* ptr;}; +struct CharPtrWrapper { + const char *ptr; +}; -inline std::ostream& operator<<(std::ostream&s,CharPtrWrapper const&ptr) -{ +inline std::ostream &operator<<(std::ostream &s, CharPtrWrapper const &ptr) { s << ptr.ptr; return s; } extern thread_local LoggerHandle _thread_logger; -void configure_logging(LoggingConfig const&cfg); -void configure_logging(bts::config::Logging const&cfg,bts::config::ThreadGroupCfg const&); -void configure_logging(bts::config::Logging const&cfg); +void configure_logging(LoggingConfig const &cfg); +void configure_logging( + bts::config::Logging const &cfg, bts::config::ThreadGroupCfg const &); +void configure_logging(bts::config::Logging const &cfg); void start_default_logging_thread(); class LoggingConfigPoller { -public: - LoggingConfigPoller (); - LoggingConfigPoller (bts::config::Logging const&cfg, bts::config::ThreadGroupCfg const&thread_cfg); - ~LoggingConfigPoller (); + public: + LoggingConfigPoller(); + LoggingConfigPoller( + bts::config::Logging const &cfg, + bts::config::ThreadGroupCfg const &thread_cfg); + ~LoggingConfigPoller(); -private: - void init(bts::config::Logging const&cfg, bts::config::ThreadGroupCfg const&thread_cfg); + private: + void init( + bts::config::Logging const &cfg, + bts::config::ThreadGroupCfg const &thread_cfg); void poll_once(); utils::DispatcherTimer _poller; std::time_t _last_ts; @@ -89,12 +99,19 @@ private: std::atomic _done; }; -boost::filesystem::path log_path (); +boost::filesystem::path log_path(); -#define LOG(subsystem,level,...) bts::log::_thread_logger.logger->is_loggable(bts::log::subsystem,level) \ - && bts::log::_thread_logger.logger->enqueue(bts::log::log_ts(),bts::log::subsystem,level,__FILE__,__LINE__,__VA_ARGS__) +#define LOG(subsystem, level, ...) \ + bts::log::_thread_logger.logger->is_loggable(bts::log::subsystem, level) && \ + bts::log::_thread_logger.logger->enqueue( \ + bts::log::log_ts(), bts::log::subsystem, level, __FILE__, __LINE__, \ + __VA_ARGS__) -#define LOG_ONCE_MAYBE(subsystem,level,...) bts::log::_thread_logger.logger->is_loggable(bts::log::subsystem,level) \ - && bts::log::_thread_logger.logger->enqueue_once_maybe(bts::log::log_ts(),log::subsystem,level,__FILE__,__LINE__,__VA_ARGS__) +#define LOG_ONCE_MAYBE(subsystem, level, ...) \ + bts::log::_thread_logger.logger->is_loggable(bts::log::subsystem, level) && \ + bts::log::_thread_logger.logger->enqueue_once_maybe( \ + bts::log::log_ts(), log::subsystem, level, __FILE__, __LINE__, \ + __VA_ARGS__) -}} +} // namespace log +} // namespace bts diff --git a/src/lib/logging/tests/logging_tests.cpp b/src/lib/logging/tests/logging_tests.cpp index db95fa93c..1f71ee0a6 100644 --- a/src/lib/logging/tests/logging_tests.cpp +++ b/src/lib/logging/tests/logging_tests.cpp @@ -1,49 +1,46 @@ #include "catch/catch.hpp" -#include "lib/utils/bts_chrono.h" #include "lib/config/config.h" -#include "lib/logging/logging.h" #include "lib/config/protos/logging.pb.h" +#include "lib/logging/logging.h" +#include "lib/utils/bts_chrono.h" namespace bts { -int logging_tests ; +int logging_tests; -TEST_CASE("Logging Tests","[logging] [benchmark]") { +TEST_CASE("Logging Tests", "[logging] [benchmark]") { auto sz = 1000000; log::Filter f; for (auto &l : f) l = Diag; log::LoggingConfig cfg; - cfg.logger_initial_queue_size = sz*10; - cfg.sinks["null_sink"] = std::make_pair ( [](log::LogMsg const&) {}, f ); + cfg.logger_initial_queue_size = sz * 10; + cfg.sinks["null_sink"] = std::make_pair([](log::LogMsg const &) {}, f); log::configure_logging(cfg); - LOG(Gen,Info,"Kicking things off"); + LOG(Gen, Info, "Kicking things off"); - SECTION("timestamp_interpolation") - { + 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()); + 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(Testing,Info,"Logging: ns/msg for log with timestamps: {} tt: {} ", - bts::ns_diff(stop,start) / sz, - bts::ns_diff(stop,start) ); + LOG(Testing, Info, "Logging: ns/msg for log with timestamps: {} tt: {} ", + bts::ns_diff(stop, start) / sz, bts::ns_diff(stop, start)); } - SECTION("int_interpolation") - { + SECTION("int_interpolation") { auto start = bts::Timer::now(); - for (int i = 0; i < sz;i++) - LOG(Gen,Info,"Hello World. This is interpolating a number {0}",12); + for (int i = 0; i < sz; i++) + LOG(Gen, Info, "Hello World. This is interpolating a number {0}", 12); auto stop = bts::Timer::now(); - LOG(Testing,Info,"Logging: ns/msg for log with simple number interpolation: {} tt: {} ", - bts::ns_diff(stop,start) / sz, - bts::ns_diff(stop,start) ); + LOG(Testing, Info, + "Logging: ns/msg for log with simple number interpolation: {} tt: " + "{} ", + bts::ns_diff(stop, start) / sz, bts::ns_diff(stop, start)); } - SECTION("large_string_interpolation") - { - std::array strs; + SECTION("large_string_interpolation") { + std::array strs; int i = 0; strs[i++] = "aaaaaaaaaaaaaaaaa"; strs[i++] = "aaaaaaaaaaaaaaaaa"; @@ -55,27 +52,26 @@ TEST_CASE("Logging Tests","[logging] [benchmark]") { strs[i++] = "aaaaaaaaaaaaaaaaa"; auto start = bts::Timer::now(); - for (int i = 0; i < sz;i++) - LOG(Gen,Info,"Hello World. This is interpolating a string ",strs[i & 0x00000007] ); + for (int i = 0; i < sz; i++) + LOG(Gen, Info, "Hello World. This is interpolating a string ", + strs[i & 0x00000007]); auto stop = bts::Timer::now(); - LOG(Testing,Info,"Logging: ns/msg for log with large string interpolation: {} tt: {} ", - bts::ns_diff(stop,start) / sz, - bts::ns_diff(stop,start) ); + LOG(Testing, Info, + "Logging: ns/msg for log with large string interpolation: {} tt: {} ", + bts::ns_diff(stop, start) / sz, bts::ns_diff(stop, start)); } - SECTION("log_skipping") - { + SECTION("log_skipping") { auto start = bts::Timer::now(); - for (int i = 0; i < sz;i++) - LOG(Gen,Diag,"Hello World. I am {} years old!",i); + for (int i = 0; i < sz; i++) + LOG(Gen, Diag, "Hello World. I am {} years old!", i); auto stop = bts::Timer::now(); - LOG(Testing,Info,"Logging: ns/msg for log skipping: {} tt: {} ", - bts::ns_diff(stop,start) / sz, - bts::ns_diff(stop,start) ); + LOG(Testing, Info, "Logging: ns/msg for log skipping: {} tt: {} ", + bts::ns_diff(stop, start) / sz, bts::ns_diff(stop, start)); } - auto cfg2 = config::get (); + auto cfg2 = config::get(); cfg2.mutable_console()->set_default_level("Fatal"); log::configure_logging(cfg2); } -} +} // namespace bts diff --git a/src/lib/md/Diag/MDPeriodicDumper.cpp b/src/lib/md/Diag/MDPeriodicDumper.cpp index d25ab3d5f..0eda31815 100644 --- a/src/lib/md/Diag/MDPeriodicDumper.cpp +++ b/src/lib/md/Diag/MDPeriodicDumper.cpp @@ -1,27 +1,27 @@ #include "MDPeriodicDumper.h" +#include "lib/config/protos/system.pb.h" #include "lib/md/MDConsumer.h" #include "lib/md/SecurityCache.h" -#include "lib/utils/TimeStamp.h" #include "lib/utils/Dispatcher.h" +#include "lib/utils/TimeStamp.h" #include "lib/utils/datetime.h" -#include "lib/config/protos/system.pb.h" #include "lib/utils/thread_manager.h" +#include +#include #include #include -#include -#include namespace bts { namespace md { /* * Design considerations - * + * * - We want this test to be 'fair' * - We want a manageable amount of data - * - -*/ + * - + */ struct Entry { uint32_t seq; @@ -30,93 +30,97 @@ struct Entry { }; std::string print_book( - PrintFormat format, - const Entry& e, - utils::TimeStamp twrite, - utils::TimeStamp tread, - uint32_t seq, - bool ambiguous, - const std::array& bid, - const std::array& ask) { + PrintFormat format, const Entry &e, utils::TimeStamp twrite, + utils::TimeStamp tread, uint32_t seq, bool ambiguous, + const std::array &bid, + const std::array &ask) { - std::stringstream ss; - if(format == PrintFormat::Human) { - ss << std::endl; - ss << e.security->glbx().security_desc() << " (" << e.handle.key() << ")" << std::endl; - ss << "Sequence: " << seq; - if (ambiguous) ss << "*"; - ss << std::endl; - ss << "TWrit: " << twrite.to_uint64() << " ns" << std::endl; - ss << "TRead: " << tread.to_uint64() << " ns" << std::endl; - char buffer[512]; + std::stringstream ss; + if (format == PrintFormat::Human) { + ss << std::endl; + ss << e.security->glbx().security_desc() << " (" << e.handle.key() << ")" + << std::endl; + ss << "Sequence: " << seq; + if (ambiguous) + ss << "*"; + ss << std::endl; + ss << "TWrit: " << twrite.to_uint64() << " ns" << std::endl; + ss << "TRead: " << tread.to_uint64() << " ns" << std::endl; + char buffer[512]; - snprintf(buffer, 512, "%-5s %-14s | %-14s %-5s\n", "sz", "bid", "ask", "sz"); - ss << buffer; - ss << "-------------------- - -------------------- \n"; - for (auto x = COCONUT_MAX_DEPTH; x != 0; --x) { - auto a = ask[x-1]; - if (!os::is_nan(a.price())) { - snprintf(buffer, 512, "%5s %14s | %14.7f %5d\n", "", "", a.price(), a.size()); - ss << buffer; - } - } - ss << "-------------------- - -------------------- \n"; - for (uint32_t x = 0; x < COCONUT_MAX_DEPTH; ++x) { - auto b = bid[x]; - if (!os::is_nan(b.price())) { - snprintf(buffer, 512, "%5d %14.7f | \n", b.size(), b.price()); - ss << buffer; - } + snprintf( + buffer, 512, "%-5s %-14s | %-14s %-5s\n", "sz", "bid", "ask", "sz"); + ss << buffer; + ss << "-------------------- - -------------------- \n"; + for (auto x = COCONUT_MAX_DEPTH; x != 0; --x) { + auto a = ask[x - 1]; + if (!os::is_nan(a.price())) { + snprintf( + buffer, 512, "%5s %14s | %14.7f %5d\n", "", "", a.price(), + a.size()); + ss << buffer; } } - else if (format == PrintFormat::CSV) { - // Symbol, Id, Sequence, Ambiguous, TWrite, TRead, BidBook, AskBook - ss << e.security->glbx().security_desc() << "," - << e.security->id() << "," - << seq << "," - << (ambiguous ? "true," : "false,") - << (e.handle.status() == co2::COCONUTSECURITYSTATUS_OK ? "OK," : "GAP,") - << twrite.to_uint64() << "," - << tread.to_uint64() << ","; - for (size_t x = 0; x < COCONUT_MAX_DEPTH; ++x) { - if (!bid[x].is_nan()) { - ss << " " << std::setprecision(11) << bid[x].price() << "-"; - if (bid[x].implied_size() > 0) { ss << "*"; } - ss << bid[x].size(); - } + ss << "-------------------- - -------------------- \n"; + for (uint32_t x = 0; x < COCONUT_MAX_DEPTH; ++x) { + auto b = bid[x]; + if (!os::is_nan(b.price())) { + snprintf(buffer, 512, "%5d %14.7f | \n", b.size(), b.price()); + ss << buffer; } - ss << ","; - for (size_t x = 0; x < COCONUT_MAX_DEPTH; ++x) { - if (!ask[x].is_nan()) { - ss << " " << std::setprecision(11) << ask[x].price() << "-"; - if (ask[x].implied_size() > 0) { ss << "*"; } - ss << ask[x].size(); - } - } - ss << std::endl; } - return ss.str(); + } else if (format == PrintFormat::CSV) { + // Symbol, Id, Sequence, Ambiguous, TWrite, TRead, BidBook, AskBook + ss << e.security->glbx().security_desc() << "," << e.security->id() << "," + << seq << "," << (ambiguous ? "true," : "false,") + << (e.handle.status() == co2::COCONUTSECURITYSTATUS_OK ? "OK," + : "GAP,") + << twrite.to_uint64() << "," << tread.to_uint64() << ","; + for (size_t x = 0; x < COCONUT_MAX_DEPTH; ++x) { + if (!bid[x].is_nan()) { + ss << " " << std::setprecision(11) << bid[x].price() << "-"; + if (bid[x].implied_size() > 0) { + ss << "*"; + } + ss << bid[x].size(); + } + } + ss << ","; + for (size_t x = 0; x < COCONUT_MAX_DEPTH; ++x) { + if (!ask[x].is_nan()) { + ss << " " << std::setprecision(11) << ask[x].price() << "-"; + if (ask[x].implied_size() > 0) { + ss << "*"; + } + ss << ask[x].size(); + } + } + ss << std::endl; + } + return ss.str(); } -datetime::Date expiration(const api::Security& sec) { +datetime::Date expiration(const api::Security &sec) { auto f = sec.future(); - return { (uint16_t)f.expiration_year(), (uint8_t)f.expiration_month(), (uint8_t)f.expiration_day() }; + return { + (uint16_t)f.expiration_year(), (uint8_t)f.expiration_month(), + (uint8_t)f.expiration_day()}; } -std::vector filter_entries(std::vector& entries) { +std::vector filter_entries(std::vector &entries) { // Choose the front month for all symbols auto today = datetime::today(); - std::map map; - for (auto& e : entries) { + std::map map; + for (auto &e : entries) { auto type = securitytype_of(*e.security); // Only futures because front month is complicated - if (type != api::SECURITYTYPE_FUTURE) continue; - UserSymbol key { e.security->symbol(), e.security->exchange(), type }; - auto& current_entry = map[key]; + if (type != api::SECURITYTYPE_FUTURE) + continue; + UserSymbol key{e.security->symbol(), e.security->exchange(), type}; + auto ¤t_entry = map[key]; if (current_entry == nullptr) { current_entry = &e; - } - else { + } else { auto cur = expiration(*current_entry->security); auto next = expiration(*e.security); if (next > today && next < cur) { @@ -126,34 +130,39 @@ std::vector filter_entries(std::vector& entries) { } std::vector result; - for (const auto& pair : map) { + for (const auto &pair : map) { result.push_back(std::move(*pair.second)); } return result; } -void write_header(PrintFormat format, long seq_mod, const std::vector& entries) { +void write_header( + PrintFormat format, long seq_mod, const std::vector &entries) { if (format == PrintFormat::Human) { std::cout << "Dumping every sequence % " << seq_mod << " == 0 for\n"; std::cout << "Selected securities: " << std::endl; - for (const auto& e : entries) { + for (const auto &e : entries) { std::cout << e.security->glbx().security_desc() << std::endl; } - } - else { + } else { // CSV header - std::cout << "Symbol,Id,Sequence,Ambiguous,Status,TWrite,TRead,BidBook,AskBook"; + std::cout + << "Symbol,Id,Sequence,Ambiguous,Status,TWrite,TRead,BidBook,AskBook"; // for (size_t x = 0; x < COCONUT_MAX_DEPTH; ++x) { - // std::cout << "," << "Bid" << x << ", DirectBidSize" << x << ", ImpliedBidSize" << x; + // std::cout << "," << "Bid" << x << ", DirectBidSize" << x << ", + // ImpliedBidSize" << x; // } // for (size_t x = 0; x < COCONUT_MAX_DEPTH; ++x) { - // std::cout << "," << "Ask" << x << ", AskSize" << x << ", ImpliedAskSize" << x; + // std::cout << "," << "Ask" << x << ", AskSize" << x << ", + // ImpliedAskSize" << x; // } std::cout << std::endl; } } -void run_periodic_dumper(const std::set& symbols, uint32_t seq_mod, PrintFormat format, bool monitor_all) { +void run_periodic_dumper( + const std::set &symbols, uint32_t seq_mod, PrintFormat format, + bool monitor_all) { auto qualifier = config::get().qualifier(); auto thread_name = "tail-" + qualifier; @@ -164,9 +173,10 @@ void run_periodic_dumper(const std::set& symbols, uint32_t seq_mod, // read all securities into a vector std::vector entries; - consumer.walk_security_list([&](const SecurityPtr& sec, MDConsumerHandle handle) { - entries.push_back({ 0, handle, sec }); - }); + consumer.walk_security_list( + [&](const SecurityPtr &sec, MDConsumerHandle handle) { + entries.push_back({0, handle, sec}); + }); if (!monitor_all) { entries = filter_entries(entries); @@ -174,26 +184,30 @@ void run_periodic_dumper(const std::set& symbols, uint32_t seq_mod, write_header(format, seq_mod, entries); - auto& disp = utils::Dispatcher::background(); + auto &disp = utils::Dispatcher::background(); // spin around on the vector detecting changes - std::array bid,ask; - while(true) { - for(auto& e : entries) { + std::array bid, ask; + while (true) { + for (auto &e : entries) { auto sequence = e.handle.sequence(); if (sequence != e.seq && sequence % seq_mod == 0) { e.seq = sequence; auto tread = TimeStamp::now(); utils::TimeStamp twrite; - e.handle.get_book(twrite, COCONUT_MAX_DEPTH, bid.data(), ask.data()); + e.handle.get_book( + twrite, COCONUT_MAX_DEPTH, bid.data(), ask.data()); auto seq2 = e.handle.sequence(); // print book to stdout (async?) - disp.post([=,&e]() { - std::cout << print_book(format, e, twrite, tread, sequence, (sequence != seq2), bid, ask); + disp.post([=, &e]() { + std::cout << print_book( + format, e, twrite, tread, sequence, (sequence != seq2), bid, + ask); }); } } } } -}}//ns \ No newline at end of file +} // namespace md +} // namespace bts \ No newline at end of file diff --git a/src/lib/md/Diag/MDPeriodicDumper.h b/src/lib/md/Diag/MDPeriodicDumper.h index 483901cd0..21965ec5d 100644 --- a/src/lib/md/Diag/MDPeriodicDumper.h +++ b/src/lib/md/Diag/MDPeriodicDumper.h @@ -5,13 +5,11 @@ namespace bts { namespace md { -enum class PrintFormat { - Human, - CSV -}; +enum class PrintFormat { Human, CSV }; +void run_periodic_dumper( + const std::set &, uint32_t seq_mod, PrintFormat format, + bool monitor_all); -void run_periodic_dumper(const std::set&, uint32_t seq_mod, PrintFormat format, bool monitor_all); - - -}}//ns \ No newline at end of file +} // namespace md +} // namespace bts \ No newline at end of file diff --git a/src/lib/md/Diag/ShmDumper.cpp b/src/lib/md/Diag/ShmDumper.cpp index c75ac60a8..fba409c81 100644 --- a/src/lib/md/Diag/ShmDumper.cpp +++ b/src/lib/md/Diag/ShmDumper.cpp @@ -7,8 +7,8 @@ #include "../Shm/MDStructure.h" #include "lib/logging/logging.h" -#include #include +#include namespace bts { namespace md { @@ -16,14 +16,11 @@ using namespace utils; using namespace std; using namespace api; -ShmDumper::ShmDumper(const string& name) : _name(name) -{} +ShmDumper::ShmDumper(const string &name) : _name(name) {} ShmDumper::~ShmDumper() {} -double dump(TimeStamp time) { - return (TimeStamp::now() - time).seconds(); -} +double dump(TimeStamp time) { return (TimeStamp::now() - time).seconds(); } string dump(IntPrice price) { stringstream res; @@ -33,7 +30,7 @@ string dump(IntPrice price) { string dump(PriceSize ps) { stringstream res; res << "{"; - res << "'price': " << std::setprecision(11) << ps.price(); + res << "'price': " << std::setprecision(11) << ps.price(); if (!ps.is_nan()) { res << " (^" << (int)ps.exponent() << ")"; } @@ -44,11 +41,11 @@ string dump(PriceSize ps) { return res.str(); } -string dump(const AtomicPriceSize& pss) { +string dump(const AtomicPriceSize &pss) { return dump(std::get(pss.load())); } -string dump_header(const ColdHeader& header) { +string dump_header(const ColdHeader &header) { stringstream res; res << "{"; res << "'count': " << header.count << ", "; @@ -66,8 +63,9 @@ string dump_header(const ColdHeader& header) { res << "}"; return res.str(); } -void write_date_string(uint32_t year, uint32_t month, uint32_t day, std::ostringstream& result); -string dump_security(const FixedSecurity& security) { +void write_date_string( + uint32_t year, uint32_t month, uint32_t day, std::ostringstream &result); +string dump_security(const FixedSecurity &security) { ostringstream res; res << "{"; res << "'key': " << security.key << ", "; @@ -90,50 +88,56 @@ string dump_security(const FixedSecurity& security) { res << "'low_tick': " << security.low_tick << ", "; res << "'high_tick': " << security.high_tick << ", "; res << "'cpp': " << security.cash_per_point << ", "; - - res << "'market_description ': " << security.ice_market_description() << ", "; + + res << "'market_description ': " << security.ice_market_description() + << ", "; res << "'cleared_alias ': " << security.ice_cleared_alias() << ", "; res << "'product_description ': " << security.ice_product_name() << ", "; res << "'hub_alias ': " << security.ice_hub_alias() << ", "; res << "'strip_name': " << security.ice_strip_name() << ", "; res << "'mic_code': " << security.mic_code() << ", "; - switch(security.type) { - case SECURITYTYPE_STOCK: break; - case SECURITYTYPE_FUTURE: { - auto* psec = static_cast(&security); - res << "'expiration': '"; - write_date_string(psec->expiration_year, psec->expiration_month, psec->expiration_day, res); - res << "' "; - break; + switch (security.type) { + case SECURITYTYPE_STOCK: + break; + case SECURITYTYPE_FUTURE: { + auto *psec = static_cast(&security); + res << "'expiration': '"; + write_date_string( + psec->expiration_year, psec->expiration_month, psec->expiration_day, + res); + res << "' "; + break; + } + case SECURITYTYPE_OPTION: { + auto *psec = static_cast(&security); + res << "'expiration': '"; + write_date_string( + psec->expiration_year, psec->expiration_month, psec->expiration_day, + res); + res << "', "; + res << "'strike': " << psec->strike << ", "; + res << "'callput': '" << api::PutOrCall_Name(psec->call_put) << "' "; + break; + } + case SECURITYTYPE_SPREAD: { + auto *psec = static_cast(&security); + res << "'legs': ["; + for (size_t x = 0; x < psec->leg_count(); ++x) { + auto &leg = psec->legs[x]; + if (x > 0) + res << ","; + res << "{ 'key': " << leg.key << ", 'exkey': " << leg.exchange_key + << ", 'quantity': " << leg.leg_quantity + << ", 'leg_price': " << leg.leg_price + << ", 'delta': " << leg.leg_delta << ", 'side': '" + << api::Side_Name(leg.leg_side) << "' }"; } - case SECURITYTYPE_OPTION: { - auto* psec = static_cast(&security); - res << "'expiration': '"; - write_date_string(psec->expiration_year, psec->expiration_month, psec->expiration_day, res); - res << "', "; - res << "'strike': " <strike << ", "; - res << "'callput': '" << api::PutOrCall_Name(psec->call_put) << "' "; - break; - } - case SECURITYTYPE_SPREAD: { - auto* psec = static_cast(&security); - res << "'legs': ["; - for (size_t x = 0; x < psec->leg_count(); ++x) { - auto& leg = psec->legs[x]; - if (x > 0) res << ","; - res << "{ 'key': " << leg.key - << ", 'exkey': " << leg.exchange_key - << ", 'quantity': " << leg.leg_quantity - << ", 'leg_price': " << leg.leg_price - << ", 'delta': " << leg.leg_delta - << ", 'side': '" << api::Side_Name(leg.leg_side) - << "' }"; - } - res << "]"; - break; - } - default: break; + res << "]"; + break; + } + default: + break; } res << "}"; @@ -151,36 +155,48 @@ string dump(datetime::Date date) { } bool has_value(PriceSize p) { return p.size() > 0; } -bool has_value(const AtomicPriceSize& p) { return has_value(std::get(p.load())); } +bool has_value(const AtomicPriceSize &p) { + return has_value(std::get(p.load())); +} -string dump_entry(const ColdEntry& entry) { +string dump_entry(const ColdEntry &entry) { stringstream res; res << "{"; res << "'security': " << dump_security(entry.security) << ", "; - if (has_value(entry.last_trade)) res << "'last_trade': " << dump(entry.last_trade) << ", "; - if (entry.total_volume > 0) res << "'total_volume': " << entry.total_volume << ", "; - if (entry.last_trade_time > 0) res << "'last_trade_time_ll': " << entry.last_trade_time << ", "; + if (has_value(entry.last_trade)) + res << "'last_trade': " << dump(entry.last_trade) << ", "; + if (entry.total_volume > 0) + res << "'total_volume': " << entry.total_volume << ", "; + if (entry.last_trade_time > 0) + res << "'last_trade_time_ll': " << entry.last_trade_time << ", "; // Reminder: settlement price is in hot - if (entry.misc.settlement_date.year > 0) res << "'settlement_date': " << dump(entry.misc.settlement_date) << ", "; - if (!(entry.misc.previous_settlement_price.is_nan())) res << "'previous_settlement_price': " << entry.misc.previous_settlement_price.price() << ", "; - if (entry.misc.previous_settlement_date.year > 0) res << "'previous_settlement_date': " << dump(entry.misc.previous_settlement_date) << ", "; + if (entry.misc.settlement_date.year > 0) + res << "'settlement_date': " << dump(entry.misc.settlement_date) << ", "; + if (!(entry.misc.previous_settlement_price.is_nan())) + res << "'previous_settlement_price': " + << entry.misc.previous_settlement_price.price() << ", "; + if (entry.misc.previous_settlement_date.year > 0) + res << "'previous_settlement_date': " + << dump(entry.misc.previous_settlement_date) << ", "; res << "'status': " << co2::TradingStatus_Name(entry.exchange_status) << " "; res << "'deleted': " << std::boolalpha << entry.deleted << " "; res << "}"; return res.str(); } -string dump_entry(const HotDepthEntry& entry) { +string dump_entry(const HotDepthEntry &entry) { stringstream res; res << "{ "; res << "'timestamp': " << dump(entry.time()) << ", "; res << "'key': " << entry.key << ", "; res << "'settlement': '" << dump(entry.settlement) << "', "; - res << "'status': '" << CoconutSecurityStatus_Name((CoconutSecurityStatus)entry.status) << "', "; + res << "'status': '" + << CoconutSecurityStatus_Name((CoconutSecurityStatus)entry.status) + << "', "; res << "'sequence': '" << entry.sequence << "', "; - + res << "\n 'bid': ["; - for (const auto& level : entry.direct) { + for (const auto &level : entry.direct) { if (!level.bid().is_nan()) { res << dump(level.bid()) << ", "; } @@ -188,15 +204,15 @@ string dump_entry(const HotDepthEntry& entry) { res << "], "; res << "\n 'ask': ["; - for (const auto& level : entry.direct) { + for (const auto &level : entry.direct) { if (!level.ask().is_nan()) { res << dump(level.ask()) << ", "; } } res << "], "; - + res << "\n 'implied_bid': ["; - for (const auto& level : entry.implied) { + for (const auto &level : entry.implied) { if (!level.bid().is_nan()) { res << dump(level.bid()) << ", "; } @@ -204,7 +220,7 @@ string dump_entry(const HotDepthEntry& entry) { res << "], "; res << "\n 'implied_ask': ["; - for (const auto& level : entry.implied) { + for (const auto &level : entry.implied) { if (!level.ask().is_nan()) { res << dump(level.ask()) << ", "; } @@ -215,30 +231,37 @@ string dump_entry(const HotDepthEntry& entry) { return res.str(); } -string dump_entry(const HotEntry& entry) { +string dump_entry(const HotEntry &entry) { stringstream res; res << "{ "; res << "'timestamp': " << dump(entry.time()) << ", "; res << "'key': " << entry.key << ", "; res << "'bid': " << dump(entry.book.bid()) << ", "; res << "'ask': " << dump(entry.book.ask()) << ", "; - res << "'status': '" << CoconutSecurityStatus_Name((CoconutSecurityStatus)entry.status) << "', "; + res << "'status': '" + << CoconutSecurityStatus_Name((CoconutSecurityStatus)entry.status) + << "', "; res << "'sequence': '" << entry.sequence << "', "; res << " }"; return res.str(); } void ShmDumper::dump_cold() { - SharedListReader reader(_name+"_cold"); - if (!reader.is_initialized()) { LOG(md,Info,"Unable to initialize section {}", _name); return; } - const auto& header = reader.header(); + SharedListReader reader(_name + "_cold"); + if (!reader.is_initialized()) { + LOG(md, Info, "Unable to initialize section {}", _name); + return; + } + const auto &header = reader.header(); // dump the header cout << "{ " << endl; cout << "'header': " << dump_header(header) << "," << endl; cout << "'entries': [" << endl; bool first = true; - reader.all_entries([&](const ColdEntry& entry) { - if (!first) { cout << "," << endl; } + reader.all_entries([&](const ColdEntry &entry) { + if (!first) { + cout << "," << endl; + } cout << dump_entry(entry); first = false; }); @@ -246,41 +269,43 @@ void ShmDumper::dump_cold() { } template -void dump_hot_t(SharedListReader& reader) { - if (!reader.is_initialized()) { LOG(md,Info,"Unable to initialize section "); return; } - auto& header = reader.header(); +void dump_hot_t(SharedListReader &reader) { + if (!reader.is_initialized()) { + LOG(md, Info, "Unable to initialize section "); + return; + } + auto &header = reader.header(); cout << "{ " << endl; - cout << "'header': { 'count': " << header.count - << ", 'segment_count': " << header.segment_count - << ", 'direct_count': " << header.direct_count - << ", 'implied_count': " << header.implied_count << "}," << endl; + cout << "'header': { 'count': " << header.count + << ", 'segment_count': " << header.segment_count + << ", 'direct_count': " << header.direct_count + << ", 'implied_count': " << header.implied_count << "}," << endl; cout << "'entries': [ " << endl; - reader.all_entries([&](const TEntry& entry) { cout << dump_entry(entry) << "," << endl; }); + reader.all_entries( + [&](const TEntry &entry) { cout << dump_entry(entry) << "," << endl; }); cout << "] }" << endl; } void ShmDumper::dump_hot() { SharedListReader cold_reader(_name + "_cold"); - if (!cold_reader.is_initialized()) - { - LOG(md,Info, + if (!cold_reader.is_initialized()) { + LOG(md, Info, "Unable to initialize section {}_cold - needed to " - "determine metadata.",_name); + "determine metadata.", + _name); return; } - - const auto& header = cold_reader.header(); + + const auto &header = cold_reader.header(); if (header.has_depth) { SharedListReader reader(_name + "_hot"); dump_hot_t(reader); - } - else { + } else { SharedListReader reader(_name + "_hot"); dump_hot_t(reader); } - } - -}}//namespace +} // namespace md +} // namespace bts #endif diff --git a/src/lib/md/Diag/ShmDumper.h b/src/lib/md/Diag/ShmDumper.h index 40d50a6a5..312032257 100644 --- a/src/lib/md/Diag/ShmDumper.h +++ b/src/lib/md/Diag/ShmDumper.h @@ -1,24 +1,23 @@ #pragma once -#include "lib/utils/bts_no_copy.h" #include "lib/utils/bts_export.h" +#include "lib/utils/bts_no_copy.h" #include namespace bts { namespace md { -class BTS_EXPORT ShmDumper -{ -public: - ShmDumper(const std::string& name); +class BTS_EXPORT ShmDumper { + public: + ShmDumper(const std::string &name); ~ShmDumper(); void dump_hot(); void dump_cold(); -private: + private: BTS_NO_COPY(ShmDumper); std::string _name; }; -}}//namespace - +} // namespace md +} // namespace bts diff --git a/src/lib/md/ExchangeOrderKey.h b/src/lib/md/ExchangeOrderKey.h index b3d59e459..61a43cdd0 100644 --- a/src/lib/md/ExchangeOrderKey.h +++ b/src/lib/md/ExchangeOrderKey.h @@ -1,7 +1,9 @@ #pragma once #include "lib/utils/ValueWrapper.h" namespace bts { -namespace md { -using ExchangeOrderKey = utils::ValueWrapper; -using SparkOrderKey = utils::ValueWrapper; -} } \ No newline at end of file +namespace md { +using ExchangeOrderKey = + utils::ValueWrapper; +using SparkOrderKey = utils::ValueWrapper; +} // namespace md +} // namespace bts \ No newline at end of file diff --git a/src/lib/md/ExchangeSecurityKey.h b/src/lib/md/ExchangeSecurityKey.h index 7ff62dbd2..106cba0ee 100644 --- a/src/lib/md/ExchangeSecurityKey.h +++ b/src/lib/md/ExchangeSecurityKey.h @@ -1,5 +1,6 @@ #pragma once #include "lib/utils/ValueWrapper.h" namespace bts { -using ExchangeSecurityKey = utils::ValueWrapper; +using ExchangeSecurityKey = + utils::ValueWrapper; } \ No newline at end of file diff --git a/src/lib/md/ISyntheticSecurityService.h b/src/lib/md/ISyntheticSecurityService.h index b038d31ed..d982e7254 100644 --- a/src/lib/md/ISyntheticSecurityService.h +++ b/src/lib/md/ISyntheticSecurityService.h @@ -9,11 +9,12 @@ namespace bts { namespace api { class ISyntheticSecurityService { -public: - virtual const std::unordered_map securities() = 0; - virtual utils::EventSubscriber& on_securities() = 0; - virtual const synthetic::Metadata* get_metadata(SecurityKey) = 0; - virtual utils::EventSubscriber& on_metadata() = 0; + public: + virtual const std::unordered_map securities() = 0; + virtual utils::EventSubscriber &on_securities() = 0; + virtual const synthetic::Metadata *get_metadata(SecurityKey) = 0; + virtual utils::EventSubscriber &on_metadata() = 0; }; -}} +} // namespace api +} // namespace bts diff --git a/src/lib/md/IntPrice.h b/src/lib/md/IntPrice.h index 3c35a6a11..85a6f50c1 100644 --- a/src/lib/md/IntPrice.h +++ b/src/lib/md/IntPrice.h @@ -1,7 +1,7 @@ #pragma once -#include "lib/utils/bts_assert.h" -#include "lib/utils/bts_array_size.h" #include "lib/domain_model/Security.pb.h" +#include "lib/utils/bts_array_size.h" +#include "lib/utils/bts_assert.h" namespace bts { namespace md { @@ -9,10 +9,10 @@ namespace md { const extern double NO_PRICE; static const double powers_10[] = { - 1E-20, 1E-19, 1E-18, 1E-17, 1E-16, 1E-15, 1E-14, 1E-13, 1E-12, 1E-11, 1E-10, 1E-9, 1E-8, 1E-7, 1E-6, 1E-5, 1E-4, 1E-3, 1E-2, 1E-1, - 1E0, - 1E1, 1E2, 1E3, 1E4, 1E5, 1E6, 1E7, 1E8, 1E9, 1E10, 1E11, 1E12, 1E13, 1E14, 1E15, 1E16, 1E17, 1E18, 1E19, 1E20 -}; + 1E-20, 1E-19, 1E-18, 1E-17, 1E-16, 1E-15, 1E-14, 1E-13, 1E-12, 1E-11, 1E-10, + 1E-9, 1E-8, 1E-7, 1E-6, 1E-5, 1E-4, 1E-3, 1E-2, 1E-1, 1E0, 1E1, + 1E2, 1E3, 1E4, 1E5, 1E6, 1E7, 1E8, 1E9, 1E10, 1E11, 1E12, + 1E13, 1E14, 1E15, 1E16, 1E17, 1E18, 1E19, 1E20}; static const int max_abs_power_10 = BTS_ARRAYSIZE(powers_10) / 2; inline double pow10(int power) { const int offset = power + max_abs_power_10; @@ -26,128 +26,120 @@ inline double pow10(int power) { class IntPrice { #ifdef _WIN32 - int64_t _mantissa : 56; - int64_t _exponent : 8; + int64_t _mantissa : 56; + int64_t _exponent : 8; #else - int64_t _mantissa : 56; - int8_t _exponent : 8; + int64_t _mantissa : 56; + int8_t _exponent : 8; #endif - public: - constexpr IntPrice() : _mantissa(0), _exponent(127) {/*nan*/} - constexpr IntPrice(int64_t mantissa, int8_t exponent) : _mantissa(mantissa), _exponent(exponent) {} - constexpr IntPrice(const IntPrice& other) : _mantissa(other._mantissa), _exponent(other._exponent) {} + public: + constexpr IntPrice() : _mantissa(0), _exponent(127) { /*nan*/ + } + constexpr IntPrice(int64_t mantissa, int8_t exponent) + : _mantissa(mantissa), _exponent(exponent) {} + constexpr IntPrice(const IntPrice &other) + : _mantissa(other._mantissa), _exponent(other._exponent) {} - bool operator==(const IntPrice& other) const { - if(_exponent == other._exponent) { + bool operator==(const IntPrice &other) const { + if (_exponent == other._exponent) { return _mantissa == other._mantissa; - } - else { - return price()==other.price(); + } else { + return price() == other.price(); } } - bool operator!=(const IntPrice& other) const { - return !(*this == other); - } - bool operator<(const IntPrice& other) const { + bool operator!=(const IntPrice &other) const { return !(*this == other); } + bool operator<(const IntPrice &other) const { if (_exponent == other._exponent) { return _mantissa < other._mantissa; - } - else { + } else { // avoiding conversion to double is 4-5% faster // return price() < other.price(); auto delta = *this - other; return delta.mantissa() < 0; } } - bool operator <=(const IntPrice& other) const { + bool operator<=(const IntPrice &other) const { return *this == other || *this < other; } - bool operator >(const IntPrice& other) const { - return other < *this; - } - bool operator >=(const IntPrice& other) const { - return !(*this < other); - } - IntPrice operator - (const IntPrice& o) const { + bool operator>(const IntPrice &other) const { return other < *this; } + bool operator>=(const IntPrice &other) const { return !(*this < other); } + IntPrice operator-(const IntPrice &o) const { return op(o, [](int64_t m1, int64_t m2) { return m1 - m2; }); } - IntPrice operator + (const IntPrice& o) const { + IntPrice operator+(const IntPrice &o) const { return op(o, [](int64_t m1, int64_t m2) { return m1 + m2; }); } - IntPrice& operator +=(const IntPrice& o) { + IntPrice &operator+=(const IntPrice &o) { auto temp = *this + o; _mantissa = temp._mantissa; _exponent = temp._exponent; return *this; } - IntPrice& operator -=(const IntPrice& o) { + IntPrice &operator-=(const IntPrice &o) { auto temp = *this - o; _mantissa = temp._mantissa; _exponent = temp._exponent; return *this; } - IntPrice operator -() { - return IntPrice(-_mantissa, _exponent); - } - IntPrice operator * (const IntPrice& other) const { + IntPrice operator-() { return IntPrice(-_mantissa, _exponent); } + IntPrice operator*(const IntPrice &other) const { return op(other, [](int64_t m1, int64_t m2) { return m1 * m2; }); } - IntPrice operator * (const int& other) const { + IntPrice operator*(const int &other) const { return IntPrice(_mantissa * other, _exponent); } - IntPrice& operator *=(const int& other) { + IntPrice &operator*=(const int &other) { _mantissa *= other; return *this; } - IntPrice operator / (double v) const { - return { (int64_t)(_mantissa / v), exponent() }; + IntPrice operator/(double v) const { + return {(int64_t)(_mantissa / v), exponent()}; } IntPrice sign_extend(int8_t new_exponent) const { int8_t delta = _exponent - new_exponent; int64_t m = _mantissa * pow10(delta); - return { m, new_exponent }; + return {m, new_exponent}; } int64_t mantissa() const { return _mantissa; } - int8_t exponent() const { return _exponent; } - double price() const { - if (is_nan()) return NO_PRICE; + int8_t exponent() const { return _exponent; } + double price() const { + if (is_nan()) + return NO_PRICE; return mantissa() * pow10(exponent()); } bool is_nan() const { return _exponent == 127; } - private: + private: template - IntPrice op(const IntPrice& o, MantissaOp operation) const { - if (_exponent==o._exponent) { - return IntPrice { operation(_mantissa,o.mantissa()), exponent() }; - } - else { - if (is_nan() || o.is_nan()) return IntPrice(); + IntPrice op(const IntPrice &o, MantissaOp operation) const { + if (_exponent == o._exponent) { + return IntPrice{operation(_mantissa, o.mantissa()), exponent()}; + } else { + if (is_nan() || o.is_nan()) + return IntPrice(); bts_assert_d(o.exponent() <= 0 && _exponent <= 0); if (o.exponent() < _exponent) { int8_t delta = _exponent - o.exponent(); int64_t m = _mantissa * pow10(delta); - return { operation(m, o.mantissa()), o.exponent() }; - } - else { + return {operation(m, o.mantissa()), o.exponent()}; + } else { int8_t delta = o.exponent() - _exponent; int64_t m = o.mantissa() * pow10(delta); - return { operation(_mantissa, m), exponent() }; + return {operation(_mantissa, m), exponent()}; } } } - }; static_assert(sizeof(IntPrice) == 8, "IntPrice should be this big |--------|"); extern IntPrice INT_NAN; extern IntPrice INT_ZERO; -template -IntPrice IntPrice_from_double(double price) { - if (os::is_nan(price)) return INT_NAN; +template IntPrice IntPrice_from_double(double price) { + if (os::is_nan(price)) + return INT_NAN; double temp; if (fabs(modf(price, &temp)) != 0.0) { const double rounding = 0.5 * pow10(-PRECISION); @@ -162,50 +154,51 @@ IntPrice IntPrice_from_double(double price) { // return { (int64_t)(price * pow10(-precision)), precision }; // } -inline md::IntPrice round_to_quote_price(const IntPrice& tick, const IntPrice& price, api::Side side) { +inline md::IntPrice round_to_quote_price( + const IntPrice &tick, const IntPrice &price, api::Side side) { bts_assert_d(tick.mantissa() != 0); - if (price.is_nan()) return price; + if (price.is_nan()) + return price; bts_assert_d(price.exponent() <= 0 && tick.exponent() <= 0); if (price.exponent() == tick.exponent()) { auto mod = price.mantissa() % tick.mantissa(); - if (mod == 0) return price; + if (mod == 0) + return price; else if (side == api::SIDE_BUY) { // buy, round down if (price.mantissa() > 0) { - return { price.mantissa() - mod, price.exponent() }; + return {price.mantissa() - mod, price.exponent()}; + } else { + return {price.mantissa() - mod - tick.mantissa(), price.exponent()}; } - else { - return { price.mantissa() - mod - tick.mantissa(), price.exponent() }; - } - } - else if (side == api::SIDE_SELL) { + } else if (side == api::SIDE_SELL) { // sell, round up if (price.mantissa() > 0) { - return { price.mantissa() - mod + tick.mantissa(), price.exponent() }; - } - else { - return { price.mantissa() - mod, price.exponent() }; + return {price.mantissa() - mod + tick.mantissa(), price.exponent()}; + } else { + return {price.mantissa() - mod, price.exponent()}; } } - } - else { + } else { // Uncommon path // Math is reversed because exponents are negative if (tick.exponent() < price.exponent()) { - return round_to_quote_price(tick, price.sign_extend(tick.exponent()), side); - } - else { + return round_to_quote_price( + tick, price.sign_extend(tick.exponent()), side); + } else { // Extend tick to price's exponent - return round_to_quote_price(tick.sign_extend(price.exponent()), price, side); + return round_to_quote_price( + tick.sign_extend(price.exponent()), price, side); } } return price; } -inline std::ostream& operator<<(std::ostream& os, const IntPrice& p) { +inline std::ostream &operator<<(std::ostream &os, const IntPrice &p) { os << p.price(); return os; } -}} +} // namespace md +} // namespace bts diff --git a/src/lib/md/MBOProcessor.cpp b/src/lib/md/MBOProcessor.cpp index 926d7903a..4e2df2f70 100644 --- a/src/lib/md/MBOProcessor.cpp +++ b/src/lib/md/MBOProcessor.cpp @@ -1,15 +1,15 @@ #include "MBOProcessor.h" -#include "lib/utils/ConcurrentPool.h" #include "lib/config/config.h" #include "lib/config/protos/toggles.pb.h" +#include "lib/utils/ConcurrentPool.h" #include "lib/utils/thread_manager.h" -#include +#include #include -#include +#include #include #include -#include +#include #ifndef _WIN32 #include @@ -17,23 +17,20 @@ #include #include - namespace bts { namespace md { struct SecurityKeyHashCompare { - static size_t hash(const SecurityKey& k) { - return k.value(); - } - static bool equal(const SecurityKey& a, const SecurityKey& b) { + static size_t hash(const SecurityKey &k) { return k.value(); } + static bool equal(const SecurityKey &a, const SecurityKey &b) { return a.value() == b.value(); } }; -void print_pool_stats(const utils::ConcurrentPool& pool) { +void print_pool_stats(const utils::ConcurrentPool &pool) { size_t count = 0; - std::vector bid_sz,ask_sz; - pool.unsafe_iterate([&](const MBOSnapshot& s) { + std::vector bid_sz, ask_sz; + pool.unsafe_iterate([&](const MBOSnapshot &s) { if (s.bids.size() > 0 || s.asks.size() > 0) { count++; bid_sz.push_back(s.bids.size()); @@ -41,30 +38,38 @@ void print_pool_stats(const utils::ConcurrentPool& pool) { } }); - if (count == 0) return; + if (count == 0) + return; std::sort(bid_sz.begin(), bid_sz.end()); std::sort(ask_sz.begin(), ask_sz.end()); - size_t bid_tot =0, ask_tot = 0; - for(size_t i : bid_sz) { bid_tot += i; } - for(size_t i : ask_sz) { ask_tot += i; } + size_t bid_tot = 0, ask_tot = 0; + for (size_t i : bid_sz) { + bid_tot += i; + } + for (size_t i : ask_sz) { + ask_tot += i; + } std::stringstream bid_percentiles, ask_percentiles; - for (double x : { 0.5, 0.75, 0.9, 0.95, 0.99 }) { + for (double x : {0.5, 0.75, 0.9, 0.95, 0.99}) { size_t index = count * x; bid_percentiles << bid_sz[index] << " "; ask_percentiles << ask_sz[index] << " "; } - bid_percentiles << bid_sz[count-1] << " "; - ask_percentiles << ask_sz[count-1] << " "; - LOG(md,Info, - "MBO statistics: count: {} - %[50,75,90,95,99,100] bid: [{}] - ask: [{}]", - count, bid_percentiles.str(), ask_percentiles.str()); + bid_percentiles << bid_sz[count - 1] << " "; + ask_percentiles << ask_sz[count - 1] << " "; + LOG(md, Info, + "MBO statistics: count: {} - %[50,75,90,95,99,100] bid: [{}] - ask: " + "[{}]", + count, bid_percentiles.str(), ask_percentiles.str()); } -typedef tbb::concurrent_hash_map MapType; +typedef tbb::concurrent_hash_map< + SecurityKey, MBOSnapshot *, SecurityKeyHashCompare> + MapType; struct Incremental { - MBOWorkingState* state; + MBOWorkingState *state; inc::Update update; }; struct MBOProcessorImpl { @@ -75,17 +80,14 @@ struct MBOProcessorImpl { utils::TimeStamp last_pool_print; std::thread thread; - MBOProcessorImpl() : - pool(2048,512), - snapshots(), - running(true), - last_pool_print(utils::TimeStamp::invalid()), - thread(threading::make_thread("MBO", [=]() { process_incremental(); })) - { + MBOProcessorImpl() + : pool(2048, 512), snapshots(), running(true), + last_pool_print(utils::TimeStamp::invalid()), + thread( + threading::make_thread("MBO", [=]() { process_incremental(); })) { if (config::get().enabled()) { last_pool_print = utils::TimeStamp::now(); } - } ~MBOProcessorImpl() { @@ -93,18 +95,19 @@ struct MBOProcessorImpl { thread.join(); } - void publish_snapshot(SecurityKey key, MBOSnapshot** snapshot) { + void publish_snapshot(SecurityKey key, MBOSnapshot **snapshot) { bts_assert(*snapshot != nullptr); MapType::accessor accessor; snapshots.insert(accessor, key); std::swap(accessor->second, *snapshot); if (*snapshot != nullptr) { - // Note: relase() must happen inside accessor lifetime to ensure correctness + // Note: relase() must happen inside accessor lifetime to ensure + // correctness pool.release(snapshot); } } - void publish_incremental(MBOWorkingState& state) { + void publish_incremental(MBOWorkingState &state) { // determine if we need to publish auto key = SecurityKey(state.handle.key()); if (key.value() != invalid_security_key) { @@ -117,20 +120,20 @@ struct MBOProcessorImpl { } void process_incremental() { - #ifndef _WIN32 +#ifndef _WIN32 // drain queue and update state // insert changed state pointers into a set // after draining publish the set in small batches - // re-check input queue regularly + // re-check input queue regularly - btree::btree_set dirty; - std::vector clean; + btree::btree_set dirty; + std::vector clean; - while(running) { + while (running) { Incremental temp; // Drain entire input queue quickly - while(incremental_input.try_pop(temp)) { + while (incremental_input.try_pop(temp)) { bts_assert_d(temp.state != nullptr); if (temp.state != nullptr) { apply_incremental(*temp.state, temp.update); @@ -142,70 +145,62 @@ struct MBOProcessorImpl { for (auto iter = dirty.begin(); iter != dirty.end(); ++iter) { publish_incremental(**iter); clean.push_back(*iter); - if (clean.size() >= 128) break; + if (clean.size() >= 128) + break; } // Remove 'clean' from set - for (const auto& iter : clean) { + for (const auto &iter : clean) { dirty.erase(iter); } clean.clear(); // If the queue is still empty sleep briefly - if (incremental_input.empty()) { + if (incremental_input.empty()) { if (last_pool_print != TimeStamp::invalid()) { auto now = TimeStamp::now(); if ((now - last_pool_print).seconds() > 600) { - last_pool_print = now; + last_pool_print = now; print_pool_stats(pool); } } - std::this_thread::sleep_for( - std::chrono::milliseconds(1) - ); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); } - } - #endif +#endif } - }; // // Processor -MBOProcessor::MBOProcessor() : - _me(std::make_shared()), - _writer(_me), - _reader(_me) -{ -} +MBOProcessor::MBOProcessor() + : _me(std::make_shared()), _writer(_me), _reader(_me) {} -MBOWriter& MBOProcessor::writer() { return _writer;} -MBOReader& MBOProcessor::reader() { return _reader; } +MBOWriter &MBOProcessor::writer() { return _writer; } +MBOReader &MBOProcessor::reader() { return _reader; } // // Writer -MBOWriter::MBOWriter(std::shared_ptr& me): _me(me) { } -MBOWriter::~MBOWriter() { } -MBOSnapshot* MBOWriter::allocate_snapshot(size_t, size_t) { +MBOWriter::MBOWriter(std::shared_ptr &me) : _me(me) {} +MBOWriter::~MBOWriter() {} +MBOSnapshot *MBOWriter::allocate_snapshot(size_t, size_t) { return _me->pool.allocate(); } -void MBOWriter::release_snapshot(MBOSnapshot** s) { - _me->pool.release(s); -} -void MBOWriter::publish_snapshot(SecurityKey key, MBOSnapshot** snapshot) { - _me->publish_snapshot(key,snapshot); +void MBOWriter::release_snapshot(MBOSnapshot **s) { _me->pool.release(s); } +void MBOWriter::publish_snapshot(SecurityKey key, MBOSnapshot **snapshot) { + _me->publish_snapshot(key, snapshot); } #if 0 bool MBOWriter::validate_snapshot(uint32_t exchid, SecurityKey key, MBOSnapshot* control) { - #define REQUIRE(a,b,y) \ - if ((a) != (b)) { \ - LOG(md,Error, "Validation error exch:{} sec:{} {}!={} other:{}", exchid, key.value(), a, b, y); \ - return false; \ - } +#define REQUIRE(a, b, y) \ + if ((a) != (b)) { \ + LOG(md, Error, "Validation error exch:{} sec:{} {}!={} other:{}", \ + exchid, key.value(), a, b, y); \ + return false; \ + } // retrieve current snapshot and check they are equal _me->dispatcher.post([this,exchid,key,control]() { @@ -225,123 +220,135 @@ bool MBOWriter::validate_snapshot(uint32_t exchid, SecurityKey key, MBOSnapshot* } return true; }); - #undef REQUIRE +#undef REQUIRE return true; } #endif -void MBOWriter::enqueue_incremental(MBOWorkingState& state, const inc::Update& update) { - LOG(md,Diag, "sec:{} : {}", state.handle.key(), update); +void MBOWriter::enqueue_incremental( + MBOWorkingState &state, const inc::Update &update) { + LOG(md, Diag, "sec:{} : {}", state.handle.key(), update); _me->incremental_input.push({&state, update}); } -void copy_to_snapshot(MBOWorkingState& state, MBOSnapshot* dest) { - if (dest == nullptr) return; +void copy_to_snapshot(MBOWorkingState &state, MBOSnapshot *dest) { + if (dest == nullptr) + return; // copy working state to snapshot dest->updated = state.updated; auto type_map = [](auto pair) { - return SnapshotOrder { pair.second.id, std::get(pair.first), pair.second.size }; - }; - std::transform(state.bid.begin(), state.bid.end(), std::back_inserter(dest->bids), type_map); - std::transform(state.ask.begin(), state.ask.end(), std::back_inserter(dest->asks), type_map); + return SnapshotOrder{ + pair.second.id, std::get(pair.first), pair.second.size}; + }; + std::transform( + state.bid.begin(), state.bid.end(), std::back_inserter(dest->bids), + type_map); + std::transform( + state.ask.begin(), state.ask.end(), std::back_inserter(dest->asks), + type_map); } template -void apply_incremental(uint32_t security_key, C& collection, std::unordered_map& index, const inc::Update& update) { +void apply_incremental( + uint32_t security_key, C &collection, + std::unordered_map &index, + const inc::Update &update) { auto key = std::make_tuple(update.price, update.priority); - switch(update.action) { - case inc::UpdateAction::New: - collection.insert(std::make_pair(key, MBOWorkingState::Data { update.order_id, update.size })); - index[update.order_id] = key; - break; - case inc::UpdateAction::Change: { - // look up old key - auto r = index.find(update.order_id); - if (r != index.end()) { - auto oldkey = r->second; - collection.erase(oldkey); - index.erase(r); - } - else { - LOG(md,Warn, "MBO Update w/out Add for: sec:{} {}", security_key, update); - } - collection.insert(std::make_pair(key, MBOWorkingState::Data { update.order_id, update.size })); - index[update.order_id] = key; - } + switch (update.action) { + case inc::UpdateAction::New: + collection.insert(std::make_pair( + key, MBOWorkingState::Data{update.order_id, update.size})); + index[update.order_id] = key; break; - case inc::UpdateAction::Delete: - collection.erase(key); - index.erase(update.order_id); + case inc::UpdateAction::Change: { + // look up old key + auto r = index.find(update.order_id); + if (r != index.end()) { + auto oldkey = r->second; + collection.erase(oldkey); + index.erase(r); + } else { + LOG(md, Warn, "MBO Update w/out Add for: sec:{} {}", security_key, + update); + } + collection.insert(std::make_pair( + key, MBOWorkingState::Data{update.order_id, update.size})); + index[update.order_id] = key; + } break; + case inc::UpdateAction::Delete: + collection.erase(key); + index.erase(update.order_id); break; } } -void apply_incremental(MBOWorkingState& state, const inc::Update& update) { +void apply_incremental(MBOWorkingState &state, const inc::Update &update) { // apply the update to the working state if (update.type == inc::UpdateType::Bid) { - apply_incremental(state.handle.key(), state.bid, state.orderid_index, update); - } - else { - apply_incremental(state.handle.key(),state.ask, state.orderid_index, update); + apply_incremental( + state.handle.key(), state.bid, state.orderid_index, update); + } else { + apply_incremental( + state.handle.key(), state.ask, state.orderid_index, update); } } // // Reader -MBOReader::MBOReader(std::shared_ptr& me): _me(me) { } -MBOReader::~MBOReader() { } -MBOSnapshot* MBOReader::acquire_snapshot(SecurityKey key) const { - // get a result eagerly so we don't have to do it while accessor has the entry locked +MBOReader::MBOReader(std::shared_ptr &me) : _me(me) {} +MBOReader::~MBOReader() {} +MBOSnapshot *MBOReader::acquire_snapshot(SecurityKey key) const { + // get a result eagerly so we don't have to do it while accessor has the + // entry locked auto result = _me->pool.allocate(); MapType::const_accessor accessor; if (_me->snapshots.find(accessor, key) && accessor->second != nullptr) { result->copy_from(*accessor->second); - } - else { + } else { release_snapshot(&result); } return result; } -void MBOReader::release_snapshot(MBOSnapshot**s) const { +void MBOReader::release_snapshot(MBOSnapshot **s) const { _me->pool.release(s); } -}} +} // namespace md +} // namespace bts namespace std { - using namespace bts; - using namespace bts::md; +using namespace bts; +using namespace bts::md; -ostream& operator<<(ostream& os, const inc::Update& update) { +ostream &operator<<(ostream &os, const inc::Update &update) { os << "Update: { " << "id:" << update.order_id.value() << " " - << "pri:" << update.priority << " " - << update.price.price() << " " + << "pri:" << update.priority << " " << update.price.price() << " " << update.size << " "; - switch(update.type) { - case inc::UpdateType::Bid: - os << "B "; - break; - case inc::UpdateType::Ask: - os << "A "; - break; + switch (update.type) { + case inc::UpdateType::Bid: + os << "B "; + break; + case inc::UpdateType::Ask: + os << "A "; + break; } - switch(update.action) { - case inc::UpdateAction::New: - os << "+"; - break; - case inc::UpdateAction::Change: - os << "C"; - break; - case inc::UpdateAction::Delete: - os << "-"; - break; + switch (update.action) { + case inc::UpdateAction::New: + os << "+"; + break; + case inc::UpdateAction::Change: + os << "C"; + break; + case inc::UpdateAction::Delete: + os << "-"; + break; } os << "}"; return os; } -} +} // namespace std diff --git a/src/lib/md/MBOProcessor.h b/src/lib/md/MBOProcessor.h index 56f0c034f..bb3e85648 100644 --- a/src/lib/md/MBOProcessor.h +++ b/src/lib/md/MBOProcessor.h @@ -1,20 +1,20 @@ -#pragma once -#include "lib/domain_model/SecurityKey.h" -#include "lib/domain_model/Security.h" -#include "lib/utils/TimeStamp.h" -#include "IntPrice.h" +#pragma once #include "ExchangeOrderKey.h" +#include "IntPrice.h" #include "MDProducerHandle.h" +#include "lib/domain_model/Security.h" +#include "lib/domain_model/SecurityKey.h" +#include "lib/utils/TimeStamp.h" #include "google/btree/btree_map.h" -#include -#include #include +#include #include +#include -namespace bts { -namespace md { +namespace bts { +namespace md { struct SnapshotOrder { ExchangeOrderKey id; @@ -23,14 +23,14 @@ struct SnapshotOrder { }; struct MBOSnapshot { MBOSnapshot() = default; - MBOSnapshot(const MBOSnapshot&) = delete; - MBOSnapshot(MBOSnapshot&& other) = delete; + MBOSnapshot(const MBOSnapshot &) = delete; + MBOSnapshot(MBOSnapshot &&other) = delete; utils::TimeStamp updated; std::vector bids; std::vector asks; - void copy_from(const MBOSnapshot& src) { + void copy_from(const MBOSnapshot &src) { bids = src.bids; asks = src.asks; updated = src.updated; @@ -52,72 +52,65 @@ struct MBOSnapshot { namespace inc { - // according to this link MBO book only has these updates types - // https://www.cmegroup.com/confluence/display/EPICSANDBOX/MDP+3.0+-+Market+Data+Snapshot+Full+Refresh#MDP3.0-MarketDataSnapshotFullRefresh-MarketbyOrder(MBO)DataBlock - enum class UpdateType { - Bid = 0, - Ask = 1, - // ImpliedBid, // 'E' - // ImpliedAsk, // 'F' - // BookReset // 'J' - }; +// according to this link MBO book only has these updates types +// https://www.cmegroup.com/confluence/display/EPICSANDBOX/MDP+3.0+-+Market+Data+Snapshot+Full+Refresh#MDP3.0-MarketDataSnapshotFullRefresh-MarketbyOrder(MBO)DataBlock +enum class UpdateType { + Bid = 0, + Ask = 1, + // ImpliedBid, // 'E' + // ImpliedAsk, // 'F' + // BookReset // 'J' +}; - // OrderUpdateAction=37708 - enum class UpdateAction { - New = 0, - Change = 1, - Delete = 2 - }; - - typedef uint64_t Priority; - struct Update { - ExchangeOrderKey order_id; - Priority priority; - IntPrice price; - int32_t size; - UpdateType type; - UpdateAction action; - }; -} +// OrderUpdateAction=37708 +enum class UpdateAction { New = 0, Change = 1, Delete = 2 }; +typedef uint64_t Priority; +struct Update { + ExchangeOrderKey order_id; + Priority priority; + IntPrice price; + int32_t size; + UpdateType type; + UpdateAction action; +}; +} // namespace inc struct MBOWorkingState { - typedef std::tuple key_t; + typedef std::tuple key_t; struct Data { ExchangeOrderKey id; int32_t size; }; struct LessBid { - bool operator()(const key_t& left, const key_t& right) const { - const auto& left_price = std::get(left); - const auto& right_price = std::get(right); + bool operator()(const key_t &left, const key_t &right) const { + const auto &left_price = std::get(left); + const auto &right_price = std::get(right); if (left_price == right_price) { - return - std::get(left) < - std::get(right); + return std::get(left) < + std::get(right); } return !(left_price < right_price); } }; - MBOWorkingState(MDProducerHandle& h) : handle(h), updated(), bid(),ask() {} + MBOWorkingState(MDProducerHandle &h) : handle(h), updated(), bid(), ask() {} MDProducerHandle handle; utils::TimeStamp updated; // Used for 'change' messages which update price std::unordered_map orderid_index; - btree::btree_map bid; - btree::btree_map ask; + btree::btree_map bid; + btree::btree_map ask; }; - -void copy_to_snapshot(MBOWorkingState& state, MBOSnapshot* destination); -void apply_incremental(MBOWorkingState&, const inc::Update&); +void copy_to_snapshot(MBOWorkingState &state, MBOSnapshot *destination); +void apply_incremental(MBOWorkingState &, const inc::Update &); template -void apply_incremental(MBOWorkingState& state, const V& vec) { - for (const auto& update : vec) { +void apply_incremental(MBOWorkingState &state, const V &vec) { + for (const auto &update : vec) { apply_incremental(state, update); } } @@ -128,33 +121,34 @@ class MBOProcessor; class MBOWriter { std::shared_ptr _me; friend class MBOProcessor; - MBOWriter(std::shared_ptr&); + MBOWriter(std::shared_ptr &); ~MBOWriter(); - public: + public: // // Snapshot api - MBOSnapshot* allocate_snapshot(size_t bid_count=0, size_t ask_count=0); - void release_snapshot(MBOSnapshot**); - void publish_snapshot(SecurityKey, MBOSnapshot**); - bool validate_snapshot(uint32_t, SecurityKey, MBOSnapshot*); + MBOSnapshot *allocate_snapshot(size_t bid_count = 0, size_t ask_count = 0); + void release_snapshot(MBOSnapshot **); + void publish_snapshot(SecurityKey, MBOSnapshot **); + bool validate_snapshot(uint32_t, SecurityKey, MBOSnapshot *); // // Incremental api // Enqueue the update to the mbo work queue. - void enqueue_incremental(MBOWorkingState&, const inc::Update&); + void enqueue_incremental(MBOWorkingState &, const inc::Update &); }; class MBOReader { std::shared_ptr _me; friend class MBOProcessor; friend class MBOWriter; - MBOReader(std::shared_ptr&); + MBOReader(std::shared_ptr &); ~MBOReader(); - public: - MBOSnapshot* acquire_snapshot(SecurityKey key) const; - void release_snapshot(MBOSnapshot**) const; + + public: + MBOSnapshot *acquire_snapshot(SecurityKey key) const; + void release_snapshot(MBOSnapshot **) const; }; class MBOProcessor { @@ -162,16 +156,15 @@ class MBOProcessor { MBOWriter _writer; MBOReader _reader; -public: + public: MBOProcessor(); - MBOWriter& writer(); - MBOReader& reader(); + MBOWriter &writer(); + MBOReader &reader(); }; - -}} +} // namespace md +} // namespace bts namespace std { -std::ostream& operator<<(std::ostream& os, const bts::md::inc::Update&); +std::ostream &operator<<(std::ostream &os, const bts::md::inc::Update &); } - diff --git a/src/lib/md/MBOServiceServer.cpp b/src/lib/md/MBOServiceServer.cpp index 3ba697a18..1178b42a1 100644 --- a/src/lib/md/MBOServiceServer.cpp +++ b/src/lib/md/MBOServiceServer.cpp @@ -108,8 +108,9 @@ class ActiveOrder { // MBOService struct MBOServiceImpl { - MBOServiceImpl(api::ServiceContext &ctx, utils::Dispatcher &d, - md::MDClient &c, MBOServiceBase::PiqPublisher &&pub) + MBOServiceImpl( + api::ServiceContext &ctx, utils::Dispatcher &d, md::MDClient &c, + MBOServiceBase::PiqPublisher &&pub) : dispatcher(d), client(c), orders(ctx.locate()), handle_index(c), publish(pub), timer(d, 200, [&]() { timer_tick(); }), orders_sub() {} @@ -131,9 +132,8 @@ struct MBOServiceImpl { /////////////////////// -std::optional -search_orders(const ExchangeOrderKey oid, - const std::vector &orders) { +std::optional search_orders( + const ExchangeOrderKey oid, const std::vector &orders) { IntPrice price = {}; size_t position = 0; for (size_t x = 0; x < orders.size(); ++x) { @@ -210,8 +210,9 @@ bool is_active_exchange_order(const OrderRecord &record) { native_order_state(record) != nullptr; } -void try_remove(MBOServiceImpl &me, std::set &to_remove, - const OrderRecord &record) { +void try_remove( + MBOServiceImpl &me, std::set &to_remove, + const OrderRecord &record) { auto key = SparkOrderKey(record.key()); auto iter = me.active.find(key); if (iter != me.active.end()) { @@ -219,31 +220,32 @@ void try_remove(MBOServiceImpl &me, std::set &to_remove, to_remove.insert(key.value()); } } -void try_add(MBOServiceImpl &me, std::vector &to_add, - const OrderRecord &record) { +void try_add( + MBOServiceImpl &me, std::vector &to_add, + const OrderRecord &record) { if (is_active_exchange_order(record)) { auto native = native_order_state(record); auto ex_key = orderman::get_exchange_order_id(*native); - auto u64_key = - std::visit(overloaded{[](orderman::ExchangeOrderID const &str) { - return std::stoul(str.value().data()); - }, - [](orderman::ExchangeOrderID64 oid) { - return oid.value(); - }}, - ex_key); + auto u64_key = std::visit( + overloaded{ + [](orderman::ExchangeOrderID const &str) { + return std::stoul(str.value().data()); + }, + [](orderman::ExchangeOrderID64 oid) { return oid.value(); }}, + ex_key); bts_assert(native); - ActiveOrder order(SecurityKey(record.def().security_key()), - SparkOrderKey(record.key()), ExchangeOrderKey{u64_key}); + ActiveOrder order( + SecurityKey(record.def().security_key()), SparkOrderKey(record.key()), + ExchangeOrderKey{u64_key}); update_position(me.handle_index, order); to_add.push_back(order.to_piq()); me.active.insert(std::make_pair(order.id(), order)); } } -MBOServiceServer::MBOServiceServer(api::ServiceContext &ctx, - utils::Dispatcher &d, md::MDClient &c) +MBOServiceServer::MBOServiceServer( + api::ServiceContext &ctx, utils::Dispatcher &d, md::MDClient &c) : MBOServiceBase(ctx), _me(new MBOServiceImpl(ctx, d, c, make_piq_publisher())) { // subscribe to mdclient ✔ @@ -317,8 +319,8 @@ void MBOServiceServer::get_orders_for_security( for (const auto &o : mbo->bids) { double price = o.price.price(); bool isnan = os::is_nan(request.price_level()); - if (isnan || securities::test_price_equality(request.price_level(), - price, tick)) { + if (isnan || securities::test_price_equality( + request.price_level(), price, tick)) { ++count; if (request.limit() && count > request.limit()) break; @@ -336,8 +338,8 @@ void MBOServiceServer::get_orders_for_security( for (const auto &o : mbo->asks) { double price = o.price.price(); bool isnan = os::is_nan(request.price_level()); - if (isnan || securities::test_price_equality(request.price_level(), - price, tick)) { + if (isnan || securities::test_price_equality( + request.price_level(), price, tick)) { ++count; if (request.limit() && count > request.limit()) break; diff --git a/src/lib/md/MBOServiceServer.h b/src/lib/md/MBOServiceServer.h index 6eccab38c..44f5c1045 100644 --- a/src/lib/md/MBOServiceServer.h +++ b/src/lib/md/MBOServiceServer.h @@ -1,29 +1,34 @@ -#pragma once +#pragma once #include "lib/api/public/ServiceContext.h" #include "lib/api/services/MBOService.server.pb.h" #include #include -namespace bts { -namespace utils { class Dispatcher; } -namespace api { namespace orderman { class OrderService; } } -namespace md { +namespace bts { +namespace utils { +class Dispatcher; +} +namespace api { +namespace orderman { +class OrderService; +} +} // namespace api +namespace md { class MDClient; struct MBOServiceImpl; class MBOServiceServer : public MBOServiceBase { std::unique_ptr _me; - public: + + public: MBOServiceServer( - api::ServiceContext& ctx, - utils::Dispatcher&, - md::MDClient&); + api::ServiceContext &ctx, utils::Dispatcher &, md::MDClient &); ~MBOServiceServer(); - void get_orders_for_security(const MBOSecurityQuery&, const api::Response&) override; - + void get_orders_for_security( + const MBOSecurityQuery &, const api::Response &) override; }; - -}} //namespace +} // namespace md +} // namespace bts diff --git a/src/lib/md/MDClient.cpp b/src/lib/md/MDClient.cpp index 7bae649bb..d055082af 100644 --- a/src/lib/md/MDClient.cpp +++ b/src/lib/md/MDClient.cpp @@ -1,44 +1,38 @@ #include "MDClient.h" -#include "get_symbols.h" +#include "MBOProcessor.h" #include "SecurityCache.h" #include "SecurityOracle.h" +#include "get_symbols.h" #include "lib/utils/TimeStamp.h" -#include "MBOProcessor.h" #include namespace bts { namespace md { -struct MDClientImpl{ - utils::Dispatcher* _dispatcher; - api::ISyntheticSecurityService* _ss; +struct MDClientImpl { + utils::Dispatcher *_dispatcher; + api::ISyntheticSecurityService *_ss; SecurityCache _cache; std::unique_ptr _security_timer; std::unique_ptr _recovery_timer; std::set _symbols; - MBOReader* _mbo; + MBOReader *_mbo; MDConsumer _consumer; utils::Event _event; MDClientImpl( - 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), - _consumer(_cache, _ss, mbo, &_symbols), - _event() - { + 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), + _consumer(_cache, _ss, mbo, &_symbols), _event() { if (d) { - _security_timer = - std::make_unique(*d, config::get().security_scan_interval(),[this]() { scan_securities(); }), - _recovery_timer = - std::make_unique(*d, config::get().recovery_interval(), [this]() { check_heartbeats(); }), + _security_timer = std::make_unique( + *d, config::get().security_scan_interval(), + [this]() { scan_securities(); }), + _recovery_timer = std::make_unique( + *d, config::get().recovery_interval(), + [this]() { check_heartbeats(); }), _security_timer->start(); _recovery_timer->start(); } @@ -46,11 +40,14 @@ struct MDClientImpl{ void check_heartbeats() { if (!_consumer.all_heartbeats_ok()) { - MDConsumer temp(_cache,_ss,_mbo,&_symbols); + MDConsumer temp(_cache, _ss, _mbo, &_symbols); if (temp.all_heartbeats_ok()) { _consumer.swap(temp); - LOG(md,Info, "Recovering from bad MD. Old consumer {} new consumer {}", _consumer.id(), temp.id()); - // Subscribers are responsible for keeping the old consumer reference if they need it + LOG(md, Info, + "Recovering from bad MD. Old consumer {} new consumer {}", + _consumer.id(), temp.id()); + // Subscribers are responsible for keeping the old consumer + // reference if they need it _event.publish(_consumer); } } @@ -62,8 +59,8 @@ struct MDClientImpl{ auto count = _consumer.scan_securities(); auto delta = (TimeStamp::now() - start); if (delta.milliseconds() > 10) { - LOG(md,Diag,"Scanned handles: {}ms found: {} securities. " , - delta.milliseconds(),count); + LOG(md, Diag, "Scanned handles: {}ms found: {} securities. ", + delta.milliseconds(), count); } return count; } @@ -71,31 +68,24 @@ struct MDClientImpl{ } }; - MDClient::MDClient( - utils::Dispatcher* d, - api::ISyntheticSecurityService* s, - MBOReader* mbo, - const std::set* symbols) : - _self(new MDClientImpl(d,s,mbo,symbols)) - { } + utils::Dispatcher *d, api::ISyntheticSecurityService *s, MBOReader *mbo, + const std::set *symbols) + : _self(new MDClientImpl(d, s, mbo, symbols)) {} -MDClient::~MDClient() { } +MDClient::~MDClient() {} size_t MDClient::scan_securities() { return _self->scan_securities(); } void MDClient::check_heartbeats() { return _self->check_heartbeats(); } -utils::EventSubscriber& MDClient::on_consumer() { +utils::EventSubscriber &MDClient::on_consumer() { return _self->_event; } -MDConsumer& MDClient::current_consumer() const { - return _self->_consumer; -} +MDConsumer &MDClient::current_consumer() const { return _self->_consumer; } SecurityOracle MDClient::oracle() const { return SecurityOracle(_self->_cache); } -std::set MDClient::symbols() const { - return _self->_symbols; -} +std::set MDClient::symbols() const { return _self->_symbols; } -}}//namespace \ No newline at end of file +} // namespace md +} // namespace bts \ No newline at end of file diff --git a/src/lib/md/MDClient.h b/src/lib/md/MDClient.h index 51b03a777..624136c23 100644 --- a/src/lib/md/MDClient.h +++ b/src/lib/md/MDClient.h @@ -1,9 +1,9 @@ #pragma once +#include "ISyntheticSecurityService.h" #include "MDConsumer.h" +#include "UserSymbol.h" #include "lib/utils/Dispatcher.h" #include "lib/utils/Event.h" -#include "ISyntheticSecurityService.h" -#include "UserSymbol.h" #include #include @@ -17,24 +17,23 @@ struct MDClientImpl; class MDClient { std::unique_ptr _self; -public: + public: // Will check for recovery MDClient( - utils::Dispatcher* d=nullptr, - api::ISyntheticSecurityService* ss=nullptr, - MBOReader* mbo=nullptr, - const std::set* s=nullptr); + utils::Dispatcher *d = nullptr, + api::ISyntheticSecurityService *ss = nullptr, MBOReader *mbo = nullptr, + const std::set *s = nullptr); ~MDClient(); // Check heartbeats and attempt recovery if they are bad void check_heartbeats(); size_t scan_securities(); - utils::EventSubscriber& on_consumer(); - MDConsumer& current_consumer() const; + utils::EventSubscriber &on_consumer(); + MDConsumer ¤t_consumer() const; SecurityOracle oracle() const; std::set symbols() const; }; - -}}//namespace \ No newline at end of file +} // namespace md +} // namespace bts \ No newline at end of file diff --git a/src/lib/md/MDConsumer.cpp b/src/lib/md/MDConsumer.cpp index 2744f021c..1e9906fc1 100644 --- a/src/lib/md/MDConsumer.cpp +++ b/src/lib/md/MDConsumer.cpp @@ -1,9 +1,9 @@ #ifndef NO_CPP0X #include "MDConsumer.h" +#include "MBOProcessor.h" #include "MemorySegmentUtils.h" #include "PlatformLoader.h" #include "SecurityCache.h" -#include "MBOProcessor.h" #include "lib/config/config.h" #include "lib/utils/SharedList.h" #include "lib/utils/WaitFreeQueue.h" @@ -12,12 +12,12 @@ #include "lib/config/protos/MarketData.pb.h" #include "lib/utils/sane_algorithm.h" -#include +#include #include -#include #include #include -#include +#include +#include #include using namespace std; @@ -31,26 +31,27 @@ namespace md { * ColdHeader keeps a security count to know when a list has changed * When a security is made visible increment count (non-atomic) * When user hits walk_security_list just walk all of them - * When scanning for new securities we can short circuit the search if the security_count hasn't incremented + * When scanning for new securities we can short circuit the search if the + * security_count hasn't incremented * */ bool match_type(SecurityType val, SecurityType b) { return (val == b || b == SECURITYTYPE_UNSET); } -bool match_symbol(const string& val, const string& b) { +bool match_symbol(const string &val, const string &b) { bts_assert_d(!val.empty()); return b.empty() || (val == b); } typedef shared_ptr MutSecurityPtr; struct SecurityLess { - bool operator()(const SecurityPtr& left, const SecurityPtr& right) { + bool operator()(const SecurityPtr &left, const SecurityPtr &right) { return left->id() < right->id(); } }; -MutSecurityPtr convert_psecurity(const FixedSecurity& security) { +MutSecurityPtr convert_psecurity(const FixedSecurity &security) { auto psec = make_shared(); convert_security(security, psec.get()); return psec; @@ -62,56 +63,62 @@ MutSecurityPtr convert_psecurity(const FixedSecurity& security) { struct QueueStruct { utils::WaitFreeQueue _trade_queue; utils::WaitFreeQueue _rfq_queue; - QueueStruct(const ColdHeader& header): - _trade_queue((void*)header.trade_buffer, BTS_ARRAYSIZE(header.trade_buffer)), - _rfq_queue((void*)header.rfq_buffer, BTS_ARRAYSIZE(header.rfq_buffer)) - {} + QueueStruct(const ColdHeader &header) + : _trade_queue( + (void *)header.trade_buffer, BTS_ARRAYSIZE(header.trade_buffer)), + _rfq_queue( + (void *)header.rfq_buffer, BTS_ARRAYSIZE(header.rfq_buffer)) {} }; bool is_heart_beat_ok(const ColdHeader &); class MDConsumerInst { -public: - MDConsumerInst(const string& symbol, SecurityType type, Venue exchange, bool shared, co2::Platform platform) : - _symbol(symbol), - _type(type), - _exchange(exchange), - _platform(platform == co2::PLATFORM_UNSET ? platform_for_exchange(exchange) : platform), - _security_count(0), - _found_keys(), - _hot(), - _hot_depth(), - _cold(cold_segment_name(symbol, type, exchange, _platform), shared), - _queues() - { + public: + MDConsumerInst( + const string &symbol, SecurityType type, Venue exchange, bool shared, + co2::Platform platform) + : _symbol(symbol), _type(type), _exchange(exchange), + _platform( + platform == co2::PLATFORM_UNSET ? platform_for_exchange(exchange) + : platform), + _security_count(0), _found_keys(), _hot(), _hot_depth(), + _cold(cold_segment_name(symbol, type, exchange, _platform), shared), + _queues() { if (enable_depth(symbol, type)) { - _hot_depth.reset(new utils::SharedListReader(hot_segment_name(symbol, type, exchange, _platform), shared)); - } - else { - _hot.reset(new utils::SharedListReader(hot_segment_name(symbol, type, exchange, _platform), shared)); + _hot_depth.reset(new utils::SharedListReader( + hot_segment_name(symbol, type, exchange, _platform), shared)); + } else { + _hot.reset(new utils::SharedListReader( + hot_segment_name(symbol, type, exchange, _platform), shared)); } } - ~MDConsumerInst() { if (_queues) delete _queues; } + ~MDConsumerInst() { + if (_queues) + delete _queues; + } template - size_t walk_sec_list(CB cb, const string& symbol="", SecurityType type=SECURITYTYPE_UNSET) { + size_t walk_sec_list( + CB cb, const string &symbol = "", + SecurityType type = SECURITYTYPE_UNSET) { size_t result = 0; - _cold.all_entries([&symbol, type, &cb, &result](const ColdEntry& entry) { - // not sure this double check is needed since the caller also filters - if (entry.security.key != invalid_security_key && - match_type(entry.security.type, type) && - match_symbol(entry.security.symbol(), symbol)) { - cb(convert_psecurity(entry.security)); - ++result; - } - }); + _cold.all_entries([&symbol, type, &cb, &result](const ColdEntry &entry) { + // not sure this double check is needed since the caller also filters + if (entry.security.key != invalid_security_key && + match_type(entry.security.type, type) && + match_symbol(entry.security.symbol(), symbol)) { + cb(convert_psecurity(entry.security)); + ++result; + } + }); return result; } template - const void* find_hot(utils::SharedListReader* phot, security_key key) { - const void* hot_entry = nullptr; - phot->all_entries([&](const T& entry) { + const void * + find_hot(utils::SharedListReader *phot, security_key key) { + const void *hot_entry = nullptr; + phot->all_entries([&](const T &entry) { if (entry.key == key) { hot_entry = &entry; } @@ -119,40 +126,42 @@ public: return hot_entry; } - bool find_handle(security_key key, const ColdEntry** ppcold, const void** ppvhot) { + bool find_handle( + security_key key, const ColdEntry **ppcold, const void **ppvhot) { *ppcold = nullptr; *ppvhot = nullptr; - _cold.all_entries([&](const ColdEntry& entry) { - if (entry.security.key == key) { - *ppcold = &entry; - } - }); + _cold.all_entries([&](const ColdEntry &entry) { + if (entry.security.key == key) { + *ppcold = &entry; + } + }); // Only search the hot list if we found cold - if(*ppcold) { - // It is possible that cold is initialized and hot is not yet due to race between process mapped memory being visible + if (*ppcold) { + // It is possible that cold is initialized and hot is not yet due to + // race between process mapped memory being visible size_t count = 0; do { ++count; - *ppvhot = - cold_header().has_depth ? - find_hot(_hot_depth.get(), key) : - find_hot(_hot.get(), key); + *ppvhot = cold_header().has_depth ? find_hot(_hot_depth.get(), key) + : find_hot(_hot.get(), key); if (!*ppvhot) { std::this_thread::sleep_for(1ms); - if (count == 4096) LOG(md,Error, "Waiting an awfully long time for key: {}",key); + if (count == 4096) + LOG(md, Error, "Waiting an awfully long time for key: {}", + key); if (count == 60000) { - LOG(md,Error, - "Waited far too long for key: {} security discovery may be hung." + LOG(md, Error, + "Waited far too long for key: {} security discovery may " + "be hung." " symbol: {} type: {}", - key, - std::string((*ppcold)->security.symbol()), + key, std::string((*ppcold)->security.symbol()), SecurityType_Name((*ppcold)->security.type)); return false; } } } while (!*ppvhot); - + return true; } @@ -160,29 +169,28 @@ public: return false; } - btree_map> search_handles(const std::set& keys) { - btree_map> result; + btree_map> + search_handles(const std::set &keys) { + btree_map> result; // Walk hot and cold lists and fill in any found handles - if (!_cold.is_initialized()) return result; - _cold.all_entries([&](const ColdEntry& entry) { + if (!_cold.is_initialized()) + return result; + _cold.all_entries([&](const ColdEntry &entry) { if (keys.find(entry.security.key) != keys.end()) { - result.insert( - std::make_pair( - entry.security.key, - make_tuple(&entry,nullptr))); + result.insert(std::make_pair( + entry.security.key, make_tuple(&entry, nullptr))); } }); // Do the same for hot if (_hot_depth) { - _hot_depth->all_entries([&](const HotDepthEntry& entry) { + _hot_depth->all_entries([&](const HotDepthEntry &entry) { auto iter = result.find(entry.key); if (iter != result.end()) { iter->second = make_tuple(get<0>(iter->second), &entry); } }); - } - else if (_hot){ - _hot->all_entries([&](const HotEntry& entry) { + } else if (_hot) { + _hot->all_entries([&](const HotEntry &entry) { auto iter = result.find(entry.key); if (iter != result.end()) { iter->second = make_tuple(get<0>(iter->second), &entry); @@ -192,43 +200,45 @@ public: return result; } - template - void scan_new_securities(CB cb) { + template void scan_new_securities(CB cb) { // If the ver matches no securities have been added - if (_security_count == cold_header().security_count) return; + if (_security_count == cold_header().security_count) + return; _security_count = cold_header().security_count; - _cold.all_entries([&](const ColdEntry& entry) { - if (entry.security.key != invalid_security_key && _found_keys.count(entry.security.key) == 0) { - _found_keys.insert(entry.security.key); - cb(entry); - } - }); + _cold.all_entries([&](const ColdEntry &entry) { + if (entry.security.key != invalid_security_key && + _found_keys.count(entry.security.key) == 0) { + _found_keys.insert(entry.security.key); + cb(entry); + } + }); } void forget_security(security_key key) { _security_count -= _found_keys.erase(key); } - template - void walk_old_securities(CB cb) { + template void walk_old_securities(CB cb) { // Fire callback only for securities which *have* been seen already - if (_found_keys.empty()) return; - _cold.all_entries([&](const ColdEntry& entry) { - if (entry.security.key != invalid_security_key && _found_keys.count(entry.security.key) != 0) { + if (_found_keys.empty()) + return; + _cold.all_entries([&](const ColdEntry &entry) { + if (entry.security.key != invalid_security_key && + _found_keys.count(entry.security.key) != 0) { cb(entry); } }); } - uint32_t security_count() { - return cold_header().security_count; - } + uint32_t security_count() { return cold_header().security_count; } - const ColdHeader& cold_header() { return _cold.header(); } - const HotHeader& hot_header() { return (has_depth() ? _hot_depth->header() : _hot->header());} + const ColdHeader &cold_header() { return _cold.header(); } + const HotHeader &hot_header() { + return (has_depth() ? _hot_depth->header() : _hot->header()); + } bool has_depth() { return cold_header().has_depth; } - const string& symbol() const { return _symbol; } + const string &symbol() const { return _symbol; } SecurityType type() const { return _type; } Venue exchange() const { return _exchange; } co2::Platform platform() const { return _platform; } @@ -236,10 +246,13 @@ public: // // Queued data - int64_t read_trades(google::protobuf::RepeatedPtrField& trades, int64_t excursor) { + int64_t read_trades( + google::protobuf::RepeatedPtrField &trades, + int64_t excursor) { if (init_queues()) { bts_assert(_queues); - utils::WaitFreeQueue::Cursor cursor(_queues->_trade_queue, excursor); + utils::WaitFreeQueue::Cursor cursor( + _queues->_trade_queue, excursor); bool overrun; cursor.read(trades, &overrun); // Preserve the overrun flag in the message @@ -251,15 +264,18 @@ public: return 0; } - int64_t read_rfqs(google::protobuf::RepeatedPtrField& rfqs, int64_t extcursor) { + int64_t read_rfqs( + google::protobuf::RepeatedPtrField &rfqs, + int64_t extcursor) { if (init_queues()) { bts_assert(_queues); bool overrun; vector temp_result; - utils::WaitFreeQueue::Cursor cursor(_queues->_rfq_queue, extcursor); + utils::WaitFreeQueue::Cursor cursor( + _queues->_rfq_queue, extcursor); cursor.read(temp_result, &overrun); // deserialize the rfqs - for (const auto& entry : temp_result) { + for (const auto &entry : temp_result) { rfqs.Add()->ParsePartialFromArray(&entry[0], entry.size()); } if (overrun && rfqs.size() > 0) { @@ -272,11 +288,12 @@ public: bool is_heart_beating() { // Channel Heartbeat - not in a tight loop - if (!_cold.is_initialized()) return true; + if (!_cold.is_initialized()) + return true; return is_heart_beat_ok(cold_header()); } - void dump_shm_to(const char* directory) const { + void dump_shm_to(const char *directory) const { _cold.dump_to(directory); if (_hot) { _hot->dump_to(directory); @@ -285,17 +302,18 @@ public: _hot_depth->dump_to(directory); } } - -private: + private: bool init_queues() { - if (_queues) return true; - if (!_cold.is_initialized()) return false; + if (_queues) + return true; + if (!_cold.is_initialized()) + return false; // double assignment is OK. Leak instead of lock. _queues = new QueueStruct(_cold.header()); return true; } - + string _symbol; SecurityType _type; Venue _exchange; @@ -305,17 +323,18 @@ private: unique_ptr> _hot; unique_ptr> _hot_depth; utils::SharedListReader _cold; - QueueStruct* _queues; + QueueStruct *_queues; }; /////////////////////////////////////////////////////////////////////////////////////////////////// // Instance for synthetic securities (no shm) /////////////////////////////////////////////////////////////////////////////////////////////////// - class SyntheticConsumerInst { typedef tbb::queuing_mutex Mutex; - typedef function(const set&)> IGetHandle; + typedef function( + const set &)> + IGetHandle; typedef shared_ptr StrategyPtr; struct IncompleteStrategy { shared_ptr security; @@ -324,7 +343,7 @@ class SyntheticConsumerInst { // LOCK only public methods Mutex _workmutex; - api::ISyntheticSecurityService* _ss; + api::ISyntheticSecurityService *_ss; map _data; vector> _pending; set _seen; @@ -334,214 +353,207 @@ class SyntheticConsumerInst { int _meta_sub; std::vector> _old_strategies; - public: - SyntheticConsumerInst(api::ISyntheticSecurityService* ss, const IGetHandle& gh) : - _workmutex(), - _ss(ss), - _data(), - _pending(), - _seen(), - _get_handle(gh), - _initialized(false), - _security_sub(0), - _meta_sub(0), - _old_strategies() - { - } + public: + SyntheticConsumerInst( + api::ISyntheticSecurityService *ss, const IGetHandle &gh) + : _workmutex(), _ss(ss), _data(), _pending(), _seen(), _get_handle(gh), + _initialized(false), _security_sub(0), _meta_sub(0), + _old_strategies() {} - ~SyntheticConsumerInst() { - if (_meta_sub) { - _ss->on_metadata().unsubscribe(_meta_sub); - } - if (_security_sub) { - _ss->on_securities().unsubscribe(_security_sub); + ~SyntheticConsumerInst() { + if (_meta_sub) { + _ss->on_metadata().unsubscribe(_meta_sub); + } + if (_security_sub) { + _ss->on_securities().unsubscribe(_security_sub); + } + } + + size_t security_count() { return _ss->securities().size(); } + + const vector get_old_synthetics() { + Mutex::scoped_lock lock(_workmutex); + vector result; + for (const auto &i : _data) { + if (_seen.find(i.first) != _seen.end()) { + result.push_back(i.second); } } + return result; + } - size_t security_count() { - return _ss->securities().size(); + const StrategyPtr get_synthetic(security_key key) { + Mutex::scoped_lock lock(_workmutex); + const auto result = _data.find(key); + if (result != _data.end()) { + return result->second; } + return nullptr; + } - const vector get_old_synthetics() { - Mutex::scoped_lock lock(_workmutex); - vector result; - for (const auto& i : _data) { - if (_seen.find(i.first) != _seen.end()) { - result.push_back(i.second); - } - } - return result; + const vector scan_new_synthetics() { + Mutex::scoped_lock lock(_workmutex); + init(); + if (!_pending.empty()) { + vector> temp; + temp.swap(_pending); + add_snapshot(temp); } - - const StrategyPtr get_synthetic(security_key key) { - Mutex::scoped_lock lock(_workmutex); - const auto result = _data.find(key); - if (result != _data.end()) { - return result->second; - } - return nullptr; - } - - const vector scan_new_synthetics() { - Mutex::scoped_lock lock(_workmutex); - init(); - if (!_pending.empty()) { - vector> temp; - temp.swap(_pending); - add_snapshot(temp); - } - vector result; - for (const auto& i : _data) { - if (_seen.find(i.first) == _seen.end()) { - result.push_back(i.second); - _seen.insert(i.first); - } - } - return result; - } - -private: - void process_pending() { - } - - void init() { - if (!_initialized) { - _initialized = true; - vector> snapshot; - for (const auto& pair : _ss->securities()) { - snapshot.push_back(make_shared(pair.second)); - } - add_snapshot(snapshot); - _security_sub = _ss->on_securities().subscribe([=](const api::Security& sec) { add_security(sec); }); - _meta_sub = _ss->on_metadata().subscribe([=](const synthetic::Metadata& m) { on_metadata(m); }); + vector result; + for (const auto &i : _data) { + if (_seen.find(i.first) == _seen.end()) { + result.push_back(i.second); + _seen.insert(i.first); } } + return result; + } - void add_security(const api::Security& sec) { - Mutex::scoped_lock lock(_workmutex); - if (_data.find(sec.id()) == _data.end()) { - auto ptr = to_strategy(make_shared(sec)); - vector vec; - vec.push_back(ptr); - auto handles = get_synthetic_handles(vec, _data, _get_handle); - _data.insert(handles.begin(), handles.end()); - for (const auto& s : vec) { - if (handles.find(s.security->id()) == handles.end()) { - _pending.push_back(s.security); - } + private: + void process_pending() {} + + void init() { + if (!_initialized) { + _initialized = true; + vector> snapshot; + for (const auto &pair : _ss->securities()) { + snapshot.push_back(make_shared(pair.second)); + } + add_snapshot(snapshot); + _security_sub = _ss->on_securities().subscribe( + [=](const api::Security &sec) { add_security(sec); }); + _meta_sub = _ss->on_metadata().subscribe( + [=](const synthetic::Metadata &m) { on_metadata(m); }); + } + } + + void add_security(const api::Security &sec) { + Mutex::scoped_lock lock(_workmutex); + if (_data.find(sec.id()) == _data.end()) { + auto ptr = to_strategy(make_shared(sec)); + vector vec; + vec.push_back(ptr); + auto handles = get_synthetic_handles(vec, _data, _get_handle); + _data.insert(handles.begin(), handles.end()); + for (const auto &s : vec) { + if (handles.find(s.security->id()) == handles.end()) { + _pending.push_back(s.security); } } } + } - void on_metadata(const api::synthetic::Metadata& m) { - Mutex::scoped_lock lock(_workmutex); - // update security metadata - auto iter = _data.find(m.security_key()); - if (iter != _data.end()) { - auto updated = std::make_unique(); - updated->CopyFrom(m.strategy()); - iter->second->strategy.swap(updated); - iter->second->updated = TimeStamp::now(); - // Keep the old strategy alive because it could be in use. - // metadata is changed so seldomly this is not a significant use of memory - if (updated != nullptr) _old_strategies.push_back(std::move(updated)); + void on_metadata(const api::synthetic::Metadata &m) { + Mutex::scoped_lock lock(_workmutex); + // update security metadata + auto iter = _data.find(m.security_key()); + if (iter != _data.end()) { + auto updated = std::make_unique(); + updated->CopyFrom(m.strategy()); + iter->second->strategy.swap(updated); + iter->second->updated = TimeStamp::now(); + // Keep the old strategy alive because it could be in use. + // metadata is changed so seldomly this is not a significant use of + // memory + if (updated != nullptr) + _old_strategies.push_back(std::move(updated)); + } + } + + private: + static map get_synthetic_handles( + vector synthetics, + const map &existing, + const std::function( + const set &)> &get_handles) { + + // gather leg keys for batch processing + std::set leg_keys; + for (const auto &p : synthetics) { + for (const auto &leg : p.security->synthetic().legs()) { + leg_keys.insert(leg.security().id()); } } + // Get Handles for all of the 'real' legs + auto real_handles = get_handles(leg_keys); -private: - static map get_synthetic_handles( - vector synthetics, - const map& existing, - const std::function(const set&)>& get_handles) { - - // gather leg keys for batch processing - std::set leg_keys; - for (const auto& p : synthetics) { - for (const auto& leg : p.security->synthetic().legs()) { - leg_keys.insert(leg.security().id()); - } - } - // Get Handles for all of the 'real' legs - auto real_handles = get_handles(leg_keys); - - // result will be merged with _data - map result; - size_t result_count; - do { - result_count = result.size(); - for (const auto& strategy : synthetics) { - // skip any that have already been found - if (result.find(strategy.security->id()) != result.end()) continue; - vector legs; - legs.reserve(strategy.security->synthetic().legs_size()); - for (const auto& leg : strategy.security->synthetic().legs()) { - auto leg_key = leg.security().id(); - auto iter = real_handles.find(leg_key); - if (iter != real_handles.end()) { - // real handle - legs.push_back(iter->second); - } - else { - auto iter2 = existing.find(leg_key); - if (iter2 != existing.end()) { - // existing synthetic handle - legs.push_back(MDConsumerHandle(iter2->second)); - } - else { - auto iter3 = result.find(leg_key); - if (iter3 != result.end()) { - // new synthetic handle? - legs.push_back(MDConsumerHandle(iter3->second)); - } + // result will be merged with _data + map result; + size_t result_count; + do { + result_count = result.size(); + for (const auto &strategy : synthetics) { + // skip any that have already been found + if (result.find(strategy.security->id()) != result.end()) + continue; + vector legs; + legs.reserve(strategy.security->synthetic().legs_size()); + for (const auto &leg : strategy.security->synthetic().legs()) { + auto leg_key = leg.security().id(); + auto iter = real_handles.find(leg_key); + if (iter != real_handles.end()) { + // real handle + legs.push_back(iter->second); + } else { + auto iter2 = existing.find(leg_key); + if (iter2 != existing.end()) { + // existing synthetic handle + legs.push_back(MDConsumerHandle(iter2->second)); + } else { + auto iter3 = result.find(leg_key); + if (iter3 != result.end()) { + // new synthetic handle? + legs.push_back(MDConsumerHandle(iter3->second)); } } } - // If we found all the legs - if (legs.size() == (size_t)strategy.security->synthetic().legs_size()) { - auto s = make_shared(); - s->security.CopyFrom(*strategy.security); - s->strategy = std::make_unique(strategy.strategy); - s->legs = legs; - s->updated = TimeStamp::now(); - result.insert( - make_pair(strategy.security->id(),s)); - } } - //iterate as long as progress is made - } while(result_count < result.size()); - return result; - } - - IncompleteStrategy to_strategy(const shared_ptr& security) { - IncompleteStrategy res; - res.security = security; - auto meta = _ss->get_metadata(SecurityKey(security->id())); - // If metadata is set copy it otherwise we use the default proto - if (meta) { - res.strategy.CopyFrom(meta->strategy()); - } - return res; - } - - void add_snapshot(const vector>& securities) { - std::vector strategies; - for (const auto& sec : securities) { - if (_data.find(sec->id()) == _data.end()) { - strategies.push_back(to_strategy(sec)); + // If we found all the legs + if (legs.size() == + (size_t)strategy.security->synthetic().legs_size()) { + auto s = make_shared(); + s->security.CopyFrom(*strategy.security); + s->strategy = std::make_unique( + strategy.strategy); + s->legs = legs; + s->updated = TimeStamp::now(); + result.insert(make_pair(strategy.security->id(), s)); } } - if (strategies.size() > 0) { - auto handles = get_synthetic_handles(strategies, _data, _get_handle); - // put strategies that are incomplete into a backlog - for (const auto& s : strategies) { - if (handles.find(s.security->id()) == handles.end()) { - _pending.push_back(s.security); - } - } - _data.insert(handles.begin(), handles.end()); + // iterate as long as progress is made + } while (result_count < result.size()); + return result; + } + + IncompleteStrategy to_strategy(const shared_ptr &security) { + IncompleteStrategy res; + res.security = security; + auto meta = _ss->get_metadata(SecurityKey(security->id())); + // If metadata is set copy it otherwise we use the default proto + if (meta) { + res.strategy.CopyFrom(meta->strategy()); + } + return res; + } + + void add_snapshot(const vector> &securities) { + std::vector strategies; + for (const auto &sec : securities) { + if (_data.find(sec->id()) == _data.end()) { + strategies.push_back(to_strategy(sec)); } } - + if (strategies.size() > 0) { + auto handles = get_synthetic_handles(strategies, _data, _get_handle); + // put strategies that are incomplete into a backlog + for (const auto &s : strategies) { + if (handles.find(s.security->id()) == handles.end()) { + _pending.push_back(s.security); + } + } + _data.insert(handles.begin(), handles.end()); + } + } }; /////////////////////////////////////////////////////////////////////////////////////////////////// @@ -552,78 +564,88 @@ class MDConsumerImpl { Mutex _workmutex; vector> _instances; std::shared_ptr _sci; - MBOReader* _mbo; + MBOReader *_mbo; map> _deferred_handles; vector _callbacks; mutable SecurityCache _cache; // co2::Platform _platform; -public: + public: MDConsumerImpl( - 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) - { + 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) { std::ostringstream msg; - for (const auto& symbol : symbols) { - if (msg.tellp() > 0) { msg << ", "; } - msg << symbol.symbol() << "-" << SecurityType_Name(symbol.type()) << " " << Venue_Name(symbol.exchange()); + for (const auto &symbol : symbols) { + if (msg.tellp() > 0) { + msg << ", "; + } + msg << symbol.symbol() << "-" << SecurityType_Name(symbol.type()) + << " " << Venue_Name(symbol.exchange()); } - LOG(md,Info,"Created MDConsumer for securities: {} on {}" ,msg.str(), co2::Platform_Name(platform)); + LOG(md, Info, "Created MDConsumer for securities: {} on {}", msg.str(), + co2::Platform_Name(platform)); - for (auto& s : symbols) { + for (auto &s : symbols) { if (s.type() == SECURITYTYPE_FUTURE) { - _instances.push_back(make_shared(s.symbol(), s.type(), s.exchange(), shared, platform)); + _instances.push_back(make_shared( + s.symbol(), s.type(), s.exchange(), shared, platform)); } } - bool has_synthetic_instance = false; - for (auto& s : symbols) { + bool has_synthetic_instance = false; + for (auto &s : symbols) { if (s.type() != SECURITYTYPE_FUTURE) { if (s.type() == SECURITYTYPE_SYNTHETIC) { - // Should I look for the shared memory if we have a ISyntheticSecurityService? + // Should I look for the shared memory if we have a + // ISyntheticSecurityService? if (has_synthetic_instance == false) { - _instances.push_back(make_shared(SYNTHETIC_SYMBOL, s.type(), api::VENUE_BTS, shared, platform)); + _instances.push_back(make_shared( + SYNTHETIC_SYMBOL, s.type(), api::VENUE_BTS, shared, + platform)); } has_synthetic_instance = true; - } - else { - _instances.push_back(make_shared(s.symbol(), s.type(), s.exchange(), shared, platform)); + } else { + _instances.push_back(make_shared( + s.symbol(), s.type(), s.exchange(), shared, platform)); } } } if (ss != nullptr) { - _sci = std::make_shared(ss, [=](const set& keys) { return get_handles(keys); }); + _sci = std::make_shared( + ss, + [=](const set &keys) { return get_handles(keys); }); } - // Add the SecurityCache to on_security so it can cache discovered securities - _callbacks.push_back([this](const SecurityPtr& security, MDConsumerHandle) { - _cache.add_live_security(security); - }); + // Add the SecurityCache to on_security so it can cache discovered + // securities + _callbacks.push_back( + [this](const SecurityPtr &security, MDConsumerHandle) { + _cache.add_live_security(security); + }); } - ~MDConsumerImpl() { } + ~MDConsumerImpl() {} // This is a terrible name - size_t walk_sec_list(SecurityCallback cb, const string& symbol, SecurityType type) { + size_t + walk_sec_list(SecurityCallback cb, const string &symbol, SecurityType type) { size_t result = 0; vector securities; - for (auto& inst : _instances) { - if (match_symbol(inst->symbol(), symbol) && match_type(inst->type(), type)) { - result += inst->walk_sec_list([&](MutSecurityPtr security) { securities.push_back(security); }, symbol, type); + for (auto &inst : _instances) { + if (match_symbol(inst->symbol(), symbol) && + match_type(inst->type(), type)) { + result += inst->walk_sec_list( + [&](MutSecurityPtr security) { + securities.push_back(security); + }, + symbol, type); } } auto complete_securities = fill_leg_details(securities); auto handles = get_handles(complete_securities); - for (const auto& security : complete_securities) { + for (const auto &security : complete_securities) { auto find_result = handles.find(security->id()); if (find_result != handles.end()) { cb(security, find_result->second); @@ -636,13 +658,14 @@ public: // Check synthetics first because it's fast. if (_sci) { auto handle = _sci->get_synthetic(key); - if (handle) return MDConsumerHandle(handle); + if (handle) + return MDConsumerHandle(handle); } - const void* hot = nullptr; - const ColdEntry* cold = nullptr; + const void *hot = nullptr; + const ColdEntry *cold = nullptr; // Search through the instances for one that has this handle - for (auto& inst : _instances) { + for (auto &inst : _instances) { if (inst->find_handle(key, &cold, &hot)) { MDConsumerHandle handle; handle.init(inst->cold_header(), *cold, hot, _mbo); @@ -650,40 +673,38 @@ public: } } - // If we can't find it return an empty handle. This handle could be later initialized when the security is available. + // If we can't find it return an empty handle. This handle could be later + // initialized when the security is available. MDConsumerHandle empty_handle; return empty_handle; } - template //maybe const - map get_handles(const vector& securities) { + template // maybe const + map + get_handles(const vector &securities) { set keys; - for (const auto& sec : securities) { + for (const auto &sec : securities) { keys.insert(sec->id()); } return get_handles(keys); } - map get_handles(const set& keys) { + map + get_handles(const set &keys) { map result; - if (keys.empty()) return result; + if (keys.empty()) + return result; - for (auto& inst : _instances) { + for (auto &inst : _instances) { auto found = inst->search_handles(keys); - for (const auto& t : found) { + for (const auto &t : found) { // auto [cold,hot] = t.second; auto cold = get<0>(t.second); auto hot = get<1>(t.second); if (cold && hot) { - result.insert( - make_pair( - cold->security.key, - MDConsumerHandle { - inst->cold_header(), - *cold, - hot, - _mbo - })); + result.insert(make_pair( + cold->security.key, + MDConsumerHandle{inst->cold_header(), *cold, hot, _mbo})); } } } @@ -691,9 +712,9 @@ public: return result; } - shared_ptr get_managed_handle(security_key key) { - shared_ptr handle = make_shared(get_handle(key)); + shared_ptr handle = + make_shared(get_handle(key)); if (!handle->is_initialized()) { Mutex::scoped_lock lock(_workmutex); _deferred_handles[key] = handle; @@ -701,21 +722,24 @@ public: return handle; } - vector fill_leg_details(const vector& securities, int depth=0) { + vector + fill_leg_details(const vector &securities, int depth = 0) { vector result; - if (securities.empty() || depth > 64) return result; + if (securities.empty() || depth > 64) + return result; // // Gather ids for legs set keys; - for (const auto& sec : securities) { + for (const auto &sec : securities) { if (securitytype_of(*sec) == SECURITYTYPE_SPREAD) { - for (const auto& leg : sec->spread().legs()) { + for (const auto &leg : sec->spread().legs()) { keys.insert(leg.security().id()); } } } // If there are no spreads everything is (by definition) resolved already - if (keys.empty()) return vector{securities.begin(), securities.end()}; + if (keys.empty()) + return vector{securities.begin(), securities.end()}; // // gather handles for direct legs auto handles = get_handles(keys); @@ -724,36 +748,38 @@ public: // Some of the legs will themselves be spreads vector legs; legs.reserve(handles.size()); - for (const auto& pair : handles) { + for (const auto &pair : handles) { bts_assert_d(pair.second.is_initialized()); if (pair.second.is_initialized()) { - legs.push_back(make_shared(pair.second.get_normalized_security())); + legs.push_back( + make_shared(pair.second.get_normalized_security())); } } // recurse to find details map leg_map; - for (auto& leg : fill_leg_details(legs, depth+1)) { + for (auto &leg : fill_leg_details(legs, depth + 1)) { leg_map.insert(make_pair(leg->id(), move(leg))); } // // update legs - for (auto& sec : securities) { + for (auto &sec : securities) { if (securitytype_of(*sec) == SECURITYTYPE_SPREAD) { - for (auto& leg : *sec->mutable_spread()->mutable_legs()) { + for (auto &leg : *sec->mutable_spread()->mutable_legs()) { auto key = leg.security().id(); auto leg_iter = leg_map.find(key); - if (leg_iter == leg_map.end()) goto next; + if (leg_iter == leg_map.end()) + goto next; bts_assert(leg.security().id() == leg_iter->first); leg.mutable_security()->CopyFrom(*leg_iter->second); } sec->mutable_spread()->set_normalized(false); result.push_back(sec); - } - else { + } else { result.push_back(sec); } - next: continue; + next: + continue; } return result; } @@ -762,12 +788,14 @@ public: size_t scan_securities(bool resolve_legs) { Mutex::scoped_lock lock(_workmutex); size_t count = 0; - if (_callbacks.empty() && _deferred_handles.empty()) return 0; + if (_callbacks.empty() && _deferred_handles.empty()) + return 0; // Call each _instance and pass it a callback - for (auto& inst : _instances) { + for (auto &inst : _instances) { vector found_securities; - inst->scan_new_securities([&](const ColdEntry& entry) { - // Check if any deferred handles need this security (could be sped up with get_handles() but it isn't hot + inst->scan_new_securities([&](const ColdEntry &entry) { + // Check if any deferred handles need this security (could be sped + // up with get_handles() but it isn't hot auto iter = _deferred_handles.find(entry.security.key); if (iter != _deferred_handles.end()) { (*iter->second) = get_handle(entry.security.key); @@ -777,58 +805,66 @@ public: }); if (resolve_legs && !found_securities.empty()) { - sort(found_securities.begin(), found_securities.end(), SecurityLess()); + sort( + found_securities.begin(), found_securities.end(), + SecurityLess()); - vector resolved_securities = fill_leg_details(found_securities); - sort(resolved_securities.begin(), resolved_securities.end(), SecurityLess()); + vector resolved_securities = + fill_leg_details(found_securities); + sort( + resolved_securities.begin(), resolved_securities.end(), + SecurityLess()); // Extract the list of unresolved securities vector unresolved_securities; - set_difference(found_securities.begin(), found_securities.end(), - resolved_securities.begin(), resolved_securities.end(), - inserter(unresolved_securities, unresolved_securities.begin()), SecurityLess()); + set_difference( + found_securities.begin(), found_securities.end(), + resolved_securities.begin(), resolved_securities.end(), + inserter(unresolved_securities, unresolved_securities.begin()), + SecurityLess()); - // Return any unresolved spreads to the source so they can be 'discovered' again - // We can safely send a security key to every _instance because by definition - // a security cannot appear in 2 instances + // Return any unresolved spreads to the source so they can be + // 'discovered' again We can safely send a security key to every + // _instance because by definition a security cannot appear in 2 + // instances if (unresolved_securities.size() > 250) { - LOG(md,Info,"Failed to resolve legs for {}" - " spreads. This can happen when a spread is subscribed without " - "it's underliers and may lead to higher than expected CPU use.", - unresolved_securities.size() ); + LOG(md, Info, + "Failed to resolve legs for {}" + " spreads. This can happen when a spread is subscribed " + "without " + "it's underliers and may lead to higher than expected CPU " + "use.", + unresolved_securities.size()); } - for (auto& security : unresolved_securities) { + for (auto &security : unresolved_securities) { bts_assert(securitytype_of(*security) == SECURITYTYPE_SPREAD); bts_assert(security->id() != invalid_security_key); inst->forget_security(security->id()); } auto handles = get_handles(resolved_securities); - for (const auto& security : resolved_securities) { + for (const auto &security : resolved_securities) { auto find_result = handles.find(security->id()); if (find_result != handles.end()) { // Pass new securities to each callback - for (auto& cb : _callbacks) { + for (auto &cb : _callbacks) { cb(security, find_result->second); } - } - else { + } else { // "should never happen" inst->forget_security(security->id()); } } count += resolved_securities.size(); - } - else /* do NOT resolve_legs*/ { + } else /* do NOT resolve_legs*/ { auto handles = get_handles(found_securities); - for (const auto& security : found_securities) { + for (const auto &security : found_securities) { auto find_result = handles.find(security->id()); if (find_result != handles.end()) { - for (auto& cb : _callbacks) { + for (auto &cb : _callbacks) { cb(security, find_result->second); } - } - else { + } else { inst->forget_security(security->id()); } } @@ -837,9 +873,9 @@ public: } if (_sci) { - for (const auto& item : _sci->scan_new_synthetics()) { + for (const auto &item : _sci->scan_new_synthetics()) { count++; - const auto& security = item->security; + const auto &security = item->security; auto handle = MDConsumerHandle(item); // check deferred handles auto iter = _deferred_handles.find(security.id()); @@ -848,7 +884,7 @@ public: _deferred_handles.erase(iter); } // call all subscribers - for (auto& cb : _callbacks) { + for (auto &cb : _callbacks) { cb(std::make_shared(security), handle); } } @@ -857,24 +893,25 @@ public: _cache.flush_to_disk(); return count; } - + // Subscribe to new securities void on_security(SecurityCallback cb, bool resolve_legs) { Mutex::scoped_lock lock(_workmutex); - // Walk the current security list and fire the callbacks for existing securities - // Note: We have to lock over the initial walk because if scan_securities() finds a new security concurrently with this walk - // it might mark it seen without this callback getting called. - for (auto& inst : _instances) { + // Walk the current security list and fire the callbacks for existing + // securities Note: We have to lock over the initial walk because if + // scan_securities() finds a new security concurrently with this walk it + // might mark it seen without this callback getting called. + for (auto &inst : _instances) { vector securities; - inst->walk_old_securities([&](const ColdEntry& entry) { + inst->walk_old_securities([&](const ColdEntry &entry) { securities.push_back(convert_psecurity(entry.security)); }); - auto filled_securities = - resolve_legs ? - fill_leg_details(securities) : - vector{securities.begin(), securities.end()}; + auto filled_securities = + resolve_legs + ? fill_leg_details(securities) + : vector{securities.begin(), securities.end()}; auto handles = get_handles(filled_securities); - for (const auto& security : filled_securities) { + for (const auto &security : filled_securities) { auto find_result = handles.find(security->id()); bts_assert_d(find_result != handles.end()); if (find_result != handles.end()) { @@ -884,8 +921,8 @@ public: } // Get all existing synthetic securities if (_sci) { - for (const auto& item : _sci->get_old_synthetics()) { - const auto& security = item->security; + for (const auto &item : _sci->get_old_synthetics()) { + const auto &security = item->security; auto handle = MDConsumerHandle(item); cb(std::make_shared(security), handle); } @@ -897,7 +934,7 @@ public: scan_securities(resolve_legs); } - const Security* get_security(SecurityKey key) const { + const Security *get_security(SecurityKey key) const { return _cache.get_security(key); } @@ -905,114 +942,150 @@ public: return _cache.get_securities(); } - MDConsumerChannel get_channel(const std::string& symbol, SecurityType type, Venue exchange) const { - for (auto& inst : _instances) { - if ((inst->symbol() == symbol && inst->type() == type && inst->exchange() == exchange) || - (inst->type() == SECURITYTYPE_SYNTHETIC && type == SECURITYTYPE_SYNTHETIC)) { + MDConsumerChannel get_channel( + const std::string &symbol, SecurityType type, Venue exchange) const { + for (auto &inst : _instances) { + if ((inst->symbol() == symbol && inst->type() == type && + inst->exchange() == exchange) || + (inst->type() == SECURITYTYPE_SYNTHETIC && + type == SECURITYTYPE_SYNTHETIC)) { return MDConsumerChannel(inst); } } - bts_assert_msg(false, "Invalid symbol/type/exchange in MDConsumer::get_channel"); + bts_assert_msg( + false, "Invalid symbol/type/exchange in MDConsumer::get_channel"); } bool all_heartbeats_ok() const { - for (auto& inst : _instances) { - if (!inst->is_heart_beating()) return false; + for (auto &inst : _instances) { + if (!inst->is_heart_beating()) + return false; } return true; } size_t security_count() const { size_t result = 0; - for (auto& inst : _instances) { + for (auto &inst : _instances) { result += inst->security_count(); } - if (_sci) { result += _sci->security_count(); } + if (_sci) { + result += _sci->security_count(); + } return result; } - void dump_shm_to(const char* p) const { + void dump_shm_to(const char *p) const { // To be safe we should lock _work_mutex -but- - // we need this function to diagnose problems happening in the on_security callback - // which holds the _work_mutex. Since anyone calling this function is going down - // anyway we as well live dangerously. - for (auto& inst : _instances) { + // we need this function to diagnose problems happening in the on_security + // callback which holds the _work_mutex. Since anyone calling this + // function is going down anyway we as well live dangerously. + for (auto &inst : _instances) { inst->dump_shm_to(p); } } }; - /////////////////////////////////////////////////////////////////////////////////////////////////// // MDConsumer public interface, forwards to pimple /////////////////////////////////////////////////////////////////////////////////////////////////// MDConsumer::MDConsumer( - SecurityCache& cache, - api::ISyntheticSecurityService* ss, - MBOReader* mbo, - const std::set* symbols, - bool shared, - co2::Platform platform) : _pimpl() { + SecurityCache &cache, api::ISyntheticSecurityService *ss, MBOReader *mbo, + const std::set *symbols, bool shared, co2::Platform platform) + : _pimpl() { - set all_symbols; - if (symbols == nullptr || symbols->empty()) { - all_symbols = get_system_md_symbols(); - symbols = &all_symbols; - } + set all_symbols; + if (symbols == nullptr || symbols->empty()) { + all_symbols = get_system_md_symbols(); + symbols = &all_symbols; + } - _pimpl.reset(new MDConsumerImpl(*symbols, cache, ss, mbo, shared, platform)); + _pimpl.reset(new MDConsumerImpl(*symbols, cache, ss, mbo, shared, platform)); } MDConsumer::~MDConsumer() {} -bool MDConsumer::all_heartbeats_ok() const { return _pimpl->all_heartbeats_ok(); } -size_t MDConsumer::security_count() const { return _pimpl->security_count();} +bool MDConsumer::all_heartbeats_ok() const { + return _pimpl->all_heartbeats_ok(); +} +size_t MDConsumer::security_count() const { return _pimpl->security_count(); } -MDConsumerHandle MDConsumer::get_handle(security_key key) { return _pimpl->get_handle(key); } -std::map MDConsumer::get_handles(const std::set& keys) { return _pimpl->get_handles(keys); } -shared_ptr MDConsumer::get_managed_handle(security_key key) { return _pimpl->get_managed_handle(key); } +MDConsumerHandle MDConsumer::get_handle(security_key key) { + return _pimpl->get_handle(key); +} +std::map +MDConsumer::get_handles(const std::set &keys) { + return _pimpl->get_handles(keys); +} +shared_ptr MDConsumer::get_managed_handle(security_key key) { + return _pimpl->get_managed_handle(key); +} -size_t MDConsumer::walk_security_list(SecurityCallback cb, const string& symbol, SecurityType type) { +size_t MDConsumer::walk_security_list( + SecurityCallback cb, const string &symbol, SecurityType type) { return _pimpl->walk_sec_list(cb, symbol, type); } -size_t MDConsumer::scan_securities(bool resolve_legs) { return _pimpl->scan_securities(resolve_legs); } -void MDConsumer::on_security(SecurityCallback cb, bool resolve_legs) { _pimpl->on_security(cb, resolve_legs); } -const api::Security* MDConsumer::get_security(SecurityKey key) const { return _pimpl->get_security(key); } -std::vector MDConsumer::get_securities() const {return _pimpl->get_securities();} +size_t MDConsumer::scan_securities(bool resolve_legs) { + return _pimpl->scan_securities(resolve_legs); +} +void MDConsumer::on_security(SecurityCallback cb, bool resolve_legs) { + _pimpl->on_security(cb, resolve_legs); +} +const api::Security *MDConsumer::get_security(SecurityKey key) const { + return _pimpl->get_security(key); +} +std::vector MDConsumer::get_securities() const { + return _pimpl->get_securities(); +} -MDConsumerChannel MDConsumer::get_channel(const std::string& symbol, SecurityType type, Venue exchange) const { +MDConsumerChannel MDConsumer::get_channel( + const std::string &symbol, SecurityType type, Venue exchange) const { return _pimpl->get_channel(symbol, type, exchange); } -MDConsumerChannel MDConsumer::get_channel(const UserSymbol& u) const { +MDConsumerChannel MDConsumer::get_channel(const UserSymbol &u) const { return _pimpl->get_channel(u.symbol(), u.type(), u.exchange()); } -void MDConsumer::dump_shm_to(const char* p) const { _pimpl->dump_shm_to(p); } +void MDConsumer::dump_shm_to(const char *p) const { _pimpl->dump_shm_to(p); } - -MDConsumerChannel::MDConsumerChannel(const shared_ptr& inst) : _pimpl(inst) {} -int64_t MDConsumerChannel::read_trades(google::protobuf::RepeatedPtrField& trades, int64_t cursor) { return _pimpl->read_trades(trades, cursor); } -int64_t MDConsumerChannel::read_rfqs(google::protobuf::RepeatedPtrField& quotes, int64_t cursor) { return _pimpl->read_rfqs(quotes, cursor); } -const std::string& MDConsumerChannel::symbol() const { return _pimpl->symbol(); } +MDConsumerChannel::MDConsumerChannel(const shared_ptr &inst) + : _pimpl(inst) {} +int64_t MDConsumerChannel::read_trades( + google::protobuf::RepeatedPtrField &trades, + int64_t cursor) { + return _pimpl->read_trades(trades, cursor); +} +int64_t MDConsumerChannel::read_rfqs( + google::protobuf::RepeatedPtrField "es, + int64_t cursor) { + return _pimpl->read_rfqs(quotes, cursor); +} +const std::string &MDConsumerChannel::symbol() const { + return _pimpl->symbol(); +} SecurityType MDConsumerChannel::type() const { return _pimpl->type(); } Venue MDConsumerChannel::exchange() const { return _pimpl->exchange(); } Platform MDConsumerChannel::platform() const { return _pimpl->platform(); } -bool MDConsumerChannel::is_heart_beating() const { return _pimpl->is_heart_beating(); } -bool MDConsumerChannel::is_initialized() const { return _pimpl && security_count() > 0; } -TimeStamp MDConsumerChannel::create_time() const { return _pimpl ? _pimpl->cold_header().create_time : TimeStamp::invalid(); } +bool MDConsumerChannel::is_heart_beating() const { + return _pimpl->is_heart_beating(); +} +bool MDConsumerChannel::is_initialized() const { + return _pimpl && security_count() > 0; +} +TimeStamp MDConsumerChannel::create_time() const { + return _pimpl ? _pimpl->cold_header().create_time : TimeStamp::invalid(); +} size_t MDConsumerChannel::security_count() const { return _pimpl->cold_header().security_count; } size_t MDConsumerChannel::direct_count() const { - return is_initialized() ? - _pimpl->hot_header().direct_count : 0; + return is_initialized() ? _pimpl->hot_header().direct_count : 0; } size_t MDConsumerChannel::implied_count() const { - return is_initialized() ? - _pimpl->hot_header().implied_count : 0; + return is_initialized() ? _pimpl->hot_header().implied_count : 0; } size_t MDConsumerChannel::trade_count() const { return _pimpl->cold_header().trade_count; @@ -1024,18 +1097,18 @@ size_t MDConsumerChannel::gap_count() const { return _pimpl->cold_header().gap_count; } -bool is_heart_beat_ok(const ColdHeader &header ) { +bool is_heart_beat_ok(const ColdHeader &header) { uint32_t s_heartbeat_ms = header.heartbeat_ms; bool s_disable_heartbeat = header.disable_heartbeat; uint32_t s_grace_period_ms = header.heartbeat_boot_seconds * 1000; TimeStamp hb = header.heartbeat; TimeStamp now = TimeStamp::now(); - return (header.version == shm_version) && - (s_disable_heartbeat || - (now - hb).milliseconds() < s_heartbeat_ms || - (now - header.create_time).milliseconds() < s_grace_period_ms); + return (header.version == shm_version) && + (s_disable_heartbeat || (now - hb).milliseconds() < s_heartbeat_ms || + (now - header.create_time).milliseconds() < s_grace_period_ms); } -}}//namespace +} // namespace md +} // namespace bts #endif diff --git a/src/lib/md/MDConsumer.h b/src/lib/md/MDConsumer.h index 66a3510a0..089fe1c03 100644 --- a/src/lib/md/MDConsumer.h +++ b/src/lib/md/MDConsumer.h @@ -1,25 +1,26 @@ #pragma once -#include "lib/utils/bts_no_copy.h" #include "lib/utils/bts_export.h" +#include "lib/utils/bts_no_copy.h" -#include "common.h" -#include "MDConsumerHandle.h" -#include "UserSymbol.h" #include "ISyntheticSecurityService.h" +#include "MDConsumerHandle.h" #include "SecurityPtr.h" +#include "UserSymbol.h" +#include "common.h" #include -#include -#include -#include -#include #include +#include +#include +#include +#include namespace bts { namespace md { -typedef std::function SecurityCallback; +typedef std::function + SecurityCallback; using std::size_t; class MDConsumerImpl; @@ -28,61 +29,60 @@ class MDConsumerChannel; class SecurityCache; class MBOReader; -class MDConsumer -{ -public: +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; size_t security_count() const; - MDConsumerHandle get_handle(security_key key); - std::map get_handles(const std::set& keys); + std::map + get_handles(const std::set &keys); std::shared_ptr get_managed_handle(security_key key); - + // Walk the entire available security list - size_t walk_security_list(SecurityCallback callback, const std::string& symbol="", SecurityType type = api::SECURITYTYPE_UNSET); + size_t walk_security_list( + SecurityCallback callback, const std::string &symbol = "", + SecurityType type = api::SECURITYTYPE_UNSET); // scan the security list for changes size_t scan_securities(bool resolve_legs = true); void on_security(SecurityCallback cb, bool resolve_legs = true); // Retrieve any security that has been seen in the past - // You still need to call scan_securities() periodically to discover new securities - const api::Security* get_security(SecurityKey key) const; + // You still need to call scan_securities() periodically to discover new + // securities + const api::Security *get_security(SecurityKey key) const; // Retrieve all cached securities - std::vector get_securities() const; + std::vector get_securities() const; - MDConsumerChannel get_channel(const std::string& symbol, SecurityType type, Venue exchange) const; - MDConsumerChannel get_channel(const UserSymbol&) const; + MDConsumerChannel get_channel( + const std::string &symbol, SecurityType type, Venue exchange) const; + MDConsumerChannel get_channel(const UserSymbol &) const; - void swap(MDConsumer& other) { - _pimpl.swap(other._pimpl); - } + void swap(MDConsumer &other) { _pimpl.swap(other._pimpl); } uintptr_t id() const { return reinterpret_cast(_pimpl.get()); } - void dump_shm_to(const char* directory) const; + void dump_shm_to(const char *directory) const; -private: - //BTS_NO_COPY(MDConsumer); COPY OK + private: + // BTS_NO_COPY(MDConsumer); COPY OK std::shared_ptr _pimpl; }; class BTS_EXPORT MDConsumerChannel { std::shared_ptr _pimpl; -public: - MDConsumerChannel(const std::shared_ptr& inst); - const std::string& symbol() const; + public: + MDConsumerChannel(const std::shared_ptr &inst); + + const std::string &symbol() const; SecurityType type() const; Venue exchange() const; Platform platform() const; @@ -90,11 +90,16 @@ public: utils::TimeStamp create_time() const; // Scan for new trades. If overrun is true some trades were lost - int64_t read_trades(google::protobuf::RepeatedPtrField& trades, int64_t cursor); + int64_t read_trades( + google::protobuf::RepeatedPtrField &trades, + int64_t cursor); // Scan for new rfqs. If overrun=true some entries were lost - int64_t read_rfqs(google::protobuf::RepeatedPtrField& quotes, int64_t cursor); + int64_t read_rfqs( + google::protobuf::RepeatedPtrField "es, + int64_t cursor); - // Check the heartbeat has not passed the threshhold (PublisherOptions.heartbeat_ms) + // Check the heartbeat has not passed the threshhold + // (PublisherOptions.heartbeat_ms) bool is_heart_beating() const; // @@ -105,9 +110,7 @@ public: size_t trade_count() const; size_t rfq_count() const; size_t gap_count() const; - }; - -}}//namespace - +} // namespace md +} // namespace bts diff --git a/src/lib/md/MDConsumerHandle.cpp b/src/lib/md/MDConsumerHandle.cpp index 442473281..9ed65bd7e 100644 --- a/src/lib/md/MDConsumerHandle.cpp +++ b/src/lib/md/MDConsumerHandle.cpp @@ -6,8 +6,7 @@ #define never bts_assert(false) -template -using small_vector = boost::container::small_vector; +template using small_vector = boost::container::small_vector; namespace bts { namespace md { @@ -17,47 +16,58 @@ MDConsumerHandle::MDConsumerHandle() { _type = HANDLETYPE_VOID; static_assert(sizeof(MDConsumerHandle) <= 40, ""); } -MDConsumerHandle::MDConsumerHandle(const std::shared_ptr& def) { +MDConsumerHandle::MDConsumerHandle( + const std::shared_ptr &def) { memset(this, 0, sizeof(MDConsumerHandle)); synthetic.def = def; _type = HANDLETYPE_SYNTHETIC; - for(size_t x = 0; x < def->legs.size(); ++x) { - bts_assert(def->legs[x].key() == def->security.synthetic().legs(x).security().id()); + for (size_t x = 0; x < def->legs.size(); ++x) { + bts_assert( + def->legs[x].key() == + def->security.synthetic().legs(x).security().id()); } } -MDConsumerHandle::MDConsumerHandle(const MDConsumerHandle& other) { +MDConsumerHandle::MDConsumerHandle(const MDConsumerHandle &other) { memset(this, 0, sizeof(MDConsumerHandle)); _type = HANDLETYPE_VOID; *this = other; } -MDConsumerHandle::MDConsumerHandle(const ColdHeader& cheader, const ColdEntry& centry, const void* pvhot, const MBOReader* mbo) -{init(cheader,centry,pvhot,mbo);} +MDConsumerHandle::MDConsumerHandle( + const ColdHeader &cheader, const ColdEntry ¢ry, const void *pvhot, + const MBOReader *mbo) { + init(cheader, centry, pvhot, mbo); +} MDConsumerHandle::~MDConsumerHandle() {} -void MDConsumerHandle::init(const ColdHeader& cheader, const ColdEntry& centry, const void* pvhot, const MBOReader* mbo) { +void MDConsumerHandle::init( + const ColdHeader &cheader, const ColdEntry ¢ry, const void *pvhot, + const MBOReader *mbo) { set_cold(&cheader, ¢ry); set_hot(pvhot); set_mbo(mbo); } -TimeStamp copy_bbo(const HotEntry& hot, PriceSize& out_bid, PriceSize& out_ask) { +TimeStamp +copy_bbo(const HotEntry &hot, PriceSize &out_bid, PriceSize &out_ask) { // We expect the time, in_bid and in_ask to be changing (rapidly) - // + // TimeStamp t; int attempts = 0; - // If the publisher crashed and left TimeStamp::invalid() in memory we need to be able to escape the loop - // This max_attempts allows get_bbo() to return 'false' in this case so the calling thread can continue and - // hopefully check the heartbeat. - const int max_attempts = 1619200; + // If the publisher crashed and left TimeStamp::invalid() in memory we need + // to be able to escape the loop This max_attempts allows get_bbo() to return + // 'false' in this case so the calling thread can continue and hopefully + // check the heartbeat. + const int max_attempts = 1619200; do { t = hot.time(); out_bid = hot.book.bid(); out_ask = hot.book.ask(); ++attempts; - } while((t != hot.time() || t == TimeStamp::invalid()) && attempts < max_attempts); + } while ((t != hot.time() || t == TimeStamp::invalid()) && + attempts < max_attempts); if (attempts >= max_attempts) { return TimeStamp::invalid(); } @@ -65,20 +75,18 @@ TimeStamp copy_bbo(const HotEntry& hot, PriceSize& out_bid, PriceSize& out_ask) } TimeStamp copy_depth( - const HotDepthEntry& hot, - size_t count, - PriceSize* bid, PriceSize* ask) -{ + const HotDepthEntry &hot, size_t count, PriceSize *bid, PriceSize *ask) { TimeStamp t; int attempts = 0; - const int max_attempts = 1619200; + const int max_attempts = 1619200; do { t = hot.time(); for (size_t x = 0; x < count; ++x) { hot.read_direct(x, &bid[x], &ask[x]); } ++attempts; - } while((t != hot.time() || t == TimeStamp::invalid()) && attempts < max_attempts); + } while ((t != hot.time() || t == TimeStamp::invalid()) && + attempts < max_attempts); if (attempts >= max_attempts) { return TimeStamp::invalid(); } @@ -97,53 +105,57 @@ struct DepthTraversal { size_t head; api::Side side; double qty, price_mult; - DepthTraversal(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) { + DepthTraversal( + 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 for (size_t x = 0; x < depth_count; ++x) { levels[x].price = depth[x].price(); levels[x].size = depth[x].size(); } } - #ifdef PRECISE_SYNTHETICS +#ifdef PRECISE_SYNTHETICS double available_size() const { double available = 0.0; auto cur = head; bool partial = false; - while(cur < levels.size() && available < 1) { + while (cur < levels.size() && available < 1) { available += levels[cur].size / qty; - if (available < 1.0) partial = true; + if (available < 1.0) + partial = true; ++cur; } - if (partial && available >= 1.0) return 1.0; + if (partial && available >= 1.0) + return 1.0; return available; } double consume(double size) { bts_assert_d(size <= available_size()); double take = size * qty; double price = 0.0; - while(take > 0) { + while (take > 0) { if (levels[head].size >= take) { - price += levels[head].price * price_mult * (take/qty); + price += levels[head].price * price_mult * (take / qty); levels[head].size -= take; - if (levels[head].size <= 0) ++head; + if (levels[head].size <= 0) + ++head; break; - } - else { + } else { double available = levels[head].size; - price += levels[head].price * price_mult * (available/qty); + price += levels[head].price * price_mult * (available / qty); levels[head].size = 0; ++head; take -= available; } } - return price/size; + return price / size; } - #else +#else double available_size() const { double available = 0.0; auto cur = head; - while(cur < levels.size() && available < 1) { + while (cur < levels.size() && available < 1) { available += levels[cur].size / qty; ++cur; } @@ -153,14 +165,14 @@ struct DepthTraversal { bts_assert_d(size <= available_size()); double take = size * qty; double price = 0.0; - while(take > 0) { + while (take > 0) { if (levels[head].size >= take) { price = levels[head].price * price_mult; levels[head].size -= take; - if (levels[head].size <= 0) ++head; + if (levels[head].size <= 0) + ++head; break; - } - else { + } else { double available = levels[head].size; price = levels[head].price * price_mult; levels[head].size = 0; @@ -170,30 +182,34 @@ struct DepthTraversal { } return price; } - #endif +#endif }; -void copy_synthetic_side(size_t count, api::Side side, const api::ContractSpecification& spec, small_vector& leg_travs, Level* out_price) { +void copy_synthetic_side( + 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) { + while (out_index < count) { double price = 0.0; // Find the leg with the minimum available size double size = std::numeric_limits().max(); - for (const auto& dt : leg_travs) { + for (const auto &dt : leg_travs) { auto sz = dt.available_size(); // If we can't get 1.0 from any leg we're done - if (sz <= size) size = sz; - if (size < 1.0) break; + if (sz <= size) + size = sz; + if (size < 1.0) + break; } size = (int64_t)size; if (size < 1.0) { // We've run out of book so we nan out any remaining levels and finish - size_t start = first ? out_index : out_index+1; - for (size_t x=start; x < count; ++x) { + size_t start = first ? out_index : out_index + 1; + for (size_t x = start; x < count; ++x) { out_price[x].price = os::nan(); out_price[x].size = 0; } @@ -201,7 +217,7 @@ void copy_synthetic_side(size_t count, api::Side side, const api::ContractSpecif } // Take that size from each leg - for (auto& dt : leg_travs) { + for (auto &dt : leg_travs) { double temp = dt.consume(size); price += temp; } @@ -217,8 +233,7 @@ void copy_synthetic_side(size_t count, api::Side side, const api::ContractSpecif if (price == out_price[out_index].price) { out_price[out_index].size += size; - } - else { + } else { out_index += 1; if (out_index < count) { out_price[out_index].price = price; @@ -228,7 +243,8 @@ void copy_synthetic_side(size_t count, api::Side side, const api::ContractSpecif } } -const spark::LegSpreaderParams& get_spreader_params(const SyntheticStrategy& synth, security_key key) { +const spark::LegSpreaderParams & +get_spreader_params(const SyntheticStrategy &synth, security_key key) { auto strategy = synth.strategy.get(); if (strategy) { auto iter = strategy->leg_params_map().find(key); @@ -239,7 +255,9 @@ const spark::LegSpreaderParams& get_spreader_params(const SyntheticStrategy& syn return spark::LegSpreaderParams::default_instance(); } -TimeStamp copy_synthetic_depth(const SyntheticStrategy& synth, size_t count, PriceSize* bid, PriceSize* ask) { +TimeStamp copy_synthetic_depth( + const SyntheticStrategy &synth, size_t count, PriceSize *bid, + PriceSize *ask) { small_vector bid_leg_travs; small_vector ask_leg_travs; bid_leg_travs.reserve(synth.legs.size()); @@ -248,44 +266,52 @@ TimeStamp copy_synthetic_depth(const SyntheticStrategy& synth, size_t count, Pri for (size_t x = 0; x < synth.legs.size(); ++x) { std::array bids, asks; TimeStamp t; - const spark::LegSpreaderParams& leg_params = get_spreader_params(synth, synth.legs[x].key()); + const spark::LegSpreaderParams &leg_params = + get_spreader_params(synth, synth.legs[x].key()); auto mdtype = leg_params.market_data_type(); HandleReadResult r; if (mdtype == spark::LegSpreaderParams::DIRECT) { r = synth.legs[x].get_direct_book(t, count, &bids[0], &asks[0]); - } - else { + } else { r = synth.legs[x].get_book(t, count, &bids[0], &asks[0]); } - if (r == HandleReadResult::BUSY || t == TimeStamp::invalid()) return TimeStamp::invalid(); + if (r == HandleReadResult::BUSY || t == TimeStamp::invalid()) + return TimeStamp::invalid(); // NET Change - if (synth.security.synthetic().price_calc() == api::SyntheticContract::PRICECALC_NET_CHANGE) { + if (synth.security.synthetic().price_calc() == + api::SyntheticContract::PRICECALC_NET_CHANGE) { auto settle = synth.legs[x].settlement_price(); double tick = synth.legs[x].get_minimum_tick(); for (size_t d = 0; d < COCONUT_MAX_DEPTH; ++d) { auto b = (bids[d] - settle); auto a = (asks[d] - settle); - bids[d] = { b.int_price() / tick, b.size() }; - asks[d] = { a.int_price() / tick, a.size() }; + bids[d] = {b.int_price() / tick, b.size()}; + asks[d] = {a.int_price() / tick, a.size()}; } } rv = std::max(rv, t); - const auto& leg = synth.security.synthetic().legs(x); - const auto& eff_bid = leg.side() == api::SIDE_BUY ? bids : asks; - const auto& eff_ask = leg.side() == api::SIDE_BUY ? asks : bids; - bid_leg_travs.push_back(DepthTraversal(leg.side(), leg.quantity(), leg.price_multiplier(), &eff_bid[0], eff_bid.size())); - ask_leg_travs.push_back(DepthTraversal(leg.side(), leg.quantity(), leg.price_multiplier(), &eff_ask[0], eff_ask.size())); + const auto &leg = synth.security.synthetic().legs(x); + const auto &eff_bid = leg.side() == api::SIDE_BUY ? bids : asks; + const auto &eff_ask = leg.side() == api::SIDE_BUY ? asks : bids; + bid_leg_travs.push_back(DepthTraversal( + leg.side(), leg.quantity(), leg.price_multiplier(), &eff_bid[0], + eff_bid.size())); + ask_leg_travs.push_back(DepthTraversal( + leg.side(), leg.quantity(), leg.price_multiplier(), &eff_ask[0], + eff_ask.size())); } - std::array scratch {}; - const auto& spec = synth.security.contract_spec(); - copy_synthetic_side(count, api::SIDE_BUY, spec, bid_leg_travs, scratch.data()); + std::array scratch{}; + const auto &spec = synth.security.contract_spec(); + copy_synthetic_side( + count, api::SIDE_BUY, spec, bid_leg_travs, scratch.data()); for (size_t x = 0; x < count; ++x) { bid[x] = PriceSize_from_double<11>(scratch[x].price, scratch[x].size); } memset(scratch.data(), 0, sizeof(scratch)); - copy_synthetic_side(count, api::SIDE_SELL, spec, ask_leg_travs, scratch.data()); + copy_synthetic_side( + count, api::SIDE_SELL, spec, ask_leg_travs, scratch.data()); for (size_t x = 0; x < count; ++x) { ask[x] = PriceSize_from_double<11>(scratch[x].price, scratch[x].size); } @@ -296,98 +322,124 @@ TimeStamp copy_synthetic_depth(const SyntheticStrategy& synth, size_t count, Pri // END SYNTHETIC DEPTH ///////////////////////////// -bool MDConsumerHandle::get_last_trade(TimeStamp& time, PriceSize& trade, datetime::LLDateTime& trade_timestamp, size_t* total_volume, int* from_spread) const { - switch(_type) { - case HANDLETYPE_VOID: return false; - case HANDLETYPE_DEPTH: - case HANDLETYPE_BBO: { - const ColdEntry* pcold = (_type == HANDLETYPE_BBO) ? bbo.cdata : book.cdata; - bool result = pcold->last_trade.load_if_new(time, trade); - if (result) { - trade_timestamp = pcold->last_trade_time; - if (total_volume) { *total_volume = pcold->total_volume; } - if (from_spread) { *from_spread = pcold->from_spread; } +bool MDConsumerHandle::get_last_trade( + TimeStamp &time, PriceSize &trade, datetime::LLDateTime &trade_timestamp, + size_t *total_volume, int *from_spread) const { + switch (_type) { + case HANDLETYPE_VOID: + return false; + case HANDLETYPE_DEPTH: + case HANDLETYPE_BBO: { + const ColdEntry *pcold = + (_type == HANDLETYPE_BBO) ? bbo.cdata : book.cdata; + bool result = pcold->last_trade.load_if_new(time, trade); + if (result) { + trade_timestamp = pcold->last_trade_time; + if (total_volume) { + *total_volume = pcold->total_volume; + } + if (from_spread) { + *from_spread = pcold->from_spread; } - return result; } - case HANDLETYPE_SYNTHETIC: return false; + return result; + } + case HANDLETYPE_SYNTHETIC: + return false; } never; } TimeStamp MDConsumerHandle::misc_timestamp() const { - switch(_type) { - case HANDLETYPE_SYNTHETIC: - case HANDLETYPE_VOID: - return std::numeric_limits::min(); - case HANDLETYPE_DEPTH: - return book.cdata->misc.misc_timestamp; - case HANDLETYPE_BBO: - return bbo.cdata->misc.misc_timestamp; + switch (_type) { + case HANDLETYPE_SYNTHETIC: + case HANDLETYPE_VOID: + return std::numeric_limits::min(); + case HANDLETYPE_DEPTH: + return book.cdata->misc.misc_timestamp; + case HANDLETYPE_BBO: + return bbo.cdata->misc.misc_timestamp; } never; } MiscData MDConsumerHandle::misc() const { - switch(_type) { - case HANDLETYPE_SYNTHETIC: - case HANDLETYPE_VOID: - return MiscData(); - case HANDLETYPE_DEPTH: - return book.cdata->misc; - case HANDLETYPE_BBO: - return bbo.cdata->misc; + switch (_type) { + case HANDLETYPE_SYNTHETIC: + case HANDLETYPE_VOID: + return MiscData(); + case HANDLETYPE_DEPTH: + return book.cdata->misc; + case HANDLETYPE_BBO: + return bbo.cdata->misc; } never; } - bool is_heart_beat_ok(const ColdHeader &); bool MDConsumerHandle::is_heart_beating() const { - switch(_type) { - case HANDLETYPE_VOID: return true; - case HANDLETYPE_DEPTH: return is_heart_beat_ok(*book.cheader); - case HANDLETYPE_BBO: return is_heart_beat_ok(*bbo.cheader); - case HANDLETYPE_SYNTHETIC: return sane::true_for_all(synthetic.def->legs, [](const MDConsumerHandle& h) { return h.is_heart_beating(); }); + switch (_type) { + case HANDLETYPE_VOID: + return true; + case HANDLETYPE_DEPTH: + return is_heart_beat_ok(*book.cheader); + case HANDLETYPE_BBO: + return is_heart_beat_ok(*bbo.cheader); + case HANDLETYPE_SYNTHETIC: + return sane::true_for_all( + synthetic.def->legs, + [](const MDConsumerHandle &h) { return h.is_heart_beating(); }); } never; } TimeStamp MDConsumerHandle::heartbeat() const { - switch(_type) { - case HANDLETYPE_VOID: return TimeStamp::now(); - case HANDLETYPE_DEPTH: return book.cheader->heartbeat; - case HANDLETYPE_BBO: return bbo.cheader->heartbeat; - case HANDLETYPE_SYNTHETIC: return sane::min(synthetic.def->legs, [](const MDConsumerHandle& h) { return h.heartbeat(); }); + switch (_type) { + case HANDLETYPE_VOID: + return TimeStamp::now(); + case HANDLETYPE_DEPTH: + return book.cheader->heartbeat; + case HANDLETYPE_BBO: + return bbo.cheader->heartbeat; + case HANDLETYPE_SYNTHETIC: + return sane::min( + synthetic.def->legs, + [](const MDConsumerHandle &h) { return h.heartbeat(); }); } never; } -CoconutSecurityStatus MDConsumerHandle::status() const { - switch(_type) { - case HANDLETYPE_VOID: return CoconutSecurityStatus::COCONUTSECURITYSTATUS_OK; - case HANDLETYPE_DEPTH: return (CoconutSecurityStatus)book.hot->status; - case HANDLETYPE_BBO: return (CoconutSecurityStatus)bbo.hot->status; - case HANDLETYPE_SYNTHETIC: { - for (const auto& handle : synthetic.def->legs) { - auto status = handle.status(); - if (status != CoconutSecurityStatus::COCONUTSECURITYSTATUS_OK) { - return status; - } +CoconutSecurityStatus MDConsumerHandle::status() const { + switch (_type) { + case HANDLETYPE_VOID: + return CoconutSecurityStatus::COCONUTSECURITYSTATUS_OK; + case HANDLETYPE_DEPTH: + return (CoconutSecurityStatus)book.hot->status; + case HANDLETYPE_BBO: + return (CoconutSecurityStatus)bbo.hot->status; + case HANDLETYPE_SYNTHETIC: { + for (const auto &handle : synthetic.def->legs) { + auto status = handle.status(); + if (status != CoconutSecurityStatus::COCONUTSECURITYSTATUS_OK) { + return status; } } } + } never; } -std::unique_ptr> MDConsumerHandle::get_mbo() const { - if (_type == HANDLETYPE_DEPTH) { - MBOSnapshot* snapshot = book.mbo->acquire_snapshot(SecurityKey(key())); - if (snapshot != nullptr) { - return {snapshot,[mbo=book.mbo](auto* s) { mbo->release_snapshot(&s); }}; - } +std::unique_ptr> +MDConsumerHandle::get_mbo() const { + if (_type == HANDLETYPE_DEPTH) { + MBOSnapshot *snapshot = book.mbo->acquire_snapshot(SecurityKey(key())); + if (snapshot != nullptr) { + return {snapshot, [mbo = book.mbo](auto *s) { + mbo->release_snapshot(&s); + }}; } - return nullptr; } + return nullptr; +} -}}//namespace - +} // namespace md +} // namespace bts #endif diff --git a/src/lib/md/MDConsumerHandle.h b/src/lib/md/MDConsumerHandle.h index c271083fd..65306eb32 100644 --- a/src/lib/md/MDConsumerHandle.h +++ b/src/lib/md/MDConsumerHandle.h @@ -1,10 +1,10 @@ #pragma once -#include "lib/utils/bts_no_copy.h" -#include "lib/utils/bts_export.h" +#include "UserSymbol.h" #include "lib/md/Shm/MDStructure.h" #include "lib/sparkproto/SparkProtos.pb.h" -#include "UserSymbol.h" +#include "lib/utils/bts_export.h" +#include "lib/utils/bts_no_copy.h" #include "lib/utils/sane_algorithm.h" #include #include @@ -23,31 +23,25 @@ struct SyntheticStrategy { TimeStamp updated; }; -TimeStamp copy_bbo(const HotEntry& src, PriceSize& out_bid, PriceSize& out_ask); -TimeStamp copy_depth(const HotDepthEntry&, size_t count, PriceSize* bid, PriceSize* ask); -TimeStamp copy_synthetic_depth(const SyntheticStrategy&, size_t count, PriceSize* bid, PriceSize* ask); - -enum class HandleReadResult { - NO_CHANGE, - BUSY, - SUCCESS -}; +TimeStamp copy_bbo(const HotEntry &src, PriceSize &out_bid, PriceSize &out_ask); +TimeStamp +copy_depth(const HotDepthEntry &, size_t count, PriceSize *bid, PriceSize *ask); +TimeStamp copy_synthetic_depth( + const SyntheticStrategy &, size_t count, PriceSize *bid, PriceSize *ask); + +enum class HandleReadResult { NO_CHANGE, BUSY, SUCCESS }; inline void read_direct( - const HotDepthEntry& hot, - size_t count, - PriceSize* bid, PriceSize* ask) { + const HotDepthEntry &hot, size_t count, PriceSize *bid, PriceSize *ask) { - bts_assert_d(count <= COCONUT_MAX_DEPTH); - count = std::min(count, (size_t)COCONUT_MAX_DEPTH); + bts_assert_d(count <= COCONUT_MAX_DEPTH); + count = std::min(count, (size_t)COCONUT_MAX_DEPTH); for (size_t x = 0; x < count; ++x) { hot.read_direct(x, &bid[x], &ask[x]); } } inline void read_implied( - const HotDepthEntry& hot, - size_t count, - PriceSize* bid, PriceSize* ask) { + const HotDepthEntry &hot, size_t count, PriceSize *bid, PriceSize *ask) { bts_assert_d(count <= COCONUT_MAX_IMPLIED_DEPTH); count = std::min(count, (size_t)COCONUT_MAX_IMPLIED_DEPTH); @@ -56,13 +50,13 @@ inline void read_implied( } } inline void read_combined( - const HotDepthEntry& hot, - size_t count, - PriceSize* bid, PriceSize* ask) { + const HotDepthEntry &hot, size_t count, PriceSize *bid, PriceSize *ask) { bts_assert_d(count <= COCONUT_MAX_DEPTH); - size_t xda=0, xdb=0, xia=0, xib=0; - if (hot.implied[xib].bid().is_nan()) xib = COCONUT_MAX_IMPLIED_DEPTH; - if (hot.implied[xia].ask().is_nan()) xia = COCONUT_MAX_IMPLIED_DEPTH; + size_t xda = 0, xdb = 0, xia = 0, xib = 0; + if (hot.implied[xib].bid().is_nan()) + xib = COCONUT_MAX_IMPLIED_DEPTH; + if (hot.implied[xia].ask().is_nan()) + xia = COCONUT_MAX_IMPLIED_DEPTH; for (size_t x = 0; x < count; ++x) { if (xib < COCONUT_MAX_IMPLIED_DEPTH) { @@ -72,9 +66,7 @@ inline void read_combined( // Compare bids if (direct.int_price() == implied.int_price()) { bid[x] = PriceSize( - direct.int_price(), - direct.size(), - ImpliedSize(implied.size())); + direct.int_price(), direct.size(), ImpliedSize(implied.size())); xdb += 1; xib += 1; } @@ -82,13 +74,11 @@ inline void read_combined( else if (implied.int_price() < direct.int_price()) { bid[x] = direct; xdb += 1; - } - else { + } else { bid[x] = implied; xib += 1; } - } - else { + } else { bid[x] = hot.direct[xdb].bid(); xdb += 1; } @@ -100,9 +90,7 @@ inline void read_combined( // Compare asks if (direct.int_price() == implied.int_price()) { ask[x] = PriceSize( - direct.int_price(), - direct.size(), - ImpliedSize(implied.size())); + direct.int_price(), direct.size(), ImpliedSize(implied.size())); xda += 1; xia += 1; } @@ -110,13 +98,11 @@ inline void read_combined( else if (direct.int_price() < implied.int_price()) { ask[x] = direct; xda += 1; - } - else { + } else { ask[x] = implied; xia += 1; } - } - else { + } else { ask[x] = hot.direct[xda].ask(); xda += 1; } @@ -125,19 +111,17 @@ inline void read_combined( template TimeStamp optimistic_copy( - Read read, - const HotDepthEntry& hot, - size_t count, - PriceSize* bid, PriceSize* ask) -{ + Read read, const HotDepthEntry &hot, size_t count, PriceSize *bid, + PriceSize *ask) { TimeStamp t; int attempts = 0; - const int max_attempts = 1619200; + const int max_attempts = 1619200; do { t = hot.time(); read(hot, count, bid, ask); ++attempts; - } while((t != hot.time() || t == TimeStamp::invalid()) && attempts < max_attempts); + } while ((t != hot.time() || t == TimeStamp::invalid()) && + attempts < max_attempts); if (attempts >= max_attempts) { return TimeStamp::invalid(); } @@ -148,222 +132,293 @@ TimeStamp optimistic_copy( // MDConsumerHandle // -// Can be an invalid handle if you request a security which has not been discovered yet. -class BTS_EXPORT MDConsumerHandle -{ -public: +// Can be an invalid handle if you request a security which has not been +// discovered yet. +class BTS_EXPORT MDConsumerHandle { + public: MDConsumerHandle(); - explicit MDConsumerHandle(const std::shared_ptr&); + explicit MDConsumerHandle(const std::shared_ptr &); ~MDConsumerHandle(); - MDConsumerHandle(const MDConsumerHandle& other); - MDConsumerHandle(const ColdHeader&, const ColdEntry&, const void* hot, const MBOReader*); + MDConsumerHandle(const MDConsumerHandle &other); + MDConsumerHandle( + const ColdHeader &, const ColdEntry &, const void *hot, + const MBOReader *); - void init(const ColdHeader&, const ColdEntry&, const void* hot, const MBOReader*); + void init( + const ColdHeader &, const ColdEntry &, const void *hot, + const MBOReader *); bool is_initialized() const { return _type != HANDLETYPE_VOID; } bool is_synthetic() const { return _type == HANDLETYPE_SYNTHETIC; } - // bool has_depth() const { return _type == HANDLETYPE_DEPTH || _type == HANDLETYPE_SYNTHETIC; }; + // bool has_depth() const { return _type == HANDLETYPE_DEPTH || _type == + // HANDLETYPE_SYNTHETIC; }; bool is_heart_beating() const; TimeStamp heartbeat() const; CoconutSecurityStatus status() const; uint32_t sequence() const { - switch(_type) { - case HANDLETYPE_VOID: return 0; - case HANDLETYPE_DEPTH: return book.hot->sequence; - case HANDLETYPE_BBO: return bbo.hot->sequence; - case HANDLETYPE_SYNTHETIC: - bts_assert(!synthetic.def->legs.empty()); - return sane::min_by(synthetic.def->legs, [](const MDConsumerHandle& h) { return h.last_market_update(); })->sequence(); + switch (_type) { + case HANDLETYPE_VOID: + return 0; + case HANDLETYPE_DEPTH: + return book.hot->sequence; + case HANDLETYPE_BBO: + return bbo.hot->sequence; + case HANDLETYPE_SYNTHETIC: + bts_assert(!synthetic.def->legs.empty()); + return sane::min_by( + synthetic.def->legs, + [](const MDConsumerHandle &h) { + return h.last_market_update(); + }) + ->sequence(); } bts_assert(false); } - security_key key() const { - switch(_type) { - case HANDLETYPE_VOID: return invalid_security_key; - case HANDLETYPE_DEPTH: return book.hot->key; - case HANDLETYPE_BBO: return bbo.hot->key; - case HANDLETYPE_SYNTHETIC: return synthetic.def->security.id(); + security_key key() const { + switch (_type) { + case HANDLETYPE_VOID: + return invalid_security_key; + case HANDLETYPE_DEPTH: + return book.hot->key; + case HANDLETYPE_BBO: + return bbo.hot->key; + case HANDLETYPE_SYNTHETIC: + return synthetic.def->security.id(); } bts_assert(false); } UserSymbol get_usersymbol() const { - switch(_type) { - case HANDLETYPE_VOID: return UserSymbol(); - case HANDLETYPE_DEPTH: return UserSymbol(book.cdata->security.symbol(), book.cdata->security.exchange, book.cdata->security.type); - case HANDLETYPE_BBO: return UserSymbol(bbo.cdata->security.symbol(), bbo.cdata->security.exchange, bbo.cdata->security.type); - case HANDLETYPE_SYNTHETIC: return UserSymbol(synthetic.def->security.symbol(), synthetic.def->security.exchange(), securitytype_of(synthetic.def->security)); + switch (_type) { + case HANDLETYPE_VOID: + return UserSymbol(); + case HANDLETYPE_DEPTH: + return UserSymbol( + book.cdata->security.symbol(), book.cdata->security.exchange, + book.cdata->security.type); + case HANDLETYPE_BBO: + return UserSymbol( + bbo.cdata->security.symbol(), bbo.cdata->security.exchange, + bbo.cdata->security.type); + case HANDLETYPE_SYNTHETIC: + return UserSymbol( + synthetic.def->security.symbol(), + synthetic.def->security.exchange(), + securitytype_of(synthetic.def->security)); } return UserSymbol(); } - Security get_normalized_security() const { - switch(_type) { - case HANDLETYPE_VOID: bts_assert_msg(false, "Handle not initialized"); - case HANDLETYPE_DEPTH: return convert_security(book.cdata->security); - case HANDLETYPE_BBO: return convert_security(bbo.cdata->security); - case HANDLETYPE_SYNTHETIC: return synthetic.def->security; + Security get_normalized_security() const { + switch (_type) { + case HANDLETYPE_VOID: + bts_assert_msg(false, "Handle not initialized"); + case HANDLETYPE_DEPTH: + return convert_security(book.cdata->security); + case HANDLETYPE_BBO: + return convert_security(bbo.cdata->security); + case HANDLETYPE_SYNTHETIC: + return synthetic.def->security; } bts_assert(false); } double get_minimum_tick() const { - switch(_type) { - case HANDLETYPE_DEPTH: return book.cdata->security.low_tick * pow10(book.cdata->security.display_factor); - case HANDLETYPE_BBO: return bbo.cdata->security.low_tick * pow10(bbo.cdata->security.display_factor); - case HANDLETYPE_SYNTHETIC: return synthetic.def->security.contract_spec().low_tick(); + switch (_type) { + case HANDLETYPE_DEPTH: + return book.cdata->security.low_tick * + pow10(book.cdata->security.display_factor); + case HANDLETYPE_BBO: + return bbo.cdata->security.low_tick * + pow10(bbo.cdata->security.display_factor); + case HANDLETYPE_SYNTHETIC: + return synthetic.def->security.contract_spec().low_tick(); default: - case HANDLETYPE_VOID: return os::nan(); + case HANDLETYPE_VOID: + return os::nan(); } } co2::TradingStatus trading_status() const { - switch(_type) { - case HANDLETYPE_DEPTH: return book.cdata->exchange_status; - case HANDLETYPE_BBO: return bbo.cdata->exchange_status; - case HANDLETYPE_SYNTHETIC: { - // Return the status if all legs match otherwise return TRADINGSTATUS_UNKNOWN - if (synthetic.def->legs.size() > 0) { - auto status = synthetic.def->legs.front().trading_status(); - for (const auto& leg : synthetic.def->legs) { - if (leg.trading_status() != status) break; - } - return status; + switch (_type) { + case HANDLETYPE_DEPTH: + return book.cdata->exchange_status; + case HANDLETYPE_BBO: + return bbo.cdata->exchange_status; + case HANDLETYPE_SYNTHETIC: { + // Return the status if all legs match otherwise return + // TRADINGSTATUS_UNKNOWN + if (synthetic.def->legs.size() > 0) { + auto status = synthetic.def->legs.front().trading_status(); + for (const auto &leg : synthetic.def->legs) { + if (leg.trading_status() != status) + break; } - return co2::TRADINGSTATUS_UNKNOWN; + return status; } - default: - case HANDLETYPE_VOID: - return co2::TRADINGSTATUS_UNKNOWN; + return co2::TRADINGSTATUS_UNKNOWN; + } + default: + case HANDLETYPE_VOID: + return co2::TRADINGSTATUS_UNKNOWN; } } TimeStamp last_market_update() const { - switch(_type) { - case HANDLETYPE_VOID: - return TimeStamp::invalid(); - case HANDLETYPE_DEPTH: - return book.hot->time(); - case HANDLETYPE_BBO: - return bbo.hot->time(); - case HANDLETYPE_SYNTHETIC: - return std::max( - synthetic.def->updated, - sane::max(synthetic.def->legs, [](const MDConsumerHandle& h) { return h.last_market_update(); })); + switch (_type) { + case HANDLETYPE_VOID: + return TimeStamp::invalid(); + case HANDLETYPE_DEPTH: + return book.hot->time(); + case HANDLETYPE_BBO: + return bbo.hot->time(); + case HANDLETYPE_SYNTHETIC: + return std::max( + synthetic.def->updated, + sane::max( + synthetic.def->legs, [](const MDConsumerHandle &h) { + return h.last_market_update(); + })); } bts_assert(false); } - HandleReadResult get_direct_book(TimeStamp& time, uint32_t copydepth, PriceSize* bids, PriceSize* asks) const { + HandleReadResult get_direct_book( + 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, PriceSize* asks) const { + HandleReadResult get_implied_book( + 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, PriceSize* asks) const { + HandleReadResult get_book( + 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, datetime::LLDateTime& out_trade_timestamp, size_t* total_volume=nullptr,int* from_spread=nullptr) const; + + bool get_last_trade( + TimeStamp &time, PriceSize &out_trade, + datetime::LLDateTime &out_trade_timestamp, + size_t *total_volume = nullptr, int *from_spread = nullptr) const; IntPrice settlement_price() const { - switch(_type) { - case HANDLETYPE_DEPTH: return book.hot->settlement; - case HANDLETYPE_BBO: return bbo.hot->settlement; - default: + switch (_type) { + case HANDLETYPE_DEPTH: + return book.hot->settlement; + case HANDLETYPE_BBO: + return bbo.hot->settlement; + default: return INT_NAN; } } - datetime::Date settlement_date() const { return this->misc().settlement_date; } + datetime::Date settlement_date() const { + return this->misc().settlement_date; + } TimeStamp misc_timestamp() const; MiscData misc() const; - MDConsumerHandle& operator=(const MDConsumerHandle& other) { + MDConsumerHandle &operator=(const MDConsumerHandle &other) { _type = HANDLETYPE_VOID; - switch(other._type) { - case HANDLETYPE_VOID: break; - case HANDLETYPE_DEPTH: - book = other.book; - break; - case HANDLETYPE_BBO: - bbo = other.bbo; - break; - case HANDLETYPE_SYNTHETIC: - synthetic.def = other.synthetic.def; - break; + switch (other._type) { + case HANDLETYPE_VOID: + break; + case HANDLETYPE_DEPTH: + book = other.book; + break; + case HANDLETYPE_BBO: + bbo = other.bbo; + break; + case HANDLETYPE_SYNTHETIC: + synthetic.def = other.synthetic.def; + break; } std::atomic_thread_fence(std::memory_order_release); _type = other._type; return *this; } - std::unique_ptr> get_mbo() const; + std::unique_ptr> + get_mbo() const; -private: + private: template - HandleReadResult get_book(Read read, TimeStamp& time, uint32_t copydepth, PriceSize* bids, PriceSize* asks) const { + HandleReadResult get_book( + Read read, TimeStamp &time, uint32_t copydepth, PriceSize *bids, + PriceSize *asks) const { bts_assert_d(copydepth <= COCONUT_MAX_DEPTH); - if (!is_initialized() || copydepth == 0) return HandleReadResult::NO_CHANGE; - switch(_type) { - case HANDLETYPE_VOID: return HandleReadResult::NO_CHANGE; - case HANDLETYPE_DEPTH: - if (book.hot->time() > time || book.hot->time() == TimeStamp::invalid()) { - TimeStamp temp = optimistic_copy(read, *book.hot, copydepth, bids, asks); - if (temp == TimeStamp::invalid()) { return HandleReadResult::BUSY; } - time = temp; - return HandleReadResult::SUCCESS; + if (!is_initialized() || copydepth == 0) + return HandleReadResult::NO_CHANGE; + switch (_type) { + case HANDLETYPE_VOID: + return HandleReadResult::NO_CHANGE; + case HANDLETYPE_DEPTH: + if (book.hot->time() > time || + book.hot->time() == TimeStamp::invalid()) { + TimeStamp temp = + optimistic_copy(read, *book.hot, copydepth, bids, asks); + if (temp == TimeStamp::invalid()) { + return HandleReadResult::BUSY; } - return HandleReadResult::NO_CHANGE; - case HANDLETYPE_BBO: - bts_assert_msg(false,"Not impelmented"); - return HandleReadResult::NO_CHANGE; - case HANDLETYPE_SYNTHETIC: - auto t = last_market_update(); - if (t > time || t == TimeStamp::invalid()) { - TimeStamp temp = copy_synthetic_depth(*synthetic.def, std::min(copydepth, COCONUT_MAX_DEPTH), bids, asks); - if (temp == TimeStamp::invalid()) { return HandleReadResult::BUSY; } - time = temp; - return HandleReadResult::SUCCESS; + time = temp; + return HandleReadResult::SUCCESS; + } + return HandleReadResult::NO_CHANGE; + case HANDLETYPE_BBO: + bts_assert_msg(false, "Not impelmented"); + return HandleReadResult::NO_CHANGE; + case HANDLETYPE_SYNTHETIC: + auto t = last_market_update(); + if (t > time || t == TimeStamp::invalid()) { + TimeStamp temp = copy_synthetic_depth( + *synthetic.def, std::min(copydepth, COCONUT_MAX_DEPTH), bids, + asks); + if (temp == TimeStamp::invalid()) { + return HandleReadResult::BUSY; } - return HandleReadResult::NO_CHANGE; + time = temp; + return HandleReadResult::SUCCESS; + } + return HandleReadResult::NO_CHANGE; } bts_assert(false); } - - void set_hot(const void* hot) { - switch(_type) { - case HANDLETYPE_DEPTH: - book.hot = (HotDepthEntry*)hot; - break; - case HANDLETYPE_BBO: - bbo.hot = (HotEntry*)hot; - break; - default: - bts_assert(false); + + void set_hot(const void *hot) { + switch (_type) { + case HANDLETYPE_DEPTH: + book.hot = (HotDepthEntry *)hot; + break; + case HANDLETYPE_BBO: + bbo.hot = (HotEntry *)hot; + break; + default: + bts_assert(false); } } - void set_cold(const ColdHeader* header, const ColdEntry* cold) { + void set_cold(const ColdHeader *header, const ColdEntry *cold) { bts_assert(header != nullptr); bts_assert(cold != nullptr); if (header->has_depth) { book.cheader = header; book.cdata = cold; _type = HANDLETYPE_DEPTH; - } - else { + } else { bbo.cheader = header; bbo.cdata = cold; _type = HANDLETYPE_BBO; } } - void set_mbo(const MBOReader* mbo) { - switch(_type) { - case HANDLETYPE_DEPTH: - book.mbo = mbo; - break; - case HANDLETYPE_BBO: - bbo.mbo = mbo; - break; - default: - //ok + void set_mbo(const MBOReader *mbo) { + switch (_type) { + case HANDLETYPE_DEPTH: + book.mbo = mbo; + break; + case HANDLETYPE_BBO: + bbo.mbo = mbo; + break; + default: + // ok break; } } @@ -375,16 +430,16 @@ private: HANDLETYPE_SYNTHETIC }; struct DepthHandle { - const HotDepthEntry* hot; - const ColdEntry* cdata; - const ColdHeader* cheader; - const MBOReader* mbo; + const HotDepthEntry *hot; + const ColdEntry *cdata; + const ColdHeader *cheader; + const MBOReader *mbo; }; struct BBOHandle { - const HotEntry* hot; - const ColdEntry* cdata; - const ColdHeader* cheader; - const MBOReader* mbo; + const HotEntry *hot; + const ColdEntry *cdata; + const ColdHeader *cheader; + const MBOReader *mbo; }; struct SyntheticHandle { std::shared_ptr def; @@ -397,5 +452,5 @@ private: }; }; -}}//namespace - +} // namespace md +} // namespace bts diff --git a/src/lib/md/MDConsumerInterop.cpp b/src/lib/md/MDConsumerInterop.cpp index 88972112d..48e1da341 100644 --- a/src/lib/md/MDConsumerInterop.cpp +++ b/src/lib/md/MDConsumerInterop.cpp @@ -1,16 +1,16 @@ #ifdef _WIN32 -#include "common.h" -#include "UserSymbol.h" #include "MDConsumer.h" #include "SecurityCache.h" +#include "UserSymbol.h" +#include "common.h" #include "get_symbols.h" -#include "relay/RelayClient.h" +#include "lib/md/protos/co2.pb.h" #include "lib/utils/Dispatcher.h" #include "lib/utils/defer.h" -#include "lib/md/protos/co2.pb.h" +#include "relay/RelayClient.h" +#include #include #include -#include namespace bts { namespace md { @@ -21,95 +21,111 @@ namespace md { // MDConsumer struct BlitUserSymbol { - const char* symbol; + const char *symbol; api::Venue exchange; SecurityType type; }; -CAPI MDConsumer* create_md_consumer(BlitUserSymbol* usersymbols, uint32_t count, bool shared) { +CAPI MDConsumer * +create_md_consumer(BlitUserSymbol *usersymbols, uint32_t count, bool shared) { SecurityCache cache; std::set symbols; for (size_t x = 0; x < count; ++x) { - symbols.insert(UserSymbol(usersymbols[x].symbol, usersymbols[x].exchange, usersymbols[x].type)); + symbols.insert(UserSymbol( + usersymbols[x].symbol, usersymbols[x].exchange, usersymbols[x].type)); } - return new MDConsumer(cache, nullptr/*synthetics*/, nullptr /*mbo*/, &symbols, shared); + return new MDConsumer( + cache, nullptr /*synthetics*/, nullptr /*mbo*/, &symbols, shared); } -CAPI void destroy_md_consumer(MDConsumer* consumer) { +CAPI void destroy_md_consumer(MDConsumer *consumer) { if (consumer != nullptr) { delete consumer; } } -CAPI bool md_consumer_all_heartbeats_ok(MDConsumer* consumer) { +CAPI bool md_consumer_all_heartbeats_ok(MDConsumer *consumer) { if (consumer) { return consumer->all_heartbeats_ok(); } return false; } -CAPI bool md_consumer_get_handle(MDConsumer* consumer, security_key key, MDConsumerHandle& handle) { +CAPI bool md_consumer_get_handle( + MDConsumer *consumer, security_key key, MDConsumerHandle &handle) { bts_assert(consumer); bts_assert(key != invalid_security_key); handle = consumer->get_handle(key); return handle.is_initialized(); } -typedef void(*security_cb)(security_key, const char*, size_t, MDConsumerHandle& handle); +typedef void (*security_cb)( + security_key, const char *, size_t, MDConsumerHandle &handle); -CAPI size_t md_consumer_walk_security_list(MDConsumer* consumer, security_cb cb) { +CAPI size_t +md_consumer_walk_security_list(MDConsumer *consumer, security_cb cb) { bts_assert(consumer); std::string buffer; - return consumer->walk_security_list([&](const SecurityPtr& security, MDConsumerHandle handle) { - buffer.clear(); - security->SerializePartialToString(&buffer); - cb(security->id(), buffer.c_str(), buffer.size(), handle); - }); + return consumer->walk_security_list( + [&](const SecurityPtr &security, MDConsumerHandle handle) { + buffer.clear(); + security->SerializePartialToString(&buffer); + cb(security->id(), buffer.c_str(), buffer.size(), handle); + }); } - -CAPI void md_consumer_scan_securities(MDConsumer* consumer) { +CAPI void md_consumer_scan_securities(MDConsumer *consumer) { bts_assert(consumer); static std::atomic working = 0; if (working <= 0) { ++working; md::scan_securities_thread().post([=]() { - DEFER(--working);//exceptionsafe + DEFER(--working); // exceptionsafe consumer->scan_securities(); }); } } #ifdef _WIN32 -void safe_call_clr_callback(security_cb cb, security_key key, const char* buffer, size_t buffer_size, MDConsumerHandle& handle) { +void safe_call_clr_callback( + security_cb cb, security_key key, const char *buffer, size_t buffer_size, + MDConsumerHandle &handle) { // Protect against clr shutting down __try { cb(key, buffer, buffer_size, handle); - } __except (EXCEPTION_CONTINUE_EXECUTION) {} + } __except (EXCEPTION_CONTINUE_EXECUTION) { + } } -CAPI void md_consumer_set_on_security(MDConsumer* consumer, security_cb cb) { +CAPI void md_consumer_set_on_security(MDConsumer *consumer, security_cb cb) { bts_assert(consumer); - consumer->on_security([=](const SecurityPtr& security, MDConsumerHandle handle) { - std::string buffer; - security->SerializePartialToString(&buffer); - safe_call_clr_callback(cb, security->id(), buffer.c_str(), buffer.size(), handle); - }); + consumer->on_security( + [=](const SecurityPtr &security, MDConsumerHandle handle) { + std::string buffer; + security->SerializePartialToString(&buffer); + safe_call_clr_callback( + cb, security->id(), buffer.c_str(), buffer.size(), handle); + }); } #endif bool is_heart_beat_ok(const ColdHeader &header); -CAPI bool md_consumer_is_heart_beating(const ColdHeader* header) { - if (header == nullptr) return false; +CAPI bool md_consumer_is_heart_beating(const ColdHeader *header) { + if (header == nullptr) + return false; return is_heart_beat_ok(*header); } -typedef void(*raw_receive_pb)(const char*, size_t); -CAPI int md_consumer_read_trades(MDConsumer* consumer, BlitUserSymbol& symbol, int64_t& cursor, raw_receive_pb cb) { +typedef void (*raw_receive_pb)(const char *, size_t); +CAPI int md_consumer_read_trades( + MDConsumer *consumer, BlitUserSymbol &symbol, int64_t &cursor, + raw_receive_pb cb) { bts_assert(consumer); google::protobuf::Arena arena; - co2::TradeList* ptrades = google::protobuf::Arena::CreateMessage(&arena); - auto channel = consumer->get_channel(symbol.symbol, symbol.type, symbol.exchange); + co2::TradeList *ptrades = + google::protobuf::Arena::CreateMessage(&arena); + auto channel = + consumer->get_channel(symbol.symbol, symbol.type, symbol.exchange); if (channel.is_initialized()) { cursor = channel.read_trades(*ptrades->mutable_items(), cursor); std::string buffer; @@ -119,11 +135,15 @@ CAPI int md_consumer_read_trades(MDConsumer* consumer, BlitUserSymbol& symbol, i } return 0; } -CAPI int md_consumer_read_rfqs(MDConsumer* consumer, BlitUserSymbol& symbol, int64_t& cursor, raw_receive_pb cb) { +CAPI int md_consumer_read_rfqs( + MDConsumer *consumer, BlitUserSymbol &symbol, int64_t &cursor, + raw_receive_pb cb) { bts_assert(consumer); google::protobuf::Arena arena; - co2::RFQList* plist = google::protobuf::Arena::CreateMessage(&arena); - auto channel = consumer->get_channel(symbol.symbol, symbol.type, symbol.exchange); + co2::RFQList *plist = + google::protobuf::Arena::CreateMessage(&arena); + auto channel = + consumer->get_channel(symbol.symbol, symbol.type, symbol.exchange); if (channel.is_initialized()) { cursor = channel.read_rfqs(*plist->mutable_items(), cursor); std::string buffer; @@ -134,12 +154,13 @@ CAPI int md_consumer_read_rfqs(MDConsumer* consumer, BlitUserSymbol& symbol, int return 0; } -// +// // MDConsumerChannel // // Relay control -CAPI void add_relay_symbol(md::RelayControl* prelay, BlitUserSymbol& symbol, uint32_t flags) { +CAPI void add_relay_symbol( + md::RelayControl *prelay, BlitUserSymbol &symbol, uint32_t flags) { co2::SecurityChannel channel; channel.set_symbol(symbol.symbol); channel.set_exchange(symbol.exchange); @@ -148,40 +169,41 @@ CAPI void add_relay_symbol(md::RelayControl* prelay, BlitUserSymbol& symbol, uin if (channel.symbol() == "*") { std::set system_symbols; get_system_md_symbols(channel.exchange(), channel.type(), system_symbols); - for (const auto& sym : system_symbols) { + for (const auto &sym : system_symbols) { channel.set_symbol(sym.symbol()); md::add_relay_symbol(prelay, channel); } - } - else { + } else { md::add_relay_symbol(prelay, channel); } } -CAPI void set_relay_token(md::RelayControl* prelay, const char* token, size_t token_size) { - md::set_relay_token(prelay, std::string(token,token_size)); +CAPI void set_relay_token( + md::RelayControl *prelay, const char *token, size_t token_size) { + md::set_relay_token(prelay, std::string(token, token_size)); } - -typedef void(*usersymbol_cb)(BlitUserSymbol& symbol); +typedef void (*usersymbol_cb)(BlitUserSymbol &symbol); CAPI void md_consumer_get_system_md_symbols(usersymbol_cb cb) { std::set system_symbols; - get_system_md_symbols(api::VENUE_UNSET, api::SECURITYTYPE_UNSET, system_symbols); - for (auto& s : system_symbols) { - BlitUserSymbol blit_sym = { s.symbol().c_str(), s.exchange(), s.type() }; + get_system_md_symbols( + api::VENUE_UNSET, api::SECURITYTYPE_UNSET, system_symbols); + for (auto &s : system_symbols) { + BlitUserSymbol blit_sym = {s.symbol().c_str(), s.exchange(), s.type()}; cb(blit_sym); } } -typedef void(*just_action)(); +typedef void (*just_action)(); CAPI void post_on_scan_security_thread(just_action a) { md::scan_securities_thread().post(a); } -CAPI void dump_co2_memory_to_disk(MDConsumer* consumer, const char* path) { +CAPI void dump_co2_memory_to_disk(MDConsumer *consumer, const char *path) { if (consumer) { consumer->dump_shm_to(path); } } -}} //namespace +} // namespace md +} // namespace bts #endif diff --git a/src/lib/md/MDProducer.cpp b/src/lib/md/MDProducer.cpp index c6eed6a42..dac0c1f4c 100644 --- a/src/lib/md/MDProducer.cpp +++ b/src/lib/md/MDProducer.cpp @@ -1,64 +1,75 @@ #ifndef NO_CPP0X #include "MDProducer.h" -#include "lib/utils/SharedList.h" -#include "lib/utils/WaitFreeQueue.h" -#include "Shm/MDStructure.h" #include "MemorySegmentUtils.h" #include "SecurityIDRecorder.h" +#include "Shm/MDStructure.h" +#include "lib/utils/SharedList.h" +#include "lib/utils/WaitFreeQueue.h" using namespace std; namespace bts { namespace md { - // Owns shared memory for a single symbol+type class MDProducerImpl { -public: - MDProducerImpl(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), - config::get().hot_initial(), - config::get().hot_growth(), - flags & MDProducerFlags::Shared), - _cold(cold_segment_name(symbol, type, exchange, platform), - config::get().cold_initial(), - config::get().cold_growth(), - flags & MDProducerFlags::Shared), - _trades(_cold.header().trade_buffer, BTS_ARRAYSIZE(_cold.header().trade_buffer), true), - _rfqs(_cold.header().rfq_buffer, 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 - _cold.header().has_depth = enable_depth(symbol, type); - _cold.header().platform = platform; + public: + MDProducerImpl( + 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), + config::get().hot_initial(), + config::get().hot_growth(), + flags & MDProducerFlags::Shared), + _cold( + cold_segment_name(symbol, type, exchange, platform), + config::get().cold_initial(), + config::get().cold_growth(), + flags & MDProducerFlags::Shared), + _trades( + _cold.header().trade_buffer, + BTS_ARRAYSIZE(_cold.header().trade_buffer), true), + _rfqs( + _cold.header().rfq_buffer, + 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 + _cold.header().has_depth = enable_depth(symbol, type); + _cold.header().platform = platform; - // static_assert(sizeof(HotEntry) <= 32,"HotEntry should be less than 32 bytes"); - } - - MDProducerHandle add_security(const FixedSecurity& security, SecurityMapper& smapper) { - void* h_entry = nullptr; + // static_assert(sizeof(HotEntry) <= 32,"HotEntry should be less than 32 + // bytes"); + } + + MDProducerHandle + add_security(const FixedSecurity &security, SecurityMapper &smapper) { + void *h_entry = nullptr; if (has_depth()) { h_entry = new (_hot.add(sizeof(HotDepthEntry))) HotDepthEntry(); - } - else { + } else { h_entry = new (_hot.add(sizeof(HotEntry))) HotEntry(); } // Calculating the size for the variable sized entries is tricky - ColdEntry* c_entry = new (_cold.add(ColdEntry::fixed_size() + security.size)) ColdEntry(security.size); + ColdEntry *c_entry = + new (_cold.add(ColdEntry::fixed_size() + security.size)) + ColdEntry(security.size); memcpy(&c_entry->security, &security, security.size); smapper.apply(c_entry->security); - MDProducerHandle handle(_cold.header(), _hot.header(), *c_entry, h_entry, MDProducerChannel(*this)); + MDProducerHandle handle( + _cold.header(), _hot.header(), *c_entry, h_entry, + MDProducerChannel(*this)); if (security.key != invalid_security_key) { - // The only safe way to set the security key is through the set_key() function - // If the security had a key it was copied to cold by the memcpy but not the hot - // So we clear it from the cold and let set_key() set it in hot and cold and make the security public. + // The only safe way to set the security key is through the set_key() + // function If the security had a key it was copied to cold by the + // memcpy but not the hot So we clear it from the cold and let + // set_key() set it in hot and cold and make the security public. c_entry->security.key = invalid_security_key; handle.set_key(security.key); } @@ -66,35 +77,32 @@ public: return handle; } - void heartbeat() { - _cold.header().heartbeat = utils::TimeStamp::now(); - } + void heartbeat() { _cold.header().heartbeat = utils::TimeStamp::now(); } - void add_trade(const co2::TradeMessage& trade) { + void add_trade(const co2::TradeMessage &trade) { bts_assert(trade.key() != invalid_security_key); _trades.push(trade); _cold.header().trade_count++; } - void add_rfq(const co2::QuoteRequestMessage& rfq) { + void add_rfq(const co2::QuoteRequestMessage &rfq) { ColdHeader::RFQBuffer buffer = {{0}}; if (rfq.SerializePartialToArray(&buffer[0], buffer.size())) { _rfqs.push(buffer); _cold.header().rfq_count++; - } - else { - LOG(md,Warn, "Unable to store RFQ due to size limitation {}", + } else { + LOG(md, Warn, "Unable to store RFQ due to size limitation {}", rfq.DebugString()); } } - - const string& symbol() const { return _symbol; } + + const string &symbol() const { return _symbol; } SecurityType type() const { return _type; } Venue exchange() const { return _exchange; } bool has_depth() { return _cold.header().has_depth; } void gap() { _cold.header().gap_count++; } -private: + private: BTS_NO_COPY(MDProducerImpl); string _symbol; SecurityType _type; @@ -109,40 +117,34 @@ private: // MDProducer // -MDProducer::MDProducer(Platform platform, MDProducerFlags flags) : - _mutex(new std::mutex()), - _producers(), - _id_recorder(), - _platform(platform), - _flags(flags), - _smapper(flags & MDProducerFlags::SecurityMapper) -{ } +MDProducer::MDProducer(Platform platform, MDProducerFlags flags) + : _mutex(new std::mutex()), _producers(), _id_recorder(), + _platform(platform), _flags(flags), + _smapper(flags & MDProducerFlags::SecurityMapper) {} #ifndef WIN32 -MDProducer::MDProducer(Platform platform, SecurityIDRecorder recorder, MDProducerFlags flags) : - _mutex(new std::mutex()), - _producers(), - _id_recorder(std::make_unique(recorder)), - _platform(platform), - _flags(flags), - _smapper(flags & MDProducerFlags::SecurityMapper) -{ } +MDProducer::MDProducer( + Platform platform, SecurityIDRecorder recorder, MDProducerFlags flags) + : _mutex(new std::mutex()), _producers(), + _id_recorder(std::make_unique(recorder)), + _platform(platform), _flags(flags), + _smapper(flags & MDProducerFlags::SecurityMapper) {} #endif -MDProducer::MDProducer(MDProducer&& other) : - _mutex(std::move(other._mutex)), - _producers(std::move(other._producers)), - _platform(other._platform), - _flags(other._flags), - _smapper(_flags & MDProducerFlags::SecurityMapper) -{} +MDProducer::MDProducer(MDProducer &&other) + : _mutex(std::move(other._mutex)), _producers(std::move(other._producers)), + _platform(other._platform), _flags(other._flags), + _smapper(_flags & MDProducerFlags::SecurityMapper) {} MDProducer::~MDProducer() {} -MDProducerImpl& MDProducer::get_producer(const char* symbol, SecurityType type, Venue exchange) { +MDProducerImpl &MDProducer::get_producer( + const char *symbol, SecurityType type, Venue exchange) { // First search existing producers for one that matches - for (auto& impl : _producers) { - if ((impl->symbol() == symbol && impl->type() == type && impl->exchange() == exchange) || - //single channel for all synthetics - (impl->type() == api::SECURITYTYPE_SYNTHETIC && type == api::SECURITYTYPE_SYNTHETIC)) { + for (auto &impl : _producers) { + if ((impl->symbol() == symbol && impl->type() == type && + impl->exchange() == exchange) || + // single channel for all synthetics + (impl->type() == api::SECURITYTYPE_SYNTHETIC && + type == api::SECURITYTYPE_SYNTHETIC)) { return *impl; } } @@ -150,37 +152,42 @@ MDProducerImpl& MDProducer::get_producer(const char* symbol, SecurityType type, // Not found add a new one unique_ptr newp; if (type == api::SECURITYTYPE_SYNTHETIC) { - // synthetics are special. We don't want to allocate a separate section for each one so we put them all in one - newp.reset(new MDProducerImpl(SYNTHETIC_SYMBOL, api::SECURITYTYPE_SYNTHETIC, Venue::VENUE_BTS, _platform, _flags)); - } - else { + // synthetics are special. We don't want to allocate a separate section + // for each one so we put them all in one + newp.reset(new MDProducerImpl( + SYNTHETIC_SYMBOL, api::SECURITYTYPE_SYNTHETIC, Venue::VENUE_BTS, + _platform, _flags)); + } else { newp.reset(new MDProducerImpl(symbol, type, exchange, _platform, _flags)); } _producers.push_back(move(newp)); return *_producers.back(); } -MDProducerHandle MDProducer::add_security(const FixedSecurity& security) { +MDProducerHandle MDProducer::add_security(const FixedSecurity &security) { bts_assert_d(strlen(security.symbol()) > 0); bts_assert(security.size >= sizeof(FixedSecurity)); std::lock_guard lock(*_mutex); - auto& impl = get_producer(security.symbol(), security.type, security.exchange); + auto &impl = + get_producer(security.symbol(), security.type, security.exchange); auto result = impl.add_security(security, _smapper); - if (security.key != invalid_security_key) { result.set_key(security.key); } - else if(_id_recorder) { + if (security.key != invalid_security_key) { + result.set_key(security.key); + } else if (_id_recorder) { _id_recorder->ensure_key(result); } return result; } -MDProducerChannel MDProducer::get_channel(const char* symbol, SecurityType type, Venue exchange) { +MDProducerChannel +MDProducer::get_channel(const char *symbol, SecurityType type, Venue exchange) { std::lock_guard lock(*_mutex); return MDProducerChannel(get_producer(symbol, type, exchange)); } void MDProducer::heartbeat() { std::lock_guard lock(*_mutex); - for (auto& impl : _producers) { + for (auto &impl : _producers) { impl->heartbeat(); } } @@ -189,12 +196,17 @@ void MDProducer::heartbeat() { // MDProducerChannel // -MDProducerChannel::MDProducerChannel(MDProducerImpl& impl) : _me(&impl) {} -void MDProducerChannel::heartbeat() {_me->heartbeat();} -void MDProducerChannel::add_trade(const co2::TradeMessage& trade) {_me->add_trade(trade);} -void MDProducerChannel::add_rfq(const co2::QuoteRequestMessage& rfq) {_me->add_rfq(rfq);} +MDProducerChannel::MDProducerChannel(MDProducerImpl &impl) : _me(&impl) {} +void MDProducerChannel::heartbeat() { _me->heartbeat(); } +void MDProducerChannel::add_trade(const co2::TradeMessage &trade) { + _me->add_trade(trade); +} +void MDProducerChannel::add_rfq(const co2::QuoteRequestMessage &rfq) { + _me->add_rfq(rfq); +} void MDProducerChannel::gap() { _me->gap(); } -}}//namespace +} // namespace md +} // namespace bts #endif diff --git a/src/lib/md/MDProducer.h b/src/lib/md/MDProducer.h index 4b08f0589..111955ad7 100644 --- a/src/lib/md/MDProducer.h +++ b/src/lib/md/MDProducer.h @@ -1,16 +1,16 @@ #pragma once -#include "lib/utils/bts_no_copy.h" #include "lib/utils/bts_export.h" +#include "lib/utils/bts_no_copy.h" -#include "common.h" -#include "MDProducerHandle.h" #include "MDProducerChannel.h" -#include "Shm/FixedSecurity.h" +#include "MDProducerHandle.h" #include "SecurityMapper.h" -#include +#include "Shm/FixedSecurity.h" +#include "common.h" #include #include +#include namespace bts { namespace md { @@ -19,40 +19,51 @@ class MDProducerImpl; class SecurityIDRecorder; enum class MDProducerFlags { - None = 0x0, - Shared = 0x1, + None = 0x0, + Shared = 0x1, SecurityMapper = 0x2, }; -constexpr MDProducerFlags operator+(MDProducerFlags a, MDProducerFlags b) { return (MDProducerFlags)((uint32_t)a | (uint32_t)b); } -constexpr MDProducerFlags operator-(MDProducerFlags a, MDProducerFlags b) { return (MDProducerFlags)((uint32_t)a | (uint32_t)b); } -constexpr bool operator&(const MDProducerFlags a, const MDProducerFlags b) { return ((uint32_t)a & (uint32_t)b) == (uint32_t)b; } +constexpr MDProducerFlags operator+(MDProducerFlags a, MDProducerFlags b) { + return (MDProducerFlags)((uint32_t)a | (uint32_t)b); +} +constexpr MDProducerFlags operator-(MDProducerFlags a, MDProducerFlags b) { + return (MDProducerFlags)((uint32_t)a | (uint32_t)b); +} +constexpr bool operator&(const MDProducerFlags a, const MDProducerFlags b) { + return ((uint32_t)a & (uint32_t)b) == (uint32_t)b; +} -constexpr MDProducerFlags DefaultMDProducerFlags = MDProducerFlags::Shared + MDProducerFlags::SecurityMapper; +constexpr MDProducerFlags DefaultMDProducerFlags = + MDProducerFlags::Shared + MDProducerFlags::SecurityMapper; -class BTS_EXPORT MDProducer -{ -public: - MDProducer(Platform platform, MDProducerFlags flags=DefaultMDProducerFlags); - MDProducer(Platform platform, SecurityIDRecorder recorder, MDProducerFlags flags=DefaultMDProducerFlags); - MDProducer(MDProducer&& other); +class BTS_EXPORT MDProducer { + public: + MDProducer( + Platform platform, MDProducerFlags flags = DefaultMDProducerFlags); + MDProducer( + Platform platform, SecurityIDRecorder recorder, + MDProducerFlags flags = DefaultMDProducerFlags); + MDProducer(MDProducer &&other); ~MDProducer(); - // A single MDProducer owns a given symbol+type. - // Attempting to add the same Symbol+type to a second + // A single MDProducer owns a given symbol+type. + // Attempting to add the same Symbol+type to a second // producer (even in a different process) is a crash-worthy error - MDProducerHandle add_security(const FixedSecurity& security); + MDProducerHandle add_security(const FixedSecurity &security); - // A Producer Channel holds data shared between the - MDProducerChannel get_channel(const char* symbol, SecurityType type, Venue exchange); + // A Producer Channel holds data shared between the + MDProducerChannel + get_channel(const char *symbol, SecurityType type, Venue exchange); // Heartbeat all channels void heartbeat(); -private: + private: BTS_NO_COPY(MDProducer); - MDProducerImpl& get_producer(const char* symbol, SecurityType type, Venue exchange); + MDProducerImpl & + get_producer(const char *symbol, SecurityType type, Venue exchange); std::unique_ptr _mutex; std::vector> _producers; @@ -62,6 +73,5 @@ private: SecurityMapper _smapper; }; - -}}//namespace - +} // namespace md +} // namespace bts diff --git a/src/lib/md/MDProducerChannel.h b/src/lib/md/MDProducerChannel.h index cf750def4..7fe8e1fa5 100644 --- a/src/lib/md/MDProducerChannel.h +++ b/src/lib/md/MDProducerChannel.h @@ -1,7 +1,7 @@ #pragma once -#include "lib/utils/bts_export.h" #include "common.h" +#include "lib/utils/bts_export.h" namespace bts { namespace md { @@ -9,16 +9,18 @@ namespace md { class MDProducerImpl; class BTS_EXPORT MDProducerChannel { - MDProducerImpl* _me; - MDProducerChannel(): _me(nullptr) {} + MDProducerImpl *_me; + MDProducerChannel() : _me(nullptr) {} friend struct Co2TestInstrument; -public: + + public: friend class MDProducerHandle; - MDProducerChannel(MDProducerImpl& impl); + MDProducerChannel(MDProducerImpl &impl); void heartbeat(); - void add_trade(const co2::TradeMessage& trade); - void add_rfq(const co2::QuoteRequestMessage& rfq); + void add_trade(const co2::TradeMessage &trade); + void add_rfq(const co2::QuoteRequestMessage &rfq); void gap(); }; -}} +} // namespace md +} // namespace bts diff --git a/src/lib/md/MDProducerHandle.cpp b/src/lib/md/MDProducerHandle.cpp index 8ee9c09e3..e23fdb338 100644 --- a/src/lib/md/MDProducerHandle.cpp +++ b/src/lib/md/MDProducerHandle.cpp @@ -7,26 +7,19 @@ namespace md { using namespace datetime; using namespace co2; -MDProducerHandle::MDProducerHandle(ColdHeader& cheader, HotHeader& hheader, ColdEntry& centry, void* phot, MDProducerChannel channel) : - _hdata(phot), - _hheader(&hheader), - _cdata(¢ry), - _cheader(&cheader), - _channel(channel) -{ -} +MDProducerHandle::MDProducerHandle( + ColdHeader &cheader, HotHeader &hheader, ColdEntry ¢ry, void *phot, + MDProducerChannel channel) + : _hdata(phot), _hheader(&hheader), _cdata(¢ry), _cheader(&cheader), + _channel(channel) {} -MDProducerHandle::MDProducerHandle() : - _hdata(nullptr), - _hheader(nullptr), - _cdata(nullptr), - _cheader(nullptr), - _channel() -{} +MDProducerHandle::MDProducerHandle() + : _hdata(nullptr), _hheader(nullptr), _cdata(nullptr), _cheader(nullptr), + _channel() {} MDProducerHandle::~MDProducerHandle() {} -MDProducerHandle& MDProducerHandle::operator=(MDProducerHandle const& other) { +MDProducerHandle &MDProducerHandle::operator=(MDProducerHandle const &other) { _hdata = other._hdata; _hheader = other._hheader; _cdata = other._cdata; @@ -36,14 +29,15 @@ MDProducerHandle& MDProducerHandle::operator=(MDProducerHandle const& other) { } void MDProducerHandle::set_key(security_key key) { - if (cdata().security.key == key) return; + if (cdata().security.key == key) + return; bts_assert(cdata().security.key == invalid_security_key); // ! Assignment order important ! - // Once the cold data has a key the security becomes visible so the hot data *must* be able to be found or we assert + // Once the cold data has a key the security becomes visible so the hot data + // *must* be able to be found or we assert if (has_depth()) { hdepth().key = key; - } - else { + } else { hdata().key = key; } @@ -52,41 +46,40 @@ void MDProducerHandle::set_key(security_key key) { // Increment public security count cheader().security_count++; - // If this is a spread make sure the legs have valid keys + // If this is a spread make sure the legs have valid keys if (security().type == api::SECURITYTYPE_SPREAD) { - const auto& psecurity = static_cast(security()); + const auto &psecurity = + static_cast(security()); for (size_t x = 0; x < psecurity.leg_count(); ++x) { bts_assert(psecurity.legs[x].key != invalid_security_key); } } } -void MDProducerHandle::update_bbo(TimeStamp time, const PriceSize bid, const PriceSize ask, uint16_t seq) { +void MDProducerHandle::update_bbo( + TimeStamp time, const PriceSize bid, const PriceSize ask, uint16_t seq) { if (!has_depth()) { auto oldtime = hdata().time(); hdata().set_time(TimeStamp::invalid()); - bool updated = hdata().book.update(PriceLevel(bid,ask)); + bool updated = hdata().book.update(PriceLevel(bid, ask)); hdata().status = COCONUTSECURITYSTATUS_OK; if (updated) { hdata().set_time(time); hdata().sequence = seq; hheader().direct_count++; - } - else { + } else { hdata().set_time(oldtime); } - } - else { + } else { auto oldtime = hdepth().time(); hdepth().set_time(TimeStamp::invalid()); - bool updated = hdepth().write_direct(0, bid,ask); + bool updated = hdepth().write_direct(0, bid, ask); hdepth().status = COCONUTSECURITYSTATUS_OK; if (updated) { hdepth().set_time(time); hdepth().sequence = seq; hheader().direct_count++; - } - else { + } else { hdepth().set_time(oldtime); } } @@ -95,25 +88,25 @@ void MDProducerHandle::update_bbo(TimeStamp time, const PriceSize bid, const Pri void MDProducerHandle::set_status(CoconutSecurityStatus status) { if (has_depth()) { hdepth().status = status; - } - else { + } else { hdata().status = status; } } -void MDProducerHandle::add_trade(TimeStamp time, const PriceSize price, LLDateTime tradetime, - co2::AggressorSide agside, uint32_t volume, bool from_spread) { +void MDProducerHandle::add_trade( + 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()) { - cdata().last_trade.store(PriceSize { price.int_price(), price.size() + current.size() }, time); - } - else { - cdata().last_trade.store(price,time); + cdata().last_trade.store( + PriceSize{price.int_price(), price.size() + current.size()}, time); + } else { + cdata().last_trade.store(price, time); } cdata().last_trade_time = tradetime; cdata().from_spread = (from_spread ? 1 : 0); - if (volume > 0) + if (volume > 0) cdata().total_volume = volume; if (key() != invalid_security_key) { @@ -123,16 +116,19 @@ void MDProducerHandle::add_trade(TimeStamp time, const PriceSize price, LLDateTi trade.set_size(price.size()); trade.set_time(tradetime); trade.set_aggressor_side(agside); - if (volume > 0) trade.set_total_volume(volume); + if (volume > 0) + trade.set_total_volume(volume); trade.set_key(key()); _channel.add_trade(trade); } } -void MDProducerHandle::set_last_trade(TimeStamp time, const PriceSize ps, datetime::LLDateTime tradetime, uint32_t total_volume, bool from_spread) { - cdata().last_trade.store(ps,time); +void MDProducerHandle::set_last_trade( + 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); - if(total_volume > 0) + if (total_volume > 0) cdata().total_volume = total_volume; } @@ -140,7 +136,7 @@ void MDProducerHandle::set_total_volume(uint32_t total_volume) { cdata().total_volume = total_volume; } -void MDProducerHandle::add_rfq(TimeStamp, const co2::QuoteRequestMessage& rfq) { +void MDProducerHandle::add_rfq(TimeStamp, const co2::QuoteRequestMessage &rfq) { if (rfq.key() != invalid_security_key) { bts_assert(security().key == rfq.key()); _channel.add_rfq(rfq); @@ -154,21 +150,23 @@ void MDProducerHandle::update_exchange_status(TimeStamp, TradingStatus status) { } } -void MDProducerHandle::update_settlement(TimeStamp time, IntPrice price, Date date) { +void MDProducerHandle::update_settlement( + TimeStamp time, IntPrice price, Date date) { if (date > cdata().misc.settlement_date) { - cdata().misc.previous_settlement_price = has_depth() ? hdepth().settlement : hdata().settlement; + cdata().misc.previous_settlement_price = + has_depth() ? hdepth().settlement : hdata().settlement; cdata().misc.previous_settlement_date = cdata().misc.settlement_date; } if (has_depth()) { hdepth().settlement = price; - } - else { + } else { hdata().settlement = price; } cdata().misc.settlement_date = date; cdata().misc.misc_timestamp = time; } -void MDProducerHandle::update_previous_settlement(TimeStamp time, IntPrice price, Date date) { +void MDProducerHandle::update_previous_settlement( + TimeStamp time, IntPrice price, Date date) { cdata().misc.previous_settlement_price = price; cdata().misc.previous_settlement_date = date; cdata().misc.misc_timestamp = time; @@ -196,26 +194,26 @@ void MDProducerHandle::update_session_low(TimeStamp time, Price price) { cdata().misc.misc_timestamp = time; } -void MDProducerHandle::update_session_high_bid(TimeStamp, Price ) { - //cdata().misc.session_high_bid = price; - //cdata().misc_timestamp = TimeStamp::now(); +void MDProducerHandle::update_session_high_bid(TimeStamp, Price) { + // cdata().misc.session_high_bid = price; + // cdata().misc_timestamp = TimeStamp::now(); } -void MDProducerHandle::update_session_low_offer(TimeStamp, Price ) { - //cdata().misc.session_low_offer = price; - //cdata().misc_timestamp = TimeStamp::now(); +void MDProducerHandle::update_session_low_offer(TimeStamp, Price) { + // cdata().misc.session_low_offer = price; + // cdata().misc_timestamp = TimeStamp::now(); } -void MDProducerHandle::update_fixing_price(TimeStamp, Price ) { - //cdata().misc.fixing_price = price; - //cdata().misc_timestamp = TimeStamp::now(); +void MDProducerHandle::update_fixing_price(TimeStamp, Price) { + // cdata().misc.fixing_price = price; + // cdata().misc_timestamp = TimeStamp::now(); } void MDProducerHandle::mark_deleted() { TimeStamp ts = TimeStamp::now(); cdata().deleted = true; - std::array blank; - std::array iblank; + std::array blank; + std::array iblank; for (size_t x = 0; x < blank.size(); ++x) { blank[x] = NO_MARKET; if (x < COCONUT_MAX_IMPLIED_DEPTH) { @@ -226,6 +224,7 @@ void MDProducerHandle::mark_deleted() { update_implied(ts, iblank, iblank, 0); } -}}//namespace +} // namespace md +} // namespace bts #endif diff --git a/src/lib/md/MDProducerHandle.h b/src/lib/md/MDProducerHandle.h index 78466987a..02cda5c56 100644 --- a/src/lib/md/MDProducerHandle.h +++ b/src/lib/md/MDProducerHandle.h @@ -1,29 +1,33 @@ #pragma once -#include "lib/utils/bts_no_copy.h" -#include "lib/utils/bts_export.h" -#include "Shm/MDStructure.h" #include "MDProducerChannel.h" +#include "Shm/MDStructure.h" +#include "lib/utils/bts_export.h" +#include "lib/utils/bts_no_copy.h" #include "lib/utils/datetime.h" #include #include - namespace bts { - namespace co2 { struct Work; } +namespace co2 { +struct Work; +} namespace md { -class BTS_EXPORT MDProducerHandle -{ -public: - MDProducerHandle(ColdHeader&, HotHeader&, ColdEntry&, void* hot, MDProducerChannel channel); +class BTS_EXPORT MDProducerHandle { + public: + MDProducerHandle( + ColdHeader &, HotHeader &, ColdEntry &, void *hot, + MDProducerChannel channel); ~MDProducerHandle(); - MDProducerHandle& operator=(MDProducerHandle const& other); + MDProducerHandle &operator=(MDProducerHandle const &other); - const FixedSecurity& security() const { return cdata().security; } - FixedSecurity* mutable_security() { return key() == invalid_security_key ? &cdata().security : nullptr; } + const FixedSecurity &security() const { return cdata().security; } + FixedSecurity *mutable_security() { + return key() == invalid_security_key ? &cdata().security : nullptr; + } bool has_depth() const { return cheader().has_depth; } void set_key(security_key); @@ -33,13 +37,16 @@ public: return key; } - void update_bbo(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) { + void update_bbo( + 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) { if (!has_depth()) { update_bbo(time, bids[0], asks[0], seq); - } - else { - auto& book = hdepth(); + } else { + auto &book = hdepth(); book.set_time(TimeStamp::invalid()); for (size_t x = 0; x < COCONUT_MAX_DEPTH; ++x) { book.write_direct(x, bids[x], asks[x]); @@ -51,9 +58,13 @@ public: } } - void update_implied(TimeStamp time, const std::array& bids, const std::array& asks, uint32_t seq=0) { + void update_implied( + TimeStamp time, + const std::array &bids, + const std::array &asks, + uint32_t seq = 0) { if (has_depth()) { - auto& book = hdepth(); + auto &book = hdepth(); book.set_time(TimeStamp::invalid()); for (size_t x = 0; x < COCONUT_MAX_IMPLIED_DEPTH; ++x) { book.write_implied(x, bids[x], asks[x]); @@ -65,15 +76,15 @@ public: } } - void update_books(TimeStamp time, - const std::array& bid, - const std::array& ask, - const std::array& implied_bid, - const std::array& implied_ask, - uint32_t seq=0) { + void update_books( + TimeStamp time, const std::array &bid, + const std::array &ask, + const std::array &implied_bid, + const std::array &implied_ask, + uint32_t seq = 0) { if (has_depth()) { - auto& book = hdepth(); + auto &book = hdepth(); book.set_time(TimeStamp::invalid()); for (size_t x = 0; x < COCONUT_MAX_DEPTH; ++x) { if (x < COCONUT_MAX_IMPLIED_DEPTH) { @@ -92,68 +103,76 @@ public: void set_status(co2::CoconutSecurityStatus status); // hot // 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, bool from_spread=false); // cold + void add_trade( + 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); + void set_last_trade( + 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 + void add_rfq(TimeStamp time, const co2::QuoteRequestMessage &rfq); // cold void update_exchange_status(TimeStamp time, TradingStatus status); // cold // Misc fields - void update_settlement(TimeStamp time, IntPrice price, datetime::Date date); // cold - void update_previous_settlement(TimeStamp time, IntPrice price, datetime::Date date); // cold - void update_opening(TimeStamp time, Price price, datetime::Date date); // cold - void update_closing(TimeStamp time, Price price, datetime::Date date); // cold - void update_session_high(TimeStamp time, Price price); // cold - void update_session_low(TimeStamp time, Price price); // cold - void update_session_high_bid(TimeStamp time, Price price); // cold - void update_session_low_offer(TimeStamp time, Price price); // cold - void update_fixing_price(TimeStamp time, Price price); // cold + void update_settlement( + TimeStamp time, IntPrice price, datetime::Date date); // cold + void update_previous_settlement( + TimeStamp time, IntPrice price, datetime::Date date); // cold + void + update_opening(TimeStamp time, Price price, datetime::Date date); // cold + void + update_closing(TimeStamp time, Price price, datetime::Date date); // cold + void update_session_high(TimeStamp time, Price price); // cold + void update_session_low(TimeStamp time, Price price); // cold + void update_session_high_bid(TimeStamp time, Price price); // cold + void update_session_low_offer(TimeStamp time, Price price); // cold + void update_fixing_price(TimeStamp time, Price price); // cold void mark_deleted(); // cold - -private: - // Private default constructor allows friend classes to store this class in a concurrent_queue + private: + // Private default constructor allows friend classes to store this class in a + // concurrent_queue MDProducerHandle(); - friend class tbb::concurrent_queue < MDProducerHandle > ; + friend class tbb::concurrent_queue; friend struct SecurityIDRecorderState; friend struct bts::co2::Work; - HotEntry& hdata() const { + HotEntry &hdata() const { bts_assert_d(_hdata && !has_depth()); - return *static_cast(_hdata); + return *static_cast(_hdata); } - HotDepthEntry& hdepth() const { + HotDepthEntry &hdepth() const { bts_assert_d(_hdata && has_depth()); - return *static_cast(_hdata); + return *static_cast(_hdata); } - HotHeader& hheader() const { + HotHeader &hheader() const { bts_assert_d(_hheader); return *_hheader; } - ColdEntry& cdata() const { + ColdEntry &cdata() const { bts_assert_d(_cdata); return *_cdata; } - ColdHeader& cheader() const { + ColdHeader &cheader() const { bts_assert_d(_cheader); return *_cheader; } // COPY OK -- BTS_NO_COPY(MDConsumerHandle); - void* _hdata; - HotHeader* _hheader; - ColdEntry* _cdata; - ColdHeader* _cheader; + void *_hdata; + HotHeader *_hheader; + ColdEntry *_cdata; + ColdHeader *_cheader; MDProducerChannel _channel; }; -}}//namespace - +} // namespace md +} // namespace bts diff --git a/src/lib/md/MemorySegmentUtils.cpp b/src/lib/md/MemorySegmentUtils.cpp index 60b92b71e..d36a022f4 100644 --- a/src/lib/md/MemorySegmentUtils.cpp +++ b/src/lib/md/MemorySegmentUtils.cpp @@ -8,21 +8,32 @@ using namespace std; namespace bts { namespace md { -bool enable_depth(const string&, SecurityType) { +bool enable_depth(const string &, SecurityType) { return true; - // return type == api::SECURITYTYPE_FUTURE || type == api::SECURITYTYPE_SPREAD || type == api::SECURITYTYPE_SYNTHETIC; + // return type == api::SECURITYTYPE_FUTURE || type == + // api::SECURITYTYPE_SPREAD || type == api::SECURITYTYPE_SYNTHETIC; } -string segment_name(const string& symbol, SecurityType type, Venue exchange, Platform platform) { - return "bts_edge_" + config::get().shared_memory_namespace() + "_" + symbol + "_" + api::SecurityType_Name(type) + "_" + Venue_Name(exchange) + "_" + Platform_Name(platform); +string segment_name( + const string &symbol, SecurityType type, Venue exchange, + Platform platform) { + return "bts_edge_" + + config::get().shared_memory_namespace() + + "_" + symbol + "_" + api::SecurityType_Name(type) + "_" + + Venue_Name(exchange) + "_" + Platform_Name(platform); } -std::string hot_segment_name(const std::string& symbol, SecurityType type, Venue exchange, Platform platform) { +std::string hot_segment_name( + 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, Platform platform) { +std::string cold_segment_name( + const std::string &symbol, SecurityType type, Venue exchange, + Platform platform) { return segment_name(symbol, type, exchange, platform) + "_cold"; } -}}//namespace +} // namespace md +} // namespace bts #endif diff --git a/src/lib/md/MemorySegmentUtils.h b/src/lib/md/MemorySegmentUtils.h index 2d3c4acfe..eb7f1f82b 100644 --- a/src/lib/md/MemorySegmentUtils.h +++ b/src/lib/md/MemorySegmentUtils.h @@ -5,10 +5,16 @@ namespace bts { namespace md { -bool enable_depth(const std::string& symbol, SecurityType type); -std::string segment_name(const std::string& symbol, SecurityType type, Venue exchange, Platform platform); -std::string hot_segment_name(const std::string& symbol, SecurityType type, Venue exchange, Platform platform); -std::string cold_segment_name(const std::string& symbol, SecurityType type, Venue exchange, Platform platform); +bool enable_depth(const std::string &symbol, SecurityType type); +std::string segment_name( + const std::string &symbol, SecurityType type, Venue exchange, + Platform platform); +std::string hot_segment_name( + const std::string &symbol, SecurityType type, Venue exchange, + Platform platform); +std::string cold_segment_name( + const std::string &symbol, SecurityType type, Venue exchange, + Platform platform); - -}}//namespace +} // namespace md +} // namespace bts diff --git a/src/lib/md/PlatformLoader.cpp b/src/lib/md/PlatformLoader.cpp index 0de76bdcf..08f1ef4df 100644 --- a/src/lib/md/PlatformLoader.cpp +++ b/src/lib/md/PlatformLoader.cpp @@ -24,14 +24,15 @@ namespace md { PlatformLoader::PlatformLoader(const md::PlatformConfig &config) : _config(config), _platform(PLATFORM_UNSET) { - bts_assert_msg(Platform_Parse(config.platform(), &_platform), - "Invalid market data platform " + config.platform()); + bts_assert_msg( + Platform_Parse(config.platform(), &_platform), + "Invalid market data platform " + config.platform()); } PlatformLoader::~PlatformLoader() {} -void cleanup_shared_memory(const std::set &symbols, - Platform platform) { +void cleanup_shared_memory( + const std::set &symbols, Platform platform) { for (const auto &sym : symbols) { string name = hot_segment_name(sym.symbol(), sym.type(), sym.exchange(), platform); @@ -62,9 +63,9 @@ void PlatformLoader::run() { case PLATFORM_MDP3ONIXS: break; case PLATFORM_MDP3EMUMBA: - break; + break; case PLATFORM_ICEONIXS: - break; + break; default: bts_assert(false); break; @@ -88,26 +89,27 @@ void add_symbols_to_result( } } -size_t get_system_md_symbols(api::Venue exchange, SecurityType type, - std::set &result) { - bts_assert(config::system_symbols::Symbols::descriptor()->field_count() == 4); +size_t get_system_md_symbols( + api::Venue exchange, SecurityType type, std::set &result) { + bts_assert( + config::system_symbols::Symbols::descriptor()->field_count() == 4); { auto const &e = config::get().glbx(); if (exchange == api::VENUE_UNSET || exchange == api::VENUE_GLBX) { if (type == api::SECURITYTYPE_FUTURE || type == api::SECURITYTYPE_UNSET) { - add_symbols_to_result(e.future(), api::VENUE_GLBX, - api::SECURITYTYPE_FUTURE, &result); + add_symbols_to_result( + e.future(), api::VENUE_GLBX, api::SECURITYTYPE_FUTURE, &result); } if (type == api::SECURITYTYPE_OPTION || type == api::SECURITYTYPE_UNSET) { - add_symbols_to_result(e.option(), api::VENUE_GLBX, - api::SECURITYTYPE_OPTION, &result); + add_symbols_to_result( + e.option(), api::VENUE_GLBX, api::SECURITYTYPE_OPTION, &result); } if (type == api::SECURITYTYPE_SPREAD || type == api::SECURITYTYPE_UNSET) { - add_symbols_to_result(e.spread(), api::VENUE_GLBX, - api::SECURITYTYPE_SPREAD, &result); + add_symbols_to_result( + e.spread(), api::VENUE_GLBX, api::SECURITYTYPE_SPREAD, &result); } } if (exchange == api::VENUE_BTS || exchange == api::VENUE_UNSET) { @@ -116,83 +118,101 @@ size_t get_system_md_symbols(api::Venue exchange, SecurityType type, all_symbols.insert(e.option().begin(), e.option().end()); all_symbols.insert(e.spread().begin(), e.spread().end()); for (const auto &symbol : all_symbols) { - result.insert(UserSymbol(symbol, api::VENUE_BTS, - api::SECURITYTYPE_SYNTHETIC)); + result.insert(UserSymbol( + symbol, api::VENUE_BTS, api::SECURITYTYPE_SYNTHETIC)); } } } - + { auto const &e = config::get().ice(); - if (exchange == api::VENUE_UNSET || exchange == api::VENUE_ICE) - { - if (type == api::SECURITYTYPE_FUTURE || type == api::SECURITYTYPE_UNSET) - add_symbols_to_result(e.future(), api::VENUE_ICE, api::SECURITYTYPE_FUTURE, &result); - if (type == api::SECURITYTYPE_OPTION || type == api::SECURITYTYPE_UNSET) - add_symbols_to_result(e.option(), api::VENUE_ICE, api::SECURITYTYPE_OPTION, &result); - if (type == api::SECURITYTYPE_SPREAD || type == api::SECURITYTYPE_UNSET) - add_symbols_to_result(e.spread(), api::VENUE_ICE, api::SECURITYTYPE_SPREAD, &result); + if (exchange == api::VENUE_UNSET || exchange == api::VENUE_ICE) { + if (type == api::SECURITYTYPE_FUTURE || + type == api::SECURITYTYPE_UNSET) + add_symbols_to_result( + e.future(), api::VENUE_ICE, api::SECURITYTYPE_FUTURE, &result); + if (type == api::SECURITYTYPE_OPTION || + type == api::SECURITYTYPE_UNSET) + add_symbols_to_result( + e.option(), api::VENUE_ICE, api::SECURITYTYPE_OPTION, &result); + if (type == api::SECURITYTYPE_SPREAD || + type == api::SECURITYTYPE_UNSET) + add_symbols_to_result( + e.spread(), api::VENUE_ICE, api::SECURITYTYPE_SPREAD, &result); } - if (exchange == api::VENUE_BTS || exchange == api::VENUE_UNSET) - { + if (exchange == api::VENUE_BTS || exchange == api::VENUE_UNSET) { std::set all_symbols; all_symbols.insert(e.future().begin(), e.future().end()); all_symbols.insert(e.option().begin(), e.option().end()); all_symbols.insert(e.spread().begin(), e.spread().end()); - for (const auto &symbol : all_symbols) - result.insert(UserSymbol(symbol, api::VENUE_BTS, api::SECURITYTYPE_SYNTHETIC)); + for (const auto &symbol : all_symbols) + result.insert(UserSymbol( + symbol, api::VENUE_BTS, api::SECURITYTYPE_SYNTHETIC)); } } { auto const &e = config::get().sim(); - if (exchange == api::VENUE_UNSET || exchange == api::VENUE_SIM) - { - if (type == api::SECURITYTYPE_FUTURE || type == api::SECURITYTYPE_UNSET) - add_symbols_to_result(e.future(), api::VENUE_SIM, api::SECURITYTYPE_FUTURE, &result); - if (type == api::SECURITYTYPE_OPTION || type == api::SECURITYTYPE_UNSET) - add_symbols_to_result(e.option(), api::VENUE_SIM, api::SECURITYTYPE_OPTION, &result); - if (type == api::SECURITYTYPE_SPREAD || type == api::SECURITYTYPE_UNSET) - add_symbols_to_result(e.spread(), api::VENUE_SIM, api::SECURITYTYPE_SPREAD, &result); + if (exchange == api::VENUE_UNSET || exchange == api::VENUE_SIM) { + if (type == api::SECURITYTYPE_FUTURE || + type == api::SECURITYTYPE_UNSET) + add_symbols_to_result( + e.future(), api::VENUE_SIM, api::SECURITYTYPE_FUTURE, &result); + if (type == api::SECURITYTYPE_OPTION || + type == api::SECURITYTYPE_UNSET) + add_symbols_to_result( + e.option(), api::VENUE_SIM, api::SECURITYTYPE_OPTION, &result); + if (type == api::SECURITYTYPE_SPREAD || + type == api::SECURITYTYPE_UNSET) + add_symbols_to_result( + e.spread(), api::VENUE_SIM, api::SECURITYTYPE_SPREAD, &result); } - if (exchange == api::VENUE_BTS || exchange == api::VENUE_UNSET) - { + if (exchange == api::VENUE_BTS || exchange == api::VENUE_UNSET) { std::set all_symbols; all_symbols.insert(e.future().begin(), e.future().end()); all_symbols.insert(e.option().begin(), e.option().end()); all_symbols.insert(e.spread().begin(), e.spread().end()); - for (const auto &symbol : all_symbols) - result.insert(UserSymbol(symbol, api::VENUE_BTS, api::SECURITYTYPE_SYNTHETIC)); + for (const auto &symbol : all_symbols) + result.insert(UserSymbol( + symbol, api::VENUE_BTS, api::SECURITYTYPE_SYNTHETIC)); } } - + { auto const &e = config::get().simice(); - if (exchange == api::VENUE_UNSET || exchange == api::VENUE_SIMICE) - { - if (type == api::SECURITYTYPE_FUTURE || type == api::SECURITYTYPE_UNSET) - add_symbols_to_result(e.future(), api::VENUE_SIMICE, api::SECURITYTYPE_FUTURE, &result); - if (type == api::SECURITYTYPE_OPTION || type == api::SECURITYTYPE_UNSET) - add_symbols_to_result(e.option(), api::VENUE_SIMICE, api::SECURITYTYPE_OPTION, &result); - if (type == api::SECURITYTYPE_SPREAD || type == api::SECURITYTYPE_UNSET) - add_symbols_to_result(e.spread(), api::VENUE_SIMICE, api::SECURITYTYPE_SPREAD, &result); + if (exchange == api::VENUE_UNSET || exchange == api::VENUE_SIMICE) { + if (type == api::SECURITYTYPE_FUTURE || + type == api::SECURITYTYPE_UNSET) + add_symbols_to_result( + e.future(), api::VENUE_SIMICE, api::SECURITYTYPE_FUTURE, + &result); + if (type == api::SECURITYTYPE_OPTION || + type == api::SECURITYTYPE_UNSET) + add_symbols_to_result( + e.option(), api::VENUE_SIMICE, api::SECURITYTYPE_OPTION, + &result); + if (type == api::SECURITYTYPE_SPREAD || + type == api::SECURITYTYPE_UNSET) + add_symbols_to_result( + e.spread(), api::VENUE_SIMICE, api::SECURITYTYPE_SPREAD, + &result); } - if (exchange == api::VENUE_BTS || exchange == api::VENUE_UNSET) - { + if (exchange == api::VENUE_BTS || exchange == api::VENUE_UNSET) { std::set all_symbols; all_symbols.insert(e.future().begin(), e.future().end()); all_symbols.insert(e.option().begin(), e.option().end()); all_symbols.insert(e.spread().begin(), e.spread().end()); - for (const auto &symbol : all_symbols) - result.insert(UserSymbol(symbol, api::VENUE_BTS, api::SECURITYTYPE_SYNTHETIC)); + for (const auto &symbol : all_symbols) + result.insert(UserSymbol( + symbol, api::VENUE_BTS, api::SECURITYTYPE_SYNTHETIC)); } - } + } return result.size(); } -size_t get_system_md_symbols(api::Venue exchange, SecurityType type, - std::vector *result) { +size_t get_system_md_symbols( + api::Venue exchange, SecurityType type, std::vector *result) { bts_assert(result); set result_set; size_t size = get_system_md_symbols(exchange, type, result_set); @@ -201,8 +221,8 @@ size_t get_system_md_symbols(api::Venue exchange, SecurityType type, return size; } -size_t get_system_md_symbols(const md::PlatformConfig &config, - std::set &out_result) { +size_t get_system_md_symbols( + const md::PlatformConfig &config, std::set &out_result) { Venue v; bts_assert(api::Venue_Parse(config.exchange(), &v)); SecurityType st; @@ -219,15 +239,16 @@ std::set get_system_md_symbols() { extern "C" BTS_EXPORT Platform platform_for_exchange(Venue v) { const auto &pmap = config::get(); co2::Platform platform; - if (v == VENUE_SIM) + if (v == VENUE_SIM) return PLATFORM_SIM; - if (v == VENUE_ICE && co2::Platform_Parse(pmap.ice_platform(), &platform)) - return platform; - - //md2_tests.cpp depends on this fall through to yield SIM as the GLBX platform - if (co2::Platform_Parse(pmap.glbx_platform(), &platform)) - return platform; - + if (v == VENUE_ICE && co2::Platform_Parse(pmap.ice_platform(), &platform)) + return platform; + + // md2_tests.cpp depends on this fall through to yield SIM as the GLBX + // platform + if (co2::Platform_Parse(pmap.glbx_platform(), &platform)) + return platform; + return PLATFORM_UNSET; } diff --git a/src/lib/md/PlatformLoader.h b/src/lib/md/PlatformLoader.h index 181bdf1b2..6c4edf26d 100644 --- a/src/lib/md/PlatformLoader.h +++ b/src/lib/md/PlatformLoader.h @@ -1,39 +1,38 @@ #pragma once -#include "lib/utils/bts_no_copy.h" #include "UserSymbol.h" #include "common.h" #include "get_symbols.h" +#include "lib/utils/bts_no_copy.h" #include "lib/config/protos/MarketData.pb.h" +#include #include #include -#include namespace bts { namespace md { -class BTS_EXPORT PlatformLoader -{ -public: - PlatformLoader(const md::PlatformConfig&); +class BTS_EXPORT PlatformLoader { + public: + PlatformLoader(const md::PlatformConfig &); ~PlatformLoader(); - + // Does not return void run(); -private: - // Some linux assemblies don't have a proper SONAME so we preload them by path to satisfy imports - // void preload(Platform); + private: + // Some linux assemblies don't have a proper SONAME so we preload them by + // path to satisfy imports void preload(Platform); BTS_NO_COPY(PlatformLoader); - const md::PlatformConfig& _config; + const md::PlatformConfig &_config; Platform _platform; }; +BTS_EXPORT void +cleanup_shared_memory(const std::set &symbols, Platform platform); -BTS_EXPORT void cleanup_shared_memory(const std::set& symbols, Platform platform); - -}}//namespace - +} // namespace md +} // namespace bts diff --git a/src/lib/md/PriceSize.cpp b/src/lib/md/PriceSize.cpp index 42723246a..cbd732da3 100644 --- a/src/lib/md/PriceSize.cpp +++ b/src/lib/md/PriceSize.cpp @@ -5,19 +5,22 @@ namespace bts { namespace md { IntPrice INT_NAN = IntPrice(); -IntPrice INT_ZERO = { 0, -7 }; +IntPrice INT_ZERO = {0, -7}; PriceSize NO_MARKET = PriceSize(); int to_exponent(double value) { - if (value == 0 && os::is_nan(value)) return 0; + if (value == 0 && os::is_nan(value)) + return 0; char dest[64]; int len = sprintf(dest, "%.10f", value - long(value)); --len; // skip trailing null - while (dest[len] == '0') len--; + while (dest[len] == '0') + len--; if (len == 1) { return ceil(log10(value)); } return -(len - 1); } -}}//namespace +} // namespace md +} // namespace bts diff --git a/src/lib/md/PriceSize.h b/src/lib/md/PriceSize.h index 3a72de6b1..ca8c7ac82 100644 --- a/src/lib/md/PriceSize.h +++ b/src/lib/md/PriceSize.h @@ -1,20 +1,19 @@ #pragma once -#include "common.h" #include "IntPrice.h" #include "SizeTypes.h" +#include "common.h" #include "lib/os/os.h" -#include "lib/utils/warn_ctrl.h" +#include "lib/utils/Optimistic.h" #include "lib/utils/bts_array_size.h" #include "lib/utils/bts_assert.h" #include "lib/utils/bts_no_copy.h" -#include "lib/utils/Optimistic.h" - +#include "lib/utils/warn_ctrl.h" #include -#include #include +#include namespace bts { namespace md { @@ -30,36 +29,31 @@ class PriceSize { uint32_t _size; uint32_t _direct_size; -public: - PriceSize(IntPrice price, Size size) : - _price(size == 0 ? INT_NAN : price), - _size(size), - _direct_size(size) - { } - PriceSize(IntPrice price, Size direct_size, ImpliedSize implied_size) : - _price(price), - _size(direct_size + implied_size.value()), - _direct_size(direct_size) - { } + public: + PriceSize(IntPrice price, Size size) + : _price(size == 0 ? INT_NAN : price), _size(size), _direct_size(size) {} + PriceSize(IntPrice price, Size direct_size, ImpliedSize implied_size) + : _price(price), _size(direct_size + implied_size.value()), + _direct_size(direct_size) {} PriceSize() : _price(INT_NAN), _size(0), _direct_size(0) {} - PriceSize(const PriceSize& other) = default; - PriceSize& operator=(const PriceSize& other) = default; + PriceSize(const PriceSize &other) = default; + PriceSize &operator=(const PriceSize &other) = default; - bool operator==(const PriceSize& other) const { - return (_size == other._size && _direct_size == other._direct_size && int_price() == other.int_price()); + bool operator==(const PriceSize &other) const { + return ( + _size == other._size && _direct_size == other._direct_size && + int_price() == other.int_price()); } - bool operator!=(const PriceSize& other) const { - return !(*this == other); - } - PriceSize operator-(IntPrice price) const{ - PriceSize res=*this; - res._price=res._price-price; + bool operator!=(const PriceSize &other) const { return !(*this == other); } + PriceSize operator-(IntPrice price) const { + PriceSize res = *this; + res._price = res._price - price; return res; } - PriceSize get_divided_price(double divisor) const{ - PriceSize res=*this; - res._price=res._price/divisor; + PriceSize get_divided_price(double divisor) const { + PriceSize res = *this; + res._price = res._price / divisor; return res; } // @@ -76,52 +70,46 @@ public: }; extern PriceSize NO_MARKET; static_assert(sizeof(PriceSize) == 16, "PriceSize should be small"); - -template -PriceSize PriceSize_from_double(double price, Size size) { - if (size == 0 || os::is_nan(price)) return NO_MARKET; - return { IntPrice_from_double(price), size }; -} +template +PriceSize PriceSize_from_double(double price, Size size) { + if (size == 0 || os::is_nan(price)) + return NO_MARKET; + return {IntPrice_from_double(price), size}; +} typedef utils::Optimistic AtomicPriceSize; // -// PriceSize has grown to 12 bytes but because of 8 byte alignment it will pad out to 16 bytes -// This structure can store the same data in 24 bytes so it's more efficient for shared memory +// PriceSize has grown to 12 bytes but because of 8 byte alignment it will pad +// out to 16 bytes This structure can store the same data in 24 bytes so it's +// more efficient for shared memory struct PriceLevel { - PriceLevel() : - _bid(), _ask(), - _bid_size(0), _ask_size(0) {} - PriceLevel(const PriceSize& bid, const PriceSize& ask): - _bid(bid.int_price()), _ask(ask.int_price()), - _bid_size(bid.size()), _ask_size(ask.size()) - {} + PriceLevel() : _bid(), _ask(), _bid_size(0), _ask_size(0) {} + PriceLevel(const PriceSize &bid, const PriceSize &ask) + : _bid(bid.int_price()), _ask(ask.int_price()), _bid_size(bid.size()), + _ask_size(ask.size()) {} IntPrice _bid; IntPrice _ask; uint32_t _bid_size; uint32_t _ask_size; - const IntPrice& bid_price() const { return _bid; } - const IntPrice& ask_price() const { return _ask; } + const IntPrice &bid_price() const { return _bid; } + const IntPrice &ask_price() const { return _ask; } uint32_t bid_size() const { return _bid_size; } uint32_t ask_size() const { return _ask_size; } - bool operator==(const PriceLevel& other) const { - return _ask_size == other._ask_size && - _bid_size == other._bid_size && - _bid == other._bid && - _ask == other._ask; + bool operator==(const PriceLevel &other) const { + return _ask_size == other._ask_size && _bid_size == other._bid_size && + _bid == other._bid && _ask == other._ask; } - bool operator!=(const PriceLevel& other) const { - return _ask_size != other._ask_size || - _bid_size != other._bid_size || - _bid != other._bid || - _ask != other._ask; + bool operator!=(const PriceLevel &other) const { + return _ask_size != other._ask_size || _bid_size != other._bid_size || + _bid != other._bid || _ask != other._ask; } - bool update(const PriceLevel& temp) { + bool update(const PriceLevel &temp) { if (*this != temp) { *this = temp; return true; @@ -129,34 +117,28 @@ struct PriceLevel { return false; } - PriceSize bid() const { - return PriceSize(_bid, _bid_size); - } - PriceSize ask() const { - return PriceSize(_ask, _ask_size); - } + PriceSize bid() const { return PriceSize(_bid, _bid_size); } + PriceSize ask() const { return PriceSize(_ask, _ask_size); } }; static_assert(sizeof(PriceLevel) == 24, "PriceLevel should be small"); struct ImpliedPriceLevel : private PriceLevel { ImpliedPriceLevel() : PriceLevel() {} - ImpliedPriceLevel(const PriceSize& bid, const PriceSize& ask): - PriceLevel(bid,ask) {} - using PriceLevel::bid_price; + ImpliedPriceLevel(const PriceSize &bid, const PriceSize &ask) + : PriceLevel(bid, ask) {} using PriceLevel::ask_price; - using PriceLevel::bid_size; using PriceLevel::ask_size; + using PriceLevel::bid_price; + using PriceLevel::bid_size; using PriceLevel::operator==; using PriceLevel::operator!=; - bool operator=(const PriceLevel& other) { return update(other); } - PriceSize bid() const { - return PriceSize(_bid, 0, ImpliedSize(_bid_size)); - } - PriceSize ask() const { - return PriceSize(_ask, 0, ImpliedSize(_ask_size)); - } + bool operator=(const PriceLevel &other) { return update(other); } + PriceSize bid() const { return PriceSize(_bid, 0, ImpliedSize(_bid_size)); } + PriceSize ask() const { return PriceSize(_ask, 0, ImpliedSize(_ask_size)); } }; -static_assert(sizeof(ImpliedPriceLevel) == sizeof(PriceLevel), "ImpliedPriceLevel should not be bigger than PriceLevel"); - -}}//namespace +static_assert( + sizeof(ImpliedPriceLevel) == sizeof(PriceLevel), + "ImpliedPriceLevel should not be bigger than PriceLevel"); +} // namespace md +} // namespace bts diff --git a/src/lib/md/Product.cpp b/src/lib/md/Product.cpp index bca4d3c35..af64cde11 100644 --- a/src/lib/md/Product.cpp +++ b/src/lib/md/Product.cpp @@ -6,7 +6,7 @@ namespace bts { namespace api { -std::string product_to_string(const api::Product& p) { +std::string product_to_string(const api::Product &p) { std::string buffer = p.symbol(); buffer += ":"; buffer += SecurityType_Name(p.type()); @@ -14,17 +14,20 @@ std::string product_to_string(const api::Product& p) { buffer += Venue_Name(p.exchange()); return buffer; } -std::optional string_to_product(const std::string& s) { - boost::tokenizer> tok { s }; +std::optional string_to_product(const std::string &s) { + boost::tokenizer> tok{s}; std::vector parts; - for (const auto& t : tok) { + for (const auto &t : tok) { parts.push_back(t); } - if (parts.size() != 3) return std::nullopt; + if (parts.size() != 3) + return std::nullopt; SecurityType type = SecurityType::SECURITYTYPE_UNSET; - if (!SecurityType_Parse(parts[1], &type)) return std::nullopt; + if (!SecurityType_Parse(parts[1], &type)) + return std::nullopt; Venue v = Venue::VENUE_UNSET; - if (!Venue_Parse(parts[2], &v)) return std::nullopt; + if (!Venue_Parse(parts[2], &v)) + return std::nullopt; Product p; p.set_symbol(parts[0]); p.set_type(type); @@ -32,6 +35,6 @@ std::optional string_to_product(const std::string& s) { return {p}; } - -}}//ns +} // namespace api +} // namespace bts #endif \ No newline at end of file diff --git a/src/lib/md/Product.h b/src/lib/md/Product.h index a0505a210..92a22dd8d 100644 --- a/src/lib/md/Product.h +++ b/src/lib/md/Product.h @@ -6,8 +6,8 @@ namespace bts { namespace api { -std::string product_to_string(const api::Product&); -std::optional string_to_product(const std::string&); +std::string product_to_string(const api::Product &); +std::optional string_to_product(const std::string &); - -} } \ No newline at end of file +} // namespace api +} // namespace bts \ No newline at end of file diff --git a/src/lib/md/SecurityCache.cpp b/src/lib/md/SecurityCache.cpp index 3bc196d2e..60971d7ea 100644 --- a/src/lib/md/SecurityCache.cpp +++ b/src/lib/md/SecurityCache.cpp @@ -3,10 +3,10 @@ #include "lib/utils/Dispatcher.h" #include "lib/utils/LockBox.h" -#include #include -#include #include +#include +#include namespace bts { namespace md { @@ -15,28 +15,31 @@ struct SecurityCacheImpl { utils::LockBox> cache; utils::LockBox> ex_cache; tbb::concurrent_queue update_queue; - void enqueue_update_db(const SecurityPtr&); + void enqueue_update_db(const SecurityPtr &); void flush(); }; -void SecurityCacheImpl::enqueue_update_db(const SecurityPtr& security) { +void SecurityCacheImpl::enqueue_update_db(const SecurityPtr &security) { update_queue.push(security); } void SecurityCacheImpl::flush() { - #ifndef _WIN32 +#ifndef _WIN32 if (!update_queue.empty()) { std::vector work; SecurityPtr temp; - while(update_queue.try_pop(temp)) { work.push_back(temp); } + while (update_queue.try_pop(temp)) { + work.push_back(temp); + } if (!work.empty()) { if (db::insert_or_replace(work) == Result::error) { // If we fail to insert then retry later - for (auto& s : work) update_queue.push(std::move(s)); + for (auto &s : work) + update_queue.push(std::move(s)); } } } - #endif +#endif } ////////////////// @@ -44,33 +47,34 @@ void SecurityCacheImpl::flush() { SecurityCache::SecurityCache() : _me(std::make_shared()) {} SecurityCache::~SecurityCache() {} -const Security* SecurityCache::try_get_security(SecurityKey key) const { - return _me->cache.lock([key](btree::btree_map& t) { +const Security *SecurityCache::try_get_security(SecurityKey key) const { + return _me->cache.lock([key](btree::btree_map &t) { auto iter = t.find(key); if (iter != t.end()) { return iter->second.get(); } - return (const api::Security*)nullptr; + return (const api::Security *)nullptr; }); } -const Security* SecurityCache::try_get_security(ExchangeSecurityKey key) const { - return _me->ex_cache.lock([key](btree::btree_map& t) { - auto iter = t.find(key); - if (iter != t.end()) { - return iter->second.get(); - } - return (const api::Security*)nullptr; - }); +const Security *SecurityCache::try_get_security(ExchangeSecurityKey key) const { + return _me->ex_cache.lock( + [key](btree::btree_map &t) { + auto iter = t.find(key); + if (iter != t.end()) { + return iter->second.get(); + } + return (const api::Security *)nullptr; + }); } - -const Security* SecurityCache::get_security(SecurityKey key) { - const Security* result = try_get_security(key); +const Security *SecurityCache::get_security(SecurityKey key) { + const Security *result = try_get_security(key); if (result == nullptr) { // outside lock auto security = db::find_security(key); if (security) { - LOG(md,Info, "Loaded security from database: {} {}", security->symbol(), security->id()); + LOG(md, Info, "Loaded security from database: {} {}", + security->symbol(), security->id()); return add_db_security(security); } return nullptr; @@ -78,46 +82,48 @@ const Security* SecurityCache::get_security(SecurityKey key) { return result; } -std::vector SecurityCache::get_securities() { - std::vector result; +std::vector SecurityCache::get_securities() { + std::vector result; result.reserve(100000); - _me->cache.lock([&result](auto& cache) { - for (auto const&p : cache) { + _me->cache.lock([&result](auto &cache) { + for (auto const &p : cache) { result.push_back(p.second.get()); } }); return result; } -const Security* SecurityCache::add_db_security(const SecurityPtr& security) { +const Security *SecurityCache::add_db_security(const SecurityPtr &security) { bts_assert(security); if (security->has_glbx()) { - _me->ex_cache.lock([&security](auto& cache) { + _me->ex_cache.lock([&security](auto &cache) { ExchangeSecurityKey key(security->id()); cache.insert(std::make_pair(key, security)); }); } - return _me->cache.lock([&security](auto& cache) { + return _me->cache.lock([&security](auto &cache) { SecurityKey key(security->id()); auto result = cache.insert(std::make_pair(key, security)); // If result was inserted result.first->second is equal to security - // If the value was already present it must be a recently inserted 'live' security and we should use it + // If the value was already present it must be a recently inserted 'live' + // security and we should use it return result.first->second.get(); }); } -bool SecurityCache::add_live_security(const SecurityPtr& security) { +bool SecurityCache::add_live_security(const SecurityPtr &security) { bts_assert(security); if (security->has_glbx()) { - _me->ex_cache.lock([&security](auto& cache) { + _me->ex_cache.lock([&security](auto &cache) { ExchangeSecurityKey key(security->id()); cache.insert(std::make_pair(key, security)); }); } - return _me->cache.lock([&](auto& cache) { + return _me->cache.lock([&](auto &cache) { SecurityKey key(security->id()); // Insert but don't overwrite existing - auto result = cache.insert(std::make_pair(SecurityKey(security->id()), security)); + auto result = + cache.insert(std::make_pair(SecurityKey(security->id()), security)); _me->enqueue_update_db(security); return result.second; }); @@ -125,4 +131,5 @@ bool SecurityCache::add_live_security(const SecurityPtr& security) { void SecurityCache::flush_to_disk() { _me->flush(); } -}}//ns +} // namespace md +} // namespace bts diff --git a/src/lib/md/SecurityCache.h b/src/lib/md/SecurityCache.h index 520497c52..075cd6b83 100644 --- a/src/lib/md/SecurityCache.h +++ b/src/lib/md/SecurityCache.h @@ -1,10 +1,10 @@ #pragma once -#include "lib/domain_model/Security.pb.h" #include "MDConsumerHandle.h" +#include "SecurityPtr.h" +#include "lib/domain_model/Security.pb.h" #include "lib/domain_model/SecurityKey.h" #include "lib/md/ExchangeSecurityKey.h" -#include "SecurityPtr.h" #include namespace bts { @@ -16,26 +16,27 @@ struct SecurityCacheImpl; class SecurityCache { std::shared_ptr _me; -public: + public: SecurityCache(); ~SecurityCache(); - //Load security from cache with fallback to database - const Security* get_security(SecurityKey key); + // Load security from cache with fallback to database + const Security *get_security(SecurityKey key); // Load all securities from cache, no fallback to database - std::vector get_securities(); - - // Get the security if it's in the cache otherwise return nullptr. Does not query security database. - const Security* try_get_security(SecurityKey key) const; - const Security* try_get_security(ExchangeSecurityKey key) const; + std::vector get_securities(); + + // Get the security if it's in the cache otherwise return nullptr. Does not + // query security database. + const Security *try_get_security(SecurityKey key) const; + const Security *try_get_security(ExchangeSecurityKey key) const; // returns true if the cache was updated - bool add_live_security(const SecurityPtr& security); - const Security* add_db_security(const SecurityPtr& security); + bool add_live_security(const SecurityPtr &security); + const Security *add_db_security(const SecurityPtr &security); void flush_to_disk(); - }; -}}//ns +} // namespace md +} // namespace bts diff --git a/src/lib/md/SecurityDB.cpp b/src/lib/md/SecurityDB.cpp index a78bf9f23..d9179278f 100644 --- a/src/lib/md/SecurityDB.cpp +++ b/src/lib/md/SecurityDB.cpp @@ -5,15 +5,15 @@ #include #include "lib/config/config.h" -#include "lib/config/protos/system.pb.h" -#include "lib/md/Shm/FixedSecurity.h" #include "lib/config/protos/MarketData.pb.h" +#include "lib/config/protos/system.pb.h" #include "lib/domain_model/Security.h" +#include "lib/md/Shm/FixedSecurity.h" #include -#include -#include #include +#include +#include #include using std::string; @@ -27,7 +27,7 @@ namespace db { /* * Schema: * key, created_date, expiration_date -*/ + */ std::unique_ptr open_db() { // Directory location on disk @@ -36,61 +36,68 @@ std::unique_ptr open_db() { if (!boost::filesystem::exists(db_dir)) { boost::filesystem::create_directories(db_dir); } - + // Create table if it does not exist auto db = std::make_unique(db_path, OPEN_READWRITE | OPEN_CREATE); db->setBusyTimeout(9999); db->exec("PRAGMA journal_mode=WAL"); db->exec("PRAGMA syncronous=0"); - db->exec("CREATE TABLE IF NOT EXISTS securities (key INTEGER primary key, symbol TEXT NOT NULL, venue INTEGER NOT NULL, type INTEGER NOT NULL, security_blob BLOB NOT NULL, expiration INTEGER NOT NULL);"); - db->exec("CREATE TABLE IF NOT EXISTS metadata (key INTEGER PRIMARY KEY, data BLOB NOT NULL);"); + db->exec("CREATE TABLE IF NOT EXISTS securities (key INTEGER primary key, " + "symbol TEXT NOT NULL, venue INTEGER NOT NULL, type INTEGER NOT " + "NULL, security_blob BLOB NOT NULL, expiration INTEGER NOT NULL);"); + db->exec("CREATE TABLE IF NOT EXISTS metadata (key INTEGER PRIMARY KEY, " + "data BLOB NOT NULL);"); return db; } -datetime::Date sec_expiration_cut_off() -{ - boost::gregorian::date_duration max_exp_age - (config::get().max_days_after_expiration()); +datetime::Date sec_expiration_cut_off() { + boost::gregorian::date_duration max_exp_age( + config::get().max_days_after_expiration()); auto pt = (datetime::now() - max_exp_age); - return datetime::Date(pt.date().year(),pt.date().month(),pt.date().day()); + return datetime::Date(pt.date().year(), pt.date().month(), pt.date().day()); } -void apply_compatibilit_mutations(Security& security) { +void apply_compatibilit_mutations(Security &security) { // Migrate from old tick stuff if (security.has_glbx()) { if (security.has_glbx()) { if (security.contract_spec().main_fraction() == 0) { - security.mutable_contract_spec()->set_main_fraction(security.glbx().do_not_use_main_fraction()); + security.mutable_contract_spec()->set_main_fraction( + security.glbx().do_not_use_main_fraction()); } if (security.contract_spec().sub_fraction() == 0) { - security.mutable_contract_spec()->set_sub_fraction(security.glbx().do_not_use_sub_fraction()); + security.mutable_contract_spec()->set_sub_fraction( + security.glbx().do_not_use_sub_fraction()); } if (security.contract_spec().price_display_format() == 0) { - security.mutable_contract_spec()->set_price_display_format(security.glbx().do_not_use_price_display_format()); + security.mutable_contract_spec()->set_price_display_format( + security.glbx().do_not_use_price_display_format()); } } } } size_t load_securities( - std::function const&sym_filter, - const std::function& callback) { + std::function const &sym_filter, + const std::function &callback) { size_t count = 0; auto db = open_db(); // Load all existing securities and call the callback - SQLite::Statement select_stmt(*db, "select key,symbol,venue,type,security_blob from securities where expiration > :exp"); + SQLite::Statement select_stmt( + *db, "select key,symbol,venue,type,security_blob from securities where " + "expiration > :exp"); select_stmt.bind(":exp", sec_expiration_cut_off().to_short()); Security security; while (select_stmt.tryExecuteStep() == SQLITE_ROW) { security_key security_key = select_stmt.getColumn("key"); std::string symbol = select_stmt.getColumn("symbol"); - api::Venue venue = (api::Venue)(int) select_stmt.getColumn("venue"); - auto type = (api::SecurityType)(int) select_stmt.getColumn("type"); + api::Venue venue = (api::Venue)(int)select_stmt.getColumn("venue"); + auto type = (api::SecurityType)(int)select_stmt.getColumn("type"); UserSymbol us(symbol, venue, type); if (sym_filter(us)) { auto blob = select_stmt.getColumn("security_blob"); @@ -99,9 +106,9 @@ size_t load_securities( bts_assert(security_key == security.id()); count++; callback(security); - } - else { - LOG(md, Warn, "Failed to parse security from database. id = {}", security_key); + } else { + LOG(md, Warn, "Failed to parse security from database. id = {}", + security_key); } } } @@ -110,40 +117,45 @@ size_t load_securities( } size_t load_securities( - const std::set& symbols, - const std::function& callback) { - return load_securities([&symbols] (UserSymbol const&symbol) { - return symbols.find(symbol) != symbols.end(); - },callback); + const std::set &symbols, + const std::function &callback) { + return load_securities( + [&symbols](UserSymbol const &symbol) { + return symbols.find(symbol) != symbols.end(); + }, + callback); } SecurityPtr find_security(SecurityKey key) { try { auto db = open_db(); - SQLite::Statement select(*db, "select security_blob from securities where key = :key"); + SQLite::Statement select( + *db, "select security_blob from securities where key = :key"); select.bind(":key", key.value()); - if(select.tryExecuteStep() == SQLITE_ROW) { + if (select.tryExecuteStep() == SQLITE_ROW) { auto result = std::make_shared(); auto blob = select.getColumn(0); - if(result->ParseFromArray(blob, blob.getBytes())) { + if (result->ParseFromArray(blob, blob.getBytes())) { apply_compatibilit_mutations(*result); return result; } } - } - catch(const SQLite::Exception& e) { - LOG(md,Error, "Error reading security database. {}", std::string(e.what())); + } catch (const SQLite::Exception &e) { + LOG(md, Error, "Error reading security database. {}", + std::string(e.what())); } return nullptr; } -Result insert_or_replace(const std::vector& securities) { +Result insert_or_replace(const std::vector &securities) { try { auto db = open_db(); - SQLite::Statement insert(*db,"insert or replace into securities (key, symbol, venue, type, security_blob, expiration) values (?,?,?,?,?,?)"); + SQLite::Statement insert( + *db, "insert or replace into securities (key, symbol, venue, type, " + "security_blob, expiration) values (?,?,?,?,?,?)"); SQLite::Transaction transaction(*db); std::string buffer; - for (const auto& psecurity : securities) { + for (const auto &psecurity : securities) { if (psecurity && psecurity->SerializeToString(&buffer)) { insert.bind(1, psecurity->id()); insert.bind(2, psecurity->symbol()); @@ -152,48 +164,48 @@ Result insert_or_replace(const std::vector& securities) { insert.bind(5, buffer); auto greg_date = securities::expiration(*psecurity); if (greg_date == boost::gregorian::date()) { - insert.bind(6, datetime::Date(9999,1,1).to_short()); + insert.bind(6, datetime::Date(9999, 1, 1).to_short()); } else { ushort year = greg_date.year(); ushort month = greg_date.month(); ushort day = greg_date.day(); - insert.bind(6, datetime::Date(year,month,day).to_short()); + insert.bind(6, datetime::Date(year, month, day).to_short()); } insert.exec(); insert.reset(); } } transaction.commit(); - } - catch(const SQLite::Exception& e) { - LOG(md,Warn, "Error writing to security db (retry pending): {}", std::string(e.what())); + } catch (const SQLite::Exception &e) { + LOG(md, Warn, "Error writing to security db (retry pending): {}", + std::string(e.what())); return Result::error; } return Result::ok; } - std::vector load_metadata() { std::vector values; auto db = open_db(); SQLite::Statement select(*db, "select key,data from metadata"); - while(select.tryExecuteStep() == SQLITE_ROW) { + while (select.tryExecuteStep() == SQLITE_ROW) { uint32_t key = select.getColumn(0); auto blob = select.getColumn(1); api::synthetic::Metadata meta; if (meta.ParseFromArray(blob, blob.getBytes())) { bts_assert(key == meta.security_key()); values.push_back(meta); - } - else { - LOG(md, Warn, "Failed to parse security metadata for security_key={}", key); + } else { + LOG(md, Warn, "Failed to parse security metadata for security_key={}", + key); } } return values; } -bool store_metadata(const api::synthetic::Metadata& data) { +bool store_metadata(const api::synthetic::Metadata &data) { auto db = open_db(); - SQLite::Statement insert(*db, "insert or replace into metadata (key, data) values (?,?)"); + SQLite::Statement insert( + *db, "insert or replace into metadata (key, data) values (?,?)"); insert.bind(1, data.security_key()); std::string buffer = data.SerializeAsString(); @@ -212,13 +224,16 @@ namespace md { namespace db { size_t load_securities( - const std::set& symbols, - const std::function& callback) { - return 0; + const std::set &symbols, + const std::function &callback) { + return 0; +} +Result insert_or_replace(const std::vector &handles) { + return Result::error; } -Result insert_or_replace(const std::vector& handles) { return Result::error; } SecurityPtr find_security(SecurityKey) { return nullptr; } #endif - -}}}//namespace +} +} +} // namespace diff --git a/src/lib/md/SecurityDB.h b/src/lib/md/SecurityDB.h index 758c54bc8..59ceafd3b 100644 --- a/src/lib/md/SecurityDB.h +++ b/src/lib/md/SecurityDB.h @@ -1,44 +1,48 @@ #pragma once -#include "lib/domain_model/common.h" -#include "lib/domain_model/Security.pb.h" -#include "lib/utils/datetime.h" -#include "lib/utils/ResultEnum.h" -#include "lib/md/MDProducerHandle.h" -#include "lib/api/services/SyntheticSecurityService.pb.h" -#include "common.h" -#include "UserSymbol.h" -#include "lib/domain_model/SecurityKey.h" #include "SecurityPtr.h" +#include "UserSymbol.h" +#include "common.h" +#include "lib/api/services/SyntheticSecurityService.pb.h" +#include "lib/domain_model/Security.pb.h" +#include "lib/domain_model/SecurityKey.h" +#include "lib/domain_model/common.h" +#include "lib/md/MDProducerHandle.h" +#include "lib/utils/ResultEnum.h" +#include "lib/utils/datetime.h" +#include #include #include -#include namespace bts { -namespace api {class Security;} +namespace api { +class Security; +} namespace md { namespace db { struct SecurityDB; -// Loads securities matching the given filter for producers to pre-populate security lists -// note: possible to use this to optimize initial memory layout? sort by expiration? +// Loads securities matching the given filter for producers to pre-populate +// security lists note: possible to use this to optimize initial memory layout? +// sort by expiration? size_t load_securities( - const std::set& symbols, - const std::function& callback); + const std::set &symbols, + const std::function &callback); size_t load_securities( - std::function const&sym_filter, - const std::function& callback) ; + std::function const &sym_filter, + const std::function &callback); SecurityPtr find_security(SecurityKey); -Result insert_or_replace(const std::vector&); +Result insert_or_replace(const std::vector &); // metadata std::vector load_metadata(); -bool store_metadata(const api::synthetic::Metadata&); +bool store_metadata(const api::synthetic::Metadata &); - -}}}//namespace +} // namespace db +} // namespace md +} // namespace bts diff --git a/src/lib/md/SecurityIDRecorder.cpp b/src/lib/md/SecurityIDRecorder.cpp index afeea6f3b..106bfaee9 100644 --- a/src/lib/md/SecurityIDRecorder.cpp +++ b/src/lib/md/SecurityIDRecorder.cpp @@ -1,18 +1,17 @@ #ifndef WIN32 #include "SecurityIDRecorder.h" - #include "lib/config/config.h" -#include "lib/utils/Sqlite_utils.h" #include "lib/logging/logging.h" +#include "lib/utils/Sqlite_utils.h" #include #include #include "lib/config/protos/MarketData.pb.h" #include "lib/config/protos/system.pb.h" -#include #include +#include using namespace std; using namespace bts::utils; @@ -21,7 +20,7 @@ using std::size_t; namespace bts { namespace md { -uint64_t exchange_id(const api::Security& security); +uint64_t exchange_id(const api::Security &security); struct SecurityIDEntry { api::Security security; @@ -29,15 +28,9 @@ struct SecurityIDEntry { }; struct SecurityIDRecorderState { - SecurityIDRecorderState(SecurityIDRecorderParams& p) : - work(), - pending_handle(), - thread_id(), - db(nullptr, sqlite3_close), - timer(), - lookup_key(p.lookup_key), - unresolved_legs() - {} + SecurityIDRecorderState(SecurityIDRecorderParams &p) + : work(), pending_handle(), thread_id(), db(nullptr, sqlite3_close), + timer(), lookup_key(p.lookup_key), unresolved_legs() {} tbb::concurrent_queue> work; tbb::concurrent_queue pending_handle; @@ -46,14 +39,13 @@ struct SecurityIDRecorderState { unique_ptr timer; KeyLookupOption lookup_key; - std::map> unresolved_legs; + std::map> unresolved_legs; // Oh no, I got methods in my state - void run(utils::Dispatcher& dispatcher) { + void run(utils::Dispatcher &dispatcher) { timer = std::make_unique( - dispatcher, 200, - [=]() { do_work(); }); + dispatcher, 200, [=]() { do_work(); }); timer->start(); } void do_work() { @@ -67,15 +59,16 @@ struct SecurityIDRecorderState { void work_db(); void check_access() { bts_assert(thread_id == std::this_thread::get_id()); } - void assign_key(const api::Security& security, const SecurityIDRecorder::Callback& key_assigned); - void add_unresolved_spread(MDProducerHandle& handle); - security_key search(const std::string& descriptor); - security_key insert(const std::string& descriptor, SecurityType); + void assign_key( + const api::Security &security, + const SecurityIDRecorder::Callback &key_assigned); + void add_unresolved_spread(MDProducerHandle &handle); + security_key search(const std::string &descriptor); + security_key insert(const std::string &descriptor, SecurityType); }; -SecurityIDRecorder::SecurityIDRecorder(SecurityIDRecorderParams params): - _self(new SecurityIDRecorderState(params)) -{ +SecurityIDRecorder::SecurityIDRecorder(SecurityIDRecorderParams params) + : _self(new SecurityIDRecorderState(params)) { if (params.db) { _self->db = std::move(params.db); } @@ -85,7 +78,7 @@ SecurityIDRecorder::SecurityIDRecorder(SecurityIDRecorderParams params): } } -SecurityIDRecorder::~SecurityIDRecorder() { } +SecurityIDRecorder::~SecurityIDRecorder() {} void SecurityIDRecorder::init() { string db_dir = config::get().data_path() + "databases/md/"; @@ -104,18 +97,24 @@ void SecurityIDRecorder::init() { sqlite3_busy_timeout(_self->db.get(), 9999); sqlite::exec_nofail(_self->db, "PRAGMA journal_mode=WAL"); sqlite::exec_nofail(_self->db, "PRAGMA syncronous=0"); - sqlite::exec_nofail(_self->db, "CREATE TABLE IF NOT EXISTS security_keys (descriptor STRING NOT NULL PRIMARY KEY, type int);"); + sqlite::exec_nofail( + _self->db, "CREATE TABLE IF NOT EXISTS security_keys (descriptor STRING " + "NOT NULL PRIMARY KEY, type int);"); } void SecurityIDRecorder::ensure_key(MDProducerHandle handle) { _self->pending_handle.push(handle); } -void SecurityIDRecorder::assign_key(const api::Security& security, const SecurityIDRecorder::Callback& callback) { +void SecurityIDRecorder::assign_key( + const api::Security &security, + const SecurityIDRecorder::Callback &callback) { if (security.Contract_case() == Security::ContractCase::kSpread) { - for(const auto& leg : security.spread().legs()) { + for (const auto &leg : security.spread().legs()) { if (leg.security().id() == invalid_security_key) { - LOG(md,Error, "Security {} has legs which will never be resolved.", security.has_glbx() ? security.glbx().security_desc() : security.symbol()); + LOG(md, Error, "Security {} has legs which will never be resolved.", + security.has_glbx() ? security.glbx().security_desc() + : security.symbol()); // No point in trying to add this to the queue return; } @@ -124,7 +123,9 @@ void SecurityIDRecorder::assign_key(const api::Security& security, const Securit _self->assign_key(security, callback); } -void SecurityIDRecorderState::assign_key(const api::Security& security, const SecurityIDRecorder::Callback& callback) { +void SecurityIDRecorderState::assign_key( + const api::Security &security, + const SecurityIDRecorder::Callback &callback) { if (security.id() == invalid_security_key) { auto work = std::make_shared(); work->security = security; @@ -133,53 +134,56 @@ void SecurityIDRecorderState::assign_key(const api::Security& security, const Se } } -void SecurityIDRecorder::do_work() { - _self->do_work(); -} +void SecurityIDRecorder::do_work() { _self->do_work(); } -void SecurityIDRecorderState::add_unresolved_spread(MDProducerHandle& handle) { +void SecurityIDRecorderState::add_unresolved_spread(MDProducerHandle &handle) { bts_assert_d(lookup_key); - FixedSpreadSecurityXL* pspread = static_cast(handle.mutable_security()); + FixedSpreadSecurityXL *pspread = + static_cast(handle.mutable_security()); if (pspread != nullptr) { - for (size_t x=0; x < pspread->leg_count(); ++x) { - auto& leg = pspread->legs[x]; + for (size_t x = 0; x < pspread->leg_count(); ++x) { + auto &leg = pspread->legs[x]; bts_assert_d(leg.exchange_key.value() != 0); if (leg.key == invalid_security_key) { - // Because leg is a reference to shared memory we know it will not move - for (const auto* existing : unresolved_legs[leg.exchange_key]) { - if (existing == &leg) goto next; + // Because leg is a reference to shared memory we know it will not + // move + for (const auto *existing : unresolved_legs[leg.exchange_key]) { + if (existing == &leg) + goto next; } unresolved_legs[leg.exchange_key].push_back(&leg); } - next:; + next:; } } } void SecurityIDRecorderState::work_spreads() { check_access(); - if (!lookup_key) return; - KeyLookup& lookup = *lookup_key; + if (!lookup_key) + return; + KeyLookup &lookup = *lookup_key; int count = 0; - for (auto iter = unresolved_legs.begin(); count < 500 && iter != unresolved_legs.end();) { - const auto& pair = *iter; + for (auto iter = unresolved_legs.begin(); + count < 500 && iter != unresolved_legs.end();) { + const auto &pair = *iter; ++count; SecurityKey key = lookup(pair.first); if (key.value() != invalid_security_key) { - for (FixedSpreadLeg* leg : pair.second) { + for (FixedSpreadLeg *leg : pair.second) { leg->key = key.value(); } iter = unresolved_legs.erase(iter); - } - else { + } else { ++iter; } } } -bool has_all_leg_keys(const MDProducerHandle& handle) { +bool has_all_leg_keys(const MDProducerHandle &handle) { if (handle.security().type == SecurityType::SECURITYTYPE_SPREAD) { - const FixedSpreadSecurityXL* pspread = static_cast(&handle.security()); + const FixedSpreadSecurityXL *pspread = + static_cast(&handle.security()); for (size_t x = 0; x < pspread->leg_count(); ++x) { if (pspread->legs[x].key == invalid_security_key) { return false; @@ -200,20 +204,19 @@ void SecurityIDRecorderState::work_handles() { security.Clear(); // if a spread does not have all of its legs we need to wait if (!has_all_leg_keys(handle)) { - // add + // add add_unresolved_spread(handle); retry.push_back(handle); - } - else { + } else { convert_security(handle.security(), &security); ++count; - assign_key(security, [handle](const api::Security& security) mutable { + assign_key(security, [handle](const api::Security &security) mutable { handle.set_key(security.id()); }); } } - for(const auto& h : retry) { + for (const auto &h : retry) { pending_handle.push(h); } } @@ -224,53 +227,55 @@ void SecurityIDRecorderState::work_db() { // Query the database for each security. If it has an ID set it // If it does not have an ID add it to a list // Then persist that list - // Once a security has a key it is public so record it in the security database + // Once a security has a key it is public so record it in the security + // database std::shared_ptr temp; vector> new_entries; - // SPARK-1446 Need to try to add existing securities to the db in case we deleted them by hand + // SPARK-1446 Need to try to add existing securities to the db in case we + // deleted them by hand vector> existing_securities; vector> defer; vector new_descriptors; size_t count = 0; string descriptor; while (work.try_pop(temp)) { - descriptor = security_descriptor(temp->security); + descriptor = security_descriptor(temp->security); - // If we're unable to create a descriptor try again later - if (descriptor == "") { - defer.push_back(move(temp)); - continue; - } + // If we're unable to create a descriptor try again later + if (descriptor == "") { + defer.push_back(move(temp)); + continue; + } - security_key key = search(descriptor); - if (key != invalid_security_key) { - temp->security.set_id(key); - temp->callback(temp->security); - existing_securities.push_back(move(temp)); - } - else { - // always push in parallel - new_entries.push_back(move(temp)); - new_descriptors.push_back(descriptor); - ++count; - // Limit the amount of time we spend writing to sqlite during startup to avoid blocking the heartbeat - if (count > 200) { - break; - } + security_key key = search(descriptor); + if (key != invalid_security_key) { + temp->security.set_id(key); + temp->callback(temp->security); + existing_securities.push_back(move(temp)); + } else { + // always push in parallel + new_entries.push_back(move(temp)); + new_descriptors.push_back(descriptor); + ++count; + // Limit the amount of time we spend writing to sqlite during startup + // to avoid blocking the heartbeat + if (count > 200) { + break; } + } } - for (auto& d : defer) { + for (auto &d : defer) { work.push(move(d)); } - if (!new_entries.empty()) { sqlite::exec_nofail(db.get(), "BEGIN TRANSACTION"); for (size_t x = 0; x < new_entries.size(); ++x) { - Security& security = new_entries[x]->security; - security_key key = insert(new_descriptors[x], securitytype_of(security)); + Security &security = new_entries[x]->security; + security_key key = + insert(new_descriptors[x], securitytype_of(security)); bts_assert_d(key); security.set_id(key); } @@ -280,24 +285,30 @@ void SecurityIDRecorderState::work_db() { if (!new_entries.empty()) { for (size_t x = 0; x < new_entries.size(); ++x) { - Security& security = new_entries[x]->security; + Security &security = new_entries[x]->security; new_entries[x]->callback(security); } } } -void SecurityIDRecorder::bulk_insert(const std::vector& data, const char* prefix) { - if (data.size() == 0) return; +void SecurityIDRecorder::bulk_insert( + const std::vector &data, const char *prefix) { + if (data.size() == 0) + return; sqlite::exec_nofail(_self->db.get(), "BEGIN TRANSACTION"); std::string descriptor; { - auto insert_stmt = sqlite::prepare_query(_self->db, "INSERT INTO security_keys (rowid, descriptor, type) values (?, ?, ?)"); - for (const api::Security* sec : data) { + auto insert_stmt = sqlite::prepare_query( + _self->db, "INSERT INTO security_keys (rowid, descriptor, type) " + "values (?, ?, ?)"); + for (const api::Security *sec : data) { descriptor = prefix + security_descriptor(*sec); auto type = securitytype_of(*sec); sqlite3_bind_int(insert_stmt.get(), 1, sec->id()); - sqlite3_bind_text(insert_stmt.get(), 2, descriptor.c_str(), descriptor.size(), SQLITE_STATIC); + sqlite3_bind_text( + insert_stmt.get(), 2, descriptor.c_str(), descriptor.size(), + SQLITE_STATIC); sqlite3_bind_int(insert_stmt.get(), 3, (int)type); sqlite3_step(insert_stmt.get()); sqlite3_reset(insert_stmt.get()); @@ -306,9 +317,12 @@ void SecurityIDRecorder::bulk_insert(const std::vector& da sqlite::exec_nofail(_self->db.get(), "COMMIT TRANSACTION"); } -security_key SecurityIDRecorderState::search(const std::string& descriptor) { - auto select_stmt = sqlite::prepare_query(db, "SELECT rowid from security_keys where descriptor=? LIMIT 1;"); - sqlite3_bind_text(select_stmt.get(), 1, descriptor.c_str(), descriptor.size(), SQLITE_STATIC); +security_key SecurityIDRecorderState::search(const std::string &descriptor) { + auto select_stmt = sqlite::prepare_query( + db, "SELECT rowid from security_keys where descriptor=? LIMIT 1;"); + sqlite3_bind_text( + select_stmt.get(), 1, descriptor.c_str(), descriptor.size(), + SQLITE_STATIC); int result = sqlite3_step(select_stmt.get()); if (result == SQLITE_DONE || result == SQLITE_ROW) { return sqlite3_column_int(select_stmt.get(), 0); @@ -316,9 +330,13 @@ security_key SecurityIDRecorderState::search(const std::string& descriptor) { return invalid_security_key; } -security_key SecurityIDRecorderState::insert(const std::string& descriptor, SecurityType type) { - auto insert_stmt = sqlite::prepare_query(db, "INSERT INTO security_keys (descriptor, type) values (?, ?)"); - sqlite3_bind_text(insert_stmt.get(), 1, descriptor.c_str(), descriptor.size(), SQLITE_STATIC); +security_key SecurityIDRecorderState::insert( + const std::string &descriptor, SecurityType type) { + auto insert_stmt = sqlite::prepare_query( + db, "INSERT INTO security_keys (descriptor, type) values (?, ?)"); + sqlite3_bind_text( + insert_stmt.get(), 1, descriptor.c_str(), descriptor.size(), + SQLITE_STATIC); sqlite3_bind_int(insert_stmt.get(), 2, (int)type); int result = sqlite3_step(insert_stmt.get()); if (result == SQLITE_DONE || result == SQLITE_ROW) { @@ -327,11 +345,13 @@ security_key SecurityIDRecorderState::insert(const std::string& descriptor, Secu // Just in case our insert failed due to duplicate row auto key = search(descriptor); if (key == invalid_security_key) { - LOG(md,Error,"Failed to assign security key. SQLite return code: {}",result); + LOG(md, Error, "Failed to assign security key. SQLite return code: {}", + result); } return key; } -}}//namespace +} // namespace md +} // namespace bts #endif diff --git a/src/lib/md/SecurityIDRecorder.h b/src/lib/md/SecurityIDRecorder.h index 19895d84c..6ac662157 100644 --- a/src/lib/md/SecurityIDRecorder.h +++ b/src/lib/md/SecurityIDRecorder.h @@ -1,14 +1,14 @@ #pragma once #ifndef WIN32 -#include "common.h" #include "MDProducerHandle.h" +#include "common.h" #include "lib/utils/Sqlite_utils.h" +#include #include #include -#include -#include #include +#include typedef struct sqlite3 sqlite3; @@ -16,55 +16,63 @@ namespace bts { namespace md { /* -* Manages security to unique 32 bit id mapping across multiple processes -* Provides a callback when ids are safely persisted. -*/ + * Manages security to unique 32 bit id mapping across multiple processes + * Provides a callback when ids are safely persisted. + */ typedef const std::function KeyLookup; typedef std::optional KeyLookupOption; struct SecurityIDRecorderParams { - SecurityIDRecorderParams() : dispatcher(), db(sqlite::null_db()), lookup_key() {} - SecurityIDRecorderParams(utils::Dispatcher& d): dispatcher(&d), db(sqlite::null_db()), lookup_key() {} - SecurityIDRecorderParams(utils::Dispatcher& d, KeyLookup& get_key): dispatcher(&d), db(sqlite::null_db()), lookup_key(get_key) {} - SecurityIDRecorderParams(sqlite3_ptr& db): dispatcher(), db(std::move(db)), lookup_key() {} - SecurityIDRecorderParams(sqlite3_ptr& db, KeyLookup& get_key): dispatcher(), db(std::move(db)), lookup_key(get_key) {} - utils::Dispatcher* dispatcher; + SecurityIDRecorderParams() + : dispatcher(), db(sqlite::null_db()), lookup_key() {} + SecurityIDRecorderParams(utils::Dispatcher &d) + : dispatcher(&d), db(sqlite::null_db()), lookup_key() {} + SecurityIDRecorderParams(utils::Dispatcher &d, KeyLookup &get_key) + : dispatcher(&d), db(sqlite::null_db()), lookup_key(get_key) {} + SecurityIDRecorderParams(sqlite3_ptr &db) + : dispatcher(), db(std::move(db)), lookup_key() {} + SecurityIDRecorderParams(sqlite3_ptr &db, KeyLookup &get_key) + : dispatcher(), db(std::move(db)), lookup_key(get_key) {} + utils::Dispatcher *dispatcher; sqlite3_ptr db; KeyLookupOption lookup_key; }; struct SecurityIDRecorderState; -class SecurityIDRecorder -{ -public: +class SecurityIDRecorder { + public: SecurityIDRecorder(SecurityIDRecorderParams); ~SecurityIDRecorder(); - typedef std::function Callback; + typedef std::function Callback; // Fast - for use by market data producers void ensure_key(MDProducerHandle handle); // Slow (copies security) - for use by services - void assign_key(const api::Security& security, const Callback& key_assigned); + void assign_key(const api::Security &security, const Callback &key_assigned); - // If a dispatcher is not provided you must call work periodically to do lookups and flush the reserved ids to disk. + // If a dispatcher is not provided you must call work periodically to do + // lookups and flush the reserved ids to disk. void do_work(); - void bulk_insert(const std::vector&, const char* prefix); + void + bulk_insert(const std::vector &, const char *prefix); -private: + private: std::shared_ptr _self; void init(); }; -}}//namespace +} // namespace md +} // namespace bts #else #include "MDProducerHandle.h" namespace bts { namespace md { - class SecurityIDRecorder { - public: - void ensure_key(MDProducerHandle){}; - }; -}} +class SecurityIDRecorder { + public: + void ensure_key(MDProducerHandle){}; +}; +} // namespace md +} // namespace bts #endif diff --git a/src/lib/md/SecurityIndex.h b/src/lib/md/SecurityIndex.h index 1caea89c2..231ff8c85 100644 --- a/src/lib/md/SecurityIndex.h +++ b/src/lib/md/SecurityIndex.h @@ -1,32 +1,27 @@ #pragma once -#include "lib/utils/bts_no_copy.h" -#include "lib/logging/logging.h" #include "MDProducerHandle.h" #include "common.h" +#include "lib/logging/logging.h" +#include "lib/utils/bts_no_copy.h" +#include #include #include #include -#include #include -#include +#include namespace bts { namespace md { - /* * Maps the exchange ID to the MDProducerHandle and associated data. * Allows fast mapping of exchange id => SecurityData template type */ -template -class SimpleSecurityIndex -{ -public: - SimpleSecurityIndex(): - _map() - {} +template class SimpleSecurityIndex { + public: + SimpleSecurityIndex() : _map() {} ~SimpleSecurityIndex() {} bool has_security(ExchangeKey key) const { @@ -34,7 +29,7 @@ public: return _map.find(key) != _map.end(); } - SecurityData* get_security(ExchangeKey key) const { + SecurityData *get_security(ExchangeKey key) const { tbb::queuing_rw_mutex::scoped_lock lock(_mutex, false); auto result = _map.find(key); if (result == _map.end()) { @@ -51,54 +46,52 @@ public: return invalid_security_key; } - template - void walk_security_list(CB cb) const { + template void walk_security_list(CB cb) const { tbb::queuing_rw_mutex::scoped_lock lock(_mutex, false); - for (const auto& pair : _map) { + for (const auto &pair : _map) { cb(*pair.second); } } // Transfer ownership of the data to the index - SecurityData* add_security(ExchangeKey key, std::unique_ptr entry) { + SecurityData * + add_security(ExchangeKey key, std::unique_ptr entry) { tbb::queuing_rw_mutex::scoped_lock lock(_mutex, true); // result is pair - auto result = _map.insert(std::make_pair(key, std::unique_ptr())); + auto result = + _map.insert(std::make_pair(key, std::unique_ptr())); if (!result.second) { - LOG(md,Error, "Found duplicate entry for platform id '{} - " ,key); + LOG(md, Error, "Found duplicate entry for platform id '{} - ", key); bts_assert(result.second); } result.first->second = std::move(entry); return result.first->second.get(); } - SecurityData* add_security(ExchangeKey key, MDProducerHandle& handle) { + SecurityData *add_security(ExchangeKey key, MDProducerHandle &handle) { std::unique_ptr data(new SecurityData(key, handle)); return add_security(key, std::move(data)); } -private: + private: BTS_NO_COPY(SimpleSecurityIndex); - typedef std::unordered_map> MapType; + typedef std::unordered_map> + MapType; MapType _map; mutable tbb::queuing_rw_mutex _mutex; }; - // // SecurityIndex using tbb concurrent_hash_map -// +// template -class ConcurrentSecurityIndex -{ -public: - ConcurrentSecurityIndex() : - _map() - {} +class ConcurrentSecurityIndex { + public: + ConcurrentSecurityIndex() : _map() {} ~ConcurrentSecurityIndex() {} - SecurityData* get_security(ExchangeKey key) const { + SecurityData *get_security(ExchangeKey key) const { typename MapType::const_accessor accessor; if (_map.find(accessor, key)) { return accessor->second; @@ -111,44 +104,44 @@ public: } security_key get_key(ExchangeKey key) const { - const auto* result = get_security(key); + const auto *result = get_security(key); if (result != nullptr) { return result->handle.key(); } return invalid_security_key; } - template - void walk_security_list(CB cb) const { + template void walk_security_list(CB cb) const { for (auto iter = _map.begin(); iter != _map.end(); ++iter) { cb(*iter->second); } } // Transfer ownership of the data to the index - SecurityData* add_security(ExchangeKey key, std::unique_ptr entry) { + SecurityData * + add_security(ExchangeKey key, std::unique_ptr entry) { typename MapType::accessor accessor; if (_map.insert(accessor, key)) { - // There is no delete security and concurrent_has_map does not yet support std::move + // There is no delete security and concurrent_has_map does not yet + // support std::move accessor->second = entry.release(); return accessor->second; - } - else { - LOG(md,Error, "Found duplicate entry for platform id '{}' - ",key); + } else { + LOG(md, Error, "Found duplicate entry for platform id '{}' - ", key); bts_assert(false); } } - SecurityData* add_security(ExchangeKey key, MDProducerHandle& handle) { + SecurityData *add_security(ExchangeKey key, MDProducerHandle &handle) { std::unique_ptr data(new SecurityData(key, handle)); return add_security(key, std::move(data)); } -private: + private: BTS_NO_COPY(ConcurrentSecurityIndex); - typedef tbb::concurrent_hash_map MapType; + typedef tbb::concurrent_hash_map MapType; MapType _map; }; -}}//namespace - +} // namespace md +} // namespace bts diff --git a/src/lib/md/SecurityMapper.cpp b/src/lib/md/SecurityMapper.cpp index 5d1f046f7..856818f6c 100644 --- a/src/lib/md/SecurityMapper.cpp +++ b/src/lib/md/SecurityMapper.cpp @@ -1,7 +1,7 @@ -#include "SecurityMapper.h" -#include "UserSymbol.h" +#include "SecurityMapper.h" #include "PriceSize.h" +#include "UserSymbol.h" #include "lib/config/config.h" #include "lib/config/protos/MarketData.pb.h" #include "lib/config/protos/cme_reference_data.pb.h" @@ -10,57 +10,55 @@ #ifndef _WIN32 #include "google/btree/btree_map.h" -namespace bts { -namespace md { -struct DisplayFactorMapper : public ISecurityMapper -{ +namespace bts { +namespace md { +struct DisplayFactorMapper : public ISecurityMapper { btree::btree_map _mapped; DisplayFactorMapper() : _mapped() { - for (const auto& ov : config::get().override()) { + for (const auto &ov : config::get().override()) { if (ov.has_price_multiplier()) { - auto venue = parse_enum(ov.exchange(), "VENUE", api::Venue_Parse); - bts_assert_msg(venue, fmt::format("Invalid venue `{}`", ov.exchange())); - auto type = parse_enum(ov.type(), "SECURITYTYPE", api::SecurityType_Parse); + auto venue = parse_enum( + ov.exchange(), "VENUE", api::Venue_Parse); + bts_assert_msg( + venue, fmt::format("Invalid venue `{}`", ov.exchange())); + auto type = parse_enum( + ov.type(), "SECURITYTYPE", api::SecurityType_Parse); if (type) { - _mapped.insert( - std::make_pair( - UserSymbol { uppercase_copy(ov.symbol()), *venue, *type }, - -to_exponent(ov.price_multiplier()))); - } - else { - for (auto t : { - SecurityType::SECURITYTYPE_FUTURE, - SecurityType::SECURITYTYPE_SPREAD, - SecurityType::SECURITYTYPE_OPTION }) { - _mapped.insert( - std::make_pair( - UserSymbol { uppercase_copy(ov.symbol()), *venue, t }, - -to_exponent(ov.price_multiplier()))); + _mapped.insert(std::make_pair( + UserSymbol{uppercase_copy(ov.symbol()), *venue, *type}, + -to_exponent(ov.price_multiplier()))); + } else { + for (auto t : + {SecurityType::SECURITYTYPE_FUTURE, + SecurityType::SECURITYTYPE_SPREAD, + SecurityType::SECURITYTYPE_OPTION}) { + _mapped.insert(std::make_pair( + UserSymbol{uppercase_copy(ov.symbol()), *venue, t}, + -to_exponent(ov.price_multiplier()))); } } } } } - void apply(FixedSecurity& f) const override { - UserSymbol key { f.symbol(), f.exchange, f.type }; + void apply(FixedSecurity &f) const override { + UserSymbol key{f.symbol(), f.exchange, f.type}; auto iter = _mapped.find(key); if (iter != _mapped.end()) { f.display_factor = iter->second; } } }; - -struct CppOverride : public ISecurityMapper -{ + +struct CppOverride : public ISecurityMapper { btree::btree_map _map; CppOverride() : _map() { - for (const auto& p : config::get().cpp_entry()) { + for (const auto &p : config::get().cpp_entry()) { _map.insert(p); } } - void apply(FixedSecurity& f) const override { + void apply(FixedSecurity &f) const override { auto iter = _map.find(f.symbol()); if (iter != _map.end()) { f.cash_per_point = iter->second; @@ -68,8 +66,7 @@ struct CppOverride : public ISecurityMapper } }; - -SecurityMapper::SecurityMapper(bool enabled): _impl() { +SecurityMapper::SecurityMapper(bool enabled) : _impl() { if (enabled) { _impl.push_back(std::make_unique()); _impl.push_back(std::make_unique()); @@ -78,15 +75,16 @@ SecurityMapper::SecurityMapper(bool enabled): _impl() { } #else -namespace bts { -namespace md { -SecurityMapper::SecurityMapper(bool): _impl() {} +namespace bts { +namespace md { +SecurityMapper::SecurityMapper(bool) : _impl() {} #endif -SecurityMapper::~SecurityMapper() { } -void SecurityMapper::apply(FixedSecurity& security) { - for (const auto& m : _impl) { +SecurityMapper::~SecurityMapper() {} +void SecurityMapper::apply(FixedSecurity &security) { + for (const auto &m : _impl) { m->apply(security); } } -}} //namespace +} +} // namespace diff --git a/src/lib/md/SecurityMapper.h b/src/lib/md/SecurityMapper.h index 2ca2129fa..b15351b7f 100644 --- a/src/lib/md/SecurityMapper.h +++ b/src/lib/md/SecurityMapper.h @@ -1,24 +1,25 @@ -#pragma once +#pragma once #include "Shm/FixedSecurity.h" #include #include -namespace bts { -namespace md { +namespace bts { +namespace md { struct ISecurityMapper { virtual ~ISecurityMapper() {} - virtual void apply(FixedSecurity&) const = 0; + virtual void apply(FixedSecurity &) const = 0; }; class SecurityMapper { std::vector> _impl; - public: + + public: SecurityMapper(bool enabled); ~SecurityMapper(); // apply various mappings to the security - void apply(FixedSecurity&); + void apply(FixedSecurity &); }; - -}} //namespace +} // namespace md +} // namespace bts diff --git a/src/lib/md/SecurityOracle.cpp b/src/lib/md/SecurityOracle.cpp index d8d372df3..b430afc16 100644 --- a/src/lib/md/SecurityOracle.cpp +++ b/src/lib/md/SecurityOracle.cpp @@ -4,18 +4,20 @@ namespace bts { namespace md { -SecurityOracle::SecurityOracle(SecurityCache& cache): _cache(cache) {} -SecurityOracle::~SecurityOracle() { } -const api::Security* SecurityOracle::get_security(SecurityKey key) const { +SecurityOracle::SecurityOracle(SecurityCache &cache) : _cache(cache) {} +SecurityOracle::~SecurityOracle() {} +const api::Security *SecurityOracle::get_security(SecurityKey key) const { return _cache.get_security(key); } -const api::Security* SecurityOracle::get_security(ExchangeSecurityKey key) const { +const api::Security * +SecurityOracle::get_security(ExchangeSecurityKey key) const { return _cache.try_get_security(key); } -std::vector SecurityOracle::get_securities() const { +std::vector SecurityOracle::get_securities() const { return _cache.get_securities(); } -}}//namespace +} // namespace md +} // namespace bts diff --git a/src/lib/md/SecurityOracle.h b/src/lib/md/SecurityOracle.h index c69fe7d58..6e0bea946 100644 --- a/src/lib/md/SecurityOracle.h +++ b/src/lib/md/SecurityOracle.h @@ -7,17 +7,21 @@ #include namespace bts { -namespace api {class Security;} +namespace api { +class Security; +} namespace md { class MDClient; class SecurityOracle { - SecurityCache& _cache; -public: - SecurityOracle(SecurityCache&); + SecurityCache &_cache; + + public: + SecurityOracle(SecurityCache &); ~SecurityOracle(); - const api::Security* get_security(SecurityKey key) const; - const api::Security* get_security(ExchangeSecurityKey key) const; - std::vector get_securities() const; + const api::Security *get_security(SecurityKey key) const; + const api::Security *get_security(ExchangeSecurityKey key) const; + std::vector get_securities() const; }; -}}//namespace +} // namespace md +} // namespace bts diff --git a/src/lib/md/SecurityPtr.h b/src/lib/md/SecurityPtr.h index 228c9a198..0debb92e2 100644 --- a/src/lib/md/SecurityPtr.h +++ b/src/lib/md/SecurityPtr.h @@ -4,9 +4,12 @@ #include namespace bts { -namespace api {class Security;} +namespace api { +class Security; +} namespace md { - typedef std::shared_ptr SecurityPtr; +typedef std::shared_ptr SecurityPtr; -}} \ No newline at end of file +} +} // namespace bts \ No newline at end of file diff --git a/src/lib/md/SettlementRecorder.cpp b/src/lib/md/SettlementRecorder.cpp index 3ae2c7626..e8d17aaec 100644 --- a/src/lib/md/SettlementRecorder.cpp +++ b/src/lib/md/SettlementRecorder.cpp @@ -1,27 +1,24 @@ #ifndef WIN32 #include "SettlementRecorder.h" -#include "lib/utils/Sqlite_utils.h" #include "lib/config/config.h" #include "lib/config/protos/system.pb.h" -#include +#include "lib/utils/Sqlite_utils.h" +#include +#include +#include #include #include -#include -#include -#include +#include namespace bts { namespace co2 { using datetime::Date; -using std::unique_ptr; using std::string; +using std::unique_ptr; using namespace utils; -enum WorkType { - SNAPSHOT, - UPDATE -}; +enum WorkType { SNAPSHOT, UPDATE }; struct Work { WorkType type; @@ -31,19 +28,18 @@ struct Work { }; struct SettlementRecorderImpl { - SettlementRecorderImpl() : - work_queue(), - db(nullptr, sqlite3_close), - select_stmt(nullptr, sqlite3_finalize), - insert_stmt(nullptr, sqlite3_finalize) - {} + SettlementRecorderImpl() + : work_queue(), db(nullptr, sqlite3_close), + select_stmt(nullptr, sqlite3_finalize), + insert_stmt(nullptr, sqlite3_finalize) {} tbb::concurrent_queue work_queue; sqlite3_ptr db; sqlite3_stmt_ptr select_stmt; sqlite3_stmt_ptr insert_stmt; }; -bool record_settle(sqlite3_stmt* insert, security_key key, IntPrice price, Date date) { +bool record_settle( + sqlite3_stmt *insert, security_key key, IntPrice price, Date date) { sqlite3_bind_int64(insert, 1, key); sqlite3_bind_int(insert, 2, date.to_short()); sqlite3_bind_int64(insert, 3, price.mantissa()); @@ -52,7 +48,7 @@ bool record_settle(sqlite3_stmt* insert, security_key key, IntPrice price, Date sqlite3_reset(insert); return (result == SQLITE_DONE || result == SQLITE_ROW); } -void publish_settles(sqlite3_stmt* select, MDProducerHandle handle) { +void publish_settles(sqlite3_stmt *select, MDProducerHandle handle) { // Query sqlite for the top 2 settlements sqlite3_bind_int(select, 1, handle.key()); auto result = sqlite3_step(select); @@ -60,22 +56,25 @@ void publish_settles(sqlite3_stmt* select, MDProducerHandle handle) { int64_t mantissa = sqlite3_column_int(select, 0); int exponent = sqlite3_column_int(select, 1); Date date = Date(sqlite3_column_int(select, 2)); - handle.update_settlement(TimeStamp::now(), {mantissa,(int8_t)exponent}, date); + handle.update_settlement( + 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(TimeStamp::now(), {mantissa,(int8_t)exponent}, date); + handle.update_previous_settlement( + utils::TimeStamp::now(), {mantissa, (int8_t)exponent}, date); } } sqlite3_reset(select); } -void apply_work(SettlementRecorderImpl& me, Work work) { +void apply_work(SettlementRecorderImpl &me, Work work) { switch (work.type) { case UPDATE: - if (record_settle(me.insert_stmt.get(), work.handle.key(), work.price, work.date)) { + if (record_settle( + me.insert_stmt.get(), work.handle.key(), work.price, work.date)) { publish_settles(me.select_stmt.get(), work.handle); } break; @@ -84,11 +83,11 @@ void apply_work(SettlementRecorderImpl& me, Work work) { } } -SettlementRecorder::SettlementRecorder(Platform platform) : - _self(new SettlementRecorderImpl()) -{ +SettlementRecorder::SettlementRecorder(Platform platform) + : _self(new SettlementRecorderImpl()) { string db_dir = config::get().data_path() + "databases/md/"; - string db_path = db_dir + "/settlements_" + Platform_Name(platform) +".sqlite"; + string db_path = + db_dir + "/settlements_" + Platform_Name(platform) + ".sqlite"; if (!boost::filesystem::exists(db_dir)) { boost::filesystem::create_directories(db_dir); } @@ -96,43 +95,51 @@ SettlementRecorder::SettlementRecorder(Platform platform) : // initialize database _self->db = sqlite::open_db(db_path.c_str()); bts_assert_msg(_self->db, db_path.c_str()); - sqlite3* db = _self->db.get(); + sqlite3 *db = _self->db.get(); sqlite3_busy_timeout(db, 9999); sqlite::exec_nofail(db, "PRAGMA journal_mode=WAL"); sqlite::exec_nofail(db, "PRAGMA syncronous=0"); // key=(security_key+date) - sqlite::exec_nofail(db, - "CREATE TABLE IF NOT EXISTS settlements2 (key INTEGER NOT NULL, date INTEGER NOT NULL, mantissa INTEGER NOT NULL, exponent INTEGER NOT NULL, PRIMARY KEY (key,date));"); + sqlite::exec_nofail( + db, "CREATE TABLE IF NOT EXISTS settlements2 (key INTEGER NOT NULL, " + "date INTEGER NOT NULL, mantissa INTEGER NOT NULL, exponent INTEGER " + "NOT NULL, PRIMARY KEY (key,date));"); // Delete any records > 10 days old auto cutoff = datetime::local_now() - boost::gregorian::days(10); - auto encoded = datetime::ll_to_date(datetime::ptime_to_ll(cutoff)).to_short(); + auto encoded = + datetime::ll_to_date(datetime::ptime_to_ll(cutoff)).to_short(); char query[256]; sprintf(query, "delete from settlements2 where date < %i", encoded); sqlite::exec_nofail(db, query); // statements - _self->select_stmt = sqlite::prepare_query(db, "select mantissa,exponent,date from settlements2 where key=? order by date desc limit 2"); - _self->insert_stmt = sqlite::prepare_query(db, "insert or replace into settlements2(key, date, mantissa,exponent) values(?,?,?,?)"); + _self->select_stmt = sqlite::prepare_query( + db, "select mantissa,exponent,date from settlements2 where key=? order " + "by date desc limit 2"); + _self->insert_stmt = sqlite::prepare_query( + db, "insert or replace into settlements2(key, date, mantissa,exponent) " + "values(?,?,?,?)"); } -SettlementRecorder::~SettlementRecorder() { } +SettlementRecorder::~SettlementRecorder() {} void SettlementRecorder::restore_settlement(MDProducerHandle handle) { - Work work = { SNAPSHOT, handle, INT_NAN, Date() }; + Work work = {SNAPSHOT, handle, INT_NAN, Date()}; _self->work_queue.push(work); } -void SettlementRecorder::add_settlement(MDProducerHandle handle, IntPrice price, datetime::Date date) { - Work work = { UPDATE, handle, price, date }; +void SettlementRecorder::add_settlement( + MDProducerHandle handle, IntPrice price, datetime::Date date) { + Work work = {UPDATE, handle, price, date}; _self->work_queue.push(work); } void SettlementRecorder::do_work() { - TimeStamp start = TimeStamp::now(); + auto start = utils::TimeStamp::now(); Work work; - while ((TimeStamp::now() - start).milliseconds() < 100 && - _self->work_queue.try_pop(work)) { + while ((utils::TimeStamp::now() - start).milliseconds() < 100 && + _self->work_queue.try_pop(work)) { if (work.handle.key() == invalid_security_key) { _self->work_queue.push(work); continue; @@ -141,5 +148,6 @@ void SettlementRecorder::do_work() { } } -}}//namespace +} // namespace co2 +} // namespace bts #endif diff --git a/src/lib/md/SettlementRecorder.h b/src/lib/md/SettlementRecorder.h index 2dfc9844b..75dd9ab42 100644 --- a/src/lib/md/SettlementRecorder.h +++ b/src/lib/md/SettlementRecorder.h @@ -4,26 +4,26 @@ #include "lib/utils/datetime.h" #include - namespace bts { namespace co2 { using namespace md; struct SettlementRecorderImpl; -class SettlementRecorder -{ -public: +class SettlementRecorder { + public: SettlementRecorder(Platform platform); ~SettlementRecorder(); // Put settlement update in a queue // in do_work() drain queue and update settlement 'depth' void restore_settlement(MDProducerHandle handle); - void add_settlement(MDProducerHandle handle, IntPrice price, datetime::Date date); + void + add_settlement(MDProducerHandle handle, IntPrice price, datetime::Date date); void do_work(); -private: + private: std::unique_ptr _self; }; -}}//namespace +} // namespace co2 +} // namespace bts diff --git a/src/lib/md/Shm/FixedSecurity.cpp b/src/lib/md/Shm/FixedSecurity.cpp index a5532c59e..24a5f2b27 100644 --- a/src/lib/md/Shm/FixedSecurity.cpp +++ b/src/lib/md/Shm/FixedSecurity.cpp @@ -5,7 +5,7 @@ #include #ifdef _WIN32 -#pragma warning(disable: 4351) +#pragma warning(disable : 4351) #endif using namespace std; @@ -15,37 +15,21 @@ using std::size_t; namespace bts { namespace md { -FixedSecurity::FixedSecurity() : - size(sizeof(FixedSecurity)), - key(invalid_security_key), - numeric_id(0), - type(api::SECURITYTYPE_STOCK), - exchange(api::VENUE_UNSET), - display_factor(0), - price_break(0), - low_tick(0), - high_tick(0), - cash_per_point(0), - cboe_class_key(0), - cme_market_segment_id(0), - cme_main_fraction(0), - cme_sub_fraction(0), - cme_price_display_format(0), - ice_price_denominator(0), - ice_deal_denominator(0), - ice_settle_denominator(0), - is_ice_strip(false), - _symbol(), - _cfi_code(), - _security_desc(), - _alt_symbol() -{ +FixedSecurity::FixedSecurity() + : size(sizeof(FixedSecurity)), key(invalid_security_key), numeric_id(0), + type(api::SECURITYTYPE_STOCK), exchange(api::VENUE_UNSET), + display_factor(0), price_break(0), low_tick(0), high_tick(0), + cash_per_point(0), cboe_class_key(0), cme_market_segment_id(0), + cme_main_fraction(0), cme_sub_fraction(0), cme_price_display_format(0), + ice_price_denominator(0), ice_deal_denominator(0), + ice_settle_denominator(0), is_ice_strip(false), _symbol(), _cfi_code(), + _security_desc(), _alt_symbol() { memset(_symbol, 0, BTS_ARRAYSIZE(_symbol)); memset(_alt_symbol, 0, BTS_ARRAYSIZE(_alt_symbol)); memset(_cfi_code, 0, BTS_ARRAYSIZE(_cfi_code)); memset(_security_desc, 0, BTS_ARRAYSIZE(_security_desc)); memset(_platform_id, 0, BTS_ARRAYSIZE(_platform_id)); - + memset(_ice_market_description, 0, BTS_ARRAYSIZE(_ice_market_description)); memset(_ice_cleared_alias, 0, BTS_ARRAYSIZE(_ice_cleared_alias)); memset(_ice_product_name, 0, BTS_ARRAYSIZE(_ice_product_name)); @@ -54,98 +38,98 @@ FixedSecurity::FixedSecurity() : memset(_mic_code, 0, BTS_ARRAYSIZE(_mic_code)); } -FixedSecurity::~FixedSecurity(){} +FixedSecurity::~FixedSecurity() {} -FixedFutureSecurity::FixedFutureSecurity(): - expiration_year(0), - expiration_month(0), - expiration_day(0) -{ +FixedFutureSecurity::FixedFutureSecurity() + : expiration_year(0), expiration_month(0), expiration_day(0) { type = api::SECURITYTYPE_FUTURE; size = sizeof(FixedFutureSecurity); } -FixedOptionSecurity::FixedOptionSecurity() : - expiration_year(0), - expiration_month(0), - expiration_day(0), - strike(0) -{ +FixedOptionSecurity::FixedOptionSecurity() + : expiration_year(0), expiration_month(0), expiration_day(0), strike(0) { type = api::SECURITYTYPE_OPTION; size = sizeof(FixedOptionSecurity); } -FixedSpreadLeg::FixedSpreadLeg(): - key(invalid_security_key), - leg_side(Side_MIN), - leg_quantity(0), - leg_price(0), - leg_delta(1) -{ +FixedSpreadLeg::FixedSpreadLeg() + : key(invalid_security_key), leg_side(Side_MIN), leg_quantity(0), + leg_price(0), leg_delta(1) {} + +void write_date_string( + uint32_t year, uint32_t month, uint32_t day, std::ostringstream &result) { + result << std::setw(2) << std::setfill('0') << month << "/" << std::setw(2) + << std::setfill('0') << day << "/" << year - 2000; } -void write_date_string(uint32_t year, uint32_t month, uint32_t day, std::ostringstream& result) { - result << std::setw(2) << std::setfill('0') << month << "/" - << std::setw(2) << std::setfill('0') << day << "/" - << year - 2000; +void write_leg_descriptor( + std::ostringstream &result, char separator, const api::ContractLeg &leg) { + result << separator << leg.security().id() << "-q" << leg.quantity() << "p" + << leg.price_multiplier() << "d" << leg.leg_delta() + << (leg.side() == SIDE_BUY ? "BUY" : "SELL"); } -void write_leg_descriptor(std::ostringstream& result, char separator, const api::ContractLeg& leg) { - result << separator - << leg.security().id() << "-q" - << leg.quantity() - << "p" << leg.price_multiplier() << "d" - << leg.leg_delta() << (leg.side() == SIDE_BUY ? "BUY" : "SELL"); -} - -std::string security_descriptor(const api::Security& security) { +std::string security_descriptor(const api::Security &security) { const char separator = ' '; std::ostringstream result; - if(security.exchange() == Venue::VENUE_ICE || security.exchange() == Venue::VENUE_SIMICE) - result << security.ice().security_desc() << separator << Venue_Name(security.exchange()); + if (security.exchange() == Venue::VENUE_ICE || + security.exchange() == Venue::VENUE_SIMICE) + result << security.ice().security_desc() << separator + << Venue_Name(security.exchange()); else - result << security.symbol() << separator << Venue_Name(security.exchange()); - switch(security.Contract_case()) { - case Security::ContractCase::kOption: { - result << separator; - const auto& o = security.option(); - write_date_string(o.expiration_year(), o.expiration_month(), o.expiration_day(), result); - result << separator << o.strike() << (o.call_put() == PUTORCALL_CALL ? 'C' : 'P'); - break; + result << security.symbol() << separator + << Venue_Name(security.exchange()); + switch (security.Contract_case()) { + case Security::ContractCase::kOption: { + result << separator; + const auto &o = security.option(); + write_date_string( + o.expiration_year(), o.expiration_month(), o.expiration_day(), + result); + result << separator << o.strike() + << (o.call_put() == PUTORCALL_CALL ? 'C' : 'P'); + break; + } + case Security::ContractCase::kFuture: { + result << separator; + const auto &f = security.future(); + write_date_string( + f.expiration_year(), f.expiration_month(), f.expiration_day(), + result); + break; + } + case Security::ContractCase::kSpread: { + // If the security key of a leg is invalid return an error + const auto &s = security.spread(); + bts_assert(s.legs_size() > 0); + for (const auto &leg : s.legs()) { + if (leg.security().id() == invalid_security_key) + return ""; + write_leg_descriptor(result, separator, leg); } - case Security::ContractCase::kFuture: { - result << separator; - const auto& f = security.future(); - write_date_string(f.expiration_year(), f.expiration_month(), f.expiration_day(), result); - break; + break; + } + case Security::ContractCase::kSynthetic: { + const auto &s = security.synthetic(); + bts_assert(s.legs_size() > 0); + result << separator << s.name() + << " pc=" << SyntheticContract::PriceCalc_Name(s.price_calc()); + for (const auto &leg : s.legs()) { + if (leg.security().id() == invalid_security_key) + return ""; // unlikey with synthetics + write_leg_descriptor(result, separator, leg); } - case Security::ContractCase::kSpread: { - // If the security key of a leg is invalid return an error - const auto& s = security.spread(); - bts_assert(s.legs_size() > 0); - for (const auto& leg : s.legs()) { - if (leg.security().id() == invalid_security_key) return ""; - write_leg_descriptor(result, separator, leg); - } - break; - } - case Security::ContractCase::kSynthetic: { - const auto& s = security.synthetic(); - bts_assert(s.legs_size() > 0); - result << separator << s.name() << " pc=" << SyntheticContract::PriceCalc_Name(s.price_calc()); - for (const auto& leg : s.legs()) { - if (leg.security().id() == invalid_security_key) return ""; // unlikey with synthetics - write_leg_descriptor(result, separator, leg); - } - break; - } - case Security::ContractCase::CONTRACT_NOT_SET: - bts_assert(security.Contract_case() != Security::ContractCase::CONTRACT_NOT_SET); + break; + } + case Security::ContractCase::CONTRACT_NOT_SET: + bts_assert( + security.Contract_case() != Security::ContractCase::CONTRACT_NOT_SET); } return result.str(); } -void get_contract_spec(const FixedSecurity& source, /*out*/ api::ContractSpecification& spec) { +void get_contract_spec( + const FixedSecurity &source, /*out*/ api::ContractSpecification &spec) { spec.set_price_break(source.price_break); spec.set_low_tick(source.low_tick); spec.set_high_tick(source.high_tick); @@ -155,102 +139,105 @@ void get_contract_spec(const FixedSecurity& source, /*out*/ api::ContractSpecifi spec.set_price_break(spec.price_break() * spec.price_multiplier()); spec.set_low_tick(spec.low_tick() * spec.price_multiplier()); spec.set_high_tick(spec.high_tick() * spec.price_multiplier()); - + // Tick info spec.set_main_fraction(source.cme_main_fraction); spec.set_sub_fraction(source.cme_sub_fraction); spec.set_price_display_format(source.cme_price_display_format); } -Security convert_security(const FixedSecurity& security) { +Security convert_security(const FixedSecurity &security) { Security res; convert_security(security, &res); return res; } -void convert_security(const FixedSecurity& source, Security* presult) { +void convert_security(const FixedSecurity &source, Security *presult) { bts_assert(presult); - Security& dest = *presult; + Security &dest = *presult; dest.set_id(source.key); dest.set_exchange(source.exchange); dest.set_symbol(source.symbol()); - - switch(source.exchange) { - case Venue::VENUE_GLBX: - case Venue::VENUE_SIM: - dest.mutable_glbx()->set_exchange_id(source.numeric_id); - dest.mutable_glbx()->set_security_desc(source.security_desc()); - dest.mutable_glbx()->set_cfi_code(source.cfi_code()); - dest.mutable_glbx()->set_cme_symbol(source.alt_symbol()); - if (source.cme_market_segment_id != 0) dest.mutable_glbx()->set_market_segment_id(source.cme_market_segment_id); - break; - case Venue::VENUE_ICE: - dest.mutable_ice()->set_exchange_id(source.numeric_id); - dest.mutable_ice()->set_security_desc(source.security_desc()); - dest.mutable_ice()->set_price_denominator(source.ice_price_denominator); - dest.mutable_ice()->set_deal_denominator(source.ice_deal_denominator); - dest.mutable_ice()->set_settle_denominator(source.ice_settle_denominator); - - dest.mutable_ice()->set_market_description(source.ice_market_description()); - dest.mutable_ice()->set_cleared_alias(source.ice_cleared_alias()); - dest.mutable_ice()->set_product_name(source.ice_product_name()); - dest.mutable_ice()->set_hub_alias(source.ice_hub_alias()); - dest.mutable_ice()->set_strip_name(source.ice_strip_name()); - dest.mutable_ice()->set_mic_code(source.mic_code()); - dest.mutable_ice()->set_is_strip(source.is_ice_strip); - break; - case Venue::VENUE_BTS: + + switch (source.exchange) { + case Venue::VENUE_GLBX: + case Venue::VENUE_SIM: + dest.mutable_glbx()->set_exchange_id(source.numeric_id); + dest.mutable_glbx()->set_security_desc(source.security_desc()); + dest.mutable_glbx()->set_cfi_code(source.cfi_code()); + dest.mutable_glbx()->set_cme_symbol(source.alt_symbol()); + if (source.cme_market_segment_id != 0) + dest.mutable_glbx()->set_market_segment_id( + source.cme_market_segment_id); break; - default: - bts_assert(false); + case Venue::VENUE_ICE: + dest.mutable_ice()->set_exchange_id(source.numeric_id); + dest.mutable_ice()->set_security_desc(source.security_desc()); + dest.mutable_ice()->set_price_denominator(source.ice_price_denominator); + dest.mutable_ice()->set_deal_denominator(source.ice_deal_denominator); + dest.mutable_ice()->set_settle_denominator(source.ice_settle_denominator); + + dest.mutable_ice()->set_market_description( + source.ice_market_description()); + dest.mutable_ice()->set_cleared_alias(source.ice_cleared_alias()); + dest.mutable_ice()->set_product_name(source.ice_product_name()); + dest.mutable_ice()->set_hub_alias(source.ice_hub_alias()); + dest.mutable_ice()->set_strip_name(source.ice_strip_name()); + dest.mutable_ice()->set_mic_code(source.mic_code()); + dest.mutable_ice()->set_is_strip(source.is_ice_strip); + break; + case Venue::VENUE_BTS: + break; + default: + bts_assert(false); } - switch(source.type) { - case SECURITYTYPE_FUTURE: { - bts_assert(source.size == sizeof(FixedFutureSecurity)); - const auto* psec = static_cast(&source); - dest.mutable_future()->set_expiration_day(psec->expiration_day); - dest.mutable_future()->set_expiration_month(psec->expiration_month); - dest.mutable_future()->set_expiration_year(psec->expiration_year); - break; + switch (source.type) { + case SECURITYTYPE_FUTURE: { + bts_assert(source.size == sizeof(FixedFutureSecurity)); + const auto *psec = static_cast(&source); + dest.mutable_future()->set_expiration_day(psec->expiration_day); + dest.mutable_future()->set_expiration_month(psec->expiration_month); + dest.mutable_future()->set_expiration_year(psec->expiration_year); + break; + } + case SECURITYTYPE_OPTION: { + bts_assert(source.size == sizeof(FixedOptionSecurity)); + const auto *psec = static_cast(&source); + dest.mutable_option()->set_expiration_day(psec->expiration_day); + dest.mutable_option()->set_expiration_month(psec->expiration_month); + dest.mutable_option()->set_expiration_year(psec->expiration_year); + dest.mutable_option()->set_strike(psec->strike); + dest.mutable_option()->set_call_put(psec->call_put); + break; + } + case SECURITYTYPE_SPREAD: { + const auto *psec = static_cast(&source); + auto *spread = dest.mutable_spread(); + spread->set_normalized(true); + for (size_t leg_index = 0; leg_index < psec->leg_count(); ++leg_index) { + const FixedSpreadLeg &fleg = psec->legs[leg_index]; + auto *leg = spread->add_legs(); + leg->set_side(fleg.leg_side); + leg->set_quantity(fleg.leg_quantity); + leg->set_price_multiplier(fleg.leg_price); + leg->set_leg_delta(fleg.leg_delta); + leg->mutable_security()->set_id(fleg.key); + leg->mutable_security()->set_exchange(source.exchange); } - case SECURITYTYPE_OPTION: { - bts_assert(source.size == sizeof(FixedOptionSecurity)); - const auto* psec = static_cast(&source); - dest.mutable_option()->set_expiration_day(psec->expiration_day); - dest.mutable_option()->set_expiration_month(psec->expiration_month); - dest.mutable_option()->set_expiration_year(psec->expiration_year); - dest.mutable_option()->set_strike(psec->strike); - dest.mutable_option()->set_call_put(psec->call_put); - break; - } - case SECURITYTYPE_SPREAD: { - const auto* psec = static_cast(&source); - auto* spread = dest.mutable_spread(); - spread->set_normalized(true); - for (size_t leg_index = 0; leg_index < psec->leg_count(); ++leg_index) { - const FixedSpreadLeg& fleg = psec->legs[leg_index]; - auto* leg = spread->add_legs(); - leg->set_side(fleg.leg_side); - leg->set_quantity(fleg.leg_quantity); - leg->set_price_multiplier(fleg.leg_price); - leg->set_leg_delta(fleg.leg_delta); - leg->mutable_security()->set_id(fleg.key); - leg->mutable_security()->set_exchange(source.exchange); - } - break; - } - case SECURITYTYPE_SYNTHETIC: { - const auto* psec = static_cast(&source); - psec->deserialize(dest); - bts_assert(dest.id() == source.key); - bts_assert(dest.exchange() == source.exchange); - bts_assert(dest.symbol() == source.symbol()); - break; - } - case SECURITYTYPE_STOCK: - case SECURITYTYPE_UNSET: - case SecurityType_INT_MAX_SENTINEL_DO_NOT_USE_: - case SecurityType_INT_MIN_SENTINEL_DO_NOT_USE_: + break; + } + case SECURITYTYPE_SYNTHETIC: { + const auto *psec = static_cast(&source); + psec->deserialize(dest); + bts_assert(dest.id() == source.key); + bts_assert(dest.exchange() == source.exchange); + bts_assert(dest.symbol() == source.symbol()); + break; + } + case SECURITYTYPE_STOCK: + case SECURITYTYPE_UNSET: + case SecurityType_INT_MAX_SENTINEL_DO_NOT_USE_: + case SecurityType_INT_MIN_SENTINEL_DO_NOT_USE_: break; } @@ -258,144 +245,166 @@ void convert_security(const FixedSecurity& source, Security* presult) { } SecurityType securitytype_of_contractcase(Security::ContractCase cc) { - switch(cc) { - case Security::ContractCase::kFuture: return SECURITYTYPE_FUTURE; - case Security::ContractCase::kOption: return SECURITYTYPE_OPTION; - case Security::ContractCase::kSpread: return SECURITYTYPE_SPREAD; - case Security::ContractCase::kSynthetic: return SECURITYTYPE_SYNTHETIC; - case Security::ContractCase::CONTRACT_NOT_SET: - bts_assert(cc != Security::ContractCase::CONTRACT_NOT_SET); + switch (cc) { + case Security::ContractCase::kFuture: + return SECURITYTYPE_FUTURE; + case Security::ContractCase::kOption: + return SECURITYTYPE_OPTION; + case Security::ContractCase::kSpread: + return SECURITYTYPE_SPREAD; + case Security::ContractCase::kSynthetic: + return SECURITYTYPE_SYNTHETIC; + case Security::ContractCase::CONTRACT_NOT_SET: + bts_assert(cc != Security::ContractCase::CONTRACT_NOT_SET); } bts_assert(false); } -SecurityType securitytype_of(const Security& s) { +SecurityType securitytype_of(const Security &s) { return securitytype_of_contractcase(s.Contract_case()); } -size_t num_legs(const Security& sec) { +size_t num_legs(const Security &sec) { if (sec.Contract_case() == api::Security::ContractCase::kSpread) { return sec.spread().legs_size(); - } - else if (sec.Contract_case() == api::Security::ContractCase::kSynthetic) { + } else if (sec.Contract_case() == api::Security::ContractCase::kSynthetic) { return sec.synthetic().legs_size(); } return 0; } -uint64_t exchange_id(const Security& security) { - switch(security.ExchangeData_case()) { - case Security::ExchangeDataCase::kCboe: return security.cboe().exchange_id(); - case Security::ExchangeDataCase::kGlbx: return security.glbx().exchange_id(); - case Security::ExchangeDataCase::kCfe: return security.cfe().exchange_id(); - case Security::ExchangeDataCase::kIce: return security.ice().exchange_id(); - // Debatable whether this should be an error or not. - // If is possible that we might create a spread with no exchange in the future - // and if we did this would be a runtime error. - case Security::ExchangeDataCase::EXCHANGEDATA_NOT_SET: return 0; +uint64_t exchange_id(const Security &security) { + switch (security.ExchangeData_case()) { + case Security::ExchangeDataCase::kCboe: + return security.cboe().exchange_id(); + case Security::ExchangeDataCase::kGlbx: + return security.glbx().exchange_id(); + case Security::ExchangeDataCase::kCfe: + return security.cfe().exchange_id(); + case Security::ExchangeDataCase::kIce: + return security.ice().exchange_id(); + // Debatable whether this should be an error or not. + // If is possible that we might create a spread with no exchange in the + // future and if we did this would be a runtime error. + case Security::ExchangeDataCase::EXCHANGEDATA_NOT_SET: + return 0; } return -1; } -void convert_security(const Security& src, FixedSecurity& dest, bool set_security_key) { +void convert_security( + const Security &src, FixedSecurity &dest, bool set_security_key) { dest.key = set_security_key ? src.id() : invalid_security_key; dest.type = securitytype_of_contractcase(src.Contract_case()); dest.symbol(src.symbol()); dest.exchange = src.exchange(); dest.display_factor = to_exponent(src.contract_spec().price_multiplier()); - switch(src.ExchangeData_case()) { - case Security::ExchangeDataCase::kGlbx: - dest.numeric_id = src.glbx().exchange_id(); - dest.security_desc(src.glbx().security_desc()); - dest.cfi_code(src.glbx().cfi_code()); - dest.alt_symbol(src.glbx().cme_symbol()); - dest.cme_market_segment_id = src.glbx().market_segment_id(); - break; - case Security::ExchangeDataCase::kCboe: - dest.cboe_class_key = src.cboe().class_key(); - break; - case Security::ExchangeDataCase::kCfe: - dest.cboe_class_key = src.cfe().class_key(); - break; - case Security::ExchangeDataCase::kIce: - dest.numeric_id = src.ice().exchange_id(); - dest.security_desc(src.ice().security_desc()); - dest.ice_price_denominator = src.ice().price_denominator(); - dest.ice_deal_denominator = src.ice().deal_denominator(); - dest.ice_settle_denominator = src.ice().settle_denominator(); - dest.is_ice_strip = src.ice().is_strip(); - - dest.ice_market_description(src.ice().market_description()); - dest.ice_cleared_alias(src.ice().cleared_alias()); - dest.ice_product_name(src.ice().product_name()); - dest.ice_hub_alias(src.ice().hub_alias()); - dest.ice_strip_name(src.ice().strip_name()); - dest.mic_code(src.ice().mic_code()); - break; - case Security::ExchangeDataCase::EXCHANGEDATA_NOT_SET: - break; + switch (src.ExchangeData_case()) { + case Security::ExchangeDataCase::kGlbx: + dest.numeric_id = src.glbx().exchange_id(); + dest.security_desc(src.glbx().security_desc()); + dest.cfi_code(src.glbx().cfi_code()); + dest.alt_symbol(src.glbx().cme_symbol()); + dest.cme_market_segment_id = src.glbx().market_segment_id(); + break; + case Security::ExchangeDataCase::kCboe: + dest.cboe_class_key = src.cboe().class_key(); + break; + case Security::ExchangeDataCase::kCfe: + dest.cboe_class_key = src.cfe().class_key(); + break; + case Security::ExchangeDataCase::kIce: + dest.numeric_id = src.ice().exchange_id(); + dest.security_desc(src.ice().security_desc()); + dest.ice_price_denominator = src.ice().price_denominator(); + dest.ice_deal_denominator = src.ice().deal_denominator(); + dest.ice_settle_denominator = src.ice().settle_denominator(); + dest.is_ice_strip = src.ice().is_strip(); + + dest.ice_market_description(src.ice().market_description()); + dest.ice_cleared_alias(src.ice().cleared_alias()); + dest.ice_product_name(src.ice().product_name()); + dest.ice_hub_alias(src.ice().hub_alias()); + dest.ice_strip_name(src.ice().strip_name()); + dest.mic_code(src.ice().mic_code()); + break; + case Security::ExchangeDataCase::EXCHANGEDATA_NOT_SET: + break; } - dest.price_break = src.contract_spec().price_break() / src.contract_spec().price_multiplier(); - dest.low_tick = src.contract_spec().low_tick() / src.contract_spec().price_multiplier(); - dest.high_tick = src.contract_spec().high_tick() / src.contract_spec().price_multiplier(); + dest.price_break = src.contract_spec().price_break() / + src.contract_spec().price_multiplier(); + dest.low_tick = + src.contract_spec().low_tick() / src.contract_spec().price_multiplier(); + dest.high_tick = + src.contract_spec().high_tick() / src.contract_spec().price_multiplier(); dest.cash_per_point = src.contract_spec().cash_per_point(); dest.cme_main_fraction = src.contract_spec().main_fraction(); dest.cme_sub_fraction = src.contract_spec().sub_fraction(); dest.cme_price_display_format = src.contract_spec().price_display_format(); - switch(securitytype_of(src)) { - case SECURITYTYPE_FUTURE: { - FixedFutureSecurity& future = static_cast(dest); - future.expiration_year = src.future().expiration_year(); - future.expiration_month = src.future().expiration_month(); - future.expiration_day = src.future().expiration_day(); - break; + switch (securitytype_of(src)) { + case SECURITYTYPE_FUTURE: { + FixedFutureSecurity &future = static_cast(dest); + future.expiration_year = src.future().expiration_year(); + future.expiration_month = src.future().expiration_month(); + future.expiration_day = src.future().expiration_day(); + break; + } + case SECURITYTYPE_OPTION: { + FixedOptionSecurity &option = static_cast(dest); + option.expiration_year = src.option().expiration_year(); + option.expiration_month = src.option().expiration_month(); + option.expiration_day = src.option().expiration_day(); + option.strike = src.option().strike(); + option.call_put = src.option().call_put(); + break; + } + case SECURITYTYPE_SPREAD: { + FixedSpreadSecurityXL &spread = + static_cast(dest); + // set_leg_count sets up the size of the spread and verified that the + // number of legs does not exceed the allocated space + spread.set_leg_count( + src.spread() + .legs_size()); // NOT recursive as Co2 spreads are normalized + for (int x = 0; x < src.spread().legs_size(); ++x) { + const auto &src_leg = src.spread().legs(x); + spread.legs[x].key = + set_security_key ? src_leg.security().id() : invalid_security_key; + spread.legs[x].exchange_key = + ExchangeKey(exchange_id(src_leg.security())); + spread.legs[x].leg_side = src_leg.side(); + spread.legs[x].leg_quantity = src_leg.quantity(); + spread.legs[x].leg_price = src_leg.price_multiplier(); + spread.legs[x].leg_delta = src_leg.leg_delta(); } - case SECURITYTYPE_OPTION: { - FixedOptionSecurity& option = static_cast(dest); - option.expiration_year = src.option().expiration_year(); - option.expiration_month = src.option().expiration_month(); - option.expiration_day = src.option().expiration_day(); - option.strike = src.option().strike(); - option.call_put = src.option().call_put(); - break; - } - case SECURITYTYPE_SPREAD: { - FixedSpreadSecurityXL& spread = static_cast(dest); - // set_leg_count sets up the size of the spread and verified that the number of legs does not exceed the allocated space - spread.set_leg_count(src.spread().legs_size()); // NOT recursive as Co2 spreads are normalized - for (int x = 0; x < src.spread().legs_size(); ++x) { - const auto& src_leg = src.spread().legs(x); - spread.legs[x].key = set_security_key ? src_leg.security().id() : invalid_security_key; - spread.legs[x].exchange_key = ExchangeKey(exchange_id(src_leg.security())); - spread.legs[x].leg_side = src_leg.side(); - spread.legs[x].leg_quantity = src_leg.quantity(); - spread.legs[x].leg_price = src_leg.price_multiplier(); - spread.legs[x].leg_delta = src_leg.leg_delta(); - } - break; - } - case SECURITYTYPE_SYNTHETIC: { - FixedSyntheticSecurity& synth = static_cast(dest); - bts_assert(synth.buffer_size() > 0); - // Due to how we create a FixedSecurity this FixedSecurity should already be populated - bts_assert(synth.leg_count() == (unsigned)src.synthetic().legs_size()); + break; + } + case SECURITYTYPE_SYNTHETIC: { + FixedSyntheticSecurity &synth = + static_cast(dest); + bts_assert(synth.buffer_size() > 0); + // Due to how we create a FixedSecurity this FixedSecurity should already + // be populated + bts_assert(synth.leg_count() == (unsigned)src.synthetic().legs_size()); #ifndef NDEBUG - { - Security temp; - static_cast(&dest)->deserialize(temp); - bts_assert_d(temp.SerializeAsString() == src.SerializeAsString()); - } + { + Security temp; + static_cast(&dest)->deserialize(temp); + bts_assert_d(temp.SerializeAsString() == src.SerializeAsString()); + } #endif - break; - } - case SECURITYTYPE_STOCK: break; - case SECURITYTYPE_UNSET: - case SecurityType_INT_MAX_SENTINEL_DO_NOT_USE_: - case SecurityType_INT_MIN_SENTINEL_DO_NOT_USE_: - bts_assert(false); + break; + } + case SECURITYTYPE_STOCK: + break; + case SECURITYTYPE_UNSET: + case SecurityType_INT_MAX_SENTINEL_DO_NOT_USE_: + case SecurityType_INT_MIN_SENTINEL_DO_NOT_USE_: + bts_assert(false); } } -}}//namespace +} // namespace md +} // namespace bts #endif diff --git a/src/lib/md/Shm/FixedSecurity.h b/src/lib/md/Shm/FixedSecurity.h index 93d7f833f..9472f4ae5 100644 --- a/src/lib/md/Shm/FixedSecurity.h +++ b/src/lib/md/Shm/FixedSecurity.h @@ -1,38 +1,42 @@ #pragma once #include "../common.h" -#include "lib/utils/bts_export.h" -#include "lib/utils/warn_ctrl.h" +#include "lib/utils/ValueWrapper.h" #include "lib/utils/bts_array_size.h" #include "lib/utils/bts_assert.h" +#include "lib/utils/bts_export.h" #include "lib/utils/bts_no_copy.h" -#include "lib/utils/ValueWrapper.h" +#include "lib/utils/warn_ctrl.h" -#include #include +#include namespace bts { namespace md { -using SecurityKey = utils::ValueWrapper; -using ExchangeKey = utils::ValueWrapper; +using SecurityKey = utils::ValueWrapper; +using ExchangeKey = utils::ValueWrapper; GCC_DIAG_OFF("-Weffc++") // No Virtual Destructors by design -#define STRING_PROPERTY(NAME) const char* NAME() const { return _##NAME; } \ - void NAME(const char* val, size_t size) { strncpy(_##NAME, val, std::min(BTS_ARRAYSIZE(_##NAME)-1, size)); _##NAME[std::min(BTS_ARRAYSIZE(_##NAME)-1, size)] = '\0'; } \ - void NAME(const std::string& val) { NAME(val.c_str(), val.size()); } +#define STRING_PROPERTY(NAME) \ + const char *NAME() const { return _##NAME; } \ + void NAME(const char *val, size_t size) { \ + strncpy(_##NAME, val, std::min(BTS_ARRAYSIZE(_##NAME) - 1, size)); \ + _##NAME[std::min(BTS_ARRAYSIZE(_##NAME) - 1, size)] = '\0'; \ + } \ + void NAME(const std::string &val) { NAME(val.c_str(), val.size()); } struct ColdEntry; // Caution: FixedSecurity is a variable sized structure // Use FixedSecurity::size to determine size not sizeof() -class BTS_EXPORT FixedSecurity -{ -protected: +class BTS_EXPORT FixedSecurity { + protected: FixedSecurity(); friend ColdEntry; -public: - FixedSecurity(const FixedSecurity&) = delete; + + public: + FixedSecurity(const FixedSecurity &) = delete; ~FixedSecurity(); STRING_PROPERTY(symbol); @@ -40,7 +44,7 @@ public: STRING_PROPERTY(cfi_code); STRING_PROPERTY(security_desc); STRING_PROPERTY(platform_id); - + size_t size; security_key key; uint64_t numeric_id; @@ -63,48 +67,45 @@ public: int8_t ice_deal_denominator; int8_t ice_settle_denominator; bool is_ice_strip; - - STRING_PROPERTY(ice_market_description); + + STRING_PROPERTY(ice_market_description); STRING_PROPERTY(ice_cleared_alias); STRING_PROPERTY(ice_product_name); STRING_PROPERTY(ice_hub_alias); STRING_PROPERTY(ice_strip_name); STRING_PROPERTY(mic_code); -private: - char _symbol[16]; // CME defines this as a char[6] but I'm padding - char _cfi_code[8]; // CME defines this as char[6] - char _security_desc[32]; // cme security desc FIX=107 //ice wants this to be 35 - char _alt_symbol[16]; // "cme symbol" or alternate symbol + private: + char _symbol[16]; // CME defines this as a char[6] but I'm padding + char _cfi_code[8]; // CME defines this as char[6] + char _security_desc[32]; // cme security desc FIX=107 //ice wants this to be + // 35 + char _alt_symbol[16]; // "cme symbol" or alternate symbol char _platform_id[64]; - + char _ice_market_description[120]; char _ice_cleared_alias[15]; char _ice_product_name[62]; - char _ice_hub_alias[80]; - char _ice_strip_name[39]; + char _ice_hub_alias[80]; + char _ice_strip_name[39]; char _mic_code[4]; }; class FixedStockSecurity : public FixedSecurity { - public: - FixedStockSecurity() { - type = api::SECURITYTYPE_STOCK; - }; + public: + FixedStockSecurity() { type = api::SECURITYTYPE_STOCK; }; }; -class BTS_EXPORT FixedFutureSecurity : public FixedSecurity -{ -public: +class BTS_EXPORT FixedFutureSecurity : public FixedSecurity { + public: FixedFutureSecurity(); uint32_t expiration_year; uint32_t expiration_month; uint32_t expiration_day; }; -class BTS_EXPORT FixedOptionSecurity : public FixedSecurity -{ -public: +class BTS_EXPORT FixedOptionSecurity : public FixedSecurity { + public: FixedOptionSecurity(); uint32_t expiration_year; uint32_t expiration_month; @@ -113,8 +114,7 @@ public: api::PutOrCall call_put; }; -struct BTS_EXPORT FixedSpreadLeg -{ +struct BTS_EXPORT FixedSpreadLeg { FixedSpreadLeg(); security_key key; ExchangeKey exchange_key; @@ -124,11 +124,10 @@ struct BTS_EXPORT FixedSpreadLeg double leg_delta; }; -template -class FixedSpreadSecurity : public FixedSecurity -{ +template class FixedSpreadSecurity : public FixedSecurity { char _summary[128]; -public: + + public: FixedSpreadSecurity() : _leg_count(0), _leg_max(LEGCOUNT), legs() { type = api::SECURITYTYPE_SPREAD; size = sizeof(FixedSpreadSecurity<1>); @@ -139,144 +138,147 @@ public: bts_assert(count <= LEGCOUNT); bts_assert(count <= _leg_max); _leg_count = count; - size = sizeof(FixedSpreadSecurity<1>) + (sizeof(FixedSpreadLeg) * (count - 1)); + size = sizeof(FixedSpreadSecurity<1>) + + (sizeof(FixedSpreadLeg) * (count - 1)); } STRING_PROPERTY(summary); static size_t static_count() { return LEGCOUNT; } uint32_t leg_count() const { return _leg_count; } - -private: + + private: // memcpy only please uint32_t _leg_count; uint32_t _leg_max; BTS_NO_COPY(FixedSpreadSecurity); -public: + + public: // NO members after legs array FixedSpreadLeg legs[LEGCOUNT]; }; -// We store the normalized legs for a normal spread because they aren't available when it is created -// A synthetic security is always fully defined -class FixedSyntheticSecurity : public FixedSecurity -{ -public: - FixedSyntheticSecurity(const api::Security& sec) : - _leg_count(sec.synthetic().legs_size()), - _buffer_size(sec.ByteSize()) - { +// We store the normalized legs for a normal spread because they aren't +// available when it is created A synthetic security is always fully defined +class FixedSyntheticSecurity : public FixedSecurity { + public: + FixedSyntheticSecurity(const api::Security &sec) + : _leg_count(sec.synthetic().legs_size()), _buffer_size(sec.ByteSize()) { type = api::SECURITYTYPE_SYNTHETIC; sec.SerializeToArray(buffer(), _buffer_size); - size = sizeof(FixedSyntheticSecurity) + _buffer_size; + size = sizeof(FixedSyntheticSecurity) + _buffer_size; } uint32_t leg_count() const { return _leg_count; } uint32_t buffer_size() const { return _buffer_size; } - void deserialize(api::Security& dest) const { + void deserialize(api::Security &dest) const { dest.ParseFromArray(buffer(), _buffer_size); } -private: - uint8_t* buffer() { - return (reinterpret_cast(this) + sizeof(FixedSyntheticSecurity)); + private: + uint8_t *buffer() { + return ( + reinterpret_cast(this) + sizeof(FixedSyntheticSecurity)); } - const uint8_t* buffer() const { - return (reinterpret_cast(this) + sizeof(FixedSyntheticSecurity)); + const uint8_t *buffer() const { + return ( + reinterpret_cast(this) + + sizeof(FixedSyntheticSecurity)); } uint32_t _leg_count; uint32_t _buffer_size; - }; -// Stack allocate a FixedSpreadSecurity with a high number of legs then memcpy the right size to shared memory +// Stack allocate a FixedSpreadSecurity with a high number of legs then memcpy +// the right size to shared memory typedef FixedSpreadSecurity<2> FixedSpreadSecurityXS; typedef FixedSpreadSecurity<16> FixedSpreadSecurityS; typedef FixedSpreadSecurity<128> FixedSpreadSecurityL; typedef FixedSpreadSecurity<512> FixedSpreadSecurityXL; -std::string security_descriptor(const api::Security&); +std::string security_descriptor(const api::Security &); -// Convert a fixedsecurity to a normal Security - caveat: spreads will be normalized -Security convert_security(const FixedSecurity&); -void convert_security(const FixedSecurity&, Security*); -void convert_security(const Security& src, FixedSecurity& dest, bool set_security_key=false); +// Convert a fixedsecurity to a normal Security - caveat: spreads will be +// normalized +Security convert_security(const FixedSecurity &); +void convert_security(const FixedSecurity &, Security *); +void convert_security( + const Security &src, FixedSecurity &dest, bool set_security_key = false); SecurityType securitytype_of_contractcase(Security::ContractCase cc); -SecurityType securitytype_of(const Security&); -size_t num_legs(const Security&); -uint64_t exchange_id(const Security& security); - +SecurityType securitytype_of(const Security &); +size_t num_legs(const Security &); +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, C cb) { - switch(type) { - case api::SECURITYTYPE_STOCK: { - FixedStockSecurity security; +void with_security( + SecurityType type, size_t leg_count, const api::Security *psynthetic, + C cb) { + switch (type) { + case api::SECURITYTYPE_STOCK: { + FixedStockSecurity security; + cb(security); + return; + } + case api::SECURITYTYPE_FUTURE: { + FixedFutureSecurity security; + bts_assert(security.type == type); + cb(security); + return; + } + case api::SECURITYTYPE_OPTION: { + FixedOptionSecurity security; + bts_assert(security.type == type); + cb(security); + return; + } + case api::SECURITYTYPE_SPREAD: { + if (leg_count <= 4) { + FixedSpreadSecurity<4> security; cb(security); - return; - } - case api::SECURITYTYPE_FUTURE: { - FixedFutureSecurity security; - bts_assert(security.type == type); + } else if (leg_count <= FixedSpreadSecurityS::static_count()) { + FixedSpreadSecurityS security; cb(security); - return; - } - case api::SECURITYTYPE_OPTION: { - FixedOptionSecurity security; - bts_assert(security.type == type); + } else if (leg_count <= FixedSpreadSecurityL::static_count()) { + FixedSpreadSecurityL security; cb(security); - return; + } else if (leg_count <= FixedSpreadSecurityXL::static_count()) { + FixedSpreadSecurityXL security; + cb(security); + } else { + std::stringstream msg("Too many legs ("); + msg << leg_count; + msg << ")"; + bts_assert_msg(false, msg.str()); } - case api::SECURITYTYPE_SPREAD: { - if (leg_count <= 4) { - FixedSpreadSecurity<4> security; - cb(security); - } - else if (leg_count <= FixedSpreadSecurityS::static_count()) { - FixedSpreadSecurityS security; - cb(security); - } - else if (leg_count <= FixedSpreadSecurityL::static_count()) { - FixedSpreadSecurityL security; - cb(security); - } - else if (leg_count <= FixedSpreadSecurityXL::static_count()) { - FixedSpreadSecurityXL security; - cb(security); - } - else { - std::stringstream msg("Too many legs ("); - msg << leg_count; - msg << ")"; - bts_assert_msg(false, msg.str()); - } - return; - } - case api::SECURITYTYPE_SYNTHETIC: { - bts_assert(psynthetic); - // Use a vector to allocate the right size - // Then use the FixedSynthetic constructor to serialize the api::Security into those bytes - // We could optimize this by using a fixed size stack buffer and only heap allocating if we exceed that - // but in general FixedSynthetic is not performance sensitive - std::vector buffer; - buffer.resize(psynthetic->ByteSize() + sizeof(FixedSyntheticSecurity)); - auto* psec = new (&buffer[0]) FixedSyntheticSecurity(*psynthetic); - cb(*psec); - return; - } - case api::SECURITYTYPE_UNSET: - case api::SecurityType_INT_MAX_SENTINEL_DO_NOT_USE_: - case api::SecurityType_INT_MIN_SENTINEL_DO_NOT_USE_: + return; + } + case api::SECURITYTYPE_SYNTHETIC: { + bts_assert(psynthetic); + // Use a vector to allocate the right size + // Then use the FixedSynthetic constructor to serialize the api::Security + // into those bytes We could optimize this by using a fixed size stack + // buffer and only heap allocating if we exceed that but in general + // FixedSynthetic is not performance sensitive + std::vector buffer; + buffer.resize(psynthetic->ByteSize() + sizeof(FixedSyntheticSecurity)); + auto *psec = new (&buffer[0]) FixedSyntheticSecurity(*psynthetic); + cb(*psec); + return; + } + case api::SECURITYTYPE_UNSET: + case api::SecurityType_INT_MAX_SENTINEL_DO_NOT_USE_: + case api::SecurityType_INT_MIN_SENTINEL_DO_NOT_USE_: break; } bts_assert(false); } template -void with_security_like(const api::Security& security, C cb) { - return with_security(securitytype_of(security), num_legs(security), &security, cb); +void with_security_like(const api::Security &security, C cb) { + return with_security( + securitytype_of(security), num_legs(security), &security, cb); } -}}//namespace - +} // namespace md +} // namespace bts diff --git a/src/lib/md/Shm/MDStructure.h b/src/lib/md/Shm/MDStructure.h index 2bad7f6ee..5d0330bdd 100644 --- a/src/lib/md/Shm/MDStructure.h +++ b/src/lib/md/Shm/MDStructure.h @@ -1,21 +1,22 @@ #pragma once -#include "FixedSecurity.h" #include "../PriceSize.h" -#include "lib/config/config.h" #include "../common.h" +#include "FixedSecurity.h" +#include "lib/config/config.h" #include "lib/utils/TimeStamp.h" #include "lib/config/protos/MarketData.pb.h" -#include #include +#include /* - * Coconut 2.0 separates data into high (hot) and low (cold) priority based on how fast the clients need to access the data - * Any data critical for the quoter/eyes goes in the Hot structure and is polled very fast. This data should be kept as small as possible - * and should be cache-line aligned - * Any other data goes in the Cold list and will be accessed more slowly -*/ + * Coconut 2.0 separates data into high (hot) and low (cold) priority based on + * how fast the clients need to access the data Any data critical for the + * quoter/eyes goes in the Hot structure and is polled very fast. This data + * should be kept as small as possible and should be cache-line aligned Any + * other data goes in the Cold list and will be accessed more slowly + */ namespace bts { namespace md { @@ -31,23 +32,29 @@ const uint32_t shm_version = 107; struct ALIGNED_(CACHE_LINE) HotHeader { size_t count; size_t segment_count; - // Just the counters. Publisher process can compute messages/second by polling these counters + // Just the counters. Publisher process can compute messages/second by + // polling these counters size_t direct_count; size_t implied_count; }; -// These should not be cache line aligned because they are small enough for multiple to fit on one line easily +// These should not be cache line aligned because they are small enough for +// multiple to fit on one line easily class HotEntry { - std::atomic timestamp; // 8 - public: - HotEntry() : timestamp(TimeStamp(0)), book(), key(invalid_security_key), sequence(0), status(co2::COCONUTSECURITYSTATUS_OK) {} + std::atomic timestamp; // 8 + public: + HotEntry() + : timestamp(TimeStamp(0)), book(), key(invalid_security_key), + sequence(0), status(co2::COCONUTSECURITYSTATUS_OK) {} uint32_t size() const { return sizeof(HotEntry); } PriceLevel book; // 24 security_key key; // 4 uint32_t sequence; // 4 IntPrice settlement; // 8 uint8_t status; // 1 - void set_time(const TimeStamp& t) { timestamp.store(t, std::memory_order_release); } + void set_time(const TimeStamp &t) { + timestamp.store(t, std::memory_order_release); + } TimeStamp time() const { return timestamp.load(std::memory_order_acquire); } }; static_assert(sizeof(HotEntry) <= CACHE_LINE, "HotEntry should be small"); @@ -55,44 +62,42 @@ static_assert(sizeof(HotEntry) <= CACHE_LINE, "HotEntry should be small"); const uint32_t COCONUT_MAX_DEPTH = 10; const uint32_t COCONUT_MAX_IMPLIED_DEPTH = 2; class HotDepthEntry { - std::atomic timestamp; // 8 - public: - HotDepthEntry() : - timestamp(TimeStamp(0)), - key(invalid_security_key), - sequence(0), - direct(), - implied(), - status(co2::COCONUTSECURITYSTATUS_OK) - { } + std::atomic timestamp; // 8 + public: + HotDepthEntry() + : timestamp(TimeStamp(0)), key(invalid_security_key), sequence(0), + direct(), implied(), status(co2::COCONUTSECURITYSTATUS_OK) {} uint32_t size() const { return sizeof(HotDepthEntry); } - security_key key; // 4 NOTE: key is at a different offset than it is in HotEntry - uint32_t sequence; // 4 - IntPrice settlement; // 8 - std::array direct; // 240 + security_key + key; // 4 NOTE: key is at a different offset than it is in HotEntry + uint32_t sequence; // 4 + IntPrice settlement; // 8 + std::array direct; // 240 std::array implied; // 48 - uint8_t status; // 1 + uint8_t status; // 1 - void read_direct(uint32_t depth, PriceSize* bid, PriceSize* ask) const { + void read_direct(uint32_t depth, PriceSize *bid, PriceSize *ask) const { *bid = direct[depth].bid(); *ask = direct[depth].ask(); } - void read_implied(uint32_t depth, PriceSize* bid, PriceSize* ask) const { + void read_implied(uint32_t depth, PriceSize *bid, PriceSize *ask) const { *bid = implied[depth].bid(); *ask = implied[depth].ask(); } - bool write_direct(uint32_t depth, const PriceSize& bid, const PriceSize& ask) { + bool + write_direct(uint32_t depth, const PriceSize &bid, const PriceSize &ask) { bts_assert_d(depth < direct.size()); - auto temp = PriceLevel(bid,ask); + auto temp = PriceLevel(bid, ask); if (direct[depth] != temp) { direct[depth] = temp; return true; } return false; } - bool write_implied(uint32_t depth, const PriceSize& bid, const PriceSize& ask) { + bool + write_implied(uint32_t depth, const PriceSize &bid, const PriceSize &ask) { bts_assert_d(depth < implied.size()); - auto temp = PriceLevel(bid,ask); + auto temp = PriceLevel(bid, ask); if (implied[depth] != temp) { implied[depth] = temp; return true; @@ -100,7 +105,9 @@ class HotDepthEntry { return false; } - void set_time(const TimeStamp& t) { timestamp.store(t, std::memory_order_release); } + void set_time(const TimeStamp &t) { + timestamp.store(t, std::memory_order_release); + } TimeStamp time() const { return timestamp.load(std::memory_order_acquire); } }; static_assert(sizeof(HotDepthEntry) <= 320, "HotDepthEntry should be small"); @@ -110,23 +117,17 @@ static_assert(sizeof(HotDepthEntry) <= 320, "HotDepthEntry should be small"); /////////////////////// struct ALIGNED_(CACHE_LINE) ColdHeader { - ColdHeader() : - version(shm_version), - count(0), - segment_count(0), - create_time(TimeStamp::now()), - heartbeat(), - disable_heartbeat (config::get().disable_heartbeat ()), - heartbeat_ms (config::get().heartbeat_ms ()), - heartbeat_boot_seconds (config::get().heartbeat_boot_seconds ()), - security_count(0), - has_depth(false), - platform(co2::PLATFORM_UNSET), - trade_count(0), - coconut_status_count(0), - exchange_status_count(0), - rfq_count(0) - {} + ColdHeader() + : version(shm_version), count(0), segment_count(0), + create_time(TimeStamp::now()), heartbeat(), + disable_heartbeat( + config::get().disable_heartbeat()), + heartbeat_ms(config::get().heartbeat_ms()), + heartbeat_boot_seconds( + config::get().heartbeat_boot_seconds()), + security_count(0), has_depth(false), platform(co2::PLATFORM_UNSET), + trade_count(0), coconut_status_count(0), exchange_status_count(0), + rfq_count(0) {} uint32_t version; size_t count; @@ -140,7 +141,7 @@ struct ALIGNED_(CACHE_LINE) ColdHeader { uint32_t security_count; // incremented when a security is made public bool has_depth; Platform platform; - + std::atomic trade_count; std::atomic coconut_status_count; std::atomic exchange_status_count; @@ -148,35 +149,27 @@ struct ALIGNED_(CACHE_LINE) ColdHeader { std::atomic gap_count; // Ring buffer for LastTrade for all securities in this list - uint8_t trade_buffer[1024*1024*4]; //4mb + uint8_t trade_buffer[1024 * 1024 * 4]; // 4mb // Ring buffer for RFQ - //static const int rfq_buffer_entry_size = 64; + // static const int rfq_buffer_entry_size = 64; typedef std::array RFQBuffer; - uint8_t rfq_buffer[1024*256];//256k + uint8_t rfq_buffer[1024 * 256]; // 256k }; struct MiscData { - MiscData(): - misc_timestamp(), - settlement_date(), - previous_settlement_price(INT_NAN), - previous_settlement_date(), - open_price(NO_PRICE), - open_date(), - close_price(NO_PRICE), - close_date(), - session_high(NO_PRICE), - session_low(NO_PRICE), - session_high_bid(NO_PRICE), - session_low_offer(NO_PRICE), - fixing_price(NO_PRICE) - { } + MiscData() + : misc_timestamp(), settlement_date(), + previous_settlement_price(INT_NAN), previous_settlement_date(), + open_price(NO_PRICE), open_date(), close_price(NO_PRICE), close_date(), + session_high(NO_PRICE), session_low(NO_PRICE), + session_high_bid(NO_PRICE), session_low_offer(NO_PRICE), + fixing_price(NO_PRICE) {} TimeStamp misc_timestamp; // Settlement datetime::Date settlement_date; IntPrice previous_settlement_price; datetime::Date previous_settlement_date; - + // Opening/Closing Price open_price; datetime::Date open_date; @@ -190,47 +183,42 @@ struct MiscData { Price session_low_offer; Price fixing_price; - bool operator==(const MiscData& other) const { - return - settlement_date == other.settlement_date && - previous_settlement_price == other.previous_settlement_price && - previous_settlement_date == other.previous_settlement_date && - open_price == other.open_price && - open_date == other.open_date && - close_price == other.close_price && - close_date == other.close_date && - session_high == other.session_high && - session_low == other.session_low && - session_high_bid == other.session_high_bid && - session_low_offer == other.session_low_offer && - fixing_price == other.fixing_price; + bool operator==(const MiscData &other) const { + return settlement_date == other.settlement_date && + previous_settlement_price == other.previous_settlement_price && + previous_settlement_date == other.previous_settlement_date && + open_price == other.open_price && open_date == other.open_date && + close_price == other.close_price && + close_date == other.close_date && + session_high == other.session_high && + session_low == other.session_low && + session_high_bid == other.session_high_bid && + session_low_offer == other.session_low_offer && + fixing_price == other.fixing_price; } - bool operator!=(const MiscData& other) const { return !(*this == other); } + bool operator!=(const MiscData &other) const { return !(*this == other); } }; struct ColdEntry { - ColdEntry(size_t security_size) : - exchange_status(co2::TRADINGSTATUS_UNKNOWN), - last_trade(), - total_volume(0), - last_trade_time(), - misc(), - from_spread(0), - deleted(0) - { + ColdEntry(size_t security_size) + : exchange_status(co2::TRADINGSTATUS_UNKNOWN), last_trade(), + total_volume(0), last_trade_time(), misc(), from_spread(0), + deleted(0) { this->security.size = security_size; } - static size_t fixed_size() { return sizeof(ColdEntry) - sizeof(FixedSecurity); } + static size_t fixed_size() { + return sizeof(ColdEntry) - sizeof(FixedSecurity); + } size_t size() const { return fixed_size() + this->security.size; } co2::TradingStatus exchange_status; - + // Last Trade AtomicPriceSize last_trade; - size_t total_volume; - datetime::LLDateTime last_trade_time; - + size_t total_volume; + datetime::LLDateTime last_trade_time; + MiscData misc; int from_spread; @@ -238,5 +226,5 @@ struct ColdEntry { FixedSecurity security; }; - -}} +} // namespace md +} // namespace bts diff --git a/src/lib/md/SizeTypes.h b/src/lib/md/SizeTypes.h index 16484c8dd..a9298251a 100644 --- a/src/lib/md/SizeTypes.h +++ b/src/lib/md/SizeTypes.h @@ -2,5 +2,6 @@ #include "lib/utils/ValueWrapper.h" namespace bts { namespace md { - using ImpliedSize = utils::ValueWrapper; -}} \ No newline at end of file +using ImpliedSize = utils::ValueWrapper; +} +} // namespace bts \ No newline at end of file diff --git a/src/lib/md/SyntheticSecurityService.cpp b/src/lib/md/SyntheticSecurityService.cpp index a4ec9b962..7d405efe1 100644 --- a/src/lib/md/SyntheticSecurityService.cpp +++ b/src/lib/md/SyntheticSecurityService.cpp @@ -1,12 +1,12 @@ #ifndef WIN32 #include "SyntheticSecurityService.h" -#include "lib/config/config.h" #include "lib/api/public/ServiceContext.h" #include "lib/api/services/PersistenceService.pb.h" -#include "lib/md/common.h" -#include "lib/md/SecurityIDRecorder.h" +#include "lib/config/config.h" #include "lib/md/SecurityDB.h" +#include "lib/md/SecurityIDRecorder.h" +#include "lib/md/common.h" #include "lib/md/get_symbols.h" #include "lib/utils/Dispatcher.h" #include "lib/utils/Event.h" @@ -15,21 +15,19 @@ namespace bts { namespace api { namespace synthetic { - + struct SecurityLess { - bool operator()(const api::Security& left, const api::Security& right) { + bool operator()(const api::Security &left, const api::Security &right) { return left.id() < right.id(); } }; -typedef SyntheticSecurityServiceBase::MetadataStatefulPublisher MetadataPublisher; +typedef SyntheticSecurityServiceBase::MetadataStatefulPublisher + MetadataPublisher; struct SyntheticSecurityService::Pimpl { - Pimpl(const MetadataStatefulPublisher& fn) : - recorder(utils::Dispatcher::background()), - synthetics(), on_security(), - meta(), on_metadata(), metadata_publisher(fn) - { - } + Pimpl(const MetadataStatefulPublisher &fn) + : recorder(utils::Dispatcher::background()), synthetics(), on_security(), + meta(), on_metadata(), metadata_publisher(fn) {} md::SecurityIDRecorder recorder; std::unordered_map synthetics; utils::Event on_security; @@ -38,15 +36,15 @@ struct SyntheticSecurityService::Pimpl { MetadataStatefulPublisher metadata_publisher; }; -SyntheticSecurityService::SyntheticSecurityService(api::ServiceContext& context) - : SyntheticSecurityServiceBase(context), - _me(new Pimpl(make_metadata_stateful_publisher())) { +SyntheticSecurityService::SyntheticSecurityService(api::ServiceContext &context) + : SyntheticSecurityServiceBase(context), + _me(new Pimpl(make_metadata_stateful_publisher())) { // load securities std::set symbols; md::get_system_md_symbols(api::VENUE_BTS, api::SECURITYTYPE_UNSET, symbols); - md::db::load_securities(symbols, [=](const api::Security& security) { - if (security.Contract_case() == api::Security::kSynthetic) { + md::db::load_securities(symbols, [=](const api::Security &security) { + if (security.Contract_case() == api::Security::kSynthetic) { auto key = SecurityKey(security.id()); _me->synthetics.insert(std::make_pair(key, security)); } @@ -54,13 +52,12 @@ SyntheticSecurityService::SyntheticSecurityService(api::ServiceContext& context) // Load metadata auto metadata = md::db::load_metadata(); - for (const auto& entry : metadata) { + for (const auto &entry : metadata) { auto iter = _me->synthetics.find(SecurityKey(entry.security_key())); if (iter != _me->synthetics.end()) { if (entry.strategy().deleted()) { _me->synthetics.erase(iter); - } - else { + } else { _me->meta.insert(std::make_pair(entry.security_key(), entry)); _me->metadata_publisher.add_or_update(entry); } @@ -69,39 +66,40 @@ SyntheticSecurityService::SyntheticSecurityService(api::ServiceContext& context) if (_me->meta.size() > 0) { _me->metadata_publisher.flush(); } - } -SyntheticSecurityService::~SyntheticSecurityService() { } +SyntheticSecurityService::~SyntheticSecurityService() {} - -const std::unordered_map SyntheticSecurityService::securities() { +const std::unordered_map +SyntheticSecurityService::securities() { return _me->synthetics; } -utils::EventSubscriber& SyntheticSecurityService::on_securities() { +utils::EventSubscriber &SyntheticSecurityService::on_securities() { return _me->on_security; } -const Metadata* SyntheticSecurityService::get_metadata(SecurityKey key) { +const Metadata *SyntheticSecurityService::get_metadata(SecurityKey key) { auto iter = _me->meta.find(key); if (iter != _me->meta.end()) { return &iter->second; } return nullptr; } -utils::EventSubscriber& SyntheticSecurityService::on_metadata() { +utils::EventSubscriber &SyntheticSecurityService::on_metadata() { return _me->on_metadata; } -void send_reply(const api::Response& fn, CreateResult::Error err, uint32_t key=md::invalid_security_key) { +void send_reply( + const api::Response &fn, CreateResult::Error err, + uint32_t key = md::invalid_security_key) { CreateResult r; r.set_key(key); r.set_error(err); fn(r); - LOG(md, Info, "Create new synthetic security key={} response={}", key, CreateResult::Error_Name(err)); + LOG(md, Info, "Create new synthetic security key={} response={}", key, + CreateResult::Error_Name(err)); } void SyntheticSecurityService::create_synthetic( - const Security& security, - const api::Response& reply) { + const Security &security, const api::Response &reply) { CreateResult result; // Validate security is synthetic @@ -127,80 +125,87 @@ void SyntheticSecurityService::create_synthetic( } // Assign security key - _me->recorder.assign_key(security, [this, reply](const api::Security& security) { - // Notify listeners that a new security is added - auto iter = _me->synthetics.find(SecurityKey(security.id())); - if (iter != _me->synthetics.end()) { - auto metadata = get_metadata(iter->first); - if (metadata && metadata->strategy().deleted()) { - // If this security is deleted we can just undelete it - Metadata newmeta; - // Rather than copy from the existing metatdata create a default. - // The existing metadata is from a deleted spread so may not be valid - // UI will call update_security_metadata if non-defaults are needed - newmeta.set_security_key(security.id()); - newmeta.mutable_strategy()->set_deleted(false); - LOG(Api,Info,"Un-deleting security {}", security.id()); - auto id = security.id(); - update_security_metadata(newmeta, [id,reply](const UpdateResult& result) { - if (result.error() == UpdateResult::ERROR_OK) { - // undelete was successful. Metadata update will make this visible again - send_reply(reply, CreateResult::ERROR_OK, id); - } - else { - LOG(Api,Info,"Failed to un-delete security {}. Error {}", id, result.error()); - send_reply(reply, CreateResult::ERROR_SECURITY_ALREADY_EXISTS, id); - } - }); - } - else { - send_reply(reply, CreateResult::ERROR_SECURITY_ALREADY_EXISTS, security.id()); - } - } - else { - _me->synthetics.insert(std::make_pair(security.id(), security)); - _me->on_security.publish(security); - // signal success - send_reply(reply, CreateResult::ERROR_OK, security.id()); - } - }); + _me->recorder.assign_key( + security, [this, reply](const api::Security &security) { + // Notify listeners that a new security is added + auto iter = _me->synthetics.find(SecurityKey(security.id())); + if (iter != _me->synthetics.end()) { + auto metadata = get_metadata(iter->first); + if (metadata && metadata->strategy().deleted()) { + // If this security is deleted we can just undelete it + Metadata newmeta; + // Rather than copy from the existing metatdata create a + // default. The existing metadata is from a deleted spread so + // may not be valid UI will call update_security_metadata if + // non-defaults are needed + newmeta.set_security_key(security.id()); + newmeta.mutable_strategy()->set_deleted(false); + LOG(Api, Info, "Un-deleting security {}", security.id()); + auto id = security.id(); + update_security_metadata( + newmeta, [id, reply](const UpdateResult &result) { + if (result.error() == UpdateResult::ERROR_OK) { + // undelete was successful. Metadata update will make + // this visible again + send_reply(reply, CreateResult::ERROR_OK, id); + } else { + LOG(Api, Info, + "Failed to un-delete security {}. Error {}", id, + result.error()); + send_reply( + reply, + CreateResult::ERROR_SECURITY_ALREADY_EXISTS, id); + } + }); + } else { + send_reply( + reply, CreateResult::ERROR_SECURITY_ALREADY_EXISTS, + security.id()); + } + } else { + _me->synthetics.insert(std::make_pair(security.id(), security)); + _me->on_security.publish(security); + // signal success + send_reply(reply, CreateResult::ERROR_OK, security.id()); + } + }); } void SyntheticSecurityService::update_security_metadata( - const Metadata& request, - const api::Response& reply) { - UpdateResult result; - if (request.security_key() == md::invalid_security_key) { - result.set_error(UpdateResult::ERROR_MISSING_KEY); - reply(result); - return; - } - auto key = SecurityKey(request.security_key()); - if (_me->synthetics.find(key) == _me->synthetics.end()) { - result.set_error(UpdateResult::ERROR_UNKNOWN_SECURITY); - reply(result); - return; - } - // update the on disk database - if (!md::db::store_metadata(request)) { - result.set_error(UpdateResult::ERROR_DATABASE); - reply(result); - return; - } - // update the local database - _me->meta[key] = request; - // notify subscribers - _me->on_metadata.publish(request); - _me->metadata_publisher.add_or_update(request); - _me->metadata_publisher.flush(); - LOG(md, Info, "Update synthetic security key={} response={}", key, UpdateResult::Error_Name(result.error())); - + const Metadata &request, const api::Response &reply) { + UpdateResult result; + if (request.security_key() == md::invalid_security_key) { + result.set_error(UpdateResult::ERROR_MISSING_KEY); reply(result); + return; + } + auto key = SecurityKey(request.security_key()); + if (_me->synthetics.find(key) == _me->synthetics.end()) { + result.set_error(UpdateResult::ERROR_UNKNOWN_SECURITY); + reply(result); + return; + } + // update the on disk database + if (!md::db::store_metadata(request)) { + result.set_error(UpdateResult::ERROR_DATABASE); + reply(result); + return; + } + // update the local database + _me->meta[key] = request; + // notify subscribers + _me->on_metadata.publish(request); + _me->metadata_publisher.add_or_update(request); + _me->metadata_publisher.flush(); + LOG(md, Info, "Update synthetic security key={} response={}", key, + UpdateResult::Error_Name(result.error())); + + reply(result); } void SyntheticSecurityService::query_security_metadata( - const MetadataQuery& request, - const api::Response& reply) { + const MetadataQuery &request, + const api::Response &reply) { MetadataCollection result; for (const auto k : request.security_key()) { @@ -213,7 +218,8 @@ void SyntheticSecurityService::query_security_metadata( reply(result); } - -}}}//namespace +} // namespace synthetic +} // namespace api +} // namespace bts #endif diff --git a/src/lib/md/SyntheticSecurityService.h b/src/lib/md/SyntheticSecurityService.h index 32b169192..c7e091c74 100644 --- a/src/lib/md/SyntheticSecurityService.h +++ b/src/lib/md/SyntheticSecurityService.h @@ -1,49 +1,45 @@ #pragma once -#include "lib/md/common.h" +#include "ISyntheticSecurityService.h" #include "lib/api/services/SyntheticSecurityService.pb.h" #include "lib/api/services/SyntheticSecurityService.server.pb.h" #include "lib/domain_model/SecurityKey.h" -#include "ISyntheticSecurityService.h" +#include "lib/md/common.h" #include #include - namespace bts { namespace api { namespace synthetic { - -class SyntheticSecurityService : - private api::synthetic::SyntheticSecurityServiceBase, - public ISyntheticSecurityService -{ +class SyntheticSecurityService + : private api::synthetic::SyntheticSecurityServiceBase, + public ISyntheticSecurityService { struct Pimpl; std::unique_ptr _me; -public: - SyntheticSecurityService(api::ServiceContext& context); + public: + SyntheticSecurityService(api::ServiceContext &context); ~SyntheticSecurityService(); const std::unordered_map securities() override; - utils::EventSubscriber& on_securities() override; - const Metadata* get_metadata(SecurityKey) override; - utils::EventSubscriber& on_metadata() override; + utils::EventSubscriber &on_securities() override; + const Metadata *get_metadata(SecurityKey) override; + utils::EventSubscriber &on_metadata() override; - private: - void create_synthetic( - const Security& request, - const api::Response& reply) override; + private: + void create_synthetic( + const Security &request, + const api::Response &reply) override; - void update_security_metadata( - const Metadata& request, - const api::Response& reply) override; - - void query_security_metadata( - const MetadataQuery& request, - const api::Response& reply) override; + void update_security_metadata( + const Metadata &request, + const api::Response &reply) override; + void query_security_metadata( + const MetadataQuery &request, + const api::Response &reply) override; }; -}}}//namespace - - +} // namespace synthetic +} // namespace api +} // namespace bts diff --git a/src/lib/md/UserSymbol.h b/src/lib/md/UserSymbol.h index b7e7b701a..e384e3544 100644 --- a/src/lib/md/UserSymbol.h +++ b/src/lib/md/UserSymbol.h @@ -6,27 +6,27 @@ namespace md { struct UserSymbol { UserSymbol() : _symbol(), _exchange(), _type() {} - UserSymbol(const std::string& s, api::Venue e, SecurityType t) : - _symbol(s), _exchange(e), _type(t) {} - UserSymbol(const UserSymbol& other) : - _symbol(other._symbol), _exchange(other._exchange), _type(other._type) {} + UserSymbol(const std::string &s, api::Venue e, SecurityType t) + : _symbol(s), _exchange(e), _type(t) {} + UserSymbol(const UserSymbol &other) + : _symbol(other._symbol), _exchange(other._exchange), + _type(other._type) {} - const std::string& symbol() const { return _symbol; } + const std::string &symbol() const { return _symbol; } api::Venue exchange() const { return _exchange; } SecurityType type() const { return _type; } - bool operator== (const UserSymbol& other) const { - return _type == other.type() && _exchange == other.exchange() && _symbol == other.symbol(); + bool operator==(const UserSymbol &other) const { + return _type == other.type() && _exchange == other.exchange() && + _symbol == other.symbol(); } - bool operator< (const UserSymbol& other) const { + bool operator<(const UserSymbol &other) const { if (_type < other.type()) { return true; - } - else { + } else { if (_type == other.type()) { if (_exchange < other.exchange()) { return true; - } - else { + } else { if (_exchange == other.exchange()) { return _symbol < other.symbol(); } @@ -49,15 +49,16 @@ struct UserSymbol { } // No move constructor - - // because in this case the std::string will be a stock symbol which should be - // small enough to be inlined in both msvsc and gcc/clang + // because in this case the std::string will be a stock symbol which should + // be small enough to be inlined in both msvsc and gcc/clang -private: + private: std::string _symbol; api::Venue _exchange; SecurityType _type; }; -std::ostream& operator<<(std::ostream& os, const UserSymbol& sym); +std::ostream &operator<<(std::ostream &os, const UserSymbol &sym); -}} +} // namespace md +} // namespace bts diff --git a/src/lib/md/cme/MDP3Utils.cpp b/src/lib/md/cme/MDP3Utils.cpp index 46afaa8f4..966f362ea 100644 --- a/src/lib/md/cme/MDP3Utils.cpp +++ b/src/lib/md/cme/MDP3Utils.cpp @@ -2,20 +2,19 @@ #include "MDP3Utils.h" #include "lib/config/config.h" -#include "lib/utils/datetime.h" -#include "lib/utils/bts_chrono.h" -#include "lib/utils/download.h" #include "lib/logging/logging.h" #include "lib/md/get_symbols.h" +#include "lib/utils/bts_chrono.h" +#include "lib/utils/datetime.h" +#include "lib/utils/download.h" #include "lib/config/protos/MarketData.pb.h" #include "lib/config/protos/system.pb.h" #include -#include #include #include - +#include using namespace std; using namespace bts::api; @@ -23,31 +22,30 @@ using namespace bts::api; namespace bts { namespace md { -std::ostream& operator<<(std::ostream&out, md::CMEConnection const&c) -{ - out << "feed_type: " << c.feed_type - << " ip: " << c.ip - << " port: " << c.port +std::ostream &operator<<(std::ostream &out, md::CMEConnection const &c) { + out << "feed_type: " << c.feed_type << " ip: " << c.ip << " port: " << c.port << " feed: " << c.feed; return out; } -std::ostream& operator<<(std::ostream&out, md::CMEChannel const &ch) { +std::ostream &operator<<(std::ostream &out, md::CMEChannel const &ch) { out << "id: " << ch.id << "\n"; out << "symbols: \n"; for (auto s : ch.symbols) - out << "\t" << s.symbol() << ":" << api::SecurityType_Name(s.type()) << "\n" ; + out << "\t" << s.symbol() << ":" << api::SecurityType_Name(s.type()) + << "\n"; out << "Connections:\n"; - for (auto const &[st,c] : ch.connections) + for (auto const &[st, c] : ch.connections) out << "\t" << st << " -> {" << c << "}\n"; out << "\n"; return out; } - + string data_path() { auto p = config::get().data_path() + "cme_mdp3/"; #ifdef _WIN32 - // OnixS requires win32 paths to look like Win32 paths - everyone else in the world is ok with '/' + // OnixS requires win32 paths to look like Win32 paths - everyone else in the + // world is ok with '/' os::normalize_path(p, '\\'); #else os::normalize_path(p); @@ -56,15 +54,16 @@ string data_path() { } const string config_path() { return data_path() + "config.xml"; } const string template_path() { return data_path() + "templates.xml"; } -const std::string log_path() {return log:: log_path().string() + "/onix";} +const std::string log_path() { return log::log_path().string() + "/onix"; } -bool check_file_exists_with_instructions(const string& filename, const string& url, bool log) { +bool check_file_exists_with_instructions( + const string &filename, const string &url, bool log) { if (!boost::filesystem::exists(filename)) { download_file(url.c_str(), filename.c_str()); } if (!boost::filesystem::exists(filename)) { if (log) { - LOG(md,Error, + LOG(md, Error, "File {} is not present on this system. " "Please download it from the CME ftp site. " "I will wait until the file is present.\n$ curl {} > {} ", @@ -81,52 +80,62 @@ bool is_pow_two_or_0(uint32_t x) { return (x & (~x + 1)) == x; } void await_cme_config() { static std::mutex config_mutex; std::lock_guard guard(config_mutex); - std::string config_url; + std::string config_url; std::string templates_url; if (config::get().type() != "dev") { - config_url = "ftp://ftp.cmegroup.com/SBEFix/Production/Configuration/config.xml"; - templates_url = "ftp://ftp.cmegroup.com/SBEFix/Production/Templates/templates_FixBinary.xml"; - } - else { - config_url = "ftp://ftp.cmegroup.com/SBEFix/Cert/Configuration/config.xml"; - templates_url = "ftp://ftp.cmegroup.com/SBEFix/Cert/Templates/templates_FixBinary.xml"; + config_url = + "ftp://ftp.cmegroup.com/SBEFix/Production/Configuration/config.xml"; + templates_url = "ftp://ftp.cmegroup.com/SBEFix/Production/Templates/" + "templates_FixBinary.xml"; + } else { + config_url = + "ftp://ftp.cmegroup.com/SBEFix/Cert/Configuration/config.xml"; + templates_url = "ftp://ftp.cmegroup.com/SBEFix/Cert/Templates/" + "templates_FixBinary.xml"; } boost::filesystem::create_directories(data_path()); boost::filesystem::create_directories(log_path()); // Check config is present and give instructions for downloading it if not - // If the file is not present log an error and wait a second. Continue to log the error ever power of 2 seconds until the file appears or the process is killed. + // If the file is not present log an error and wait a second. Continue to log + // the error ever power of 2 seconds until the file appears or the process is + // killed. uint32_t count = 0; - while(!check_file_exists_with_instructions(config_path(), config_url, is_pow_two_or_0(count))) { + while (!check_file_exists_with_instructions( + config_path(), config_url, is_pow_two_or_0(count))) { ++count; std::this_thread::sleep_for(1s); } count = 0; - while(!check_file_exists_with_instructions(template_path(), templates_url, is_pow_two_or_0(count))) { + while (!check_file_exists_with_instructions( + template_path(), templates_url, is_pow_two_or_0(count))) { ++count; std::this_thread::sleep_for(1s); } - // If we waited for someone to download the file give it a second to be finished downloading + // If we waited for someone to download the file give it a second to be + // finished downloading if (count > 0) { std::this_thread::sleep_for(1s); } } -SecurityType infer_security_type(const string& label) { +SecurityType infer_security_type(const string &label) { if (label.find("Option") != std::string::npos) { return SECURITYTYPE_OPTION; } - + if (label.find("Future") != std::string::npos) { return SECURITYTYPE_FUTURE; } // TODO: Allow configuration to override this? - LOG(md,Warn,"Unable to guess security type from label: '{}" - "' Treating as OPTION.",label); + LOG(md, Warn, + "Unable to guess security type from label: '{}" + "' Treating as OPTION.", + label); return SECURITYTYPE_OPTION; } @@ -136,44 +145,49 @@ const std::vector get_configured_cme_channels() { get_system_md_symbols(api::VENUE_GLBX, api::SECURITYTYPE_UNSET, &symbols); return parse_channels(symbols); } -const vector parse_channels(const vector& symbols) { +const vector parse_channels(const vector &symbols) { await_cme_config(); vector result; bool skip_options = config::get().skip_options(); pugi::xml_document doc; - bts_assert_msg(doc.load_file(config_path().c_str()), "Error parsing config.xml as xml"); + bts_assert_msg( + doc.load_file(config_path().c_str()), "Error parsing config.xml as xml"); auto configuration = doc.root().child("configuration"); bts_assert(configuration); - LOG(md,Info,"CME: Loaded '{}' config. Last updated: {}" , + LOG(md, Info, "CME: Loaded '{}' config. Last updated: {}", std::string(configuration.attribute("environment").as_string("??")), std::string(configuration.attribute("updated").as_string("??"))); auto channels = configuration.children("channel"); - for (const auto& chan : channels) { + for (const auto &chan : channels) { CMEChannel channel; channel.id = chan.attribute("id").as_string(); - auto channel_type = infer_security_type(chan.attribute("label").as_string()); - if (channel_type == SECURITYTYPE_OPTION && skip_options) continue; + auto channel_type = + infer_security_type(chan.attribute("label").as_string()); + if (channel_type == SECURITYTYPE_OPTION && skip_options) + continue; if (!(channel.id.empty())) { auto product_list = chan.child("products").children("product"); - for (const auto& product : product_list) { + for (const auto &product : product_list) { auto symbol = product.attribute("code").as_string(); for (auto s : symbols) { - if ((s.type() == channel_type || s.type() == SECURITYTYPE_SPREAD) - && s.symbol() == symbol) { - channel.symbols.insert(s); + if ((s.type() == channel_type || + s.type() == SECURITYTYPE_SPREAD) && + s.symbol() == symbol) { + channel.symbols.insert(s); } } } if (!channel.symbols.empty()) { auto connections = chan.child("connections").children("connection"); - for (const auto& srccon : connections) { + for (const auto &srccon : connections) { std::string id = srccon.attribute("id").as_string(); if (!id.empty()) { CMEConnection connection; - connection.feed_type = srccon.child("type").attribute("feed-type").as_string(); + connection.feed_type = + srccon.child("type").attribute("feed-type").as_string(); connection.ip = srccon.child_value("ip"); connection.port = srccon.child("port").text().as_uint(); connection.feed = srccon.child_value("feed")[0]; @@ -185,10 +199,10 @@ const vector parse_channels(const vector& symbols) { } } } - + return result; } - -}} //namespace +} // namespace md +} // namespace bts #endif diff --git a/src/lib/md/cme/MDP3Utils.h b/src/lib/md/cme/MDP3Utils.h index 10378855f..17ffb43ce 100644 --- a/src/lib/md/cme/MDP3Utils.h +++ b/src/lib/md/cme/MDP3Utils.h @@ -2,8 +2,8 @@ #include "lib/md/coconut2.h" #include "lib/utils/optional.h" -#include #include +#include #include namespace bts { @@ -22,87 +22,104 @@ struct CMEChannel { std::map connections; }; -std::ostream& operator<<(std::ostream&out, md::CMEConnection const&c); -std::ostream& operator<<(std::ostream&out, md::CMEChannel const &ch); +std::ostream &operator<<(std::ostream &out, md::CMEConnection const &c); +std::ostream &operator<<(std::ostream &out, md::CMEChannel const &ch); void await_cme_config(); const std::vector get_configured_cme_channels(); -const std::vector parse_channels(const std::vector& symbols); +const std::vector +parse_channels(const std::vector &symbols); const std::string config_path(); const std::string template_path(); const std::string log_path(); -inline void decode_ticks(int vtt, double mintick, FixedSecurity& dest) { - switch(vtt) { - default: - case 0: - dest.low_tick = mintick; - dest.high_tick = mintick; - dest.price_break = 0; - break; - case 1: - dest.price_break = 500; - dest.low_tick = 5; - dest.high_tick = 10; - break; - case 2: - dest.price_break = 5; - dest.low_tick = 0.5; - dest.high_tick = 1; - break; - case 3: - dest.price_break = 10; - dest.low_tick = 1; - dest.high_tick = 2; - break; - case 4: - dest.price_break = 500; - dest.low_tick = 5; - dest.high_tick = 25; - break; - case 10: - dest.price_break = 300; - dest.low_tick = 5; - dest.high_tick = 25; - break; - case 11: - dest.price_break = 300; - dest.low_tick = 5; - dest.high_tick = 10; - break; - case 12: - dest.price_break = 5; - dest.low_tick = 0.25; - dest.high_tick = 0.5; - break; +inline void decode_ticks(int vtt, double mintick, FixedSecurity &dest) { + switch (vtt) { + default: + case 0: + dest.low_tick = mintick; + dest.high_tick = mintick; + dest.price_break = 0; + break; + case 1: + dest.price_break = 500; + dest.low_tick = 5; + dest.high_tick = 10; + break; + case 2: + dest.price_break = 5; + dest.low_tick = 0.5; + dest.high_tick = 1; + break; + case 3: + dest.price_break = 10; + dest.low_tick = 1; + dest.high_tick = 2; + break; + case 4: + dest.price_break = 500; + dest.low_tick = 5; + dest.high_tick = 25; + break; + case 10: + dest.price_break = 300; + dest.low_tick = 5; + dest.high_tick = 25; + break; + case 11: + dest.price_break = 300; + dest.low_tick = 5; + dest.high_tick = 10; + break; + case 12: + dest.price_break = 5; + dest.low_tick = 0.25; + dest.high_tick = 0.5; + break; } } inline int floorlog10(int64_t m) { bts_assert(m >= 0); - if (m < 10) return 0; - if (m < 100) return 1; - if (m < 1000) return 2; - if (m < 10000) return 3; - if (m < 100000) return 4; - if (m < 1000000) return 5; - if (m < 10000000) return 6; - if (m < 100000000) return 7; - if (m < 1000000000) return 8; - if (m < 10000000000) return 9; - if (m < 100000000000) return 10; - if (m < 1000000000000) return 11; - if (m < 10000000000000) return 12; - if (m < 100000000000000) return 13; - if (m < 1000000000000000) return 14; - if (m < 10000000000000000) return 15; - if (m < 100000000000000000) return 16; - if (m < 1000000000000000000) return 17; + if (m < 10) + return 0; + if (m < 100) + return 1; + if (m < 1000) + return 2; + if (m < 10000) + return 3; + if (m < 100000) + return 4; + if (m < 1000000) + return 5; + if (m < 10000000) + return 6; + if (m < 100000000) + return 7; + if (m < 1000000000) + return 8; + if (m < 10000000000) + return 9; + if (m < 100000000000) + return 10; + if (m < 1000000000000) + return 11; + if (m < 10000000000000) + return 12; + if (m < 100000000000000) + return 13; + if (m < 1000000000000000) + return 14; + if (m < 10000000000000000) + return 15; + if (m < 100000000000000000) + return 16; + if (m < 1000000000000000000) + return 17; return 19; } - - -}}//namespace - +} // namespace md +} // namespace bts diff --git a/src/lib/md/coconut2.h b/src/lib/md/coconut2.h index 4195a0a40..50962432f 100644 --- a/src/lib/md/coconut2.h +++ b/src/lib/md/coconut2.h @@ -1,12 +1,11 @@ -#include "common.h" #include "PlatformLoader.h" +#include "common.h" -#include "MDProducer.h" #include "MDConsumer.h" -#include "Shm/FixedSecurity.h" +#include "MDProducer.h" #include "SecurityIDRecorder.h" #include "SettlementRecorder.h" +#include "Shm/FixedSecurity.h" // TODO: separate coconut2.h into consumer and producer sides #include "SecurityIndex.h" - diff --git a/src/lib/md/common.cpp b/src/lib/md/common.cpp index c7f073647..6380c8e8a 100644 --- a/src/lib/md/common.cpp +++ b/src/lib/md/common.cpp @@ -7,36 +7,35 @@ #include "lib/config/protos/MarketData.pb.h" #include -#include #include +#include namespace bts { - namespace md { +namespace md { - const double NO_PRICE = std::numeric_limits().quiet_NaN(); - const char* SYNTHETIC_SYMBOL = "SYNTHETIC"; +const double NO_PRICE = std::numeric_limits().quiet_NaN(); +const char *SYNTHETIC_SYMBOL = "SYNTHETIC"; - std::ostream& operator<<(std::ostream& os, const UserSymbol& sym) { - os << sym.symbol() << "-" << api::SecurityType_Name(sym.type()); - return os; - } +std::ostream &operator<<(std::ostream &os, const UserSymbol &sym) { + os << sym.symbol() << "-" << api::SecurityType_Name(sym.type()); + return os; +} - } +} // namespace md - namespace co2 { - using namespace std; - using namespace md; - string topic(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) << "/" - << symbol << "/" - << api::SecurityType_Name(type) << "/" - << data_type; - return topic.str(); - } - } +namespace co2 { +using namespace std; +using namespace md; +string topic( + 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) << "/" + << symbol << "/" << api::SecurityType_Name(type) << "/" << data_type; + return topic.str(); +} +} // namespace co2 -}//namespace +} // namespace bts #endif diff --git a/src/lib/md/common.h b/src/lib/md/common.h index 06f07b294..07b763abd 100644 --- a/src/lib/md/common.h +++ b/src/lib/md/common.h @@ -1,41 +1,39 @@ #pragma once #include +#include "IntPrice.h" +#include "lib/domain_model/SecurityKey.h" #include "lib/utils/bts_export.h" #include "lib/utils/datetime.h" -#include "lib/domain_model/SecurityKey.h" -#include "IntPrice.h" -#include "lib/md/protos/co2.pb.h" #include "lib/domain_model/Security.pb.h" +#include "lib/md/protos/co2.pb.h" #include namespace bts { namespace md { - const extern char* SYNTHETIC_SYMBOL; +const extern char *SYNTHETIC_SYMBOL; - typedef uint32_t security_key; - const security_key invalid_security_key = 0; +typedef uint32_t security_key; +const security_key invalid_security_key = 0; - // Bring in o2 types - using api::Security; - using bts::co2::Platform; - using bts::co2::TradingStatus; - using bts::co2::CoconutSecurityStatus; - using bts::api::Side; - using api::Venue; - using api::SecurityType; +// Bring in o2 types +using api::Security; +using api::SecurityType; +using api::Venue; +using bts::api::Side; +using bts::co2::CoconutSecurityStatus; +using bts::co2::Platform; +using bts::co2::TradingStatus; - SecurityType securitytype_of(const Security&); -} +SecurityType securitytype_of(const Security &); +} // namespace md namespace co2 { - std::string topic(const char* data_type, const std::string& symbol, api::SecurityType type, api::Venue exchange, Platform platform); +std::string topic( + const char *data_type, const std::string &symbol, api::SecurityType type, + api::Venue exchange, Platform platform); } - -}//namespace - - - +} // namespace bts diff --git a/src/lib/md/get_symbols.h b/src/lib/md/get_symbols.h index d0226432d..6cccfe2a4 100644 --- a/src/lib/md/get_symbols.h +++ b/src/lib/md/get_symbols.h @@ -1,7 +1,7 @@ #pragma once #include "UserSymbol.h" -#include "lib/utils/bts_export.h" #include "lib/config/protos/MarketData.pb.h" +#include "lib/utils/bts_export.h" #include #include @@ -9,10 +9,14 @@ namespace bts { namespace md { std::set get_system_md_symbols(); -size_t get_system_md_symbols(api::Venue, api::SecurityType, std::vector* result); -size_t get_system_md_symbols(api::Venue, api::SecurityType, std::set& out_result); -size_t get_system_md_symbols(const md::PlatformConfig& config, std::set& out_result); -size_t get_system_md_symbols(std::set& result); +size_t get_system_md_symbols( + api::Venue, api::SecurityType, std::vector *result); +size_t get_system_md_symbols( + api::Venue, api::SecurityType, std::set &out_result); +size_t get_system_md_symbols( + const md::PlatformConfig &config, std::set &out_result); +size_t get_system_md_symbols(std::set &result); extern "C" BTS_EXPORT Platform platform_for_exchange(api::Venue exchange); -}} +} // namespace md +} // namespace bts diff --git a/src/lib/md/ice/ICEUtils.cpp b/src/lib/md/ice/ICEUtils.cpp index 98d7a6600..9434d7dcc 100644 --- a/src/lib/md/ice/ICEUtils.cpp +++ b/src/lib/md/ice/ICEUtils.cpp @@ -2,11 +2,11 @@ #include "ICEUtils.h" #include "lib/config/config.h" -#include "lib/utils/datetime.h" -#include "lib/utils/bts_chrono.h" -#include "lib/utils/download.h" #include "lib/logging/logging.h" #include "lib/md/get_symbols.h" +#include "lib/utils/bts_chrono.h" +#include "lib/utils/datetime.h" +#include "lib/utils/download.h" #include "lib/config/protos/MarketData.pb.h" #include "lib/config/protos/system.pb.h" @@ -14,70 +14,74 @@ #include #include - using namespace std; using namespace bts::api; namespace bts { namespace md { namespace ice { - -std::string ICEChannel::to_string() const -{ + +std::string ICEChannel::to_string() const { std::string mt = name; - for(const auto& x : market_types) + for (const auto &x : market_types) + mt += " " + std::to_string(x); + for (const auto &x : uds_market_types) mt += " " + std::to_string(x); - for(const auto& x : uds_market_types) - mt += " " + std::to_string(x); return mt; } -//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 -const vector parse_ice_channels(const vector& symbols) -{ +// 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 +const vector parse_ice_channels(const vector &symbols) { vector result; - const auto& ice_options = config::get(); - for(const auto& x : ice_options.channel()) - { + const auto &ice_options = config::get(); + for (const auto &x : ice_options.channel()) { md::ice::ICEChannel chan; chan.name = x.name(); chan.symbols.insert(symbols.begin(), symbols.end()); - for(const auto& xx : x.market_type()) - chan.market_types.push_back(xx); - for(const auto& xx : x.uds_market_type()) - chan.uds_market_types.push_back(xx); - - result.push_back(chan); + for (const auto &xx : x.market_type()) + chan.market_types.push_back(xx); + for (const auto &xx : x.uds_market_type()) + chan.uds_market_types.push_back(xx); + + result.push_back(chan); } return result; } - string ice_data_path() { auto p = config::get().data_path() + "onixs_ice/"; #ifdef _WIN32 - // OnixS requires win32 paths to look like Win32 paths - everyone else in the world is ok with '/' + // OnixS requires win32 paths to look like Win32 paths - everyone else in the + // world is ok with '/' os::normalize_path(p, '\\'); #else os::normalize_path(p); #endif return p; } -const string ice_config_file() { return config::get().ice_config_file(); } -const string ice_config_path() { return ice_data_path() + "/" + ice_config_file(); } +const string ice_config_file() { + return config::get().ice_config_file(); +} +const string ice_config_path() { + return ice_data_path() + "/" + ice_config_file(); +} -const std::string ice_log_path() {return log:: log_path().string() + "/onix_ice";} +const std::string ice_log_path() { + return log::log_path().string() + "/onix_ice"; +} -bool ice_check_file_exists_with_instructions(const string& filename, const string& url, bool log) { +bool ice_check_file_exists_with_instructions( + const string &filename, const string &url, bool log) { // if (!boost::filesystem::exists(filename)) { // download_file(url.c_str(), filename.c_str()); // } if (!boost::filesystem::exists(filename)) { if (log) { - LOG(md,Error, + LOG(md, Error, "File {} is not present on this system. " "Please download it from the ICE web site. " "I will wait until the file is present.\n$ curl {} > {} ", @@ -92,12 +96,12 @@ bool ice_check_file_exists_with_instructions(const string& filename, const strin bool is_pow_two_or_0(uint32_t x) { return (x & (~x + 1)) == x; } void await_ice_config() { - std::string config_url; + std::string config_url; if (config::get().type() != "dev") { - config_url = "https://drive.google.com/open?id=13_eyF2pKtn3F7chgsa_75ftUdf7emMbp"; - } - else { + config_url = + "https://drive.google.com/open?id=13_eyF2pKtn3F7chgsa_75ftUdf7emMbp"; + } else { config_url = "https://community.theice.com/docs/DOC-19989"; } @@ -105,20 +109,23 @@ void await_ice_config() { boost::filesystem::create_directories(ice_log_path()); // Check config is present and give instructions for downloading it if not - // If the file is not present log an error and wait a second. Continue to log the error ever power of 2 seconds until the file appears or the process is killed. + // If the file is not present log an error and wait a second. Continue to log + // the error ever power of 2 seconds until the file appears or the process is + // killed. auto configpath = ice_config_path(); uint32_t count = 0; - while(!ice_check_file_exists_with_instructions(configpath, config_url, is_pow_two_or_0(count))) { + while (!ice_check_file_exists_with_instructions( + configpath, config_url, is_pow_two_or_0(count))) { ++count; std::this_thread::sleep_for(1s); } - // If we waited for someone to download the file give it a second to be finished downloading + // If we waited for someone to download the file give it a second to be + // finished downloading if (count > 0) { std::this_thread::sleep_for(1s); } } - const std::vector get_configured_ice_channels() { std::vector symbols; // Get all ice symbols @@ -126,6 +133,7 @@ const std::vector get_configured_ice_channels() { return parse_ice_channels(symbols); } - -}}} //namespace +} // namespace ice +} // namespace md +} // namespace bts #endif diff --git a/src/lib/md/ice/ICEUtils.h b/src/lib/md/ice/ICEUtils.h index 7ce5f78b9..3ef8bb04b 100644 --- a/src/lib/md/ice/ICEUtils.h +++ b/src/lib/md/ice/ICEUtils.h @@ -1,16 +1,15 @@ #pragma once #include "lib/md/coconut2.h" -#include #include +#include #include namespace bts { namespace md { -namespace ice { +namespace ice { -struct ICEChannel -{ +struct ICEChannel { std::string name; std::vector market_types; std::vector uds_market_types; @@ -20,11 +19,12 @@ struct ICEChannel void await_ice_config(); const std::vector get_configured_ice_channels(); -const std::vector parse_ice_channels(const std::vector& symbols); +const std::vector +parse_ice_channels(const std::vector &symbols); const std::string ice_config_path(); const std::string ice_log_path(); - -}}} //namespace - +} // namespace ice +} // namespace md +} // namespace bts diff --git a/src/lib/md/relay/QueryServer.cpp b/src/lib/md/relay/QueryServer.cpp index e404ff2b1..53ea8fdb1 100644 --- a/src/lib/md/relay/QueryServer.cpp +++ b/src/lib/md/relay/QueryServer.cpp @@ -1,45 +1,45 @@ #ifndef _WIN32 #include "QueryServer.h" #include "lib/config/config.h" +#include "lib/utils/AuthToken.h" #include "lib/utils/Dispatcher.h" #include "lib/utils/TimeStamp.h" #include "lib/utils/helper_macros.h" -#include "lib/utils/AuthToken.h" -#include "../MDConsumer.h" -#include "../MDClient.h" -#include "../PlatformLoader.h" #include "../MBOProcessor.h" +#include "../MDClient.h" +#include "../MDConsumer.h" +#include "../PlatformLoader.h" #include "lib/logging/logging.h" -#include "lib/config/protos/system.pb.h" -#include "lib/md/protos/co2.pb.h" -#include "lib/md/SecurityCache.h" #include "lib/api/apicore.pb.h" -#include "lib/api/services/MarketDataRelay.server.pb.h" #include "lib/api/public/ServiceContext.h" -#include "lib/api/services/AdminService.client.pb.h" #include "lib/api/service_helpers/AdminServiceUtils.h" +#include "lib/api/services/AdminService.client.pb.h" +#include "lib/api/services/MarketDataRelay.server.pb.h" #include "lib/config/protos/cme_reference_data.pb.h" +#include "lib/config/protos/system.pb.h" +#include "lib/md/SecurityCache.h" +#include "lib/md/protos/co2.pb.h" #include "lib/utils/ConcurrentAppendCollection.h" #ifndef _WIN32 #include "lib/metrics/metrics.h" #endif -#include #include #include +#include #include #include -#include +#include -#include #include +#include using namespace bts::co2; -using std::unique_ptr; using std::shared_ptr; +using std::unique_ptr; namespace bts { namespace md { @@ -49,24 +49,27 @@ namespace md { * Client sends time=0 to server * Server sends complete snapshot back (time=502) * client sends time=502 to server - * Server sends any changes that have happened after time=502 and any securities discovered since time=502 - * + * Server sends any changes that have happened after time=502 and any securities + * discovered since time=502 + * * ERROR RECOVERY: * Client sends time=0 to server * Server sends complete snapshot back (time=502) * Server detects heartbeat failure and recovers. All timestamps > 502 * Client sends time=502 to server * Server sends complete snapshot back (time=605) - * - Since the server shared memory has been recreated the client will automatically overwrite all stale data. + * - Since the server shared memory has been recreated the client will + * automatically overwrite all stale data. * - If a security has been deleted the client will leave it frozen (OK) - * + * * We scan for bad heartbeats on a different time * If a bad heartbeat is detected we try to construct a new Consumer - * When a good consumer is created we std::move the old consumer and handles to delayed queue for deletion - * This way we don't have to lock anything during the recovery process because all pointers will remain valid - * for the duration of existing calls. - * -*/ + * When a good consumer is created we std::move the old consumer and handles to + * delayed queue for deletion This way we don't have to lock anything during the + * recovery process because all pointers will remain valid for the duration of + * existing calls. + * + */ struct DatedHandle { TimeStamp discovered; MDConsumerHandle handle; @@ -74,244 +77,272 @@ struct DatedHandle { struct MDConsumerGroup { // probably just have to send the consumer in from outside - MDConsumerGroup(const UserSymbol& symbol, const MDConsumer& consumer, metrics::MetricsContainer& stats) : - symbol(symbol), - platform(platform_for_exchange(symbol.exchange())), - channel(consumer.get_channel(symbol)), - handles(), - mic() - { + MDConsumerGroup( + const UserSymbol &symbol, const MDConsumer &consumer, + metrics::MetricsContainer &stats) + : symbol(symbol), platform(platform_for_exchange(symbol.exchange())), + channel(consumer.get_channel(symbol)), handles(), mic() { set_consumer(consumer); - + // create and publish a stat for this group #ifndef _WIN32 if (symbol.type() != SecurityType::SECURITYTYPE_SYNTHETIC) { std::vector labels; - labels.push_back({ "symbol", symbol.symbol() }); - labels.push_back({ "type", SecurityType_Name(symbol.type()).substr(13) /*SECURITYTYPE_*/ }); - labels.push_back({ "exch", Venue_Name(symbol.exchange()).substr(6) /*VENUE_*/ }); - stats.publish( - std::make_shared("spark_md_book_updates", [=]() { - return channel.direct_count() + channel.implied_count(); - }, labels)); - stats.publish( - std::make_shared("spark_md_security_count", [=]() { return channel.security_count(); }, labels)); - stats.publish( - std::make_shared("spark_md_trade_count", [=]() { return channel.trade_count(); }, labels)); - stats.publish( - std::make_shared("spark_md_gap_count", [=]() { auto g = channel.gap_count(); return g == 0 ? os::nan() : g; }, labels)); + labels.push_back({"symbol", symbol.symbol()}); + labels.push_back( + {"type", + SecurityType_Name(symbol.type()).substr(13) /*SECURITYTYPE_*/}); + labels.push_back( + {"exch", Venue_Name(symbol.exchange()).substr(6) /*VENUE_*/}); + stats.publish(std::make_shared( + "spark_md_book_updates", + [=]() { return channel.direct_count() + channel.implied_count(); }, + labels)); + stats.publish(std::make_shared( + "spark_md_security_count", + [=]() { return channel.security_count(); }, labels)); + stats.publish(std::make_shared( + "spark_md_trade_count", [=]() { return channel.trade_count(); }, + labels)); + stats.publish(std::make_shared( + "spark_md_gap_count", + [=]() { + auto g = channel.gap_count(); + return g == 0 ? os::nan() : g; + }, + labels)); } #endif } - MDConsumerGroup(const MDConsumerGroup& other) = delete; + MDConsumerGroup(const MDConsumerGroup &other) = delete; - // recovery has occured and we need to clear our our collection of handles and wait for new ones - void set_consumer(const MDConsumer& consumer) { + // recovery has occured and we need to clear our our collection of handles + // and wait for new ones + void set_consumer(const MDConsumer &consumer) { // create a new set of handles and swap with the old. - // If the new consumer is bad we still have to swap our handles because the consumer that owns our handles will be scheduled for deletion - auto temphandles = std::make_shared>(); + // If the new consumer is bad we still have to swap our handles because + // the consumer that owns our handles will be scheduled for deletion + auto temphandles = + std::make_shared>(); handles.swap(temphandles); channel = consumer.get_channel(symbol); } - void add_security(MDConsumerHandle& handle) { + void add_security(MDConsumerHandle &handle) { bts_assert(handles); bts_assert_d(handle.is_initialized()); bts_assert(handle.get_usersymbol() == symbol); - DatedHandle h = { TimeStamp::now(), handle }; - handles->push_back(h); - if(this->mic == "") + DatedHandle h = {TimeStamp::now(), handle}; + handles->push_back(h); + if (this->mic == "") set_mic(h); } - - void set_mic(const DatedHandle& h) - { - if(channel.exchange() == api::VENUE_ICE || channel.exchange() == api::VENUE_SIMICE) - { + + void set_mic(const DatedHandle &h) { + if (channel.exchange() == api::VENUE_ICE || + channel.exchange() == api::VENUE_SIMICE) { this->mic = h.handle.get_normalized_security().ice().mic_code(); - } - else if(channel.exchange() == api::VENUE_GLBX || channel.exchange() == api::VENUE_SIM) - { - const auto& cme_symb_mics = config::get().cme_mic(); - for(auto mic=cme_symb_mics.begin();mic!=cme_symb_mics.end();mic++) - { - const auto& micsym = mic->first; - if(micsym == symbol.symbol()) - { + } else if ( + channel.exchange() == api::VENUE_GLBX || + channel.exchange() == api::VENUE_SIM) { + const auto &cme_symb_mics = + config::get().cme_mic(); + for (auto mic = cme_symb_mics.begin(); mic != cme_symb_mics.end(); + mic++) { + const auto &micsym = mic->first; + if (micsym == symbol.symbol()) { this->mic = api::CMEMics_Name(mic->second); break; } } - } - else if(channel.exchange() == api::VENUE_BTS || channel.exchange() == api::VENUE_UNSET) - { + } else if ( + channel.exchange() == api::VENUE_BTS || + channel.exchange() == api::VENUE_UNSET) { this->mic = "BTS"; - } - else + } else bts_assert_msg(false, "unknown venue in QueryServer"); } - + UserSymbol symbol; Platform platform; MDConsumerChannel channel; - + // Can add to handles without invalidating readers (no lock needed) - // When we recover we swap a new vector into this unique_ptr and delayed-delete + // When we recover we swap a new vector into this unique_ptr and + // delayed-delete shared_ptr> handles; std::string mic; }; -void convert(PriceSize ps, PriceSizeMessage* pps) { +void convert(PriceSize ps, PriceSizeMessage *pps) { pps->set_mantissa(ps.mantissa()); pps->set_exponent(ps.exponent()); pps->set_size(ps.size()); } -void set_price(PriceSize ps, co2::TradeMessage* ptrade) { +void set_price(PriceSize ps, co2::TradeMessage *ptrade) { ptrade->set_mantissa(ps.mantissa()); ptrade->set_exponent(ps.exponent()); ptrade->set_size(ps.size()); } -void set_price(const IntPrice& price, co2::PriceMessage* dest) { +void set_price(const IntPrice &price, co2::PriceMessage *dest) { dest->set_mantissa(price.mantissa()); dest->set_exponent(price.exponent()); } -void copy_misc(IntPrice settlement, MiscData misc, co2::MiscMessage* pmisc) { +void copy_misc(IntPrice settlement, MiscData misc, co2::MiscMessage *pmisc) { set_price(settlement, pmisc->mutable_settlement()); pmisc->set_settlement_date(misc.settlement_date.to_short()); - set_price(misc.previous_settlement_price, pmisc->mutable_previous_settlement_price()); - pmisc->set_previous_settlement_date(misc.previous_settlement_date.to_short()); + set_price( + misc.previous_settlement_price, + pmisc->mutable_previous_settlement_price()); + pmisc->set_previous_settlement_date( + misc.previous_settlement_date.to_short()); pmisc->set_open_price(misc.open_price); pmisc->set_open_date(misc.open_date.to_short()); pmisc->set_close_price(misc.close_price); pmisc->set_close_date(misc.close_date.to_short()); - //pmisc->set_fixing_price(misc.fixing_price); + // pmisc->set_fixing_price(misc.fixing_price); pmisc->set_session_high(misc.session_high); pmisc->set_session_low(misc.session_low); - //pmisc->set_session_high_bid(misc.session_high_bid); - //pmisc->set_session_low_offer(misc.session_low_offer); + // pmisc->set_session_high_bid(misc.session_high_bid); + // pmisc->set_session_low_offer(misc.session_low_offer); } // Handles market data queries and responds class QueryServerImpl : public IQueryServer { - MDClient& _client; + MDClient &_client; MDConsumer _consumer; int _sub; - boost::container::flat_map> _groups; + boost::container::flat_map> _groups; -public: - QueryServerImpl(MDClient& client, metrics::MetricsContainer& stats) : - _client(client), - _consumer(client.current_consumer()), - _sub(0), - _groups() - { - for (const auto& sym : client.symbols()) { - _groups.emplace(std::make_pair(sym, std::make_unique(sym, _consumer, stats))); + public: + QueryServerImpl(MDClient &client, metrics::MetricsContainer &stats) + : _client(client), _consumer(client.current_consumer()), _sub(0), + _groups() { + for (const auto &sym : client.symbols()) { + _groups.emplace(std::make_pair( + sym, std::make_unique(sym, _consumer, stats))); } _groups.shrink_to_fit(); - _sub = client.on_consumer().subscribe([=](const MDConsumer& c) { handle_recovery(c); }); + _sub = client.on_consumer().subscribe( + [=](const MDConsumer &c) { handle_recovery(c); }); subscribe_securities(); } - QueryServerImpl(const QueryServerImpl&)=delete; - ~QueryServerImpl() { - _client.on_consumer().unsubscribe(_sub); - } + QueryServerImpl(const QueryServerImpl &) = delete; + ~QueryServerImpl() { _client.on_consumer().unsubscribe(_sub); } void subscribe_securities() { auto id = _consumer.id(); - _consumer.on_security([this,id](const SecurityPtr&, MDConsumerHandle handle) { - if (_consumer.id() == id) { - auto iter = _groups.find(handle.get_usersymbol()); - bts_assert(iter != _groups.end()); - const auto& pgroup = iter->second; - bts_assert(pgroup); - pgroup->add_security(handle); - } - }); + _consumer.on_security( + [this, id](const SecurityPtr &, MDConsumerHandle handle) { + if (_consumer.id() == id) { + auto iter = _groups.find(handle.get_usersymbol()); + bts_assert(iter != _groups.end()); + const auto &pgroup = iter->second; + bts_assert(pgroup); + pgroup->add_security(handle); + } + }); } - + // not-reentrant - void handle_recovery(const MDConsumer& consumer) { + void handle_recovery(const MDConsumer &consumer) { MDConsumer temp(consumer); if (temp.all_heartbeats_ok()) { _consumer.swap(temp); - LOG(md,Info, "Recovering from bad MD. Old consumer {} new consumer {}", _consumer.id(), temp.id()); - for (auto& pair : _groups) { + LOG(md, Info, + "Recovering from bad MD. Old consumer {} new consumer {}", + _consumer.id(), temp.id()); + for (auto &pair : _groups) { pair.second->set_consumer(_consumer); } // _handle_index.clear(); subscribe_securities(); - utils::Dispatcher::background().post([temp]() { LOG(md,Info,"QServer destroying consumer {}", temp.id()); }, 60000); + utils::Dispatcher::background().post( + [temp]() { + LOG(md, Info, "QServer destroying consumer {}", temp.id()); + }, + 60000); } } // the hot part - void fill(const SecurityChannel& chan, MDConsumerGroup& group, ChannelReply* reply, - const Entitlements* entitlements, bool bypass_entitlement) const { + void fill( + const SecurityChannel &chan, MDConsumerGroup &group, ChannelReply *reply, + const Entitlements *entitlements, bool bypass_entitlement) const { bts_assert(reply); reply->mutable_channel()->CopyFrom(chan); reply->set_platform(group.platform); reply->mutable_channel()->set_time(TimeStamp::now().to_uint64()); - + bool entitled = bypass_entitlement || chan.exchange() == api::VENUE_BTS; - if(entitlements && !entitled) + if (entitlements && !entitled) entitled = entitlements->count(group.mic); - reply->mutable_channel()->set_entitled(entitled); + reply->mutable_channel()->set_entitled(entitled); auto flags = (MDRequest::Flags)chan.flags(); // Get a copy of handles. If recovery happens during this call // we can safely continue using this pointer for 60 seconds auto phandles = group.handles; - if (!phandles) return; + if (!phandles) + return; ChannelUpdate temp_update; - for (const auto& instrument : *phandles) { + for (const auto &instrument : *phandles) { bool snapshot = false; MDConsumerHandle handle = instrument.handle; temp_update.Clear(); bts_assert_d(handle.is_initialized()); - if (!handle.is_initialized()) continue; - ChannelUpdate* pupd = &temp_update; + if (!handle.is_initialized()) + continue; + ChannelUpdate *pupd = &temp_update; pupd->set_key(instrument.handle.key()); // If the security was just discovered try to ensure all data is sent - if (instrument.discovered > TimeStamp(chan.time())) - { + if (instrument.discovered > TimeStamp(chan.time())) { auto security = handle.get_normalized_security(); pupd->mutable_security()->CopyFrom(security); snapshot = true; } - //if we are not entitled AND this is the first request since we lost our entitlement, zero out books - if (!entitled && chan.entitled() ) { - if (HASFLAG(flags, MDRequest::BBO) || HASFLAG(flags, MDRequest::DIRECT)) { - auto* p = pupd->mutable_direct(); + // if we are not entitled AND this is the first request since we lost + // our entitlement, zero out books + if (!entitled && chan.entitled()) { + if (HASFLAG(flags, MDRequest::BBO) || + HASFLAG(flags, MDRequest::DIRECT)) { + auto *p = pupd->mutable_direct(); for (size_t x = 0; x < COCONUT_MAX_DEPTH; ++x) { convert(NO_MARKET, p->add_bids()); convert(NO_MARKET, p->add_asks()); - } + } } - if ((HASFLAG(flags, MDRequest::IMPLIED) || HASFLAG(flags, MDRequest::BBO)) && !handle.is_synthetic()) { - auto* p = pupd->mutable_implied(); + if ((HASFLAG(flags, MDRequest::IMPLIED) || + HASFLAG(flags, MDRequest::BBO)) && + !handle.is_synthetic()) { + auto *p = pupd->mutable_implied(); for (size_t x = 0; x < COCONUT_MAX_IMPLIED_DEPTH; ++x) { convert(NO_MARKET, p->add_bids()); convert(NO_MARKET, p->add_asks()); } - } + } } - if(entitled) { - // If we are entitled now but this is the first request where we are ensure we send all values - if(!chan.entitled()) snapshot = true; + if (entitled) { + // If we are entitled now but this is the first request where we are + // ensure we send all values + if (!chan.entitled()) + snapshot = true; - if (HASFLAG(flags, MDRequest::BBO) || HASFLAG(flags, MDRequest::DIRECT)) { - std::array bids, asks; - TimeStamp time(snapshot ? 0 : chan.time()); - size_t copy_depth = HASFLAG(flags, MDRequest::DIRECT) ? COCONUT_MAX_DEPTH : 1; - auto result = handle.get_direct_book(time, copy_depth, bids.data(), asks.data()); + if (HASFLAG(flags, MDRequest::BBO) || + HASFLAG(flags, MDRequest::DIRECT)) { + std::array bids, asks; + TimeStamp time(snapshot ? 0 : chan.time()); + size_t copy_depth = + HASFLAG(flags, MDRequest::DIRECT) ? COCONUT_MAX_DEPTH : 1; + auto result = handle.get_direct_book( + time, copy_depth, bids.data(), asks.data()); if (result == HandleReadResult::SUCCESS) { - auto* p = pupd->mutable_direct(); + auto *p = pupd->mutable_direct(); for (size_t x = 0; x < COCONUT_MAX_DEPTH; ++x) { PriceSize b = bids[x]; if (b != NO_MARKET) { @@ -322,25 +353,33 @@ public: convert(a, p->add_asks()); } } - } - else if (result == HandleReadResult::BUSY) { - LOG(md,Info, "Busy read on handle {}. Retry on next request", instrument.handle.key()); - // If we get a busy reading BBO (which happens 1-2x per day for a single relay client) - // We move the timestamp back so the next request will try to read this value again. - // ALTERNATIVE: We could spin until the value was not busy but it could be that the writer - // was context switched out and we will have to wait multiple ms to unblock the request. - // This fix assumes it is better to send the update now with 1 stale value than to block the call - // and allow all the values to be stale until this one can be read. + } else if (result == HandleReadResult::BUSY) { + LOG(md, Info, "Busy read on handle {}. Retry on next request", + instrument.handle.key()); + // If we get a busy reading BBO (which happens 1-2x per day + // for a single relay client) We move the timestamp back so + // the next request will try to read this value again. + // ALTERNATIVE: We could spin until the value was not busy but + // it could be that the writer was context switched out and we + // will have to wait multiple ms to unblock the request. This + // fix assumes it is better to send the update now with 1 + // stale value than to block the call and allow all the values + // to be stale until this one can be read. reply->mutable_channel()->set_time(chan.time()); } } - if ((HASFLAG(flags, MDRequest::IMPLIED) || HASFLAG(flags, MDRequest::BBO)) && !handle.is_synthetic()) { + if ((HASFLAG(flags, MDRequest::IMPLIED) || + HASFLAG(flags, MDRequest::BBO)) && + !handle.is_synthetic()) { std::array bids, asks; TimeStamp time(snapshot ? 0 : chan.time()); - size_t copy_depth = HASFLAG(flags, MDRequest::IMPLIED) ? COCONUT_MAX_IMPLIED_DEPTH : 1; - auto result = handle.get_implied_book(time, copy_depth, bids.data(), asks.data()); + size_t copy_depth = HASFLAG(flags, MDRequest::IMPLIED) + ? COCONUT_MAX_IMPLIED_DEPTH + : 1; + auto result = handle.get_implied_book( + time, copy_depth, bids.data(), asks.data()); if (result == HandleReadResult::SUCCESS) { - auto* p = pupd->mutable_implied(); + auto *p = pupd->mutable_implied(); for (size_t x = 0; x < COCONUT_MAX_IMPLIED_DEPTH; ++x) { PriceSize b = bids[x]; if (b != NO_MARKET) { @@ -351,9 +390,10 @@ public: convert(a, p->add_asks()); } } - } - else if (result == HandleReadResult::BUSY) { - LOG(md,Info, "Busy read on handle (implied) {}. Retry on next request", instrument.handle.key()); + } else if (result == HandleReadResult::BUSY) { + LOG(md, Info, + "Busy read on handle (implied) {}. Retry on next request", + instrument.handle.key()); reply->mutable_channel()->set_time(chan.time()); } } @@ -361,9 +401,11 @@ public: TimeStamp time(snapshot ? 0 : chan.time()); PriceSize price; datetime::LLDateTime trade_time; - size_t volume; int from_spread; - if (handle.get_last_trade(time, price, trade_time, &volume, &from_spread)) { - auto* trade = pupd->mutable_last_trade(); + size_t volume; + int from_spread; + if (handle.get_last_trade( + time, price, trade_time, &volume, &from_spread)) { + auto *trade = pupd->mutable_last_trade(); trade->set_key(handle.key()); trade->set_time(trade_time); trade->set_total_volume(volume); @@ -374,73 +416,85 @@ public: if (HASFLAG(flags, MDRequest::MISC)) { TimeStamp time(snapshot ? 0 : chan.time()); if (handle.misc_timestamp() > time) { - copy_misc(handle.settlement_price(), handle.misc(), pupd->mutable_misc()); + copy_misc( + handle.settlement_price(), handle.misc(), + pupd->mutable_misc()); } } } - if (pupd->has_direct() || - pupd->has_implied() || - pupd->has_last_trade() || - pupd->has_misc() || + if (pupd->has_direct() || pupd->has_implied() || + pupd->has_last_trade() || pupd->has_misc() || pupd->has_security()) { reply->add_updates()->CopyFrom(*pupd); } } - reply->mutable_channel()->set_segment_id(group.channel.create_time().to_uint64()); - bool is_same_segment = (chan.segment_id() == group.channel.create_time().to_uint64()); + reply->mutable_channel()->set_segment_id( + group.channel.create_time().to_uint64()); + bool is_same_segment = + (chan.segment_id() == group.channel.create_time().to_uint64()); if (HASFLAG(flags, MDRequest::TRADE_LOG)) { int64_t request_cursor = is_same_segment ? chan.trade_cursor() : 0; - auto cursor = group.channel.read_trades(*reply->mutable_trade_log(), request_cursor); + auto cursor = group.channel.read_trades( + *reply->mutable_trade_log(), request_cursor); if (cursor != chan.trade_cursor()) { reply->mutable_channel()->set_trade_cursor(cursor); } } if (HASFLAG(flags, MDRequest::RFQ)) { int64_t request_cursor = is_same_segment ? chan.rfq_cursor() : 0; - auto cursor = group.channel.read_rfqs(*reply->mutable_rfq_log(), request_cursor); + auto cursor = + group.channel.read_rfqs(*reply->mutable_rfq_log(), request_cursor); if (cursor != chan.rfq_cursor()) { reply->mutable_channel()->set_rfq_cursor(cursor); } } } - void query(const MDRequest& request, MDReply* reply, const Entitlements* entitlements, bool bypass_entitlement) const { + void query( + const MDRequest &request, MDReply *reply, + const Entitlements *entitlements, bool bypass_entitlement) const { bts_assert(reply != nullptr); - for (auto& ch : request.channels()) { - auto groupiter = _groups.find(UserSymbol(ch.symbol(), ch.exchange(), ch.type())); + for (auto &ch : request.channels()) { + auto groupiter = + _groups.find(UserSymbol(ch.symbol(), ch.exchange(), ch.type())); if (groupiter != _groups.end()) { - auto& group = groupiter->second; - fill(ch, *group, reply->add_channels(), entitlements, bypass_entitlement); + auto &group = groupiter->second; + fill( + ch, *group, reply->add_channels(), entitlements, + bypass_entitlement); } } } - - void get_names(ExpirationNameListReply* reply) const { + + void get_names(ExpirationNameListReply *reply) const { bts_assert(reply != nullptr); Security security; - for (auto& groupiter : _groups) { - const auto& group = groupiter.second; - ExpirationNameList* psec = reply->add_securities(); + for (auto &groupiter : _groups) { + const auto &group = groupiter.second; + ExpirationNameList *psec = reply->add_securities(); psec->mutable_product()->CopyFrom(group->symbol.to_product()); - for(const auto& h : *(group->handles)) { + for (const auto &h : *(group->handles)) { security.CopyFrom(h.handle.get_normalized_security()); auto x = psec->mutable_names(); if (security.ExchangeData_case() == Security::kGlbx) { - google::protobuf::MapPair v(h.handle.key(), security.glbx().security_desc()); + google::protobuf::MapPair v( + h.handle.key(), security.glbx().security_desc()); + x->insert(v); + } else if (security.ExchangeData_case() == Security::kIce) { + google::protobuf::MapPair v( + h.handle.key(), security.ice().security_desc()); x->insert(v); } - else if (security.ExchangeData_case() == Security::kIce) { - google::protobuf::MapPair v(h.handle.key(), security.ice().security_desc()); - x->insert(v); - } // There is currently no ExchangeData for synthetics } } } - void get_securities(google::protobuf::RepeatedField keys, api::SecurityList* result) const { + void get_securities( + google::protobuf::RepeatedField keys, + api::SecurityList *result) const { bts_assert(result); // Ensure keys are unique std::set unique_keys(keys.begin(), keys.end()); @@ -454,158 +508,185 @@ public: }; struct MDRelayServer : bts::co2::AuthenticatedMarketDataRelayBase { - const QueryServerImpl& _db; - utils::Dispatcher& _threadpool; - std::shared_ptr> _entitlements; + const QueryServerImpl &_db; + utils::Dispatcher &_threadpool; + std::shared_ptr> _entitlements; #ifndef _WIN32 - std::shared_ptr> _time,_size; + std::shared_ptr> _time, _size; #endif - MDRelayServer(const QueryServerImpl& db, utils::Dispatcher& threadpool, bts::api::ServiceContext ctx, metrics::MetricsContainer& stats) : - bts::co2::AuthenticatedMarketDataRelayBase(ctx), - _db(db), _threadpool(threadpool), _entitlements() + MDRelayServer( + const QueryServerImpl &db, utils::Dispatcher &threadpool, + bts::api::ServiceContext ctx, metrics::MetricsContainer &stats) + : bts::co2::AuthenticatedMarketDataRelayBase(ctx), _db(db), + _threadpool(threadpool), _entitlements() #ifndef _WIN32 - , _time(std::make_shared>("spark_qserver_response_time_ms", std::array({ 5.0, 10.0, 20.0, 50.0, 100.0 }))), - _size(std::make_shared>("spark_qserver_size_bytes", std::array({ 10240 /*10k*/, 102400 /*100k*/, 1024*1024 /*1mb*/, 1024*1024*10 /*10mb*/, 1024*1024*100 /*100mb*/ }))) - { - stats.publish(_time); - stats.publish(_size); - } + , + _time(std::make_shared>( + "spark_qserver_response_time_ms", + std::array({5.0, 10.0, 20.0, 50.0, 100.0}))), + _size(std::make_shared>( + "spark_qserver_size_bytes", + std::array( + {10240 /*10k*/, 102400 /*100k*/, 1024 * 1024 /*1mb*/, + 1024 * 1024 * 10 /*10mb*/, 1024 * 1024 * 100 /*100mb*/}))) { + stats.publish(_time); + stats.publish(_size); + } #else - {} + { + } #endif - void update_entitlements(std::shared_ptr>& entitlements) { - _entitlements = entitlements; - } + void update_entitlements( + std::shared_ptr> + &entitlements) { + _entitlements = entitlements; + } - static const Entitlements* get_entitlements(uint32_t user_id, std::shared_ptr>& entitlements) { - if (entitlements) { + static const Entitlements *get_entitlements( + uint32_t user_id, + std::shared_ptr> + &entitlements) { + if (entitlements) { auto iter = entitlements->find(user_id); if (iter != entitlements->end()) { return &iter->second; } - } - return nullptr; - } + } + return nullptr; + } - virtual void requestmd(const api::AuthToken& token, const MDRequest& request, const std::function& reply) override { - TimeStamp start = TimeStamp::now(); - _threadpool.post([=]() { - google::protobuf::Arena arena; - MDReply* preply = google::protobuf::Arena::CreateMessage(&arena); - // addref to keep shared ptr alive - api::user::TokenPayload payload; - auto ents = _entitlements; - const Entitlements* user_entitlement = nullptr; - bool bypass_entitlement = false; - if (api::auth::decode_token(token, &payload)) { - bypass_entitlement = payload.wheel(); - if (!bypass_entitlement) { + virtual void requestmd( + const api::AuthToken &token, const MDRequest &request, + const std::function &reply) override { + TimeStamp start = TimeStamp::now(); + _threadpool.post([=]() { + google::protobuf::Arena arena; + MDReply *preply = + google::protobuf::Arena::CreateMessage(&arena); + // addref to keep shared ptr alive + api::user::TokenPayload payload; + auto ents = _entitlements; + const Entitlements *user_entitlement = nullptr; + bool bypass_entitlement = false; + if (api::auth::decode_token(token, &payload)) { + bypass_entitlement = payload.wheel(); + if (!bypass_entitlement) { user_entitlement = get_entitlements(payload.id(), ents); - } - } + } + } _db.query(request, preply, user_entitlement, bypass_entitlement); - reply(*preply); + reply(*preply); #ifndef _WIN32 - auto elapsed = (TimeStamp::now() - start); - _time->observe(elapsed.milliseconds()); - _size->observe(preply->ByteSize()); + auto elapsed = (TimeStamp::now() - start); + _time->observe(elapsed.milliseconds()); + _size->observe(preply->ByteSize()); #endif - }); - } - - virtual void request_products(const api::AuthToken&, const api::VoidMessage&, const std::function& reply) override { + }); + } + + virtual void request_products( + const api::AuthToken &, const api::VoidMessage &, + const std::function &reply) override { ProductListReply list; std::set syms; get_system_md_symbols(syms); - for(const auto& i : syms) - { + for (const auto &i : syms) { auto prod = list.add_products(); prod->set_exchange(i.exchange()); prod->set_type(i.type()); prod->set_symbol(i.symbol()); } reply(list); - } + } - virtual void request_names(const api::AuthToken&, const api::VoidMessage&, const std::function& reply) override { - _threadpool.post([=]() { - google::protobuf::Arena arena; - ExpirationNameListReply* preply = google::protobuf::Arena::CreateMessage(&arena); - _db.get_names(preply); - reply(*preply); - }); - } + virtual void request_names( + const api::AuthToken &, const api::VoidMessage &, + const std::function &reply) + override { + _threadpool.post([=]() { + google::protobuf::Arena arena; + ExpirationNameListReply *preply = + google::protobuf::Arena::CreateMessage( + &arena); + _db.get_names(preply); + reply(*preply); + }); + } - virtual void get_securities(const api::AuthToken&, const SecurityKeyList& keys, const std::function& reply) override { - _threadpool.post([=]() { - google::protobuf::Arena arena; - api::SecurityList* preply = google::protobuf::Arena::CreateMessage(&arena); - _db.get_securities(keys.keys(), preply); - reply(*preply); - }); - } + virtual void get_securities( + const api::AuthToken &, const SecurityKeyList &keys, + const std::function &reply) override { + _threadpool.post([=]() { + google::protobuf::Arena arena; + api::SecurityList *preply = + google::protobuf::Arena::CreateMessage(&arena); + _db.get_securities(keys.keys(), preply); + reply(*preply); + }); + } }; - struct QueryServer { - QueryServer(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; - MDRelayServer relay; - api::admin::AdminService admin_client; - rxcpp::composite_subscription entitlement_sub; + QueryServer( + 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; + MDRelayServer relay; + api::admin::AdminService admin_client; + rxcpp::composite_subscription entitlement_sub; }; - -QueryServerPtr run_query_server(const bts::api::ServiceContext& ctx, MDClient& client, metrics::MetricsContainer& stats) { - auto& threadpool = utils::Dispatcher::get_named("MDQuery"); - QueryServerPtr container = std::make_shared(threadpool, ctx, client, stats); +QueryServerPtr run_query_server( + const bts::api::ServiceContext &ctx, MDClient &client, + metrics::MetricsContainer &stats) { + auto &threadpool = utils::Dispatcher::get_named("MDQuery"); + + QueryServerPtr container = + std::make_shared(threadpool, ctx, client, stats); // Subscribe to entitlement data container->entitlement_sub = - container->admin_client.subscribe_md_entitlement_data().subscribe([=](const api::admin::Md_entitlement_dataUpdate& update) { - const auto& all_updates = update.all(); - utils::Dispatcher::background().post([all_updates, container]() - { - auto entitlements = std::make_shared>(); - for (const auto& row : all_updates) - { - if (row && row->enabled()) - { - auto iter = entitlements->find(row->user_id()); - if (iter == entitlements->end()) { - Entitlements ents; - ents.insert(row->mic()); - entitlements->insert(iter, std::make_pair(row->user_id(), std::move(ents))); - } - else { - iter->second.insert(row->mic()); - } - } - } - container->relay.update_entitlements(entitlements); - }); - }); + container->admin_client.subscribe_md_entitlement_data().subscribe( + [=](const api::admin::Md_entitlement_dataUpdate &update) { + const auto &all_updates = update.all(); + utils::Dispatcher::background().post([all_updates, container]() { + auto entitlements = std::make_shared< + std::unordered_map>(); + for (const auto &row : all_updates) { + if (row && row->enabled()) { + auto iter = entitlements->find(row->user_id()); + if (iter == entitlements->end()) { + Entitlements ents; + ents.insert(row->mic()); + entitlements->insert( + iter, + std::make_pair(row->user_id(), std::move(ents))); + } else { + iter->second.insert(row->mic()); + } + } + } + container->relay.update_entitlements(entitlements); + }); + }); // Add a few threads to keep md latency low for (int x = 1; x < std::min(4, os::num_cores()); ++x) { - threadpool.add_thread(); + threadpool.add_thread(); } - + return container; } -std::unique_ptr create_query_server(MDClient& mdc, metrics::MetricsContainer& mets) { +std::unique_ptr +create_query_server(MDClient &mdc, metrics::MetricsContainer &mets) { return std::make_unique(mdc, mets); } -}}//namespace +} // namespace md +} // namespace bts #endif diff --git a/src/lib/md/relay/QueryServer.h b/src/lib/md/relay/QueryServer.h index 186089658..a53a5cad6 100644 --- a/src/lib/md/relay/QueryServer.h +++ b/src/lib/md/relay/QueryServer.h @@ -1,31 +1,39 @@ #pragma once -#include "lib/utils/bts_no_copy.h" -#include "lib/utils/bts_export.h" -#include "lib/md/UserSymbol.h" #include "lib/md/ISyntheticSecurityService.h" -#include -#include +#include "lib/md/UserSymbol.h" +#include "lib/utils/bts_export.h" +#include "lib/utils/bts_no_copy.h" #include +#include +#include #include "lib/md/protos/co2.pb.h" namespace bts { - namespace api { class ServiceContext; } - namespace metrics { class MetricsContainer; } +namespace api { +class ServiceContext; +} +namespace metrics { +class MetricsContainer; +} namespace md { class MDClient; typedef boost::container::flat_set Entitlements; struct IQueryServer { virtual ~IQueryServer() {} - virtual void query(const co2::MDRequest& request, co2::MDReply* reply, const Entitlements*, bool) const = 0; + virtual void query( + const co2::MDRequest &request, co2::MDReply *reply, const Entitlements *, + bool) const = 0; }; -std::unique_ptr create_query_server(MDClient&, metrics::MetricsContainer&); +std::unique_ptr +create_query_server(MDClient &, metrics::MetricsContainer &); struct QueryServer; typedef std::shared_ptr QueryServerPtr; -QueryServerPtr run_query_server(const bts::api::ServiceContext&, MDClient&, metrics::MetricsContainer&); - -}}//namespace +QueryServerPtr run_query_server( + const bts::api::ServiceContext &, MDClient &, metrics::MetricsContainer &); +} // namespace md +} // namespace bts diff --git a/src/lib/md/relay/RelayClient.cpp b/src/lib/md/relay/RelayClient.cpp index 0cc92b7a4..824ecf59d 100644 --- a/src/lib/md/relay/RelayClient.cpp +++ b/src/lib/md/relay/RelayClient.cpp @@ -2,30 +2,30 @@ #include "RelayClient.h" #include "RelayRecorder.h" -#include "lib/config/config.h" -#include "lib/utils/TimeStamp.h" -#include "lib/utils/bts_chrono.h" -#include "lib/utils/AuthToken.h" #include "../MDProducer.h" #include "../get_symbols.h" +#include "lib/config/config.h" #include "lib/logging/logging.h" +#include "lib/utils/AuthToken.h" +#include "lib/utils/TimeStamp.h" +#include "lib/utils/bts_chrono.h" -#include "lib/config/protos/system.pb.h" -#include "lib/config/protos/MarketData.pb.h" -#include "lib/md/protos/co2.pb.h" -#include "lib/api/services/MarketDataRelay.client.pb.h" #include "lib/api/public/ServiceContext.h" +#include "lib/api/services/MarketDataRelay.client.pb.h" +#include "lib/config/protos/MarketData.pb.h" +#include "lib/config/protos/system.pb.h" +#include "lib/md/protos/co2.pb.h" #include "lib/utils/base64.hpp" +#include +#include +#include +#include +#include #include #include -#include -#include -#include #include -#include -#include -#include +#include using namespace std; @@ -33,22 +33,28 @@ namespace bts { namespace md { using namespace co2; -PriceSize convert(const PriceSizeMessage& psm) { - return psm.size() > 0 ? PriceSize({psm.mantissa(), (int8_t)psm.exponent()}, psm.size()) : NO_MARKET; +PriceSize convert(const PriceSizeMessage &psm) { + return psm.size() > 0 + ? PriceSize({psm.mantissa(), (int8_t)psm.exponent()}, psm.size()) + : NO_MARKET; } -PriceSize trade_pricesize(const co2::TradeMessage& trade) { - return trade.size() > 0 ? - PriceSize({trade.mantissa(), (int8_t)trade.exponent()}, trade.size()) : NO_MARKET; +PriceSize trade_pricesize(const co2::TradeMessage &trade) { + return trade.size() > 0 + ? PriceSize( + {trade.mantissa(), (int8_t)trade.exponent()}, trade.size()) + : NO_MARKET; } -PriceSize book_at(const google::protobuf::RepeatedPtrField& side, int index) { +PriceSize book_at( + const google::protobuf::RepeatedPtrField &side, + int index) { if (side.size() > index) { return convert(side.Get(index)); } return NO_MARKET; } -IntPrice convert(const PriceMessage& price) { - return { price.mantissa(), (int8_t)price.exponent() }; +IntPrice convert(const PriceMessage &price) { + return {price.mantissa(), (int8_t)price.exponent()}; } class RelayProducer : public IRelayWriter { @@ -56,29 +62,37 @@ class RelayProducer : public IRelayWriter { std::map _producers; unordered_map _handles; - void record_update(MDProducerHandle& handle, const ChannelUpdate& update) { + void record_update(MDProducerHandle &handle, const ChannelUpdate &update) { utils::TimeStamp updated = utils::TimeStamp::now(); bool snapshot = update.has_security(); - // If this is a snapshot an empty book() means "no market" rather than "no change" + // If this is a snapshot an empty book() means "no market" rather than "no + // change" if (update.has_direct() || update.has_implied() || snapshot) { - std::array bids, asks; - std::array implied_bids, implied_asks; + std::array bids, asks; + std::array implied_bids, + implied_asks; for (size_t x = 0; x < COCONUT_MAX_DEPTH; ++x) { bids[x] = book_at(update.direct().bids(), x); asks[x] = book_at(update.direct().asks(), x); } - for (size_t x = 0; x second; } @@ -110,53 +125,55 @@ public: return find_result->second; } - void write(const co2::MDReply& data, bool* phas_new_securities) override { - for (const auto& ch : data.channels()) { + void write(const co2::MDReply &data, bool *phas_new_securities) override { + for (const auto &ch : data.channels()) { // Per-security data int added_security_count = 0; - for (const auto& update : ch.updates()) { + for (const auto &update : ch.updates()) { auto find_result = _handles.find(update.key()); if (update.has_security() && find_result == _handles.end()) { - if (phas_new_securities) *phas_new_securities = true; + if (phas_new_securities) + *phas_new_securities = true; added_security_count++; - MDProducer& producer = ensure_producer(ch.platform()); - with_security_like(update.security(), [&](FixedSecurity& fs) { + MDProducer &producer = ensure_producer(ch.platform()); + with_security_like(update.security(), [&](FixedSecurity &fs) { convert_security(update.security(), fs, true); MDProducerHandle handle = producer.add_security(fs); _handles.insert(make_pair(handle.key(), handle)); record_update(handle, update); }); - } - else if (find_result != _handles.end()) { - MDProducerHandle& handle = find_result->second; + } else if (find_result != _handles.end()) { + MDProducerHandle &handle = find_result->second; record_update(handle, update); } } // Heartbeat auto iter = _producers.find(ch.platform()); if (iter != _producers.end()) { - auto& producer = iter->second; - auto channel = producer.get_channel(ch.channel().symbol().c_str(), ch.channel().type(), ch.channel().exchange()); + auto &producer = iter->second; + auto channel = producer.get_channel( + ch.channel().symbol().c_str(), ch.channel().type(), + ch.channel().exchange()); channel.heartbeat(); // RFQ and TRADE LOG if (ch.trade_log_size() > 0 || ch.rfq_log_size() > 0) { if (ch.trade_log_size() > 0) { - LOG(md,Diag, "Added {} trades", ch.trade_log_size()); + LOG(md, Diag, "Added {} trades", ch.trade_log_size()); } - for (const auto& trade : ch.trade_log()) { + for (const auto &trade : ch.trade_log()) { if (trade.key()) { channel.add_trade(trade); } } - for (const auto& rfq : ch.rfq_log()) { + for (const auto &rfq : ch.rfq_log()) { channel.add_rfq(rfq); } } } if (added_security_count > 0) { - LOG(md,Diag,"Added {} {} - {}" , - added_security_count , ch.channel().symbol() ,SecurityType_Name(ch.channel().type())); + LOG(md, Diag, "Added {} {} - {}", added_security_count, + ch.channel().symbol(), SecurityType_Name(ch.channel().type())); } } } @@ -169,27 +186,22 @@ shared_ptr mkrelayproducer(bool shared) { // Single Threaded class RelayClient { MDRequest _request; - MarketDataRelay& _rpc; - MDConsumer* _pconsumer; - IRelayWriter& _writer; + MarketDataRelay &_rpc; + MDConsumer *_pconsumer; + IRelayWriter &_writer; utils::TimeStamp _request_log; -public: + public: RelayClient( - MarketDataRelay& rpc, - MDConsumer* pconsumer, - const std::set& symbols, - IRelayWriter& writer) : - _request(), - _rpc(rpc), - _pconsumer(pconsumer), - _writer(writer), - _request_log(utils::TimeStamp::now()) - { + MarketDataRelay &rpc, MDConsumer *pconsumer, + const std::set &symbols, IRelayWriter &writer) + : _request(), _rpc(rpc), _pconsumer(pconsumer), _writer(writer), + _request_log(utils::TimeStamp::now()) { ostringstream fmt; - fmt << config::get().host_name() << "(" << os::process_id() << ")"; + fmt << config::get().host_name() << "(" + << os::process_id() << ")"; _request.set_host(fmt.str()); - for (const auto& s : symbols) { + for (const auto &s : symbols) { SecurityChannel ch; ch.set_symbol(s.symbol()); ch.set_type(s.type()); @@ -200,19 +212,18 @@ public: } // Can be called safely with the same symbol - void add_symbol(const SecurityChannel& ch) { - auto find_result = - std::find_if(_request.mutable_channels()->begin(), _request.mutable_channels()->end(), - [&](const SecurityChannel& c) { - return c.symbol() == ch.symbol() && - c.type() == ch.type() && - c.exchange() == ch.exchange(); }); + void add_symbol(const SecurityChannel &ch) { + auto find_result = std::find_if( + _request.mutable_channels()->begin(), + _request.mutable_channels()->end(), [&](const SecurityChannel &c) { + return c.symbol() == ch.symbol() && c.type() == ch.type() && + c.exchange() == ch.exchange(); + }); if (find_result == _request.mutable_channels()->end()) { - auto* new_channel = _request.add_channels(); + auto *new_channel = _request.add_channels(); new_channel->CopyFrom(ch); new_channel->set_time(0); - } - else { + } else { // update flags auto flags = find_result->flags() | ch.flags(); if (flags != find_result->flags()) { @@ -226,22 +237,31 @@ public: std::string compact_log_format() const { ostringstream log; log << "{"; - for (const auto& ch : _request.channels()) { + for (const auto &ch : _request.channels()) { log << std::endl; log << ch.symbol() << " "; - switch(ch.type()){ - case SecurityType::SECURITYTYPE_FUTURE: log << "Fut "; break; - case SecurityType::SECURITYTYPE_SPREAD: log << "Spr "; break; - case SecurityType::SECURITYTYPE_OPTION: log << "Opt "; break; - case SecurityType::SECURITYTYPE_SYNTHETIC: log << "Syn "; break; - default: + switch (ch.type()) { + case SecurityType::SECURITYTYPE_FUTURE: + log << "Fut "; + break; + case SecurityType::SECURITYTYPE_SPREAD: + log << "Spr "; + break; + case SecurityType::SECURITYTYPE_OPTION: + log << "Opt "; + break; + case SecurityType::SECURITYTYPE_SYNTHETIC: + log << "Syn "; + break; + default: break; } log << Venue_Name(ch.exchange()).substr(sizeof("venue")); log << " " << (uint32_t)ch.time(); log << " " << (uint16_t)ch.segment_id(); if (!ch.entitled()) { - log << " " << "Ent=0"; + log << " " + << "Ent=0"; } } log << "\n}"; @@ -250,14 +270,20 @@ public: } void request_md(std::function cont) { - auto now = utils::TimeStamp::now(); - if ((now - _request_log).seconds() > 60) { - _request_log = now; - LOG(md, Info, "Requesting MD (b64): {}", compact_log_format()); - } - _rpc.requestmd(_request, [=](const api::Result& r) { receive_md(r); cont(); }, 500u); + auto now = utils::TimeStamp::now(); + if ((now - _request_log).seconds() > 60) { + _request_log = now; + LOG(md, Info, "Requesting MD (b64): {}", compact_log_format()); + } + _rpc.requestmd( + _request, + [=](const api::Result &r) { + receive_md(r); + cont(); + }, + 500u); } - void receive_md(const api::Result& result) { + void receive_md(const api::Result &result) { if (result.success()) { // Write data to shared mem bool has_new_security = false; @@ -270,8 +296,8 @@ public: }); } // Update reply timetamps - for (auto& req : *_request.mutable_channels()) { - for (auto& reply : result.value()->channels()) { + for (auto &req : *_request.mutable_channels()) { + for (auto &reply : result.value()->channels()) { if (req.type() == reply.channel().type() && req.exchange() == reply.channel().exchange() && req.symbol() == reply.channel().symbol()) { @@ -281,7 +307,8 @@ public: req.set_trade_cursor(reply.channel().trade_cursor()); req.set_rfq_cursor(reply.channel().rfq_cursor()); if (req.segment_id() != reply.channel().segment_id()) { - LOG(md, Diag, "New segment_id = {}", reply.channel().segment_id()); + LOG(md, Diag, "New segment_id = {}", + reply.channel().segment_id()); req.set_segment_id(reply.channel().segment_id()); } } @@ -293,24 +320,22 @@ public: struct RelayScheduler { uint32_t _interval; - api::ServiceContext& _ctx; - RelayClient& _client; + api::ServiceContext &_ctx; + RelayClient &_client; bool running; double speed_factor; - RelayScheduler(api::ServiceContext& context, uint32_t interval, RelayClient& client) : - _interval(interval), - _ctx(context), - _client(client), - running(true), - speed_factor(config::get().speed()) - { } + RelayScheduler( + api::ServiceContext &context, uint32_t interval, RelayClient &client) + : _interval(interval), _ctx(context), _client(client), running(true), + speed_factor(config::get().speed()) {} void run() { if (running) { utils::TimeStamp start = utils::TimeStamp::now(); _client.request_md([=]() { - int64_t elapsed_ms = (utils::TimeStamp::now() - start).milliseconds(); + int64_t elapsed_ms = + (utils::TimeStamp::now() - start).milliseconds(); int64_t delay = (_interval - elapsed_ms) / speed_factor; _ctx.post([=]() { run(); }, std::max(delay, (int64_t)0)); }); @@ -324,10 +349,13 @@ api::ServiceContext elevated_relay_context() { return ctx; } -void relay_selected(api::ServiceContext& ctx, const std::set& symbols, IRelayWriter& writer) { +void relay_selected( + api::ServiceContext &ctx, const std::set &symbols, + IRelayWriter &writer) { auto relay = ctx.locate(); RelayClient client(relay, nullptr, symbols, writer); - RelayScheduler scheduler(ctx, config::get().naggle_ms(), client); + RelayScheduler scheduler( + ctx, config::get().naggle_ms(), client); ctx.post([&]() { scheduler.run(); }); // block forever, I guess @@ -346,13 +374,12 @@ std::set get_relay_symbols(bool record_sim) { std::set symbols; if (record_sim) { get_system_md_symbols(symbols); - } - else { + } else { std::set system_symbols; get_system_md_symbols(system_symbols); // Filter out VENUE_SIM - for (const auto& s : system_symbols) { + for (const auto &s : system_symbols) { if (s.exchange() != api::VENUE_SIM) { symbols.insert(s); } @@ -361,7 +388,7 @@ std::set get_relay_symbols(bool record_sim) { return symbols; } -void local_relay(IRelayWriter& writer) { +void local_relay(IRelayWriter &writer) { api::ServiceContext ctx = elevated_relay_context(); ctx.login(api::auth::generate_wheel_token()); auto relay = ctx.locate(); @@ -373,22 +400,20 @@ void record_everything(std::string path, std::string filename) { auto options = config::get(); if (filename.empty()) { ostringstream file; - file << "marketdata" << "-"; + file << "marketdata" + << "-"; int year, month, day, hour, minute, unused; - datetime::ll_to_parts(datetime::ll_local_now(), year, month, day, hour, minute, unused, unused); - file - << year - << setw(2) << setfill('0') << month - << setw(2) << setfill('0') << day - << "-" - << setw(2) << setfill('0') << hour - << setw(2) << setfill('0') << minute - << ".coconut"; + datetime::ll_to_parts( + datetime::ll_local_now(), year, month, day, hour, minute, unused, + unused); + file << year << setw(2) << setfill('0') << month << setw(2) + << setfill('0') << day << "-" << setw(2) << setfill('0') << hour + << setw(2) << setfill('0') << minute << ".coconut"; filename = file.str(); } if (path.empty()) { - path = os::sparkdata_path("record"); + path = os::sparkdata_path("record"); } auto naggle_ms = config::get().naggle_ms(); @@ -397,7 +422,8 @@ void record_everything(std::string path, std::string filename) { api::ServiceContext ctx = elevated_relay_context(); auto relay = ctx.locate(); - std::set system_symbols = get_relay_symbols(options.record_sim()); + std::set system_symbols = + get_relay_symbols(options.record_sim()); RelayClient client(relay, nullptr, system_symbols, recorder); RelayScheduler scheduler(ctx, naggle_ms, client); @@ -408,16 +434,13 @@ void record_everything(std::string path, std::string filename) { /* * extern api for c# -*/ + */ struct RelayControl { - RelayControl(MDConsumer* pconsumer, uint32_t interval) : - context(), - relay(context.locate()), - producer(false), - client(relay, pconsumer, std::set(), producer), - scheduler(context, interval, client) - { + RelayControl(MDConsumer *pconsumer, uint32_t interval) + : context(), relay(context.locate()), producer(false), + client(relay, pconsumer, std::set(), producer), + scheduler(context, interval, client) { scheduler.run(); } api::ServiceContext context; @@ -427,26 +450,22 @@ struct RelayControl { RelayScheduler scheduler; }; -RelayControl* start_private_relay(MDConsumer* pconsumer, uint32_t interval) { +RelayControl *start_private_relay(MDConsumer *pconsumer, uint32_t interval) { bts_assert(pconsumer); return new RelayControl(pconsumer, interval); } -void stop_relay(RelayControl* relay) { +void stop_relay(RelayControl *relay) { if (relay) { relay->scheduler.running = false; bool terminated = false; - relay->context.post([&]() { - terminated = true; - }, 500); + relay->context.post([&]() { terminated = true; }, 500); } } -void add_relay_symbol(RelayControl* relay, const SecurityChannel& chan) { +void add_relay_symbol(RelayControl *relay, const SecurityChannel &chan) { bts_assert(relay); - relay->context.post([=]() { - relay->client.add_symbol(chan); - }); + relay->context.post([=]() { relay->client.add_symbol(chan); }); } -void set_relay_token(RelayControl* relay, const std::string& token) { +void set_relay_token(RelayControl *relay, const std::string &token) { bts_assert(relay); relay->context.post([=]() { api::AuthToken auth_token; @@ -455,10 +474,10 @@ void set_relay_token(RelayControl* relay, const std::string& token) { }); } -utils::Dispatcher& scan_securities_thread() { +utils::Dispatcher &scan_securities_thread() { return utils::Dispatcher::background(); } - -} }//namespace +} // namespace md +} // namespace bts #endif diff --git a/src/lib/md/relay/RelayClient.h b/src/lib/md/relay/RelayClient.h index e4694012a..0de94e4d4 100644 --- a/src/lib/md/relay/RelayClient.h +++ b/src/lib/md/relay/RelayClient.h @@ -1,44 +1,47 @@ #pragma once -#include "lib/utils/bts_no_copy.h" -#include "lib/utils/bts_export.h" -#include "../UserSymbol.h" #include "../MDConsumer.h" +#include "../UserSymbol.h" #include "lib/utils/Dispatcher.h" -#include +#include "lib/utils/bts_export.h" +#include "lib/utils/bts_no_copy.h" #include +#include #include "lib/md/protos/co2.pb.h" namespace bts { namespace pubsub { - class PubsubHub; +class PubsubHub; } namespace api { - class ServiceContext; +class ServiceContext; } namespace md { struct RelayControl; -void add_relay_symbol(RelayControl* relay, const co2::SecurityChannel& chan); -void set_relay_token(RelayControl* relay, const std::string& token); +void add_relay_symbol(RelayControl *relay, const co2::SecurityChannel &chan); +void set_relay_token(RelayControl *relay, const std::string &token); struct IRelayWriter { - virtual ~IRelayWriter() {}; - virtual void write(const co2::MDReply& data, bool* has_new_securities) = 0; + virtual ~IRelayWriter(){}; + virtual void write(const co2::MDReply &data, bool *has_new_securities) = 0; }; -utils::Dispatcher& scan_securities_thread(); +utils::Dispatcher &scan_securities_thread(); -void relay_selected(api::ServiceContext& ctx, const std::set& symbols, IRelayWriter& writer); -void local_relay(IRelayWriter& writer); +void relay_selected( + api::ServiceContext &ctx, const std::set &symbols, + IRelayWriter &writer); +void local_relay(IRelayWriter &writer); extern "C" { BTS_EXPORT void relay_everything(); -BTS_EXPORT RelayControl* start_private_relay(MDConsumer* consumer, uint32_t interval); -BTS_EXPORT void stop_relay(RelayControl* relay); +BTS_EXPORT RelayControl * +start_private_relay(MDConsumer *consumer, uint32_t interval); +BTS_EXPORT void stop_relay(RelayControl *relay); } -}}//namespace - +} // namespace md +} // namespace bts diff --git a/src/lib/md/relay/RelayRecorder.cpp b/src/lib/md/relay/RelayRecorder.cpp index f443c0926..c693b5393 100644 --- a/src/lib/md/relay/RelayRecorder.cpp +++ b/src/lib/md/relay/RelayRecorder.cpp @@ -2,16 +2,16 @@ #include "RelayRecorder.h" #include "lib/config/config.h" -#include "lib/utils/HTTPStream.h" -#include "lib/utils/datetime.h" #include "lib/logging/logging.h" +#include "lib/utils/HTTPStream.h" #include "lib/utils/bts_chrono.h" +#include "lib/utils/datetime.h" +#include "lib/config/protos/MarketData.pb.h" +#include "lib/config/protos/system.pb.h" +#include "lib/md/SecurityIDRecorder.h" #include "lib/md/common.h" #include "lib/md/protos/co2.pb.h" -#include "lib/md/SecurityIDRecorder.h" -#include "lib/config/protos/system.pb.h" -#include "lib/config/protos/MarketData.pb.h" #include "lib/utils/bts_chrono.h" #include @@ -26,21 +26,19 @@ using namespace bts::co2; namespace bts { namespace md { -const char* magic = "Co2"; +const char *magic = "Co2"; const uint32_t recorder_version = 3; -template -void writebuf(ofstream& out, const T& pb) { +template void writebuf(ofstream &out, const T &pb) { uint32_t size = pb.ByteSize(); - out.write(reinterpret_cast(&size), sizeof(size)); + out.write(reinterpret_cast(&size), sizeof(size)); bts_assert(pb.SerializeToOstream(&out)); } -template -bool readbuf(istream& in, T* result) { +template bool readbuf(istream &in, T *result) { if (result) { uint32_t size; - in.read(reinterpret_cast(&size), sizeof(size)); + in.read(reinterpret_cast(&size), sizeof(size)); vector buffer(size); in.read(&buffer[0], size); if (!in.fail()) { @@ -51,11 +49,10 @@ bool readbuf(istream& in, T* result) { return false; } -RelayRecorder::RelayRecorder(const std::string& base_path, const std::string& filename, uint32_t naggle): - _filename(base_path+"/"+filename), - _file() -{ - LOG(md,Info,"Recording market data to: {}" , _filename); +RelayRecorder::RelayRecorder( + const std::string &base_path, const std::string &filename, uint32_t naggle) + : _filename(base_path + "/" + filename), _file() { + LOG(md, Info, "Recording market data to: {}", _filename); boost::system::error_code ec; boost::filesystem::create_directories(base_path, ec); _file.open(_filename, ios::out | ios::binary | ios::trunc); @@ -70,23 +67,19 @@ RelayRecorder::RelayRecorder(const std::string& base_path, const std::string& fi writebuf(_file, header); } -RelayRecorder::~RelayRecorder() { } +RelayRecorder::~RelayRecorder() {} -void RelayRecorder::write(const co2::MDReply& data, bool*) { +void RelayRecorder::write(const co2::MDReply &data, bool *) { writebuf(_file, data); flush(); } -void RelayRecorder::flush() { - _file.flush(); -} +void RelayRecorder::flush() { _file.flush(); } -struct ConsoleReplayWriter : IRelayWriter -{ - ConsoleReplayWriter() : count(0) { } +struct ConsoleReplayWriter : IRelayWriter { + ConsoleReplayWriter() : count(0) {} int count; - virtual void write(const co2::MDReply& data, bool*) override - { + virtual void write(const co2::MDReply &data, bool *) override { ++count; cout << count << " MDReply {" << endl; data.PrintDebugString(); @@ -94,15 +87,14 @@ struct ConsoleReplayWriter : IRelayWriter } }; -struct ConsoleTraceWriter : IRelayWriter -{ +struct ConsoleTraceWriter : IRelayWriter { int count; security_key key; - ConsoleTraceWriter(security_key k): count(0), key(k) { } - virtual void write(const co2::MDReply & data, bool*) override { + ConsoleTraceWriter(security_key k) : count(0), key(k) {} + virtual void write(const co2::MDReply &data, bool *) override { ++count; - for (const auto& chan : data.channels()) { - for (const auto& update : chan.updates()) { + for (const auto &chan : data.channels()) { + for (const auto &update : chan.updates()) { if (update.key() == key) { cout << count << " Update {" << endl; update.PrintDebugString(); @@ -114,10 +106,11 @@ struct ConsoleTraceWriter : IRelayWriter }; #ifndef _WIN32 -void record_security_keys(md::SecurityIDRecorder& idrec, const co2::MDReply& reply) { - std::vector data; - for (const auto& chan : reply.channels()) { - for (const auto& upd : chan.updates()) { +void record_security_keys( + md::SecurityIDRecorder &idrec, const co2::MDReply &reply) { + std::vector data; + for (const auto &chan : reply.channels()) { + for (const auto &upd : chan.updates()) { if (upd.has_security()) { data.push_back(&upd.security()); } @@ -127,62 +120,67 @@ void record_security_keys(md::SecurityIDRecorder& idrec, const co2::MDReply& rep } #endif -void replay_recording(istream& in, IRelayWriter& writer, int32_t naggle_ms) { +void replay_recording(istream &in, IRelayWriter &writer, int32_t naggle_ms) { bts_assert(!in.bad()); CoconutReplayHeader header; size_t count = 0; - #ifndef _WIN32 - md::SecurityIDRecorder idrec {{}}; - #endif - if (readbuf(in, &header) && header.magic() == magic && header.version() == recorder_version) { +#ifndef _WIN32 + md::SecurityIDRecorder idrec{{}}; +#endif + if (readbuf(in, &header) && header.magic() == magic && + header.version() == recorder_version) { co2::MDReply message; while (readbuf(in, &message)) { bool has_securities = false; writer.write(message, &has_securities); if (has_securities) { - // record security ids to avoid breaking simulator - #ifndef _WIN32 +// record security ids to avoid breaking simulator +#ifndef _WIN32 record_security_keys(idrec, message); - #endif +#endif } message.Clear(); - if (naggle_ms >0) std::this_thread::sleep_for(std::chrono::duration(naggle_ms)); - else if (naggle_ms == -1/*interactive*/) { + if (naggle_ms > 0) + std::this_thread::sleep_for( + std::chrono::duration(naggle_ms)); + else if (naggle_ms == -1 /*interactive*/) { ++count; cout << count << endl; cin.get(); } } - } - else { + } else { cout << "Invalid file format." << endl; } } -void replay_file(const std::string& filename, IRelayWriter& writer, int32_t naggle_ms, bool loop) { +void replay_file( + const std::string &filename, IRelayWriter &writer, int32_t naggle_ms, + bool loop) { do { ifstream in; in.open(filename, ios::binary | ios::in); if (in.is_open()) { replay_recording(in, writer, naggle_ms); - } - else { - LOG(md,Diag, "Cannot read file {}", filename); + } else { + LOG(md, Diag, "Cannot read file {}", filename); if (loop) sleep_for(10s); } } while (loop); } -bool replay_url(const std::string& url, IRelayWriter& writer, int32_t naggle_ms, bool loop) { +bool replay_url( + const std::string &url, IRelayWriter &writer, int32_t naggle_ms, + bool loop) { // split up url parts size_t http_len = BTS_ARRAYSIZE("http://") - 1; auto after_host = url.find('/', http_len); - auto host = url.substr(http_len, after_host-http_len); + auto host = url.substr(http_len, after_host - http_len); auto path = url.substr(after_host); auto last_slash = url.rfind('/'); - auto filename = url.substr(last_slash+1); - filename = os::sparkdata_path("data/replay/") + filename; + auto filename = url.substr(last_slash + 1); + filename = os::sparkdata_path("data/replay/") + filename; utils::download_file_if_newer(host, path, filename); if (boost::filesystem::exists(filename)) { replay_file(filename, writer, naggle_ms, loop); @@ -191,7 +189,9 @@ bool replay_url(const std::string& url, IRelayWriter& writer, int32_t naggle_ms, return false; } -void replay_url_with_fallback(const std::string& url, IRelayWriter& writer, int32_t naggle_ms, bool loop) { +void replay_url_with_fallback( + 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(); if (boost::filesystem::exists(fallback)) { @@ -203,15 +203,17 @@ void replay_url_with_fallback(const std::string& url, IRelayWriter& writer, int3 struct SecurityExtractorDone : public std::bad_exception {}; struct SecurityExtractor : public IRelayWriter { size_t _count; - std::function _cb; + std::function _cb; std::set _keys; - SecurityExtractor(std::function& cb, size_t count) - : _count(count), _cb(cb), _keys() { } - ~SecurityExtractor() override {}; - void write(const co2::MDReply& data, bool*) override { + SecurityExtractor( + std::function &cb, size_t count) + : _count(count), _cb(cb), _keys() {} + ~SecurityExtractor() override{}; + void write(const co2::MDReply &data, bool *) override { for (auto const &ch : data.channels()) { for (auto const &cr : ch.updates()) { - if (cr.has_security() && _keys.find(cr.security().id()) == _keys.end()) { + if (cr.has_security() && + _keys.find(cr.security().id()) == _keys.end()) { _keys.insert(cr.security().id()); _cb(cr.security()); } @@ -223,19 +225,20 @@ struct SecurityExtractor : public IRelayWriter { } }; -void get_securities_from_replay(std::function cb) { +void get_securities_from_replay(std::function cb) { SecurityExtractor extractor(cb, 100); auto url = config::get().url(); try { replay_url_with_fallback(url, extractor, 0, false); - } catch(const SecurityExtractorDone&) { } + } catch (const SecurityExtractorDone &) { + } } - shared_ptr mkrelayproducer(bool shared); /*this is the public one*/ -void replay_recording(const string& filename, int32_t naggle_ms, const std::string fallback) { +void replay_recording( + const string &filename, int32_t naggle_ms, const std::string fallback) { auto writer = mkrelayproducer(true); if (config::get().interactive()) { naggle_ms = -1; @@ -247,8 +250,7 @@ void replay_recording(const string& filename, int32_t naggle_ms, const std::stri if (filename.find("http://") == 0) { // loops forever replay_url(filename, *writer, naggle_ms); - } - else if (boost::filesystem::exists(filename)) { + } else if (boost::filesystem::exists(filename)) { // loops forever replay_file(filename, *writer, naggle_ms); } @@ -257,17 +259,17 @@ void replay_recording(const string& filename, int32_t naggle_ms, const std::stri replay_file(fallback, *writer, naggle_ms); } } -void print_recording(const string& filename) { +void print_recording(const string &filename) { ConsoleReplayWriter writer; replay_file(filename, writer, 0); } -void trace_recording(const string& filename, security_key key) { +void trace_recording(const string &filename, security_key key) { ConsoleTraceWriter writer(key); replay_file(filename, writer, 0); } -void unprint_recording(const std::string& src, const std::string& dest) { +void unprint_recording(const std::string &src, const std::string &dest) { // quick and dirty minimal error checking ifstream in; in.open(src, ios::binary | ios::in); @@ -294,7 +296,8 @@ void unprint_recording(const std::string& src, const std::string& dest) { while (in) { // '1 MDReply {' in >> index; - if (in.eof()) break; + if (in.eof()) + break; cout << index << " "; char buffer[128]; in.getline(buffer, BTS_ARRAYSIZE(buffer), '{'); @@ -305,13 +308,17 @@ void unprint_recording(const std::string& src, const std::string& dest) { while (bcount > 0 && !in.eof()) { char ch; in.get(ch); - if (ch == '{') ++bcount; - if (ch == '}') --bcount; - if (bcount > 0) message_buffer += ch; + if (ch == '{') + ++bcount; + if (ch == '}') + --bcount; + if (bcount > 0) + message_buffer += ch; } cout << "buffered "; reply_buffer.Clear(); - if (google::protobuf::TextFormat::ParseFromString(message_buffer, &reply_buffer)) { + if (google::protobuf::TextFormat::ParseFromString( + message_buffer, &reply_buffer)) { cout << "parsed "; writebuf(out, reply_buffer); cout << "written"; @@ -321,5 +328,6 @@ void unprint_recording(const std::string& src, const std::string& dest) { out.flush(); } -}}//namespace +} // namespace md +} // namespace bts #endif diff --git a/src/lib/md/relay/RelayRecorder.h b/src/lib/md/relay/RelayRecorder.h index da6286340..b9a670890 100644 --- a/src/lib/md/relay/RelayRecorder.h +++ b/src/lib/md/relay/RelayRecorder.h @@ -1,38 +1,47 @@ #pragma once -#include "lib/utils/bts_no_copy.h" #include "RelayClient.h" -#include -#include +#include "lib/utils/bts_no_copy.h" #include +#include +#include namespace bts { namespace md { class RelayRecorder : public IRelayWriter { -public: - RelayRecorder(const std::string& base_path, const std::string& filename, uint32_t naggle); + public: + RelayRecorder( + const std::string &base_path, const std::string &filename, + uint32_t naggle); ~RelayRecorder(); - virtual void write(const co2::MDReply&, bool*) override; + virtual void write(const co2::MDReply &, bool *) override; - //void flush_and_copy(); + // void flush_and_copy(); void flush(); -private: + private: std::string _filename; std::ofstream _file; BTS_NO_COPY(RelayRecorder); }; void record_everything(std::string path, std::string filename); -void print_recording(const std::string&); -void unprint_recording(const std::string& src, const std::string& dest); -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, bool loop=true); -void replay_url_with_fallback(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, bool loop=false); -void get_securities_from_replay(std::function); - -}}//namespace +void print_recording(const std::string &); +void unprint_recording(const std::string &src, const std::string &dest); +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, + bool loop = true); +void replay_url_with_fallback( + 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, + bool loop = false); +void get_securities_from_replay(std::function); +} // namespace md +} // namespace bts diff --git a/src/lib/md/service/MarketDataServiceServer.cpp b/src/lib/md/service/MarketDataServiceServer.cpp index be72bb7d3..6d9a52919 100644 --- a/src/lib/md/service/MarketDataServiceServer.cpp +++ b/src/lib/md/service/MarketDataServiceServer.cpp @@ -1,26 +1,26 @@ #ifndef _WIN32 -#include "MarketDataServiceServer.h" -#include "lib/metrics/metrics.h" +#include "MarketDataServiceServer.h" +#include "lib/md/Product.h" #include "lib/md/UserSymbol.h" #include "lib/md/get_symbols.h" -#include "lib/md/Product.h" +#include "lib/metrics/metrics.h" #include "lib/utils/AuthToken.h" #include #include - -namespace bts { -namespace md { +namespace bts { +namespace md { struct MarketDataServiceImpl { - MarketDataServiceImpl(api::MarketDataServiceBase::SecuritiesStatefulPublisher); - utils::Dispatcher& dispatcher; + MarketDataServiceImpl( + api::MarketDataServiceBase::SecuritiesStatefulPublisher); + utils::Dispatcher &dispatcher; api::MarketDataServiceBase::SecuritiesStatefulPublisher security_publisher; std::atomic sec_outstanding; - void add_security(const SecurityPtr& sec) { + void add_security(const SecurityPtr &sec) { ++sec_outstanding; - dispatcher.post([this,sec]() { + dispatcher.post([this, sec]() { security_publisher.add_or_update(*sec); auto flush = (--sec_outstanding) == 0; if (flush) { @@ -31,41 +31,36 @@ struct MarketDataServiceImpl { }; MarketDataServiceImpl::MarketDataServiceImpl( - api::MarketDataServiceBase::SecuritiesStatefulPublisher security_pub) : - dispatcher(utils::Dispatcher::get_named("MDService")), - security_publisher(security_pub), - sec_outstanding(0) -{ -} + api::MarketDataServiceBase::SecuritiesStatefulPublisher security_pub) + : dispatcher(utils::Dispatcher::get_named("MDService")), + security_publisher(security_pub), sec_outstanding(0) {} MarketDataService::MarketDataService( - MDClient& md, - api::ServiceContext ctx, - metrics::MetricsContainer&) : - api::AuthenticatedMarketDataServiceBase(ctx) -{ - _me = std::make_shared(make_securities_stateful_publisher()); - md.current_consumer().on_security([me=_me](const SecurityPtr& sec, MDConsumerHandle) { - me->add_security(sec); - }); + MDClient &md, api::ServiceContext ctx, metrics::MetricsContainer &) + : api::AuthenticatedMarketDataServiceBase(ctx) { + _me = std::make_shared( + make_securities_stateful_publisher()); + md.current_consumer().on_security( + [me = _me](const SecurityPtr &sec, MDConsumerHandle) { + me->add_security(sec); + }); } // This method duplicates MarketDataRelayServer::request_products() void MarketDataService::get_products( - const api::AuthToken&, - const ::bts::api::VoidMessage&, - const api::Response<::bts::api::ProductList>& reply) { + const api::AuthToken &, const ::bts::api::VoidMessage &, + const api::Response<::bts::api::ProductList> &reply) { - api::ProductList list; - std::set syms; - md::get_system_md_symbols(syms); - for(const auto& i : syms) { - auto prod = list.add_products(); - prod->set_exchange(i.exchange()); - prod->set_type(i.type()); - prod->set_symbol(i.symbol()); - } - reply(list); + api::ProductList list; + std::set syms; + md::get_system_md_symbols(syms); + for (const auto &i : syms) { + auto prod = list.add_products(); + prod->set_exchange(i.exchange()); + prod->set_type(i.type()); + prod->set_symbol(i.symbol()); + } + reply(list); } api::StreamAccessResponse authorized(bool is_authorized) { @@ -75,42 +70,40 @@ api::StreamAccessResponse authorized(bool is_authorized) { } void MarketDataService::allow_securities( - const bts::api::AuthToken&, - const std::string& qualifier, - const api::Response& reply) { - // Non-empty qualifier is invalid and rejected - reply(authorized(qualifier.empty())); + 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 api::Response& reply) { - api::user::TokenPayload payload; - if (api::auth::decode_token(token, &payload)) { - auto product = api::string_to_product(qualifier); - if (product) { - // todo: start streaming - reply(authorized(true)); - } + const bts::api::AuthToken &token, const std::string &qualifier, + const api::Response &reply) { + api::user::TokenPayload payload; + if (api::auth::decode_token(token, &payload)) { + auto product = api::string_to_product(qualifier); + if (product) { + // todo: start streaming + reply(authorized(true)); } - reply(authorized(false)); -} - -void MarketDataService::allow_trades( - const bts::api::AuthToken& token, - const std::string& qualifier, - const api::Response& reply) { - api::user::TokenPayload payload; - if (api::auth::decode_token(token, &payload)) { - auto product = api::string_to_product(qualifier); - if (product) { - // todo: start streaming - reply(authorized(true)); - } - } - reply(authorized(false)); + } + reply(authorized(false)); } -}} //namespace +void MarketDataService::allow_trades( + const bts::api::AuthToken &token, const std::string &qualifier, + const api::Response &reply) { + api::user::TokenPayload payload; + if (api::auth::decode_token(token, &payload)) { + auto product = api::string_to_product(qualifier); + if (product) { + // todo: start streaming + reply(authorized(true)); + } + } + reply(authorized(false)); +} + +} // namespace md +} // namespace bts #endif \ No newline at end of file diff --git a/src/lib/md/service/MarketDataServiceServer.h b/src/lib/md/service/MarketDataServiceServer.h index 6734828a7..8c3d0cd33 100644 --- a/src/lib/md/service/MarketDataServiceServer.h +++ b/src/lib/md/service/MarketDataServiceServer.h @@ -1,43 +1,41 @@ -#pragma once -#include "lib/utils/Dispatcher.h" +#pragma once #include "lib/api/public/ServiceContext.h" #include "lib/api/services/MarketDataService.server.pb.h" #include "lib/md/MDClient.h" +#include "lib/utils/Dispatcher.h" #include -namespace bts { -namespace metrics { class MetricsContainer; } -namespace md { +namespace bts { +namespace metrics { +class MetricsContainer; +} +namespace md { struct MarketDataServiceImpl; class MarketDataService : public api::AuthenticatedMarketDataServiceBase { std::shared_ptr _me; -public: + + public: MarketDataService( - MDClient& md, - api::ServiceContext ctx, - metrics::MetricsContainer& stats); + MDClient &md, api::ServiceContext ctx, metrics::MetricsContainer &stats); void get_products( - const api::AuthToken&, - const ::bts::api::VoidMessage&, - const api::Response<::bts::api::ProductList>&) override; - + 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 api::Response& reply) override; - + 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 api::Response& reply) override; - + 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 api::Response& reply) override; + const bts::api::AuthToken &token, const std::string &qualifier, + const api::Response &reply) override; }; -}} //namespace +} // namespace md +} // namespace bts diff --git a/src/lib/md/test/Co2ManagedTestHelper.cpp b/src/lib/md/test/Co2ManagedTestHelper.cpp index a59e9a618..56e6244cb 100644 --- a/src/lib/md/test/Co2ManagedTestHelper.cpp +++ b/src/lib/md/test/Co2ManagedTestHelper.cpp @@ -1,9 +1,9 @@ #ifdef _WIN32 -#include "lib/utils/bts_export.h" #include "../coconut2.h" #include "lib/config/config.h" #include "lib/md/protos/co2.pb.h" #include "lib/utils/TimeStamp.h" +#include "lib/utils/bts_export.h" #include #include @@ -13,17 +13,22 @@ namespace test { using namespace co2; -std::vector create_test_securities(MDProducer& producer, const char* postfix = "M"); +std::vector +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); +void assign_ids( + std::vector::iterator begin, + 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) { +extern "C" BTS_EXPORT void co2_get_1234_handle( + 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); std::vector buffer; buffer.resize(1024); - auto pheader = reinterpret_cast(&buffer[0]); + auto pheader = reinterpret_cast(&buffer[0]); pheader->has_depth = false; size = sizeof(MDConsumerHandle); handle.init(*pheader, *pcold, phot.get(), nullptr); @@ -33,30 +38,30 @@ extern "C" BTS_EXPORT void co2_get_1234_handle(size_t& size, MDConsumerHandle& *headeraddr = (uintptr_t)pheader; } -extern "C" BTS_EXPORT void co2_get_sample_hot(size_t& size, HotEntry& entry) { +extern "C" BTS_EXPORT void co2_get_sample_hot(size_t &size, HotEntry &entry) { size = sizeof(HotEntry); entry.key = 1234; entry.book = PriceLevel( - PriceSize_from_double<2>(7.2, 101), - PriceSize_from_double<2>(-9.7, 245)); + PriceSize_from_double<2>(7.2, 101), PriceSize_from_double<2>(-9.7, 245)); entry.sequence = 777; entry.status = COCONUTSECURITYSTATUS_PACKET_LOSS; entry.settlement = IntPrice_from_double<7>(98.6); entry.set_time(utils::TimeStamp::now()); } -extern "C" BTS_EXPORT void co2_get_sample_depth(size_t& size, HotDepthEntry& entry) { +extern "C" BTS_EXPORT void +co2_get_sample_depth(size_t &size, HotDepthEntry &entry) { size = sizeof(HotDepthEntry); entry.key = 1234; for (size_t x = 0; x < COCONUT_MAX_DEPTH; ++x) { - entry.write_direct(x, - PriceSize_from_double<2>(x + 0.5, x + 1), - PriceSize_from_double<2>(x + 0.6, x + 2)); + entry.write_direct( + x, PriceSize_from_double<2>(x + 0.5, x + 1), + PriceSize_from_double<2>(x + 0.6, x + 2)); } for (size_t x = 0; x < COCONUT_MAX_IMPLIED_DEPTH; ++x) { - entry.write_implied(x, - PriceSize_from_double<3>(77, x + 1), - PriceSize_from_double<3>(88, x + 2)); + entry.write_implied( + x, PriceSize_from_double<3>(77, x + 1), + PriceSize_from_double<3>(88, x + 2)); } entry.set_time(utils::TimeStamp::now()); entry.status = COCONUTSECURITYSTATUS_PACKET_LOSS; @@ -64,10 +69,10 @@ extern "C" BTS_EXPORT void co2_get_sample_depth(size_t& size, HotDepthEntry& ent entry.settlement = IntPrice_from_double<7>(98.6); } -extern "C" BTS_EXPORT void co2_get_sample_cold(size_t& size, ColdEntry& entry) { +extern "C" BTS_EXPORT void co2_get_sample_cold(size_t &size, ColdEntry &entry) { size = sizeof(entry); entry.exchange_status = TRADINGSTATUS_NORMAL; - + // Last trade entry.last_trade.store(PriceSize_from_double<2>(4.2, 101)); entry.total_volume = 12345; @@ -81,7 +86,7 @@ extern "C" BTS_EXPORT void co2_get_sample_cold(size_t& size, ColdEntry& entry) { entry.misc.open_date = datetime::Date(2015, 8, 29); entry.misc.close_price = 4.5; entry.misc.close_date = datetime::Date(2015, 7, 7); - + entry.misc.session_high = 1.1; entry.misc.session_low = 2.2; entry.misc.session_high_bid = 4.4; @@ -91,7 +96,7 @@ extern "C" BTS_EXPORT void co2_get_sample_cold(size_t& size, ColdEntry& entry) { entry.from_spread = 0; } -extern "C" BTS_EXPORT void co2_get_sample_cold_header(ColdHeader& header) { +extern "C" BTS_EXPORT void co2_get_sample_cold_header(ColdHeader &header) { header.segment_count = 1; header.create_time = utils::TimeStamp::now(); header.heartbeat = utils::TimeStamp::now(); @@ -113,28 +118,34 @@ struct TestProducer { std::vector handles; }; -extern "C" BTS_EXPORT TestProducer* co2_produce_test_md() { - config::internal::initialize_for_test( - "PlatformMap {" - " value {" - " glbx_platform: 'PLATFORM_SIM'" - " }" - "}"); - auto* tp = new TestProducer(); +extern "C" BTS_EXPORT TestProducer *co2_produce_test_md() { + config::internal::initialize_for_test("PlatformMap {" + " value {" + " glbx_platform: 'PLATFORM_SIM'" + " }" + "}"); + auto *tp = new TestProducer(); tp->md = std::make_shared(PLATFORM_SIM, MDProducerFlags::None); tp->handles = create_test_securities(*(tp->md)); - auto& producers = tp->handles; + auto &producers = tp->handles; assign_ids(producers.begin(), producers.end()); - for (auto& p : producers) { - p.update_bbo(utils::TimeStamp::now(), PriceSize_from_double<3>(1.1, 101), PriceSize_from_double<3>(2.2,202)); - p.add_trade(utils::TimeStamp::now(), - PriceSize_from_double<3>(5.5, 505), - datetime::ll_from_date(datetime::Date(2015, 9, 22)), - AGGRESSOR_SIDE_NONE, 4200); - p.update_settlement(utils::TimeStamp::now(), IntPrice_from_double<7>(6.6), datetime::Date(2000, 8, 8)); - p.update_settlement(utils::TimeStamp::now(), IntPrice_from_double<7>(6.6), datetime::Date(2000, 8, 9)); + for (auto &p : producers) { + p.update_bbo( + utils::TimeStamp::now(), PriceSize_from_double<3>(1.1, 101), + PriceSize_from_double<3>(2.2, 202)); + p.add_trade( + utils::TimeStamp::now(), PriceSize_from_double<3>(5.5, 505), + datetime::ll_from_date(datetime::Date(2015, 9, 22)), + AGGRESSOR_SIDE_NONE, 4200); + p.update_settlement( + utils::TimeStamp::now(), IntPrice_from_double<7>(6.6), + datetime::Date(2000, 8, 8)); + p.update_settlement( + utils::TimeStamp::now(), IntPrice_from_double<7>(6.6), + datetime::Date(2000, 8, 9)); - p.update_opening(utils::TimeStamp::now(), 7.7, datetime::Date(2001, 1, 2)); + p.update_opening( + utils::TimeStamp::now(), 7.7, datetime::Date(2001, 1, 2)); auto t = utils::TimeStamp::now(); p.update_closing(t, 8.8, datetime::Date(2002, 3, 4)); p.update_session_high(t, 9.9); @@ -147,27 +158,32 @@ extern "C" BTS_EXPORT TestProducer* co2_produce_test_md() { return tp; } -extern "C" BTS_EXPORT void co2_destroy_test_md(TestProducer* producer) { - if (producer != nullptr) delete producer; +extern "C" BTS_EXPORT void co2_destroy_test_md(TestProducer *producer) { + if (producer != nullptr) + delete producer; config::internal::reset(); } -extern "C" BTS_EXPORT void co2_get_zero_and_nan_book(PriceLevel& price) { - price = { NO_MARKET, PriceSize_from_double<7>(0,1) }; +extern "C" BTS_EXPORT void co2_get_zero_and_nan_book(PriceLevel &price) { + price = {NO_MARKET, PriceSize_from_double<7>(0, 1)}; } -extern "C" BTS_EXPORT void co2_get_nan_price_size(PriceSize& ps) { +extern "C" BTS_EXPORT void co2_get_nan_price_size(PriceSize &ps) { ps = NO_MARKET; } -extern "C" BTS_EXPORT void co2_test_get_constants(size_t& max_depth, size_t& max_implied_depth, uint8_t& nan_exponent) { +extern "C" BTS_EXPORT void co2_test_get_constants( + size_t &max_depth, size_t &max_implied_depth, uint8_t &nan_exponent) { max_depth = COCONUT_MAX_DEPTH; max_implied_depth = COCONUT_MAX_IMPLIED_DEPTH; nan_exponent = INT_NAN.exponent(); } -extern "C" BTS_EXPORT void co2_get_sample_datetime(datetime::LLDateTime& now, datetime::LLDateTime& utc_now) { - now = datetime::ll_local_now(); - utc_now = datetime::ll_now(); +extern "C" BTS_EXPORT void co2_get_sample_datetime( + datetime::LLDateTime &now, datetime::LLDateTime &utc_now) { + now = datetime::ll_local_now(); + utc_now = datetime::ll_now(); } -}}}//namespace +} // namespace test +} // namespace md +} // namespace bts #endif diff --git a/src/lib/md/test/Co2TestInstrument.cpp b/src/lib/md/test/Co2TestInstrument.cpp index 0c2c2274a..a22ab5b0c 100644 --- a/src/lib/md/test/Co2TestInstrument.cpp +++ b/src/lib/md/test/Co2TestInstrument.cpp @@ -5,48 +5,52 @@ namespace bts { namespace md { -Co2TestInstrument::Co2TestInstrument(const std::string& symbol, SecurityType type): - _cold_buffer(), - _cold(nullptr), - _hot(std::make_shared()), - _cheader(std::make_shared()), - _hheader(std::make_shared()) -{ +Co2TestInstrument::Co2TestInstrument( + const std::string &symbol, SecurityType type) + : _cold_buffer(), _cold(nullptr), _hot(std::make_shared()), + _cheader(std::make_shared()), + _hheader(std::make_shared()) { _cheader->has_depth = enable_depth(symbol, type); - with_security(type, 4, nullptr, [&](FixedSecurity& fsec) { + with_security(type, 4, nullptr, [&](FixedSecurity &fsec) { fsec.exchange = api::VENUE_BTS; - _cold_buffer = std::shared_ptr(new uint8_t[ColdEntry::fixed_size() + fsec.size], std::default_delete()); + _cold_buffer = std::shared_ptr( + new uint8_t[ColdEntry::fixed_size() + fsec.size], + std::default_delete()); _cold = new (_cold_buffer.get()) ColdEntry(fsec.size); memcpy(&_cold->security, &fsec, fsec.size); }); } -Co2TestInstrument::Co2TestInstrument(const Security& security, std::shared_ptr cheader, std::shared_ptr hheader): - _cold(nullptr), - _hot(std::make_shared()), - _cheader(cheader), - _hheader(hheader) -{ +Co2TestInstrument::Co2TestInstrument( + 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()); - with_security_like(security, [&](FixedSecurity& fsec) { + //_cheader->has_depth = enable_depth(md::SecurityHelper::symbol(security), + //security.security_type()); + with_security_like(security, [&](FixedSecurity &fsec) { convert_security(security, fsec, false); - _cold_buffer = std::shared_ptr(new uint8_t[ColdEntry::fixed_size() + fsec.size], std::default_delete()); + _cold_buffer = std::shared_ptr( + new uint8_t[ColdEntry::fixed_size() + fsec.size], + std::default_delete()); _cold = new (_cold_buffer.get()) ColdEntry(fsec.size); memcpy(&_cold->security, &fsec, fsec.size); }); } MDProducerHandle Co2TestInstrument::producer() { - return MDProducerHandle(*_cheader, *_hheader, *_cold, _hot.get(), MDProducerChannel()); + return MDProducerHandle( + *_cheader, *_hheader, *_cold, _hot.get(), MDProducerChannel()); } MDConsumerHandle Co2TestInstrument::consumer() { MDConsumerHandle handle; - handle.init(*_cheader, *_cold, _hot.get(), nullptr/*mbo*/); + handle.init(*_cheader, *_cold, _hot.get(), nullptr /*mbo*/); return handle; } -Co2TestInstrument::~Co2TestInstrument() { } +Co2TestInstrument::~Co2TestInstrument() {} -}}//namespace +} // namespace md +} // namespace bts diff --git a/src/lib/md/test/Co2TestInstrument.h b/src/lib/md/test/Co2TestInstrument.h index dfd784908..4b85b86a4 100644 --- a/src/lib/md/test/Co2TestInstrument.h +++ b/src/lib/md/test/Co2TestInstrument.h @@ -1,30 +1,31 @@ #pragma once -#include "lib/utils/bts_no_copy.h" #include "../coconut2.h" +#include "lib/utils/bts_no_copy.h" #include namespace bts { namespace md { -struct Co2TestInstrument -{ - Co2TestInstrument(const std::string& symbol, SecurityType type); - Co2TestInstrument(const Security& security, std::shared_ptr, std::shared_ptr); +struct Co2TestInstrument { + Co2TestInstrument(const std::string &symbol, SecurityType type); + Co2TestInstrument( + const Security &security, std::shared_ptr, + std::shared_ptr); ~Co2TestInstrument(); MDProducerHandle producer(); MDConsumerHandle consumer(); - ColdEntry& cold() { return *_cold; } + ColdEntry &cold() { return *_cold; } -private: + private: std::shared_ptr _cold_buffer; - ColdEntry* _cold; + ColdEntry *_cold; std::shared_ptr _hot; std::shared_ptr _cheader; std::shared_ptr _hheader; }; -}}//namespace - +} // namespace md +} // namespace bts diff --git a/src/lib/md/test/mbo_tests.cpp b/src/lib/md/test/mbo_tests.cpp index 69abb194e..1425cb3ac 100644 --- a/src/lib/md/test/mbo_tests.cpp +++ b/src/lib/md/test/mbo_tests.cpp @@ -1,17 +1,18 @@ #ifndef _WIN32 -#include "catch/catch.hpp" #include "../IntPrice.h" #include "../MBOProcessor.h" #include "Co2TestInstrument.h" +#include "catch/catch.hpp" -#include #include +#include namespace bts { namespace md { // fwd declare from MBOServiceServer.cpp -std::optional search_orders(const ExchangeOrderKey oid, const std::vector& orders); +std::optional search_orders( + const ExchangeOrderKey oid, const std::vector &orders); namespace test { int mbo_tests = 0; @@ -21,9 +22,9 @@ TEST_CASE("MBO publish snapshot", "[md][mbo]") { // publish a snapshot auto sec = SecurityKey(99); { - auto s = p.writer().allocate_snapshot(); - s->bids.push_back({ ExchangeOrderKey(1), { 100, 0 }, 42 }); - p.writer().publish_snapshot(sec, &s); + auto s = p.writer().allocate_snapshot(); + s->bids.push_back({ExchangeOrderKey(1), {100, 0}, 42}); + p.writer().publish_snapshot(sec, &s); } auto s = p.reader().acquire_snapshot(sec); @@ -33,25 +34,21 @@ TEST_CASE("MBO publish snapshot", "[md][mbo]") { REQUIRE(s->asks.size() == 0); } -std::vector gen_test_orders(uint64_t id=100, inc::UpdateType type=inc::UpdateType::Bid) { +std::vector gen_test_orders( + uint64_t id = 100, inc::UpdateType type = inc::UpdateType::Bid) { std::vector result; inc::Priority priority = 10000; - for (int p = 100; p < 501; p+=100) { + for (int p = 100; p < 501; p += 100) { // 6 sizes for (int32_t s = 1; s <= 5; ++s) { - IntPrice price { p + 5 , -2}; + IntPrice price{p + 5, -2}; auto order_id = ExchangeOrderKey(++id); auto size = s; priority++; - result.push_back( inc::Update { - order_id, - priority, - price, - size, - type, - inc::UpdateAction::New - }); - // std::cout << std::endl << order_id.value() << ": " << price.price() << "-" << size; + result.push_back(inc::Update{ + order_id, priority, price, size, type, inc::UpdateAction::New}); + // std::cout << std::endl << order_id.value() << ": " << price.price() + // << "-" << size; } } std::random_shuffle(result.begin(), result.end()); @@ -60,7 +57,7 @@ std::vector gen_test_orders(uint64_t id=100, inc::UpdateType type=i TEST_CASE("MBO state to snapshot", "[md][mbo]") { // convert state to snapshot - Co2TestInstrument instr { "MBO", api::SECURITYTYPE_FUTURE }; + Co2TestInstrument instr{"MBO", api::SECURITYTYPE_FUTURE}; auto handle = instr.producer(); MBOWorkingState state(handle); @@ -80,15 +77,15 @@ TEST_CASE("MBO state to snapshot", "[md][mbo]") { REQUIRE(bids.size() == result.bids.size()); REQUIRE(asks.size() == result.asks.size()); for (size_t x = 0; x < result.bids.size() - 1; ++x) { - REQUIRE(result.bids[x].price >= result.bids[x+1].price); + REQUIRE(result.bids[x].price >= result.bids[x + 1].price); } for (size_t x = 0; x < result.asks.size() - 1; ++x) { - REQUIRE(result.asks[x].price <= result.asks[x+1].price); + REQUIRE(result.asks[x].price <= result.asks[x + 1].price); } } template -std::vector concat(const std::vector& a, const std::vector& b) { +std::vector concat(const std::vector &a, const std::vector &b) { std::vector res; std::copy(a.begin(), a.end(), std::back_inserter(res)); std::copy(b.begin(), b.end(), std::back_inserter(res)); @@ -97,13 +94,13 @@ std::vector concat(const std::vector& a, const std::vector& b) { TEST_CASE("MBO incremental", "[md][mbo]") { // basic incremental test - Co2TestInstrument instr { "MBO", api::SECURITYTYPE_FUTURE }; + Co2TestInstrument instr{"MBO", api::SECURITYTYPE_FUTURE}; auto handle = instr.producer(); MBOWorkingState state(handle); - - auto orders = - concat( gen_test_orders(128, inc::UpdateType::Bid), - gen_test_orders(256, inc::UpdateType::Ask)); + + auto orders = concat( + gen_test_orders(128, inc::UpdateType::Bid), + gen_test_orders(256, inc::UpdateType::Ask)); std::random_shuffle(orders.begin(), orders.end()); apply_incremental(state, orders); @@ -115,42 +112,31 @@ TEST_CASE("MBO incremental", "[md][mbo]") { // - change all size=2 to size=6 // - delete all size=3 size_t removed = 0; - for (const auto& e : orders) { + for (const auto &e : orders) { if (e.size == 2) { - updates.push_back( inc::Update { - e.order_id, - e.priority, - e.price, - 6, - e.type, - inc::UpdateAction::Change - }); - } - else if (e.size == 3) { + updates.push_back(inc::Update{ + e.order_id, e.priority, e.price, 6, e.type, + inc::UpdateAction::Change}); + } else if (e.size == 3) { ++removed; - updates.push_back( inc::Update { - e.order_id, - e.priority, - e.price, - e.size, - e.type, - inc::UpdateAction::Delete - }); + updates.push_back(inc::Update{ + e.order_id, e.priority, e.price, e.size, e.type, + inc::UpdateAction::Delete}); } } - apply_incremental(state,updates); + apply_incremental(state, updates); REQUIRE(state.bid.size() + state.ask.size() == (orders.size() - removed)); MBOSnapshot result; copy_to_snapshot(state, &result); - auto all = concat (result.bids, result.asks); - std::map counts; - for (const auto& order : all) { + auto all = concat(result.bids, result.asks); + std::map counts; + for (const auto &order : all) { REQUIRE(order.size != 3); REQUIRE(order.size != 2); - counts[order.size] ++; + counts[order.size]++; } REQUIRE(counts[6] > 0); REQUIRE(counts[6] == counts[1]); @@ -159,33 +145,31 @@ TEST_CASE("MBO incremental", "[md][mbo]") { } TEST_CASE("MBO sort order", "[md][mbo]") { - Co2TestInstrument instr { "MBO", api::SECURITYTYPE_FUTURE }; + Co2TestInstrument instr{"MBO", api::SECURITYTYPE_FUTURE}; auto handle = instr.producer(); MBOWorkingState state(handle); std::vector updates; // multiple updates at the same price - for (unsigned x=0; x < 100; ++x) { + for (unsigned x = 0; x < 100; ++x) { // bid auto p = 1000 + x; - updates.push_back( inc::Update { - ExchangeOrderKey(1000 + x), - 1000 + x, - { 1000, -1 }, - (int)x+1, - inc::UpdateType::Bid, - inc::UpdateAction::New - }); + updates.push_back(inc::Update{ + ExchangeOrderKey(1000 + x), + 1000 + x, + {1000, -1}, + (int)x + 1, + inc::UpdateType::Bid, + inc::UpdateAction::New}); // ask if (x < 75) { // ensure bid.size != ask.size - updates.push_back( inc::Update { - ExchangeOrderKey(2000 + x), - 2000 + x, - { 2000, -1 }, - (int)x+1, - inc::UpdateType::Ask, - inc::UpdateAction::New - }); + updates.push_back(inc::Update{ + ExchangeOrderKey(2000 + x), + 2000 + x, + {2000, -1}, + (int)x + 1, + inc::UpdateType::Ask, + inc::UpdateAction::New}); } } std::random_shuffle(updates.begin(), updates.end()); @@ -195,24 +179,24 @@ TEST_CASE("MBO sort order", "[md][mbo]") { MBOSnapshot result; copy_to_snapshot(state, &result); - // Since all orders are at the same price we can assert they are in priority order - // Since priority is not explicit in the shapshot we set order_id to the same value + // Since all orders are at the same price we can assert they are in priority + // order Since priority is not explicit in the shapshot we set order_id to + // the same value for (size_t x = 0; x < result.bids.size() - 1; ++x) { - REQUIRE(result.bids[x].id.value() < result.bids[x+1].id.value()); + REQUIRE(result.bids[x].id.value() < result.bids[x + 1].id.value()); } for (size_t x = 0; x < result.asks.size() - 1; ++x) { - REQUIRE(result.asks[x].id.value() < result.asks[x+1].id.value()); + REQUIRE(result.asks[x].id.value() < result.asks[x + 1].id.value()); } } - TEST_CASE("MBO change price and size", "[md][mbo]") { // When an order's size goes up it gets a new priority - Co2TestInstrument instr { "MBO", api::SECURITYTYPE_FUTURE }; + Co2TestInstrument instr{"MBO", api::SECURITYTYPE_FUTURE}; auto handle = instr.producer(); MBOWorkingState state(handle); - + constexpr auto bid = inc::UpdateType::Bid; constexpr auto ask = inc::UpdateType::Ask; constexpr auto add = inc::UpdateAction::New; @@ -222,28 +206,28 @@ TEST_CASE("MBO change price and size", "[md][mbo]") { // snapshot std::vector snapshot = { - { ExchangeOrderKey(701267154552), 1160179309, p(2.975), 1, ask, add}, - { ExchangeOrderKey(701267991871), 1161068569, p(2.925), 9, bid, add}, - { ExchangeOrderKey(701267963307), 1161037482, p(2.975), 1, ask, add}, - { ExchangeOrderKey(701267991967), 1161068670, p(2.900), 1, bid, add}, - { ExchangeOrderKey(701267928346), 1160999982, p(3.000), 1, ask, add}, - { ExchangeOrderKey(701267993125), 1161069878, p(2.900), 3, bid, add}, - { ExchangeOrderKey(701267037972), 1160052467, p(2.875), 1, bid, add}, - { ExchangeOrderKey(701267099137), 1160119020, p(2.875), 5, bid, add}, - { ExchangeOrderKey(701267299079), 1160330214, p(2.875), 1, bid, add}, - { ExchangeOrderKey(701267308619), 1160340068, p(2.875), 5, bid, add}, - { ExchangeOrderKey(701267310436), 1160341952, p(2.875), 3, bid, add}, - { ExchangeOrderKey(701267872642), 1160939720, p(2.875), 1, bid, add}, - { ExchangeOrderKey(701267895533), 1160964252, p(2.875), 1, bid, add}, - { ExchangeOrderKey(701267953989), 1161027476, p(2.875), 3, bid, add}, - { ExchangeOrderKey(701267993135), 1161069890, p(2.875), 2, bid, add}, - { ExchangeOrderKey(701266410447), 1159379621, p(2.850), 3, bid, add}, - { ExchangeOrderKey(701267324626), 1160356597, p(2.850), 3, bid, add}, - { ExchangeOrderKey(701267992564), 1161069297, p(2.850), 1, bid, add}, - { ExchangeOrderKey(701266420294), 1159389827, p(2.775), 5, bid, add}, - { ExchangeOrderKey(701267334462), 1160366796, p(2.775), 5, bid, add}, - { ExchangeOrderKey(701266411103), 1159380297, p(2.625), 5, bid, add}, - { ExchangeOrderKey(701267325284), 1160357275, p(2.625), 5, bid, add}, + {ExchangeOrderKey(701267154552), 1160179309, p(2.975), 1, ask, add}, + {ExchangeOrderKey(701267991871), 1161068569, p(2.925), 9, bid, add}, + {ExchangeOrderKey(701267963307), 1161037482, p(2.975), 1, ask, add}, + {ExchangeOrderKey(701267991967), 1161068670, p(2.900), 1, bid, add}, + {ExchangeOrderKey(701267928346), 1160999982, p(3.000), 1, ask, add}, + {ExchangeOrderKey(701267993125), 1161069878, p(2.900), 3, bid, add}, + {ExchangeOrderKey(701267037972), 1160052467, p(2.875), 1, bid, add}, + {ExchangeOrderKey(701267099137), 1160119020, p(2.875), 5, bid, add}, + {ExchangeOrderKey(701267299079), 1160330214, p(2.875), 1, bid, add}, + {ExchangeOrderKey(701267308619), 1160340068, p(2.875), 5, bid, add}, + {ExchangeOrderKey(701267310436), 1160341952, p(2.875), 3, bid, add}, + {ExchangeOrderKey(701267872642), 1160939720, p(2.875), 1, bid, add}, + {ExchangeOrderKey(701267895533), 1160964252, p(2.875), 1, bid, add}, + {ExchangeOrderKey(701267953989), 1161027476, p(2.875), 3, bid, add}, + {ExchangeOrderKey(701267993135), 1161069890, p(2.875), 2, bid, add}, + {ExchangeOrderKey(701266410447), 1159379621, p(2.850), 3, bid, add}, + {ExchangeOrderKey(701267324626), 1160356597, p(2.850), 3, bid, add}, + {ExchangeOrderKey(701267992564), 1161069297, p(2.850), 1, bid, add}, + {ExchangeOrderKey(701266420294), 1159389827, p(2.775), 5, bid, add}, + {ExchangeOrderKey(701267334462), 1160366796, p(2.775), 5, bid, add}, + {ExchangeOrderKey(701266411103), 1159380297, p(2.625), 5, bid, add}, + {ExchangeOrderKey(701267325284), 1160357275, p(2.625), 5, bid, add}, }; apply_incremental(state, snapshot); @@ -251,61 +235,61 @@ TEST_CASE("MBO change price and size", "[md][mbo]") { REQUIRE(state.ask.size() == 3); std::vector incremental = { - { ExchangeOrderKey(701267993738), 1161070510, p(2.925), 2, bid, add}, - { ExchangeOrderKey(701267993759), 1161070532, p(2.975), 3, ask, add}, - { ExchangeOrderKey(701267993884), 1161070662, p(2.950), 3, ask, add}, - { ExchangeOrderKey(701267994228), 1161071029, p(2.925), 2, bid, add}, - { ExchangeOrderKey(701267994243), 1161071044, p(2.925), 4, bid, add}, - { ExchangeOrderKey(701267994228), 1161071029, p(2.925), 2, bid, remove}, - { ExchangeOrderKey(701267993135), 1161071281, p(2.875), 3, bid, change}, + {ExchangeOrderKey(701267993738), 1161070510, p(2.925), 2, bid, add}, + {ExchangeOrderKey(701267993759), 1161070532, p(2.975), 3, ask, add}, + {ExchangeOrderKey(701267993884), 1161070662, p(2.950), 3, ask, add}, + {ExchangeOrderKey(701267994228), 1161071029, p(2.925), 2, bid, add}, + {ExchangeOrderKey(701267994243), 1161071044, p(2.925), 4, bid, add}, + {ExchangeOrderKey(701267994228), 1161071029, p(2.925), 2, bid, remove}, + {ExchangeOrderKey(701267993135), 1161071281, p(2.875), 3, bid, change}, }; apply_incremental(state, incremental); REQUIRE(state.bid.size() == 21); REQUIRE(state.ask.size() == 5); - + { - auto iter = state.bid.begin(); - auto next = state.bid.begin(); - next++; - for (; next != state.bid.end(); ++iter, ++next) { - auto cur_price = std::get(iter->first); - auto cur_prio = std::get<1>(iter->first); - auto next_price = std::get(next->first); - auto next_prio = std::get<1>(next->first); - REQUIRE(cur_price >= next_price); - if (cur_price == next_price) { - REQUIRE(cur_prio < next_prio); + auto iter = state.bid.begin(); + auto next = state.bid.begin(); + next++; + for (; next != state.bid.end(); ++iter, ++next) { + auto cur_price = std::get(iter->first); + auto cur_prio = std::get<1>(iter->first); + auto next_price = std::get(next->first); + auto next_prio = std::get<1>(next->first); + REQUIRE(cur_price >= next_price); + if (cur_price == next_price) { + REQUIRE(cur_prio < next_prio); + } } } - } { - auto iter = state.ask.begin(); - auto next = state.ask.begin(); - next++; - for (; next != state.ask.end(); ++iter, ++next) { - auto cur_price = std::get(iter->first); - auto cur_prio = std::get<1>(iter->first); - auto next_price = std::get(next->first); - auto next_prio = std::get<1>(next->first); - REQUIRE(cur_price <= next_price); - if (cur_price == next_price) { - REQUIRE(cur_prio < next_prio); + auto iter = state.ask.begin(); + auto next = state.ask.begin(); + next++; + for (; next != state.ask.end(); ++iter, ++next) { + auto cur_price = std::get(iter->first); + auto cur_prio = std::get<1>(iter->first); + auto next_price = std::get(next->first); + auto next_prio = std::get<1>(next->first); + REQUIRE(cur_price <= next_price); + if (cur_price == next_price) { + REQUIRE(cur_prio < next_prio); + } } } - } // Do some tests on the snapshot MBOSnapshot result; copy_to_snapshot(state, &result); - auto ask30 = search_orders(ExchangeOrderKey(701267928346), result.asks); + auto ask30 = search_orders(ExchangeOrderKey(701267928346), result.asks); REQUIRE(ask30); REQUIRE(*ask30 == 0); auto bid2875 = search_orders(ExchangeOrderKey(701267993135), result.bids); REQUIRE(bid2875); REQUIRE(*bid2875 == 20); - + bid2875 = search_orders(ExchangeOrderKey(701267299079), result.bids); REQUIRE(bid2875); REQUIRE(*bid2875 == 6); @@ -316,5 +300,7 @@ TEST_CASE("MBO change price and size", "[md][mbo]") { REQUIRE(!not_ask); } -}}} +} // namespace test +} // namespace md +} // namespace bts #endif \ No newline at end of file diff --git a/src/lib/md/test/md2_tests.cpp b/src/lib/md/test/md2_tests.cpp index 74370e662..3dd8ea1ea 100644 --- a/src/lib/md/test/md2_tests.cpp +++ b/src/lib/md/test/md2_tests.cpp @@ -1,35 +1,35 @@ #ifndef _WIN32 -#include "catch/catch.hpp" +#include "../MDClient.h" +#include "../SecurityCache.h" #include "../SettlementRecorder.h" #include "../coconut2.h" #include "../relay/QueryServer.h" -#include "../SecurityCache.h" -#include "../MDClient.h" #include "Co2TestInstrument.h" +#include "catch/catch.hpp" #include "lib/config/config.h" +#include "lib/metrics/metrics.h" #include "lib/os/os.h" #include "lib/utils/Dispatcher.h" +#include "lib/utils/bts_chrono.h" #include "lib/utils/defer.h" #include "lib/utils/warn_ctrl.h" -#include "lib/utils/bts_chrono.h" -#include "lib/metrics/metrics.h" #include "lib/config/protos/MarketData.pb.h" #include "lib/utils/Sqlite_utils.h" #include "md_test_utils.h" -#include -#include +#include +#include #include +#include +#include #include +#include #include #include -#include -#include -#include -#include #include -#include +#include +#include using namespace std; @@ -37,16 +37,18 @@ namespace bts { #ifdef _WIN32 namespace metrics { -struct MetricCollection{}; +struct MetricCollection {}; MetricsContainer::MetricsContainer() {} MetricsContainer::~MetricsContainer() {} -} +} // namespace metrics #endif int md_tests = 0; namespace md { // import this from RelayClient.cpp -PriceSize book_at(const google::protobuf::RepeatedPtrField& side, int index); +PriceSize book_at( + const google::protobuf::RepeatedPtrField &side, + int index); namespace test { using namespace api; @@ -58,18 +60,22 @@ Platform TEST_PLATFORM = PLATFORM_SIM; // Helper functions for Producer/Consumer tests // -std::vector create_test_securities(MDProducer& producer, const char* postfix = ""); +std::vector +create_test_securities(MDProducer &producer, const char *postfix = ""); -set get_test_symbols(const char* postfix="") { +set get_test_symbols(const char *postfix = "") { set symbols; - UserSymbol future_symbol(string("FOO")+postfix, VENUE_BTS, SECURITYTYPE_FUTURE); + UserSymbol future_symbol( + string("FOO") + postfix, VENUE_BTS, SECURITYTYPE_FUTURE); symbols.insert(future_symbol); - UserSymbol option_symbol(string("FOOX")+postfix, VENUE_BTS, SECURITYTYPE_OPTION); + UserSymbol option_symbol( + string("FOOX") + postfix, VENUE_BTS, SECURITYTYPE_OPTION); symbols.insert(option_symbol); return symbols; } -Security mkfuture(string symbol, security_key key, int year, int month, int day) { +Security +mkfuture(string symbol, security_key key, int year, int month, int day) { Security result; result.set_symbol(symbol); result.set_exchange(VENUE_BTS); @@ -79,7 +85,9 @@ Security mkfuture(string symbol, security_key key, int year, int month, int day) result.mutable_future()->set_expiration_year(year); return result; } -Security mkoption(string symbol, security_key key, int year, int month, int day, double strike) { +Security mkoption( + string symbol, security_key key, int year, int month, int day, + double strike) { Security result; result.set_symbol(symbol); result.set_exchange(VENUE_BTS); @@ -91,7 +99,8 @@ Security mkoption(string symbol, security_key key, int year, int month, int day, result.mutable_option()->set_call_put(PUTORCALL_PUT); return result; } -unique_ptr mkfixedfuture(string symbol, security_key key, int year, int month, int day) { +unique_ptr +mkfixedfuture(string symbol, security_key key, int year, int month, int day) { unique_ptr ffs(new FixedFutureSecurity()); ffs->type = SECURITYTYPE_FUTURE; ffs->exchange = VENUE_BTS; @@ -102,24 +111,28 @@ unique_ptr mkfixedfuture(string symbol, security_key key, i ffs->symbol(symbol); return ffs; } -Security mkspread(string symbol, security_key key, const vector& legs) { +Security +mkspread(string symbol, security_key key, const vector &legs) { Security result; result.set_symbol(symbol); result.set_exchange(VENUE_BTS); result.set_id(key); - for (const auto& leg : legs) { - auto* pleg = result.mutable_spread()->add_legs(); + for (const auto &leg : legs) { + auto *pleg = result.mutable_spread()->add_legs(); pleg->mutable_security()->CopyFrom(leg); } return result; } -Security mkspread(string symbol, security_key key, Security leg1, Security leg2) { +Security +mkspread(string symbol, security_key key, Security leg1, Security leg2) { vector vlegs; vlegs.push_back(leg1); vlegs.push_back(leg2); return mkspread(symbol, key, vlegs); } -Security mkspread(string symbol, security_key key, Security leg1, Security leg2, Security leg3) { +Security mkspread( + string symbol, security_key key, Security leg1, Security leg2, + Security leg3) { vector vlegs; vlegs.push_back(leg1); vlegs.push_back(leg2); @@ -127,28 +140,25 @@ Security mkspread(string symbol, security_key key, Security leg1, Security leg2, return mkspread(symbol, key, vlegs); } - -class Co2Tests -{ -public: +class Co2Tests { + public: void setup() { config::internal::initialize_for_test( - "PlatformMap {" - " value {" - " glbx_platform: 'PLATFORM_SIM'" - " }" - "}" - "PublisherOptions {" - " value {" - " heartbeat_ms: 100" - " heartbeat_boot_seconds: 1" - " }" - "}" - ); + "PlatformMap {" + " value {" + " glbx_platform: 'PLATFORM_SIM'" + " }" + "}" + "PublisherOptions {" + " value {" + " heartbeat_ms: 100" + " heartbeat_boot_seconds: 1" + " }" + "}"); } #ifndef WIN32 - void test_security_id_recorder(const std::string& db_name) { + void test_security_id_recorder(const std::string &db_name) { // Verify callbacks happen after work complete auto db1 = sqlite::open_db(db_name.c_str()); REQUIRE(db1); @@ -159,27 +169,24 @@ public: security_key result = invalid_security_key; Security s1 = mkoption("FOOX", invalid_security_key, 2018, 1, 20, 1850); Security f1 = mkfuture("FOO", invalid_security_key, 2018, 1, 20); - idsvc.assign_key(f1, [](const api::Security& s) { + idsvc.assign_key(f1, [](const api::Security &s) { REQUIRE(s.id() != invalid_security_key); }); - idsvc.assign_key(s1, [&result](const api::Security& s) { - result = s.id(); - }); + idsvc.assign_key( + s1, [&result](const api::Security &s) { result = s.id(); }); idsvc.do_work(); REQUIRE(s1.id() == invalid_security_key); REQUIRE(result != invalid_security_key); security_key result2 = invalid_security_key; - idsvc2.assign_key(s1, [&result2](const api::Security& s) { - result2 = s.id(); - }); + idsvc2.assign_key( + s1, [&result2](const api::Security &s) { result2 = s.id(); }); idsvc2.do_work(); if (db_name == ":memory:") { - // This is a meta-test to make sure we don't accidently generate the same key sequence - // when writing to different databases. + // This is a meta-test to make sure we don't accidently generate the + // same key sequence when writing to different databases. REQUIRE(result != result2); - } - else { + } else { REQUIRE(result == result2); } } @@ -195,27 +202,36 @@ public: auto f1 = mkfuture("FO1", invalid_security_key, 2018, 1, 17); f1.mutable_glbx()->set_exchange_id(100); REQUIRE(f1.id() == invalid_security_key); - auto f1handle = std::make_unique (f1, cold_header, hot_header); + auto f1handle = + std::make_unique(f1, cold_header, hot_header); auto f2 = mkfuture("FO2", invalid_security_key, 2018, 1, 20); f2.mutable_glbx()->set_exchange_id(200); - auto f2handle = std::make_unique (f2, cold_header, hot_header); + auto f2handle = + std::make_unique(f2, cold_header, hot_header); - auto s1 = mkspread("FOO", invalid_security_key, { f1, f2 }); - auto s1handle = std::make_unique (s1, cold_header, hot_header); + auto s1 = mkspread("FOO", invalid_security_key, {f1, f2}); + auto s1handle = + std::make_unique(s1, cold_header, hot_header); // Add spread to SecurityIDRecorder and work it auto db = sqlite::open_db(":memory:"); REQUIRE(db); - SecurityIDRecorder idsvc { {db, [&](ExchangeKey k) -> SecurityKey { - for (const auto fut : { f1handle->producer(), f2handle->producer() }) { - if (k.value() == fut.security().numeric_id) return SecurityKey(fut.key()); - } - return SecurityKey(invalid_security_key); - } } }; + SecurityIDRecorder idsvc{ + {db, [&](ExchangeKey k) -> SecurityKey { + for (const auto fut : + {f1handle->producer(), f2handle->producer()}) { + if (k.value() == fut.security().numeric_id) + return SecurityKey(fut.key()); + } + return SecurityKey(invalid_security_key); + }}}; - auto workwork = [&]() { idsvc.do_work(); idsvc.do_work(); }; + auto workwork = [&]() { + idsvc.do_work(); + idsvc.do_work(); + }; idsvc.ensure_key(s1handle->producer()); workwork(); @@ -238,38 +254,39 @@ public: void test_price_size() { // PriceSize violates some type punning rules - // So it is important to have this test work correctly on the target platform + // So it is important to have this test work correctly on the target + // platform PriceSize p2; auto bid = PriceSize_from_double<2>(4.5, 14); auto ask = PriceSize_from_double<9>(4.5, 14); PriceLevel memory; - memory = PriceLevel(bid,ask); + memory = PriceLevel(bid, ask); REQUIRE(bid.price() == memory.bid().price()); - REQUIRE(bid.size() == memory.bid().size()); + REQUIRE(bid.size() == memory.bid().size()); REQUIRE(ask.price() == memory.ask().price()); - REQUIRE(ask.size() == memory.ask().size()); - for (auto p : { memory.bid(), memory.ask() }) { + REQUIRE(ask.size() == memory.ask().size()); + for (auto p : {memory.bid(), memory.ask()}) { REQUIRE(p.price() == 4.5); REQUIRE(p.size() == 14); } auto p = PriceSize_from_double<2>(4.0, 5); - memory = PriceLevel(p,p); - for (auto p2 : { memory.bid(), memory.ask() }) { + memory = PriceLevel(p, p); + for (auto p2 : {memory.bid(), memory.ask()}) { REQUIRE(p2.price() == 4.0); REQUIRE(p2.size() == 5); } p = PriceSize_from_double<2>(-4.2, 6); - memory = PriceLevel(p,p); - for (auto p2 : { memory.bid(), memory.ask() }) { + memory = PriceLevel(p, p); + for (auto p2 : {memory.bid(), memory.ask()}) { REQUIRE(p2.price() == -4.2); REQUIRE(p2.size() == 6); } p = PriceSize({4, -1}, 2); - memory = PriceLevel(p,p); - for (auto p2 : { memory.bid(), memory.ask() }) { + memory = PriceLevel(p, p); + for (auto p2 : {memory.bid(), memory.ask()}) { REQUIRE(p2.price() == 0.4); REQUIRE(p2.size() == 2); } @@ -277,8 +294,8 @@ public: // Test requirement for more than 32 bit mantissa double bigval = -9999.9921875; p = PriceSize_from_double<7>(bigval, 42); - memory = PriceLevel(p,p); - for (auto p2 : { memory.bid(), memory.ask() }) { + memory = PriceLevel(p, p); + for (auto p2 : {memory.bid(), memory.ask()}) { REQUIRE(p2.price() == bigval); REQUIRE(p2.size() == 42); } @@ -288,22 +305,22 @@ public: auto min_tick_2017 = 9999.0078125; auto p17 = PriceSize_from_double<7>(min_tick_2017, 2017); PriceLevel m17(p17, p17); - for (auto p : { m17.bid(), m17.ask() }) { + for (auto p : {m17.bid(), m17.ask()}) { REQUIRE(min_tick_2017 == p.price()); REQUIRE(p.size() == 2017); } auto min_tick_2018 = 1999.00390625; auto p18 = PriceSize_from_double<8>(min_tick_2018, 2018); PriceLevel m18(p18, p18); - for (auto p : { m18.bid(), m18.ask() }) { + for (auto p : {m18.bid(), m18.ask()}) { REQUIRE(min_tick_2018 == p.price()); REQUIRE(p.size() == 2018); } } void test_slow_double_conversion() { - double values[] = { 1.5, 0.5, 0.2155, 0.216, 42.1 }; - int expected[] = { -1, -1, -4, -3, -1 }; + double values[] = {1.5, 0.5, 0.2155, 0.216, 42.1}; + int expected[] = {-1, -1, -4, -3, -1}; static_assert(BTS_ARRAYSIZE(values) == BTS_ARRAYSIZE(expected), ""); for (size_t x = 0; x < BTS_ARRAYSIZE(values); ++x) { REQUIRE(to_exponent(values[x]) == expected[x]); @@ -334,42 +351,53 @@ public: // Add bbo data for those expirations auto write_time = TimeStamp::now(); - for (auto& p : producers) { - p.update_bbo(write_time, PriceSize_from_double<2>(5.0, 5), PriceSize_from_double<2>(5.0, 5)); + for (auto &p : producers) { + p.update_bbo( + write_time, PriceSize_from_double<2>(5.0, 5), + PriceSize_from_double<2>(5.0, 5)); } // Symbol list for the consumer set symbols; - UserSymbol future_symbol( "FOO", VENUE_BTS, SECURITYTYPE_FUTURE ); + UserSymbol future_symbol("FOO", VENUE_BTS, SECURITYTYPE_FUTURE); symbols.insert(future_symbol); - UserSymbol option_symbol( "FOOX", VENUE_BTS, SECURITYTYPE_OPTION ); + UserSymbol option_symbol("FOOX", VENUE_BTS, SECURITYTYPE_OPTION); symbols.insert(option_symbol); SecurityCache cache; - MDConsumer consumer(cache, nullptr, nullptr, &symbols, true, TEST_PLATFORM); + MDConsumer consumer( + cache, nullptr, nullptr, &symbols, true, TEST_PLATFORM); vector consumer_securities; // Poll for security list - none visible until they have keys - size_t count = consumer.walk_security_list([&](const SecurityPtr& security, MDConsumerHandle) {consumer_securities.push_back(*security);}); + size_t count = consumer.walk_security_list( + [&](const SecurityPtr &security, MDConsumerHandle) { + consumer_securities.push_back(*security); + }); // Since no security has an id none are "public" REQUIRE(consumer_securities.size() == count); REQUIRE(count == 0); // Assign a unique ID to each security (from the producer) assign_ids(producers.begin(), producers.end()); // Now securities can be enumerated by the client - count = consumer.walk_security_list([&](const SecurityPtr& security, MDConsumerHandle) {consumer_securities.push_back(*security);}); + count = consumer.walk_security_list( + [&](const SecurityPtr &security, MDConsumerHandle) { + consumer_securities.push_back(*security); + }); REQUIRE(consumer_securities.size() == count); REQUIRE(count == 24); vector consumers; - for(const auto& security : consumer_securities) { + for (const auto &security : consumer_securities) { consumers.push_back(consumer.get_handle(security.id())); } - for (const auto& c : consumers) { + for (const auto &c : consumers) { PriceSize bid, ask; TimeStamp read_time; // get_boo returns true becuase this time is after the change - REQUIRE(c.get_direct_book(read_time, 1, &bid, &ask) == HandleReadResult::SUCCESS); + REQUIRE( + c.get_direct_book(read_time, 1, &bid, &ask) == + HandleReadResult::SUCCESS); REQUIRE((read_time - TimeStamp()).seconds() > 0); REQUIRE(bid.price() == 5.0); REQUIRE(ask.price() == 5.0); @@ -379,24 +407,30 @@ public: // Second query before a write has happend finds no updates auto read_time = TimeStamp::now(); - for (const auto& c : consumers) { + for (const auto &c : consumers) { PriceSize bid, ask; - REQUIRE(c.get_direct_book(read_time, 1, &bid, &ask) != HandleReadResult::SUCCESS); + REQUIRE( + c.get_direct_book(read_time, 1, &bid, &ask) != + HandleReadResult::SUCCESS); } // update everything once more write_time = TimeStamp::now(); - for (auto& p : producers) { + for (auto &p : producers) { // Update bid/ask with one call - p.update_bbo(write_time, PriceSize_from_double<2>(6.55, 6), PriceSize_from_double<2>(6.55, 6)); + p.update_bbo( + write_time, PriceSize_from_double<2>(6.55, 6), + PriceSize_from_double<2>(6.55, 6)); } // Now read_time is < write_time - for (const auto& c : consumers) { + for (const auto &c : consumers) { TimeStamp modified_time = read_time; PriceSize bid, ask; // get_direct_book returns true becuase this time is after the change - REQUIRE(c.get_direct_book(modified_time, 1, &bid, &ask) == HandleReadResult::SUCCESS); - REQUIRE( (modified_time - read_time).seconds() > 0); + REQUIRE( + c.get_direct_book(modified_time, 1, &bid, &ask) == + HandleReadResult::SUCCESS); + REQUIRE((modified_time - read_time).seconds() > 0); REQUIRE(bid.price() == 6.55); REQUIRE(ask.price() == 6.55); REQUIRE(bid.size() == 6); @@ -411,20 +445,22 @@ public: // Symbol list for the consumer set symbols; - UserSymbol future_symbol( "FOO", VENUE_BTS, SECURITYTYPE_FUTURE ); + UserSymbol future_symbol("FOO", VENUE_BTS, SECURITYTYPE_FUTURE); symbols.insert(future_symbol); - UserSymbol option_symbol( "FOOX", VENUE_BTS, SECURITYTYPE_OPTION ); + UserSymbol option_symbol("FOOX", VENUE_BTS, SECURITYTYPE_OPTION); symbols.insert(option_symbol); SecurityCache cache; - MDConsumer consumer(cache, nullptr, nullptr, &symbols, true, TEST_PLATFORM); + MDConsumer consumer( + cache, nullptr, nullptr, &symbols, true, TEST_PLATFORM); // Add the on_security callback vector securities; - consumer.on_security([&](const SecurityPtr& security, MDConsumerHandle handle) { - REQUIRE(security->id() != invalid_security_key); - REQUIRE(security->id() == handle.key()); - securities.push_back(*security); - }); + consumer.on_security( + [&](const SecurityPtr &security, MDConsumerHandle handle) { + REQUIRE(security->id() != invalid_security_key); + REQUIRE(security->id() == handle.key()); + securities.push_back(*security); + }); // No securities have ids yet REQUIRE(securities.size() == 0); // Check for new securities @@ -436,104 +472,123 @@ public: REQUIRE(securities.size() == 1); // Assign the rest of the ids - assign_ids(producers.begin() + 1, producers.end(), producers.front().security().key); + assign_ids( + producers.begin() + 1, producers.end(), + producers.front().security().key); consumer.scan_securities(); REQUIRE(securities.size() == producers.size()); } - // If an MDConsumer is asked for a handle to a security which does not exist in the system - // The consumer should return a handle which always returns false on all calls but wakes up - // when the security is added. - // * Case 1 - the shared memory has been created but the security has not been discovered + // If an MDConsumer is asked for a handle to a security which does not exist + // in the system The consumer should return a handle which always returns + // false on all calls but wakes up when the security is added. + // * Case 1 - the shared memory has been created but the security has not + // been discovered // * Case 2 - The producer has never been created void test_consumer_defer_handle1() { MDProducer producer(TEST_PLATFORM); vector producers = create_test_securities(producer); set symbols; - UserSymbol future_symbol( "FOO", VENUE_BTS, SECURITYTYPE_FUTURE ); + UserSymbol future_symbol("FOO", VENUE_BTS, SECURITYTYPE_FUTURE); symbols.insert(future_symbol); - UserSymbol option_symbol( "FOOX", VENUE_BTS, SECURITYTYPE_OPTION ); + UserSymbol option_symbol("FOOX", VENUE_BTS, SECURITYTYPE_OPTION); symbols.insert(option_symbol); SecurityCache cache; - MDConsumer consumer(cache, nullptr, nullptr, &symbols, true, TEST_PLATFORM); + MDConsumer consumer( + cache, nullptr, nullptr, &symbols, true, TEST_PLATFORM); // Get a handle to 24 consumers which haven't been created yet vector consumers; vector> managed_consumers; security_key key = 1; - for(; key < 24; ++key) { - consumers.push_back(consumer.get_handle(key+1000)); - managed_consumers.push_back(consumer.get_managed_handle(key+1000)); + for (; key < 24; ++key) { + consumers.push_back(consumer.get_handle(key + 1000)); + managed_consumers.push_back(consumer.get_managed_handle(key + 1000)); } // Set bbo on the producers - still not public TimeStamp write_time = TimeStamp::now(); - for (auto& p : producers) { - p.update_bbo(write_time, PriceSize_from_double<3>(4.5, 5), PriceSize_from_double<3>(6.75, 7)); + for (auto &p : producers) { + p.update_bbo( + write_time, PriceSize_from_double<3>(4.5, 5), + PriceSize_from_double<3>(6.75, 7)); } - // Even though bbo is available it is not given out because the producing security does not have an id + // Even though bbo is available it is not given out because the producing + // security does not have an id PriceSize bid, ask; - for(auto& c : consumers) { + for (auto &c : consumers) { TimeStamp zerotime; - REQUIRE(c.get_direct_book(zerotime, 1, &bid, &ask) != HandleReadResult::SUCCESS); + REQUIRE( + c.get_direct_book(zerotime, 1, &bid, &ask) != + HandleReadResult::SUCCESS); } - for(auto& mc : managed_consumers) { + for (auto &mc : managed_consumers) { TimeStamp zerotime; - REQUIRE(mc->get_direct_book(zerotime, 1, &bid, &ask) != HandleReadResult::SUCCESS); + REQUIRE( + mc->get_direct_book(zerotime, 1, &bid, &ask) != + HandleReadResult::SUCCESS); } assign_ids(producers.begin(), producers.end()); consumer.scan_securities(); size_t bbo_count = 0; // Existing old handles remain invalid - for(auto& c : consumers) { + for (auto &c : consumers) { TimeStamp zerotime; - if (c.get_direct_book(zerotime, 1, &bid, &ask) == HandleReadResult::SUCCESS) { + if (c.get_direct_book(zerotime, 1, &bid, &ask) == + HandleReadResult::SUCCESS) { bbo_count++; } } - REQUIRE(bbo_count == 0); + REQUIRE(bbo_count == 0); // Now, magically, the existing (managed) handles are valid - for(auto& mc : managed_consumers) { + for (auto &mc : managed_consumers) { TimeStamp zerotime; - if (mc->get_direct_book(zerotime, 1, &bid, &ask) == HandleReadResult::SUCCESS) { + if (mc->get_direct_book(zerotime, 1, &bid, &ask) == + HandleReadResult::SUCCESS) { bbo_count++; } } - REQUIRE(bbo_count > 0); + REQUIRE(bbo_count > 0); } - - // It is legal and valid to create a consumer before the producer process has started - // Handles given out by that consumer will become valid once the securities are discovered + // It is legal and valid to create a consumer before the producer process has + // started Handles given out by that consumer will become valid once the + // securities are discovered void test_consumer_defer_handle2() { set symbols; - UserSymbol future_symbol( "FOO", VENUE_BTS, SECURITYTYPE_FUTURE ); + UserSymbol future_symbol("FOO", VENUE_BTS, SECURITYTYPE_FUTURE); symbols.insert(future_symbol); - UserSymbol option_symbol( "FOOX", VENUE_BTS, SECURITYTYPE_OPTION ); + UserSymbol option_symbol("FOOX", VENUE_BTS, SECURITYTYPE_OPTION); symbols.insert(option_symbol); SecurityCache cache; - MDConsumer consumer(cache, nullptr, nullptr, &symbols, true, TEST_PLATFORM); + MDConsumer consumer( + cache, nullptr, nullptr, &symbols, true, TEST_PLATFORM); // Get a handle to 24 consumers which haven't been created yet vector consumers; vector> managed_consumers; security_key key = 1; - for(; key < 24; ++key) { - consumers.push_back(consumer.get_handle(key+1000)); - managed_consumers.push_back(consumer.get_managed_handle(key+1000)); + for (; key < 24; ++key) { + consumers.push_back(consumer.get_handle(key + 1000)); + managed_consumers.push_back(consumer.get_managed_handle(key + 1000)); } - // Even though bbo is available it is not given out because the producing security does not have an id + // Even though bbo is available it is not given out because the producing + // security does not have an id PriceSize bid, ask; - for(auto& c : consumers) { + for (auto &c : consumers) { TimeStamp zerotime; - REQUIRE(c.get_direct_book(zerotime, 1, &bid, &ask) != HandleReadResult::SUCCESS); + REQUIRE( + c.get_direct_book(zerotime, 1, &bid, &ask) != + HandleReadResult::SUCCESS); } - for(auto& mc : managed_consumers) { + for (auto &mc : managed_consumers) { TimeStamp zerotime; - REQUIRE(mc->get_direct_book(zerotime, 1, &bid, &ask) != HandleReadResult::SUCCESS); + REQUIRE( + mc->get_direct_book(zerotime, 1, &bid, &ask) != + HandleReadResult::SUCCESS); } // Only NOW create the producers (and the shared memory) @@ -541,29 +596,33 @@ public: vector producers = create_test_securities(producer); // Set bbo on the producers - still not public TimeStamp write_time = TimeStamp::now(); - for (auto& p : producers) { - p.update_bbo(write_time, PriceSize_from_double<3>( 4.5, 5 ), PriceSize_from_double<3>(6.75, 7)); + for (auto &p : producers) { + p.update_bbo( + write_time, PriceSize_from_double<3>(4.5, 5), + PriceSize_from_double<3>(6.75, 7)); } assign_ids(producers.begin(), producers.end()); consumer.scan_securities(); size_t bbo_count = 0; // Existing old handles remain invalid - for(auto& c : consumers) { + for (auto &c : consumers) { TimeStamp zerotime; - if (c.get_direct_book(zerotime, 1, &bid, &ask) == HandleReadResult::SUCCESS) { + if (c.get_direct_book(zerotime, 1, &bid, &ask) == + HandleReadResult::SUCCESS) { bbo_count++; } } - REQUIRE(bbo_count == 0); + REQUIRE(bbo_count == 0); // Now, magically, the existing (managed) handles are valid - for(auto& mc : managed_consumers) { + for (auto &mc : managed_consumers) { TimeStamp zerotime; - if (mc->get_direct_book(zerotime, 1, &bid, &ask) == HandleReadResult::SUCCESS) { + if (mc->get_direct_book(zerotime, 1, &bid, &ask) == + HandleReadResult::SUCCESS) { bbo_count++; } } - REQUIRE(bbo_count > 0); + REQUIRE(bbo_count > 0); } void test_no_double_security_callback() { @@ -575,15 +634,17 @@ public: // Symbol list for the consumer auto symbols = get_test_symbols(); SecurityCache cache; - MDConsumer consumer(cache, nullptr, nullptr, &symbols, true, TEST_PLATFORM); + MDConsumer consumer( + cache, nullptr, nullptr, &symbols, true, TEST_PLATFORM); // Add the on_security callback - callback fires for existing securities vector securities; - consumer.on_security([&](const SecurityPtr& security, MDConsumerHandle handle) { - REQUIRE(security->id() != invalid_security_key); - REQUIRE(security->id() == handle.key()); - securities.push_back(*security); - }); + consumer.on_security( + [&](const SecurityPtr &security, MDConsumerHandle handle) { + REQUIRE(security->id() != invalid_security_key); + REQUIRE(security->id() == handle.key()); + securities.push_back(*security); + }); // Found all securities REQUIRE(securities.size() == producers.size()); // Check for new securities @@ -594,11 +655,15 @@ public: void test_recovery() { auto producer1 = make_shared(TEST_PLATFORM); - vector producers = create_test_securities(*producer1); + vector producers = create_test_securities(*producer1); assign_ids(producers.begin(), producers.end()); producer1->get_channel("FOO", SECURITYTYPE_FUTURE, VENUE_BTS).heartbeat(); - producer1->get_channel("FOOX", SECURITYTYPE_OPTION, VENUE_BTS).heartbeat(); - for (auto& pro : producers) { pro.update_bbo(TimeStamp::now(), PriceSize({1, 0}, 1), PriceSize({2, 0}, 2)); } + producer1->get_channel("FOOX", SECURITYTYPE_OPTION, VENUE_BTS) + .heartbeat(); + for (auto &pro : producers) { + pro.update_bbo( + TimeStamp::now(), PriceSize({1, 0}, 1), PriceSize({2, 0}, 2)); + } // Symbol list for the consumer SecurityCache cache; @@ -606,16 +671,17 @@ public: MDClient client(nullptr, nullptr, nullptr, &symbols); MDConsumer consumer = client.current_consumer(); map products; - consumer.on_security([&](const SecurityPtr& security, MDConsumerHandle handle) { - REQUIRE(security->id() == handle.key()); - products.insert(make_pair(security->id(), handle)); - }); + consumer.on_security( + [&](const SecurityPtr &security, MDConsumerHandle handle) { + REQUIRE(security->id() == handle.key()); + products.insert(make_pair(security->id(), handle)); + }); client.scan_securities(); REQUIRE(products.size() == producers.size()); // Check handles - for (auto& pair : products) { - auto& handle = pair.second; + for (auto &pair : products) { + auto &handle = pair.second; REQUIRE(handle.is_initialized()); REQUIRE(handle.is_heart_beating()); } @@ -624,26 +690,29 @@ public: try { producers.clear(); producer1.reset(); - } catch(std::exception&) { - LOG(md,Error,"Failed test trying to destroy producer."); + } catch (std::exception &) { + LOG(md, Error, "Failed test trying to destroy producer."); REQUIRE(false); } // Wait out the heartbeat auto options = config::get(); - auto ms = std::max(options.heartbeat_ms(), options.heartbeat_boot_seconds()*1000)+10; - + auto ms = + std::max( + options.heartbeat_ms(), options.heartbeat_boot_seconds() * 1000) + + 10; + std::this_thread::sleep_for(std::chrono::duration(ms)); // Make sure heartbeat is done try { - for (auto& pair : products) { - auto& handle = pair.second; + for (auto &pair : products) { + auto &handle = pair.second; REQUIRE(handle.is_initialized()); REQUIRE(handle.is_heart_beating() == false); } - } catch(std::exception&) { - LOG(md,Error,"Failed to validate heartbeat while producer is down."); + } catch (std::exception &) { + LOG(md, Error, "Failed to validate heartbeat while producer is down."); REQUIRE(false); } @@ -651,24 +720,26 @@ public: shared_ptr producer2; try { producer2 = make_shared(TEST_PLATFORM); - } catch(std::exception&) { - LOG(md,Error,"Failed to create new producer"); + } catch (std::exception &) { + LOG(md, Error, "Failed to create new producer"); REQUIRE(false); } producers = create_test_securities(*producer2); REQUIRE(products.size() == producers.size()); assign_ids(producers.begin(), producers.end()); producer2->get_channel("FOO", SECURITYTYPE_FUTURE, VENUE_BTS).heartbeat(); - producer2->get_channel("FOOX", SECURITYTYPE_OPTION, VENUE_BTS).heartbeat(); + producer2->get_channel("FOOX", SECURITYTYPE_OPTION, VENUE_BTS) + .heartbeat(); // set bbo to a different value - for (auto& pro : producers) { - pro.update_bbo(TimeStamp::now(), PriceSize({4, 0}, 5), PriceSize({6, 0}, 7)); + for (auto &pro : producers) { + pro.update_bbo( + TimeStamp::now(), PriceSize({4, 0}, 5), PriceSize({6, 0}, 7)); } // Attempt to recover the managed handles int on_consumer_count = 0; - auto handle = client.on_consumer().subscribe([&](const MDConsumer& c) { + auto handle = client.on_consumer().subscribe([&](const MDConsumer &c) { ++on_consumer_count; consumer = c; products.clear(); @@ -676,21 +747,24 @@ public: client.check_heartbeats(); REQUIRE(on_consumer_count == 1); REQUIRE(products.empty()); - // Consumer has been updated - consumer.on_security([&](const SecurityPtr& security, MDConsumerHandle handle) { - REQUIRE(security->id() == handle.key()); - products.insert(make_pair(security->id(), handle)); - }); + // Consumer has been updated + consumer.on_security( + [&](const SecurityPtr &security, MDConsumerHandle handle) { + REQUIRE(security->id() == handle.key()); + products.insert(make_pair(security->id(), handle)); + }); client.on_consumer().unsubscribe(handle); // Check that the new product handles have been updated - for (auto& pair : products) { - auto& handle = pair.second; + for (auto &pair : products) { + auto &handle = pair.second; REQUIRE(handle.is_initialized()); REQUIRE(handle.is_heart_beating()); TimeStamp tzero; PriceSize bid, ask; - REQUIRE(handle.get_direct_book(tzero, 1, &bid, &ask) == HandleReadResult::SUCCESS); + REQUIRE( + handle.get_direct_book(tzero, 1, &bid, &ask) == + HandleReadResult::SUCCESS); REQUIRE(bid.price() == 4.0); REQUIRE(bid.size() == 5); REQUIRE(ask.price() == 6.0); @@ -698,18 +772,20 @@ public: } } - void test_no_block_forever_on_publisher_crash() { #ifdef _WIN32 #pragma warning(push, 0) #endif // OK if this isn't aligned for testing - auto src = std::make_unique ("Foo", SECURITYTYPE_FUTURE); + auto src = + std::make_unique("Foo", SECURITYTYPE_FUTURE); #ifdef _WIN32 #pragma warning(pop) #endif TimeStamp read = TimeStamp::now(); - src->producer().update_bbo(TimeStamp::invalid(), PriceSize_from_double<3>(100.0, 100), PriceSize_from_double<3>(101.0, 101)); + src->producer().update_bbo( + TimeStamp::invalid(), PriceSize_from_double<3>(100.0, 100), + PriceSize_from_double<3>(101.0, 101)); PriceSize bid, ask; TimeStamp start = TimeStamp::now(); auto result = src->consumer().get_direct_book(read, 1, &bid, &ask); @@ -717,33 +793,41 @@ public: REQUIRE(result != HandleReadResult::SUCCESS); REQUIRE((end - start).seconds() < 5); } - + void test_get_handles() { MDProducer producer(TEST_PLATFORM); vector producers = create_test_securities(producer); // Add entries to the shared memory that we aren't looking for - vector p2_no_id = create_test_securities(producer, "2"); + vector p2_no_id = create_test_securities(producer, "2"); vector p3 = create_test_securities(producer, "3"); - - for (auto& p : producers) { p.update_bbo(TimeStamp::now(), PriceSize_from_double<3>(5.0, 5), PriceSize_from_double<3>(5.0, 5)); } + + for (auto &p : producers) { + p.update_bbo( + TimeStamp::now(), PriceSize_from_double<3>(5.0, 5), + PriceSize_from_double<3>(5.0, 5)); + } assign_ids(producers.begin(), producers.end()); assign_ids(p3.begin(), p3.end()); // Symbol list for the consumer - only search half of the symbols set symbols; - UserSymbol future_symbol( "FOO", VENUE_BTS, SECURITYTYPE_FUTURE ); + UserSymbol future_symbol("FOO", VENUE_BTS, SECURITYTYPE_FUTURE); symbols.insert(future_symbol); - UserSymbol option_symbol( "FOOX", VENUE_BTS, SECURITYTYPE_OPTION ); + UserSymbol option_symbol("FOOX", VENUE_BTS, SECURITYTYPE_OPTION); symbols.insert(option_symbol); SecurityCache cache; - MDConsumer consumer(cache, nullptr, nullptr, &symbols, true, TEST_PLATFORM); + MDConsumer consumer( + cache, nullptr, nullptr, &symbols, true, TEST_PLATFORM); set keys; - consumer.walk_security_list([&](const SecurityPtr& security, MDConsumerHandle) { keys.insert(security->id()); }); + consumer.walk_security_list( + [&](const SecurityPtr &security, MDConsumerHandle) { + keys.insert(security->id()); + }); REQUIRE(keys.size() == producers.size()); auto map = consumer.get_handles(keys); REQUIRE(map.size() == keys.size()); - for (const auto& entry : map) { + for (const auto &entry : map) { REQUIRE(entry.second.is_initialized()); } } @@ -760,15 +844,15 @@ public: Security s3 = mkspread("S4", ++key, o1, s4); Security s2 = mkspread("S2", ++key, o1, s4, s3); Security s1 = mkspread("S1", ++key, f1, s2); - Security all_secs_array[] = { f1, o1, o2, o3, s1, s2, s3, s4 }; + Security all_secs_array[] = {f1, o1, o2, o3, s1, s2, s3, s4}; MDProducer producer(TEST_PLATFORM); vector producers; - for (auto& sec : all_secs_array) { - with_security_like(sec, [&](FixedSecurity& fsec) { - convert_security(sec, fsec, true); - producers.push_back(producer.add_security(fsec)); - }); + for (auto &sec : all_secs_array) { + with_security_like(sec, [&](FixedSecurity &fsec) { + convert_security(sec, fsec, true); + producers.push_back(producer.add_security(fsec)); + }); } set csymbols; @@ -781,18 +865,25 @@ public: csymbols.insert(UserSymbol("S3", VENUE_BTS, SECURITYTYPE_SPREAD)); csymbols.insert(UserSymbol("S4", VENUE_BTS, SECURITYTYPE_SPREAD)); SecurityCache cache; - MDConsumer consumer(cache, nullptr, nullptr, &csymbols, true, TEST_PLATFORM); + MDConsumer consumer( + cache, nullptr, nullptr, &csymbols, true, TEST_PLATFORM); - auto check_sec = [&](const SecurityPtr& security, MDConsumerHandle handle) { + auto check_sec = [&](const SecurityPtr &security, + MDConsumerHandle handle) { REQUIRE(security->id() == handle.key()); - auto iter = find_if(std::begin(all_secs_array), std::end(all_secs_array), [&](const Security& sec) { return sec.id() == security->id(); }); + auto iter = find_if( + std::begin(all_secs_array), std::end(all_secs_array), + [&](const Security &sec) { return sec.id() == security->id(); }); REQUIRE(iter != end(all_secs_array)); REQUIRE(iter->symbol() == (security->symbol())); if (security->Contract_case() == Security::kSpread) { REQUIRE(security->spread().normalized() == false); - REQUIRE(security->spread().legs_size() == iter->spread().legs_size()); + REQUIRE( + security->spread().legs_size() == iter->spread().legs_size()); for (int x = 0; x < security->spread().legs_size(); ++x) { - REQUIRE((security->spread().legs(x).security().id()) == (iter->spread().legs(x).security().id())); + REQUIRE( + (security->spread().legs(x).security().id()) == + (iter->spread().legs(x).security().id())); } } }; @@ -812,15 +903,15 @@ public: Security s3 = mkspread("SS", ++key, o1, s4); Security s2 = mkspread("SS", ++key, o1, s4, s3); Security s1 = mkspread("SS", ++key, f1, s2); - Security all_secs_array[] = { f1, o1, o2, o3, s1, s2, s3, s4 }; + Security all_secs_array[] = {f1, o1, o2, o3, s1, s2, s3, s4}; MDProducer producer(TEST_PLATFORM); vector producers; - for (auto& sec : all_secs_array) { - with_security_like(sec, [&](FixedSecurity& fsec) { - convert_security(sec, fsec, true); - producers.push_back(producer.add_security(fsec)); - }); + for (auto &sec : all_secs_array) { + with_security_like(sec, [&](FixedSecurity &fsec) { + convert_security(sec, fsec, true); + producers.push_back(producer.add_security(fsec)); + }); } set csymbols; @@ -828,18 +919,25 @@ public: csymbols.insert(UserSymbol("OO", VENUE_BTS, SECURITYTYPE_OPTION)); csymbols.insert(UserSymbol("SS", VENUE_BTS, SECURITYTYPE_SPREAD)); SecurityCache cache; - MDConsumer consumer(cache, nullptr, nullptr, &csymbols, true, TEST_PLATFORM); + MDConsumer consumer( + cache, nullptr, nullptr, &csymbols, true, TEST_PLATFORM); - auto check_sec = [&](const SecurityPtr& security, MDConsumerHandle handle) { + auto check_sec = [&](const SecurityPtr &security, + MDConsumerHandle handle) { REQUIRE(security->id() == handle.key()); - auto iter = find_if(begin(all_secs_array), end(all_secs_array), [&](const Security& sec) { return sec.id() == security->id(); }); + auto iter = find_if( + begin(all_secs_array), end(all_secs_array), + [&](const Security &sec) { return sec.id() == security->id(); }); REQUIRE(iter != end(all_secs_array)); REQUIRE((iter->id()) == (security->id())); if (security->Contract_case() == Security::kSpread) { REQUIRE(security->spread().normalized() == false); - REQUIRE(security->spread().legs_size() == iter->spread().legs_size()); + REQUIRE( + security->spread().legs_size() == iter->spread().legs_size()); for (int x = 0; x < security->spread().legs_size(); ++x) { - REQUIRE((security->spread().legs(x).security().id()) == (iter->spread().legs(x).security().id())); + REQUIRE( + (security->spread().legs(x).security().id()) == + (iter->spread().legs(x).security().id())); } } }; @@ -848,12 +946,12 @@ public: consumer.on_security(check_sec); consumer.scan_securities(); } - + void test_retry_unresolved_spread() { // Make 2 spreads with option legs // Leave out one leg for hte other spread // The other spread only shows up once its option leg is produced - + Security o1 = mkoption("OO", 400, 2016, 5, 1, 100); Security o2 = mkoption("OO", 401, 2016, 5, 2, 200); Security o3 = mkoption("OO", 402, 2016, 5, 3, 300); @@ -862,16 +960,16 @@ public: MDProducer producer(TEST_PLATFORM); map handles; - auto add_security = [&](const Security& sec) { - with_security_like(sec, [&](FixedSecurity& fsec) { - convert_security(sec, fsec, true); - handles.insert(make_pair(fsec.key, producer.add_security(fsec))); - }); + auto add_security = [&](const Security &sec) { + with_security_like(sec, [&](FixedSecurity &fsec) { + convert_security(sec, fsec, true); + handles.insert(make_pair(fsec.key, producer.add_security(fsec))); + }); }; // "options publisher has not started yet" - //add_security(o1); - //add_security(o2); - //add_security(o3); + // add_security(o1); + // add_security(o2); + // add_security(o3); add_security(s1); add_security(s2); @@ -880,25 +978,27 @@ public: consumer_symbols.insert(UserSymbol("OO", VENUE_BTS, SECURITYTYPE_OPTION)); consumer_symbols.insert(UserSymbol("SS", VENUE_BTS, SECURITYTYPE_SPREAD)); SecurityCache cache; - MDConsumer consumer(cache, nullptr, nullptr, &consumer_symbols, true, TEST_PLATFORM); + MDConsumer consumer( + cache, nullptr, nullptr, &consumer_symbols, true, TEST_PLATFORM); size_t security_count = 0; // Indirection for check function - function check_func; - check_func = [&](const Security&) { - REQUIRE(false); - }; - consumer.on_security([&](const SecurityPtr& sec, MDConsumerHandle) { ++security_count; check_func(*sec); }); + function check_func; + check_func = [&](const Security &) { REQUIRE(false); }; + consumer.on_security([&](const SecurityPtr &sec, MDConsumerHandle) { + ++security_count; + check_func(*sec); + }); consumer.scan_securities(); REQUIRE(security_count == 0); // OK, now add enough options to resolve s1 but not s2 add_security(o1); add_security(o2); - check_func = [&](const Security& security) { + check_func = [&](const Security &security) { if (security.Contract_case() == Security::kSpread) { set legs; - for (const auto& leg : security.spread().legs()) { + for (const auto &leg : security.spread().legs()) { legs.insert(leg.security().id()); } REQUIRE(security.id() == 500); @@ -913,10 +1013,10 @@ public: // Then add the last security and we should see s2 add_security(o3); - check_func = [&](const Security& security) { + check_func = [&](const Security &security) { if (security.Contract_case() == Security::kSpread) { set legs; - for (const auto& leg : security.spread().legs()) { + for (const auto &leg : security.spread().legs()) { legs.insert(leg.security().id()); } REQUIRE(security.id() == 501); @@ -928,20 +1028,20 @@ public: consumer.scan_securities(); REQUIRE(security_count == 5); } - - #ifndef WIN32 + +#ifndef WIN32 void test_settlement_recorder() { using namespace datetime; security_key k1 = 401, k2 = 402; Security o1 = mkoption("OO", k1, 2016, 5, 1, 100); Security o2 = mkoption("OO", k2, 2016, 5, 2, 200); MDProducer producer(TEST_PLATFORM); - auto add_security = [&](const Security& sec) { + auto add_security = [&](const Security &sec) { unique_ptr phandle; - with_security_like(sec, [&](FixedSecurity& fsec) { - convert_security(sec, fsec, true); - phandle.reset(new MDProducerHandle(producer.add_security(fsec))); - }); + with_security_like(sec, [&](FixedSecurity &fsec) { + convert_security(sec, fsec, true); + phandle.reset(new MDProducerHandle(producer.add_security(fsec))); + }); return phandle; }; auto ph1 = *add_security(o1); @@ -949,7 +1049,8 @@ public: set consumer_symbols; consumer_symbols.insert(UserSymbol("OO", VENUE_BTS, SECURITYTYPE_OPTION)); SecurityCache cache; - MDConsumer consumer(cache, nullptr, nullptr, &consumer_symbols, true, TEST_PLATFORM); + MDConsumer consumer( + cache, nullptr, nullptr, &consumer_symbols, true, TEST_PLATFORM); auto h1 = consumer.get_handle(k1); REQUIRE(h1.is_initialized()); auto h2 = consumer.get_handle(k2); @@ -961,10 +1062,10 @@ public: { co2::SettlementRecorder recorder(PLATFORM_UNSET); - recorder.add_settlement(ph1, {101,0}, yesterday); - recorder.add_settlement(ph1, {102,0}, today); - recorder.add_settlement(ph2, {199,0}, yesterday); - recorder.add_settlement(ph2, {188,0}, today); + recorder.add_settlement(ph1, {101, 0}, yesterday); + recorder.add_settlement(ph1, {102, 0}, today); + recorder.add_settlement(ph2, {199, 0}, yesterday); + recorder.add_settlement(ph2, {188, 0}, today); recorder.do_work(); recorder.do_work(); } @@ -979,20 +1080,20 @@ public: // Update but skip persist auto tomorrow = datetime::add_days(today, 1); - ph1.update_settlement(TimeStamp::now(), {103,0}, tomorrow); + ph1.update_settlement(TimeStamp::now(), {103, 0}, tomorrow); REQUIRE(h1.settlement_price().price() == 103); REQUIRE(h1.misc().settlement_date == tomorrow); REQUIRE(h1.misc().previous_settlement_price.price() == 102); REQUIRE(h1.misc().previous_settlement_date == today); - ph1.update_previous_settlement(TimeStamp::now(), {0,0}, Date()); + ph1.update_previous_settlement(TimeStamp::now(), {0, 0}, Date()); REQUIRE(h1.settlement_price().price() == 103); REQUIRE(h1.misc().settlement_date == tomorrow); - ph1.update_settlement(TimeStamp::now(),{0,0}, Date()); + ph1.update_settlement(TimeStamp::now(), {0, 0}, Date()); REQUIRE(h1.settlement_price().price() == 0); REQUIRE(h1.misc().settlement_date.day == 0); // pushing a new settlement for today doesn't invalidate yesterday - ph2.update_settlement(TimeStamp::now(), {201,0}, today); + ph2.update_settlement(TimeStamp::now(), {201, 0}, today); REQUIRE(h2.settlement_price().price() == 201); REQUIRE(h2.misc().settlement_date == today); REQUIRE(h2.misc().previous_settlement_price.price() == 199); @@ -1014,20 +1115,20 @@ public: REQUIRE(h2.misc().previous_settlement_price.price() == 199); REQUIRE(h2.misc().previous_settlement_date == yesterday); } - #endif +#endif void teardown() {} -} ; +}; std::unique_ptr co2_tests; -TEST_CASE("CO2Tests","[md]") { +TEST_CASE("CO2Tests", "[md]") { // Lazy created this for config if (!co2_tests) co2_tests = std::make_unique(); co2_tests->setup(); - - #ifndef WIN32 + +#ifndef WIN32 SECTION("test_security_id_recorder") { co2_tests->test_security_id_recorder(":memory:"); co2_tests->test_security_id_recorder("file::memory:?cache=shared"); @@ -1035,19 +1136,15 @@ TEST_CASE("CO2Tests","[md]") { SECTION("test_security_id_recorder_spreads") { co2_tests->test_security_id_recorder_spreads(); } - #endif - SECTION("test_price_size") { - co2_tests->test_price_size(); - } +#endif + SECTION("test_price_size") { co2_tests->test_price_size(); } SECTION("test_price_size_required_precision") { co2_tests->test_price_size_required_precision(); } SECTION("test_slow_double_conversion") { co2_tests->test_slow_double_conversion(); } - SECTION("test_producer_consumer") { - co2_tests->test_producer_consumer(); - } + SECTION("test_producer_consumer") { co2_tests->test_producer_consumer(); } SECTION("test_consumer_callback_on_security_added") { co2_tests->test_consumer_callback_on_security_added(); } @@ -1060,29 +1157,21 @@ TEST_CASE("CO2Tests","[md]") { SECTION("test_no_double_security_callback") { co2_tests->test_no_double_security_callback(); } - SECTION("test_recovery") { - co2_tests->test_recovery(); - } + SECTION("test_recovery") { co2_tests->test_recovery(); } SECTION("test_no_block_forever_on_publisher_crash") { co2_tests->test_no_block_forever_on_publisher_crash(); } - SECTION("test_get_handles") { - co2_tests->test_get_handles(); - } - SECTION("test_denormalization") { - co2_tests->test_denormalization(); - } - SECTION("test_denormalization2") { - co2_tests->test_denormalization2(); - } + SECTION("test_get_handles") { co2_tests->test_get_handles(); } + SECTION("test_denormalization") { co2_tests->test_denormalization(); } + SECTION("test_denormalization2") { co2_tests->test_denormalization2(); } SECTION("test_retry_unresolved_spread") { co2_tests->test_retry_unresolved_spread(); } - #ifndef WIN32 +#ifndef WIN32 SECTION("test_settlement_recorder") { co2_tests->test_settlement_recorder(); } - #endif +#endif } struct Co2IndexTests { @@ -1091,12 +1180,9 @@ struct Co2IndexTests { const int iterations; tbb::task_scheduler_init _tbb; - Co2IndexTests() : - random_ids(), - used_ids(), - iterations(50), - _tbb(tbb::task_scheduler_init::automatic) - {} + Co2IndexTests() + : random_ids(), used_ids(), iterations(50), + _tbb(tbb::task_scheduler_init::automatic) {} void setup() { used_ids.clear(); @@ -1108,7 +1194,9 @@ struct Co2IndexTests { set temp_ids; for (int x = 0; x < 9999; ++x) { auto r = genrandom(); - if (x < 1000) { used_ids.insert(r); } + if (x < 1000) { + used_ids.insert(r); + } temp_ids.insert(r); } for (uint64_t id : temp_ids) { @@ -1130,11 +1218,10 @@ struct Co2IndexTests { Handle handle; }; - template - void gen_securities(Index& index) { + template void gen_securities(Index &index) { unique_ptr temp; uint32_t count = 0; - for (auto& id : used_ids) { + for (auto &id : used_ids) { ++count; temp.reset(new SecurityData()); temp->security.Clear(); @@ -1147,26 +1234,22 @@ struct Co2IndexTests { } } - - template - void test_random_search(Index& index) { + template void test_random_search(Index &index) { vector temp(random_ids); std::random_shuffle(temp.begin(), temp.end()); - for (auto& id : temp) { + for (auto &id : temp) { if (used_ids.find(id) != used_ids.end()) { REQUIRE(index.has_security(id)); - } - else { + } else { REQUIRE(index.get_security(id) == nullptr); } } } - template - void test_walk(Index& index) { + template void test_walk(Index &index) { int count = 0; - index.walk_security_list([&count](const SecurityData&) { ++count; }); - REQUIRE(count == (int) used_ids.size()); + index.walk_security_list([&count](const SecurityData &) { ++count; }); + REQUIRE(count == (int)used_ids.size()); } typedef SimpleSecurityIndex MySimpleIndex; @@ -1181,9 +1264,7 @@ struct Co2IndexTests { void test_simple_index_parallel_search() { MySimpleIndex index; gen_securities(index); - tbb::parallel_for(0, iterations, [&](int) { - test_random_search(index); - }); + tbb::parallel_for(0, iterations, [&](int) { test_random_search(index); }); } void test_simple_index_iterate() { @@ -1203,28 +1284,25 @@ struct Co2IndexTests { void test_concurrent_index_parallel_search() { MyConcurrentIndex index; gen_securities(index); - tbb::parallel_for(0, iterations, [&](int) { - test_random_search(index); - }); + tbb::parallel_for(0, iterations, [&](int) { test_random_search(index); }); } void test_concurrent_index_iterate() { MyConcurrentIndex index; gen_securities(index); test_walk(index); } -} ; +}; struct Co2RelayTests { SecurityCache cache; Co2RelayTests() : _stats() {} void setup() { config::internal::initialize_for_test( - "PlatformMap {" - " value {" - " glbx_platform: 'PLATFORM_SIM'" - " }" - "}"); - + "PlatformMap {" + " value {" + " glbx_platform: 'PLATFORM_SIM'" + " }" + "}"); } void teardown() {} @@ -1239,9 +1317,7 @@ struct Co2RelayTests { return consumer; } - - template - T simulate_wire_transfer(const T& request) { + template T simulate_wire_transfer(const T &request) { T temp; std::string buffer; request.SerializeToString(&buffer); @@ -1253,35 +1329,31 @@ struct Co2RelayTests { const std::set setup_symbols() { std::set result; - for (const auto& symbol : { "FOO", "FOOF" }) { + for (const auto &symbol : {"FOO", "FOOF"}) { result.insert({symbol, VENUE_BTS, SECURITYTYPE_FUTURE}); } return result; } std::unique_ptr setup_query_server( - MDClient& client, - MDProducer& producer, - Entitlements* out_entitlements, - vector* out_producers) { + MDClient &client, MDProducer &producer, Entitlements *out_entitlements, + vector *out_producers) { // Create a bunch of securities for (size_t x = 0; x < 100; ++x) { // That's right. Expirations daily. - out_producers->push_back( - producer.add_security( - *mkfixedfuture("FOO", invalid_security_key, 2017, 1+(x/28), x%27+1))); - out_producers->push_back( - producer.add_security( - *mkfixedfuture("FOOF", invalid_security_key, 2017, 1+(x/28), x%27+1))); + out_producers->push_back(producer.add_security(*mkfixedfuture( + "FOO", invalid_security_key, 2017, 1 + (x / 28), x % 27 + 1))); + out_producers->push_back(producer.add_security(*mkfixedfuture( + "FOOF", invalid_security_key, 2017, 1 + (x / 28), x % 27 + 1))); } assign_ids(out_producers->begin(), out_producers->end(), 1000); - + // set query server set symbols; symbols.insert({"FOO", VENUE_BTS, SECURITYTYPE_FUTURE}); symbols.insert({"FOOF", VENUE_BTS, SECURITYTYPE_FUTURE}); - for (const auto& s : symbols) { + for (const auto &s : symbols) { out_entitlements->insert(s.symbol()); } auto server = create_query_server(client, _stats); @@ -1290,39 +1362,39 @@ struct Co2RelayTests { return server; } - void relay_nans() { MDProducer producer(TEST_PLATFORM); Entitlements entitlements; - + // initialize data vector producers; // - // todo: setup_query_server should use client.symbols() instead of it's own list + // todo: setup_query_server should use client.symbols() instead of it's + // own list // const auto symbols = setup_symbols(); MDClient client(nullptr, nullptr, nullptr, &symbols); - auto server = setup_query_server(client, producer, &entitlements, &producers); + auto server = + setup_query_server(client, producer, &entitlements, &producers); // assign prices PriceSize price35 = PriceSize_from_double<2>(3.5, 5); PriceSize price5 = PriceSize_from_double<2>(5, 5); - for(auto p : producers) { + for (auto p : producers) { p.update_bbo(TimeStamp::now(), price35, price35); } // Request via query server co2::MDRequest request; - for (const auto& symbol : symbols) { - auto* chan = request.add_channels(); + for (const auto &symbol : symbols) { + auto *chan = request.add_channels(); chan->set_type(symbol.type()); chan->set_symbol(symbol.symbol()); chan->set_exchange(symbol.exchange()); chan->set_flags(co2::MDRequest::BBO | co2::MDRequest::SECURITY); chan->set_entitled(true); } - // This request should include everything co2::MDReply reply; @@ -1331,8 +1403,10 @@ struct Co2RelayTests { REQUIRE((size_t)reply.channels().size() == 2); // update the request to match the server time for (int ch = 0; ch < 2; ++ch) { - REQUIRE((size_t)reply.channels(ch).updates().size() == producers.size()/2); - for (auto& update : reply.channels(ch).updates()) { + REQUIRE( + (size_t)reply.channels(ch).updates().size() == + producers.size() / 2); + for (auto &update : reply.channels(ch).updates()) { REQUIRE(update.has_security()); REQUIRE(update.has_direct()); REQUIRE(update.direct().asks_size() > 0); @@ -1341,7 +1415,7 @@ struct Co2RelayTests { REQUIRE(book_at(update.direct().asks(), 0) == price35); } } - + // Second request with updated time should include nothing request.mutable_channels(0)->set_time(reply.channels(0).channel().time()); request.mutable_channels(1)->set_time(reply.channels(1).channel().time()); @@ -1362,11 +1436,13 @@ struct Co2RelayTests { REQUIRE(reply.channels(0).updates().size() == 1); REQUIRE(reply.channels(1).updates().size() == 0); REQUIRE(reply.channels(0).updates(0).has_direct()); - REQUIRE(book_at(reply.channels(0).updates(0).direct().bids(), 0) == price5); - REQUIRE(book_at(reply.channels(0).updates(0).direct().asks(), 0) == price5); + REQUIRE( + book_at(reply.channels(0).updates(0).direct().bids(), 0) == price5); + REQUIRE( + book_at(reply.channels(0).updates(0).direct().asks(), 0) == price5); // NaN out all the prices - expect to get a full set of updates - for(auto p : producers) { + for (auto p : producers) { p.update_bbo(TimeStamp::now(), NO_MARKET, NO_MARKET, 2); } request.mutable_channels(0)->set_time(reply.channels(0).channel().time()); @@ -1374,19 +1450,23 @@ struct Co2RelayTests { server->query(request, &reply, &entitlements, false); reply = simulate_wire_transfer(reply); REQUIRE(reply.channels().size() == 2); - REQUIRE((size_t)reply.channels(0).updates().size() == producers.size()/2); - REQUIRE((size_t)reply.channels(1).updates().size() == producers.size()/2); - for (auto& channel : reply.channels()) { - for (auto& update : channel.updates()) { + REQUIRE( + (size_t)reply.channels(0).updates().size() == producers.size() / 2); + REQUIRE( + (size_t)reply.channels(1).updates().size() == producers.size() / 2); + for (auto &channel : reply.channels()) { + for (auto &update : channel.updates()) { REQUIRE(update.has_direct()); - // We need to have a book to signal that it was updated but it can have no rows. This signifies an empty book and will be written as such by the relay client. + // We need to have a book to signal that it was updated but it can + // have no rows. This signifies an empty book and will be written + // as such by the relay client. REQUIRE(book_at(update.direct().bids(), 0) == NO_MARKET); REQUIRE(book_at(update.direct().asks(), 0) == NO_MARKET); } } // Fill up the markets again - for(auto p : producers) { + for (auto p : producers) { p.update_bbo(TimeStamp::now(), price35, price35, 3); } request.mutable_channels(0)->set_time(reply.channels(0).channel().time()); @@ -1395,10 +1475,12 @@ struct Co2RelayTests { server->query(request, &reply, &entitlements, false); reply = simulate_wire_transfer(reply); REQUIRE(reply.channels().size() == 2); - REQUIRE((size_t)reply.channels(0).updates().size() == producers.size()/2); - REQUIRE((size_t)reply.channels(1).updates().size() == producers.size()/2); - for (auto& channel : reply.channels()) { - for (auto& update : channel.updates()) { + REQUIRE( + (size_t)reply.channels(0).updates().size() == producers.size() / 2); + REQUIRE( + (size_t)reply.channels(1).updates().size() == producers.size() / 2); + for (auto &channel : reply.channels()) { + for (auto &update : channel.updates()) { REQUIRE(update.has_direct()); REQUIRE(update.direct().bids_size() > 0); REQUIRE(update.direct().asks_size() > 0); @@ -1408,7 +1490,7 @@ struct Co2RelayTests { } // NaN out the bids - for(auto p : producers) { + for (auto p : producers) { p.update_bbo(TimeStamp::now(), NO_MARKET, price35, 4); } request.mutable_channels(0)->set_time(reply.channels(0).channel().time()); @@ -1417,10 +1499,12 @@ struct Co2RelayTests { server->query(request, &reply, &entitlements, false); reply = simulate_wire_transfer(reply); REQUIRE(reply.channels().size() == 2); - REQUIRE((size_t)reply.channels(0).updates().size() == producers.size()/2); - REQUIRE((size_t)reply.channels(1).updates().size() == producers.size()/2); - for (auto& channel : reply.channels()) { - for (auto& update : channel.updates()) { + REQUIRE( + (size_t)reply.channels(0).updates().size() == producers.size() / 2); + REQUIRE( + (size_t)reply.channels(1).updates().size() == producers.size() / 2); + for (auto &channel : reply.channels()) { + for (auto &update : channel.updates()) { REQUIRE(update.has_direct()); REQUIRE(book_at(update.direct().bids(), 0) == NO_MARKET); REQUIRE(book_at(update.direct().asks(), 0) == price35); @@ -1430,28 +1514,34 @@ struct Co2RelayTests { void relay_implied() { MDProducer producer(TEST_PLATFORM); - + // initialize data vector producers; Entitlements entitlements; const auto symbols = setup_symbols(); MDClient client(nullptr, nullptr, nullptr, &symbols); - auto server = setup_query_server(client, producer, &entitlements, &producers); + auto server = + setup_query_server(client, producer, &entitlements, &producers); // assign prices to all levels auto set_direct = [&](PriceSize bid, PriceSize ask) { - for(auto p : producers) { + for (auto p : producers) { std::array bids, asks; - for (auto& p : bids) p = bid; - for (auto& p : asks) p = ask; + for (auto &p : bids) + p = bid; + for (auto &p : asks) + p = ask; p.update_direct(TimeStamp::now(), bids, asks); } }; auto set_implied = [&](PriceSize bid, PriceSize ask) { - for(auto p : producers) { - std::array implied_bids, implied_asks; - for (auto& p : implied_bids) p = bid; - for (auto& p : implied_asks) p = ask; + for (auto p : producers) { + std::array implied_bids, + implied_asks; + for (auto &p : implied_bids) + p = bid; + for (auto &p : implied_asks) + p = ask; p.update_implied(TimeStamp::now(), implied_bids, implied_asks); } }; @@ -1462,21 +1552,21 @@ struct Co2RelayTests { // Form the request co2::MDRequest request; - auto* chan = request.add_channels(); + auto *chan = request.add_channels(); chan->set_type(SECURITYTYPE_FUTURE); chan->set_symbol("FOO"); chan->set_exchange(VENUE_BTS); chan->set_flags(co2::MDRequest::DIRECT | co2::MDRequest::IMPLIED); - + // Send the request co2::MDReply reply; server->query(request, &reply, &entitlements, false); reply = simulate_wire_transfer(reply); - + // check price levels REQUIRE(reply.channels_size() > 0); - for (auto& channel : reply.channels()) { - for (auto& update : channel.updates()) { + for (auto &channel : reply.channels()) { + for (auto &update : channel.updates()) { REQUIRE(update.has_direct()); REQUIRE(update.has_implied()); REQUIRE(update.direct().bids_size() == COCONUT_MAX_DEPTH); @@ -1501,9 +1591,9 @@ struct Co2RelayTests { reply.Clear(); server->query(request, &reply, &entitlements, false); reply = simulate_wire_transfer(reply); - - for (auto& channel : reply.channels()) { - for (auto& update : channel.updates()) { + + for (auto &channel : reply.channels()) { + for (auto &update : channel.updates()) { REQUIRE(update.has_direct()); REQUIRE(update.has_implied()); REQUIRE(update.direct().bids_size() == COCONUT_MAX_DEPTH); @@ -1528,9 +1618,9 @@ struct Co2RelayTests { reply.Clear(); server->query(request, &reply, &entitlements, false); reply = simulate_wire_transfer(reply); - - for (auto& channel : reply.channels()) { - for (auto& update : channel.updates()) { + + for (auto &channel : reply.channels()) { + for (auto &update : channel.updates()) { REQUIRE(update.has_direct()); REQUIRE(update.has_implied()); REQUIRE(update.direct().bids_size() == 0); @@ -1556,9 +1646,9 @@ struct Co2RelayTests { reply.Clear(); server->query(request, &reply, &entitlements, false); reply = simulate_wire_transfer(reply); - - for (auto& channel : reply.channels()) { - for (auto& update : channel.updates()) { + + for (auto &channel : reply.channels()) { + for (auto &update : channel.updates()) { REQUIRE(update.has_direct()); REQUIRE(update.has_implied()); REQUIRE(update.direct().bids_size() == COCONUT_MAX_DEPTH); @@ -1576,71 +1666,73 @@ struct Co2RelayTests { } } } -} ; +}; -TEST_CASE ("Co2RelayTests","[md]") -{ +TEST_CASE("Co2RelayTests", "[md]") { Co2RelayTests co2_relay_tests; co2_relay_tests.setup(); - SECTION("relay_nans") { - co2_relay_tests.relay_nans(); - } - SECTION("relay_implied") { - co2_relay_tests.relay_implied(); - } + SECTION("relay_nans") { co2_relay_tests.relay_nans(); } + SECTION("relay_implied") { co2_relay_tests.relay_implied(); } } namespace ImpliedTests { - void test_merge(const std::array& direct_bid, - const std::array& implied_bid, - const std::array& direct_ask, - const std::array& implied_ask, - const std::function&)>& validate) { - MDProducer producer(TEST_PLATFORM); - vector producers = create_test_securities(producer); - auto write_time = TimeStamp::now(); - - // update both direct and implied - for (auto& p : producers) { - p.update_direct(write_time, direct_bid, direct_ask, 0); - p.update_implied(write_time, implied_bid, implied_ask, 1); - } - // read from both - set symbols; - UserSymbol future_symbol( "FOO", VENUE_BTS, SECURITYTYPE_FUTURE ); - symbols.insert(future_symbol); - UserSymbol option_symbol( "FOOX", VENUE_BTS, SECURITYTYPE_OPTION ); - symbols.insert(option_symbol); - SecurityCache cache; - MDConsumer consumer(cache, nullptr, nullptr, &symbols); - vector consumer_securities; - // Poll for security list - none visible until they have keys - size_t count = consumer.walk_security_list([&](const SecurityPtr& security, MDConsumerHandle) {consumer_securities.push_back(*security);}); - // Since no security has an id none are "public" - REQUIRE(consumer_securities.size() == count); - REQUIRE(count == 0); - assign_ids(producers.begin(), producers.end()); - // Now securities can be enumerated by the client - count = consumer.walk_security_list([&](const SecurityPtr& security, MDConsumerHandle) {consumer_securities.push_back(*security);}); - REQUIRE(consumer_securities.size() == count); - REQUIRE(count == 24); - vector consumers; - for(const auto& security : consumer_securities) { - consumers.push_back(consumer.get_handle(security.id())); - } +void test_merge( + const std::array &direct_bid, + const std::array &implied_bid, + const std::array &direct_ask, + const std::array &implied_ask, + const std::function &)> &validate) { + MDProducer producer(TEST_PLATFORM); + vector producers = create_test_securities(producer); + auto write_time = TimeStamp::now(); - validate(consumers); + // update both direct and implied + for (auto &p : producers) { + p.update_direct(write_time, direct_bid, direct_ask, 0); + p.update_implied(write_time, implied_bid, implied_ask, 1); } + // read from both + set symbols; + UserSymbol future_symbol("FOO", VENUE_BTS, SECURITYTYPE_FUTURE); + symbols.insert(future_symbol); + UserSymbol option_symbol("FOOX", VENUE_BTS, SECURITYTYPE_OPTION); + symbols.insert(option_symbol); + SecurityCache cache; + MDConsumer consumer(cache, nullptr, nullptr, &symbols); + vector consumer_securities; + // Poll for security list - none visible until they have keys + size_t count = consumer.walk_security_list( + [&](const SecurityPtr &security, MDConsumerHandle) { + consumer_securities.push_back(*security); + }); + // Since no security has an id none are "public" + REQUIRE(consumer_securities.size() == count); + REQUIRE(count == 0); + assign_ids(producers.begin(), producers.end()); + // Now securities can be enumerated by the client + count = consumer.walk_security_list( + [&](const SecurityPtr &security, MDConsumerHandle) { + consumer_securities.push_back(*security); + }); + REQUIRE(consumer_securities.size() == count); + REQUIRE(count == 24); + vector consumers; + for (const auto &security : consumer_securities) { + consumers.push_back(consumer.get_handle(security.id())); + } + + validate(consumers); } +} // namespace ImpliedTests TEST_CASE("MergeImpliedTests", "[md]") { config::internal::initialize_for_test( - "PlatformMap {" - " value {" - " glbx_platform: 'PLATFORM_SIM'" - " }" - "}"); + "PlatformMap {" + " value {" + " glbx_platform: 'PLATFORM_SIM'" + " }" + "}"); // create a handle with implied and direct std::array direct_bid, direct_ask; std::array implied_bid, implied_ask; @@ -1654,631 +1746,703 @@ TEST_CASE("MergeImpliedTests", "[md]") { } direct_ask = direct_bid; implied_ask = implied_bid; - ImpliedTests::test_merge(direct_bid,implied_bid, direct_ask, implied_ask, [](const vector& consumers) { - for (const auto& c : consumers) { - std::array bids, asks; - TimeStamp read_time; - // get_book returns true becuase this time is after the change - REQUIRE(c.get_direct_book(read_time, COCONUT_MAX_DEPTH, &bids[0], &asks[0]) == HandleReadResult::SUCCESS); - for (size_t x = 0; x < COCONUT_MAX_DEPTH; ++x) { - REQUIRE(bids[x].size() == 2); - REQUIRE(bids[x].direct_size() == 2); - REQUIRE(bids[x].implied_size() == 0); - REQUIRE(asks[x].size() == 2); - REQUIRE(asks[x].direct_size() == 2); - REQUIRE(asks[x].implied_size() == 0); - } - read_time = TimeStamp(); - REQUIRE(c.get_implied_book(read_time, COCONUT_MAX_IMPLIED_DEPTH, &bids[0], &asks[0]) == HandleReadResult::SUCCESS); - for (size_t x = 0; x < COCONUT_MAX_IMPLIED_DEPTH; ++x) { - REQUIRE(bids[x].size() == 1); - REQUIRE(asks[x].size() == 1); - - REQUIRE(bids[x].direct_size() == 0); - REQUIRE(bids[x].implied_size() == 1); - REQUIRE(asks[x].direct_size() == 0); - REQUIRE(asks[x].implied_size() == 1); - } - read_time = TimeStamp(); - REQUIRE(c.get_book(read_time, COCONUT_MAX_IMPLIED_DEPTH, &bids[0], &asks[0]) == HandleReadResult::SUCCESS); - for (size_t x = 0; x < COCONUT_MAX_DEPTH; ++x) { - if (x < COCONUT_MAX_IMPLIED_DEPTH) { - REQUIRE(bids[x].size() == 3); - REQUIRE(asks[x].size() == 3); - - REQUIRE(bids[x].direct_size() == 2); - REQUIRE(bids[x].implied_size() == 1); - REQUIRE(asks[x].direct_size() == 2); - REQUIRE(asks[x].implied_size() == 1); - } - else { - REQUIRE(bids[x].size() == 2); - REQUIRE(asks[x].size() == 2); - - REQUIRE(bids[x].direct_size() == 2); - REQUIRE(bids[x].implied_size() == 0); - REQUIRE(asks[x].direct_size() == 2); - REQUIRE(asks[x].implied_size() == 0); - } - } - } - }); + ImpliedTests::test_merge( + direct_bid, implied_bid, direct_ask, implied_ask, + [](const vector &consumers) { + for (const auto &c : consumers) { + std::array bids, asks; + TimeStamp read_time; + // get_book returns true becuase this time is after the change + REQUIRE( + c.get_direct_book( + read_time, COCONUT_MAX_DEPTH, &bids[0], &asks[0]) == + HandleReadResult::SUCCESS); + for (size_t x = 0; x < COCONUT_MAX_DEPTH; ++x) { + REQUIRE(bids[x].size() == 2); + REQUIRE(bids[x].direct_size() == 2); + REQUIRE(bids[x].implied_size() == 0); + REQUIRE(asks[x].size() == 2); + REQUIRE(asks[x].direct_size() == 2); + REQUIRE(asks[x].implied_size() == 0); + } + read_time = TimeStamp(); + REQUIRE( + c.get_implied_book( + read_time, COCONUT_MAX_IMPLIED_DEPTH, &bids[0], + &asks[0]) == HandleReadResult::SUCCESS); + for (size_t x = 0; x < COCONUT_MAX_IMPLIED_DEPTH; ++x) { + REQUIRE(bids[x].size() == 1); + REQUIRE(asks[x].size() == 1); + + REQUIRE(bids[x].direct_size() == 0); + REQUIRE(bids[x].implied_size() == 1); + REQUIRE(asks[x].direct_size() == 0); + REQUIRE(asks[x].implied_size() == 1); + } + read_time = TimeStamp(); + REQUIRE( + c.get_book( + read_time, COCONUT_MAX_IMPLIED_DEPTH, &bids[0], + &asks[0]) == HandleReadResult::SUCCESS); + for (size_t x = 0; x < COCONUT_MAX_DEPTH; ++x) { + if (x < COCONUT_MAX_IMPLIED_DEPTH) { + REQUIRE(bids[x].size() == 3); + REQUIRE(asks[x].size() == 3); + + REQUIRE(bids[x].direct_size() == 2); + REQUIRE(bids[x].implied_size() == 1); + REQUIRE(asks[x].direct_size() == 2); + REQUIRE(asks[x].implied_size() == 1); + } else { + REQUIRE(bids[x].size() == 2); + REQUIRE(asks[x].size() == 2); + + REQUIRE(bids[x].direct_size() == 2); + REQUIRE(bids[x].implied_size() == 0); + REQUIRE(asks[x].direct_size() == 2); + REQUIRE(asks[x].implied_size() == 0); + } + } + } + }); } SECTION("partial_Read") { - direct_bid[0] = { {700, 1}, 1 }; - direct_bid[1] = { {600, 1}, 1 }; - direct_bid[2] = { {500, 1}, 1 }; - direct_bid[3] = { {400, 1}, 1 }; + direct_bid[0] = {{700, 1}, 1}; + direct_bid[1] = {{600, 1}, 1}; + direct_bid[2] = {{500, 1}, 1}; + direct_bid[3] = {{400, 1}, 1}; - direct_ask[0] = { {800, 1}, 1 }; - direct_ask[1] = { {900, 1}, 1 }; - direct_ask[2] = { {1000, 1}, 1 }; - direct_ask[3] = { {1100, 1}, 1 }; - - implied_bid[0] = { {700, 1}, 2 }; - implied_bid[1] = { {600, 1}, 2 }; + direct_ask[0] = {{800, 1}, 1}; + direct_ask[1] = {{900, 1}, 1}; + direct_ask[2] = {{1000, 1}, 1}; + direct_ask[3] = {{1100, 1}, 1}; - implied_ask[0] = { {800, 1}, 2 }; - implied_ask[1] = { {900, 1}, 2 }; + implied_bid[0] = {{700, 1}, 2}; + implied_bid[1] = {{600, 1}, 2}; + implied_ask[0] = {{800, 1}, 2}; + implied_ask[1] = {{900, 1}, 2}; - ImpliedTests::test_merge(direct_bid,implied_bid,direct_ask,implied_ask, [](const vector& consumers) { - const size_t TEST_DEPTH = 4; - for (const auto& c : consumers) { - std::array bids, asks; - int canary = 0; - TimeStamp read_time; - // get_boo returns true becuase this time is after the change - REQUIRE(c.get_direct_book(read_time, TEST_DEPTH, &bids[0], &asks[0]) == HandleReadResult::SUCCESS); - for (size_t x = 0; x < TEST_DEPTH; ++x) { - REQUIRE(bids[x].size() == 1); - REQUIRE(asks[x].size() == 1); - REQUIRE(bids[x].direct_size() == 1); - REQUIRE(bids[x].implied_size() == 0); - REQUIRE(asks[x].direct_size() == 1); - REQUIRE(asks[x].implied_size() == 0); - } - read_time = TimeStamp(); - REQUIRE(c.get_implied_book(read_time, COCONUT_MAX_IMPLIED_DEPTH, &bids[0], &asks[0]) == HandleReadResult::SUCCESS); - for (size_t x = 0; x < COCONUT_MAX_IMPLIED_DEPTH; ++x) { - REQUIRE(bids[x].size() == 2); - REQUIRE(asks[x].size() == 2); - REQUIRE(bids[x].direct_size() == 0); - REQUIRE(bids[x].implied_size() == 2); - REQUIRE(asks[x].direct_size() == 0); - REQUIRE(asks[x].implied_size() == 2); - } - read_time = TimeStamp(); - REQUIRE(c.get_book(read_time, TEST_DEPTH, &bids[0], &asks[0]) == HandleReadResult::SUCCESS); - for (size_t x = 0; x < TEST_DEPTH; ++x) { - if (x < COCONUT_MAX_IMPLIED_DEPTH) { - REQUIRE(bids[x].size() == 3); - REQUIRE(asks[x].size() == 3); - REQUIRE(bids[x].direct_size() == 1); - REQUIRE(bids[x].implied_size() == 2); - REQUIRE(asks[x].direct_size() == 1); - REQUIRE(asks[x].implied_size() == 2); - } - else { - REQUIRE(bids[x].size() == 1); - REQUIRE(asks[x].size() == 1); - REQUIRE(bids[x].direct_size() == 1); - REQUIRE(bids[x].implied_size() == 0); - REQUIRE(asks[x].direct_size() == 1); - REQUIRE(asks[x].implied_size() == 0); - } - } - REQUIRE(canary == 0); - } - }); + ImpliedTests::test_merge( + direct_bid, implied_bid, direct_ask, implied_ask, + [](const vector &consumers) { + const size_t TEST_DEPTH = 4; + for (const auto &c : consumers) { + std::array bids, asks; + int canary = 0; + TimeStamp read_time; + // get_boo returns true becuase this time is after the change + REQUIRE( + c.get_direct_book( + read_time, TEST_DEPTH, &bids[0], &asks[0]) == + HandleReadResult::SUCCESS); + for (size_t x = 0; x < TEST_DEPTH; ++x) { + REQUIRE(bids[x].size() == 1); + REQUIRE(asks[x].size() == 1); + REQUIRE(bids[x].direct_size() == 1); + REQUIRE(bids[x].implied_size() == 0); + REQUIRE(asks[x].direct_size() == 1); + REQUIRE(asks[x].implied_size() == 0); + } + read_time = TimeStamp(); + REQUIRE( + c.get_implied_book( + read_time, COCONUT_MAX_IMPLIED_DEPTH, &bids[0], + &asks[0]) == HandleReadResult::SUCCESS); + for (size_t x = 0; x < COCONUT_MAX_IMPLIED_DEPTH; ++x) { + REQUIRE(bids[x].size() == 2); + REQUIRE(asks[x].size() == 2); + REQUIRE(bids[x].direct_size() == 0); + REQUIRE(bids[x].implied_size() == 2); + REQUIRE(asks[x].direct_size() == 0); + REQUIRE(asks[x].implied_size() == 2); + } + read_time = TimeStamp(); + REQUIRE( + c.get_book(read_time, TEST_DEPTH, &bids[0], &asks[0]) == + HandleReadResult::SUCCESS); + for (size_t x = 0; x < TEST_DEPTH; ++x) { + if (x < COCONUT_MAX_IMPLIED_DEPTH) { + REQUIRE(bids[x].size() == 3); + REQUIRE(asks[x].size() == 3); + REQUIRE(bids[x].direct_size() == 1); + REQUIRE(bids[x].implied_size() == 2); + REQUIRE(asks[x].direct_size() == 1); + REQUIRE(asks[x].implied_size() == 2); + } else { + REQUIRE(bids[x].size() == 1); + REQUIRE(asks[x].size() == 1); + REQUIRE(bids[x].direct_size() == 1); + REQUIRE(bids[x].implied_size() == 0); + REQUIRE(asks[x].direct_size() == 1); + REQUIRE(asks[x].implied_size() == 0); + } + } + REQUIRE(canary == 0); + } + }); } SECTION("better_implied") { - direct_bid[0] = { {500, 1}, 1 }; - direct_bid[1] = { {400, 1}, 1 }; - direct_bid[2] = { {300, 1}, 1 }; - direct_bid[3] = { {200, 1}, 1 }; + direct_bid[0] = {{500, 1}, 1}; + direct_bid[1] = {{400, 1}, 1}; + direct_bid[2] = {{300, 1}, 1}; + direct_bid[3] = {{200, 1}, 1}; - direct_ask[0] = { {1000, 1}, 1 }; - direct_ask[1] = { {1100, 1}, 1 }; - direct_ask[2] = { {1200, 1}, 1 }; - direct_ask[3] = { {1300, 1}, 1 }; - - implied_bid[0] = { {600, 1}, 2 }; - implied_bid[1] = { {500, 1}, 2 }; + direct_ask[0] = {{1000, 1}, 1}; + direct_ask[1] = {{1100, 1}, 1}; + direct_ask[2] = {{1200, 1}, 1}; + direct_ask[3] = {{1300, 1}, 1}; - implied_ask[0] = { {900, 1}, 2 }; - implied_ask[1] = { {1000, 1}, 2 }; + implied_bid[0] = {{600, 1}, 2}; + implied_bid[1] = {{500, 1}, 2}; + implied_ask[0] = {{900, 1}, 2}; + implied_ask[1] = {{1000, 1}, 2}; - ImpliedTests::test_merge(direct_bid,implied_bid,direct_ask,implied_ask, [=](const vector& consumers) { - const size_t TEST_DEPTH = 4; - for (const auto& c : consumers) { - std::array bids, asks; - int canary = 0; - TimeStamp read_time; - // get_boo returns true becuase this time is after the change - REQUIRE(c.get_direct_book(read_time, TEST_DEPTH, &bids[0], &asks[0]) == HandleReadResult::SUCCESS); - for (size_t x = 0; x < TEST_DEPTH; ++x) { - REQUIRE(bids[x].size() == 1); - REQUIRE(asks[x].size() == 1); - REQUIRE(bids[x].direct_size() == 1); - REQUIRE(bids[x].implied_size() == 0); - REQUIRE(asks[x].direct_size() == 1); - REQUIRE(asks[x].implied_size() == 0); - } - read_time = TimeStamp(); - REQUIRE(c.get_implied_book(read_time, COCONUT_MAX_IMPLIED_DEPTH, &bids[0], &asks[0]) == HandleReadResult::SUCCESS); - for (size_t x = 0; x < COCONUT_MAX_IMPLIED_DEPTH; ++x) { - REQUIRE(bids[x].size() == 2); - REQUIRE(asks[x].size() == 2); - REQUIRE(bids[x].direct_size() == 0); - REQUIRE(bids[x].implied_size() == 2); - REQUIRE(asks[x].direct_size() == 0); - REQUIRE(asks[x].implied_size() == 2); - } - read_time = TimeStamp(); - REQUIRE(c.get_book(read_time, TEST_DEPTH, &bids[0], &asks[0]) == HandleReadResult::SUCCESS); - REQUIRE(bids[0].size() == 2); - REQUIRE(bids[0].mantissa() == 600); - REQUIRE(asks[0].size() == 2); - REQUIRE(asks[0].mantissa() == 900); - REQUIRE(bids[1].size() == 3); - REQUIRE(asks[1].size() == 3); - REQUIRE(bids[1].direct_size() == 1); - REQUIRE(bids[1].implied_size() == 2); - REQUIRE(asks[1].direct_size() == 1); - REQUIRE(asks[1].implied_size() == 2); - for (size_t x = 2; x < TEST_DEPTH; ++x) { - REQUIRE(bids[x].size() == 1); - REQUIRE(asks[x].size() == 1); - REQUIRE(bids[x].direct_size() == 1); - REQUIRE(bids[x].implied_size() == 0); - REQUIRE(asks[x].direct_size() == 1); - REQUIRE(asks[x].implied_size() == 0); - } - REQUIRE(canary == 0); - } - }); + ImpliedTests::test_merge( + direct_bid, implied_bid, direct_ask, implied_ask, + [=](const vector &consumers) { + const size_t TEST_DEPTH = 4; + for (const auto &c : consumers) { + std::array bids, asks; + int canary = 0; + TimeStamp read_time; + // get_boo returns true becuase this time is after the change + REQUIRE( + c.get_direct_book( + read_time, TEST_DEPTH, &bids[0], &asks[0]) == + HandleReadResult::SUCCESS); + for (size_t x = 0; x < TEST_DEPTH; ++x) { + REQUIRE(bids[x].size() == 1); + REQUIRE(asks[x].size() == 1); + REQUIRE(bids[x].direct_size() == 1); + REQUIRE(bids[x].implied_size() == 0); + REQUIRE(asks[x].direct_size() == 1); + REQUIRE(asks[x].implied_size() == 0); + } + read_time = TimeStamp(); + REQUIRE( + c.get_implied_book( + read_time, COCONUT_MAX_IMPLIED_DEPTH, &bids[0], + &asks[0]) == HandleReadResult::SUCCESS); + for (size_t x = 0; x < COCONUT_MAX_IMPLIED_DEPTH; ++x) { + REQUIRE(bids[x].size() == 2); + REQUIRE(asks[x].size() == 2); + REQUIRE(bids[x].direct_size() == 0); + REQUIRE(bids[x].implied_size() == 2); + REQUIRE(asks[x].direct_size() == 0); + REQUIRE(asks[x].implied_size() == 2); + } + read_time = TimeStamp(); + REQUIRE( + c.get_book(read_time, TEST_DEPTH, &bids[0], &asks[0]) == + HandleReadResult::SUCCESS); + REQUIRE(bids[0].size() == 2); + REQUIRE(bids[0].mantissa() == 600); + REQUIRE(asks[0].size() == 2); + REQUIRE(asks[0].mantissa() == 900); + REQUIRE(bids[1].size() == 3); + REQUIRE(asks[1].size() == 3); + REQUIRE(bids[1].direct_size() == 1); + REQUIRE(bids[1].implied_size() == 2); + REQUIRE(asks[1].direct_size() == 1); + REQUIRE(asks[1].implied_size() == 2); + for (size_t x = 2; x < TEST_DEPTH; ++x) { + REQUIRE(bids[x].size() == 1); + REQUIRE(asks[x].size() == 1); + REQUIRE(bids[x].direct_size() == 1); + REQUIRE(bids[x].implied_size() == 0); + REQUIRE(asks[x].direct_size() == 1); + REQUIRE(asks[x].implied_size() == 0); + } + REQUIRE(canary == 0); + } + }); } - + SECTION("worse_implied") { - direct_bid[0] = { {500, 1}, 1 }; - direct_bid[1] = { {400, 1}, 1 }; - direct_bid[2] = { {300, 1}, 1 }; - direct_bid[3] = { {200, 1}, 1 }; + direct_bid[0] = {{500, 1}, 1}; + direct_bid[1] = {{400, 1}, 1}; + direct_bid[2] = {{300, 1}, 1}; + direct_bid[3] = {{200, 1}, 1}; - direct_ask[0] = { {1000, 1}, 1 }; - direct_ask[1] = { {1100, 1}, 1 }; - direct_ask[2] = { {1200, 1}, 1 }; - direct_ask[3] = { {1300, 1}, 1 }; - - implied_bid[0] = { {400, 1}, 2 }; - implied_bid[1] = { {300, 1}, 2 }; + direct_ask[0] = {{1000, 1}, 1}; + direct_ask[1] = {{1100, 1}, 1}; + direct_ask[2] = {{1200, 1}, 1}; + direct_ask[3] = {{1300, 1}, 1}; - implied_ask[0] = { {1100, 1}, 2 }; - implied_ask[1] = { {1200, 1}, 2 }; + implied_bid[0] = {{400, 1}, 2}; + implied_bid[1] = {{300, 1}, 2}; + implied_ask[0] = {{1100, 1}, 2}; + implied_ask[1] = {{1200, 1}, 2}; - ImpliedTests::test_merge(direct_bid,implied_bid,direct_ask,implied_ask, [=](const vector& consumers) { - const size_t TEST_DEPTH = 4; - for (const auto& c : consumers) { - std::array bids, asks; - int canary = 0; - TimeStamp read_time; - // get_boo returns true becuase this time is after the change - REQUIRE(c.get_direct_book(read_time, TEST_DEPTH, &bids[0], &asks[0]) == HandleReadResult::SUCCESS); - for (size_t x = 0; x < TEST_DEPTH; ++x) { - REQUIRE(bids[x].size() == 1); - REQUIRE(asks[x].size() == 1); - REQUIRE(bids[x].direct_size() == 1); - REQUIRE(bids[x].implied_size() == 0); - REQUIRE(asks[x].direct_size() == 1); - REQUIRE(asks[x].implied_size() == 0); - } - read_time = TimeStamp(); - REQUIRE(c.get_implied_book(read_time, COCONUT_MAX_IMPLIED_DEPTH, &bids[0], &asks[0]) == HandleReadResult::SUCCESS); - for (size_t x = 0; x < COCONUT_MAX_IMPLIED_DEPTH; ++x) { - REQUIRE(bids[x].size() == 2); - REQUIRE(asks[x].size() == 2); - REQUIRE(bids[x].direct_size() == 0); - REQUIRE(bids[x].implied_size() == 2); - REQUIRE(asks[x].direct_size() == 0); - REQUIRE(asks[x].implied_size() == 2); - } - read_time = TimeStamp(); - REQUIRE(c.get_book(read_time, TEST_DEPTH, &bids[0], &asks[0]) == HandleReadResult::SUCCESS); - REQUIRE(bids[0].mantissa() == 500); - REQUIRE(bids[0].size() == 1); - REQUIRE(asks[0].mantissa() == 1000); - REQUIRE(asks[0].size() == 1); - REQUIRE(bids[0].direct_size() == 1); - REQUIRE(bids[0].implied_size() == 0); - REQUIRE(asks[0].direct_size() == 1); - REQUIRE(asks[0].implied_size() == 0); + ImpliedTests::test_merge( + direct_bid, implied_bid, direct_ask, implied_ask, + [=](const vector &consumers) { + const size_t TEST_DEPTH = 4; + for (const auto &c : consumers) { + std::array bids, asks; + int canary = 0; + TimeStamp read_time; + // get_boo returns true becuase this time is after the change + REQUIRE( + c.get_direct_book( + read_time, TEST_DEPTH, &bids[0], &asks[0]) == + HandleReadResult::SUCCESS); + for (size_t x = 0; x < TEST_DEPTH; ++x) { + REQUIRE(bids[x].size() == 1); + REQUIRE(asks[x].size() == 1); + REQUIRE(bids[x].direct_size() == 1); + REQUIRE(bids[x].implied_size() == 0); + REQUIRE(asks[x].direct_size() == 1); + REQUIRE(asks[x].implied_size() == 0); + } + read_time = TimeStamp(); + REQUIRE( + c.get_implied_book( + read_time, COCONUT_MAX_IMPLIED_DEPTH, &bids[0], + &asks[0]) == HandleReadResult::SUCCESS); + for (size_t x = 0; x < COCONUT_MAX_IMPLIED_DEPTH; ++x) { + REQUIRE(bids[x].size() == 2); + REQUIRE(asks[x].size() == 2); + REQUIRE(bids[x].direct_size() == 0); + REQUIRE(bids[x].implied_size() == 2); + REQUIRE(asks[x].direct_size() == 0); + REQUIRE(asks[x].implied_size() == 2); + } + read_time = TimeStamp(); + REQUIRE( + c.get_book(read_time, TEST_DEPTH, &bids[0], &asks[0]) == + HandleReadResult::SUCCESS); + REQUIRE(bids[0].mantissa() == 500); + REQUIRE(bids[0].size() == 1); + REQUIRE(asks[0].mantissa() == 1000); + REQUIRE(asks[0].size() == 1); + REQUIRE(bids[0].direct_size() == 1); + REQUIRE(bids[0].implied_size() == 0); + REQUIRE(asks[0].direct_size() == 1); + REQUIRE(asks[0].implied_size() == 0); - REQUIRE(bids[1].mantissa() == 400); - REQUIRE(bids[1].size() == 3); - REQUIRE(asks[1].mantissa() == 1100); - REQUIRE(asks[1].size() == 3); - REQUIRE(bids[1].direct_size() == 1); - REQUIRE(bids[1].implied_size() == 2); - REQUIRE(asks[1].direct_size() == 1); - REQUIRE(asks[1].implied_size() == 2); + REQUIRE(bids[1].mantissa() == 400); + REQUIRE(bids[1].size() == 3); + REQUIRE(asks[1].mantissa() == 1100); + REQUIRE(asks[1].size() == 3); + REQUIRE(bids[1].direct_size() == 1); + REQUIRE(bids[1].implied_size() == 2); + REQUIRE(asks[1].direct_size() == 1); + REQUIRE(asks[1].implied_size() == 2); - REQUIRE(bids[2].mantissa() == 300); - REQUIRE(bids[2].size() == 3); - REQUIRE(asks[2].mantissa() == 1200); - REQUIRE(asks[2].size() == 3); - REQUIRE(bids[2].direct_size() == 1); - REQUIRE(bids[2].implied_size() == 2); - REQUIRE(asks[2].direct_size() == 1); - REQUIRE(asks[2].implied_size() == 2); - - REQUIRE(bids[3].mantissa() == 200); - REQUIRE(bids[3].size() == 1); - REQUIRE(asks[3].mantissa() == 1300); - REQUIRE(asks[3].size() == 1); - REQUIRE(bids[3].direct_size() == 1); - REQUIRE(bids[3].implied_size() == 0); - REQUIRE(asks[3].direct_size() == 1); - REQUIRE(asks[3].implied_size() == 0); + REQUIRE(bids[2].mantissa() == 300); + REQUIRE(bids[2].size() == 3); + REQUIRE(asks[2].mantissa() == 1200); + REQUIRE(asks[2].size() == 3); + REQUIRE(bids[2].direct_size() == 1); + REQUIRE(bids[2].implied_size() == 2); + REQUIRE(asks[2].direct_size() == 1); + REQUIRE(asks[2].implied_size() == 2); - REQUIRE(canary == 0); - } - }); + REQUIRE(bids[3].mantissa() == 200); + REQUIRE(bids[3].size() == 1); + REQUIRE(asks[3].mantissa() == 1300); + REQUIRE(asks[3].size() == 1); + REQUIRE(bids[3].direct_size() == 1); + REQUIRE(bids[3].implied_size() == 0); + REQUIRE(asks[3].direct_size() == 1); + REQUIRE(asks[3].implied_size() == 0); + + REQUIRE(canary == 0); + } + }); } SECTION("worse_implied_bid") { - direct_bid[0] = { {500, 1}, 1 }; - direct_bid[1] = { {400, 1}, 1 }; - direct_bid[2] = { {300, 1}, 1 }; - direct_bid[3] = { {200, 1}, 1 }; + direct_bid[0] = {{500, 1}, 1}; + direct_bid[1] = {{400, 1}, 1}; + direct_bid[2] = {{300, 1}, 1}; + direct_bid[3] = {{200, 1}, 1}; - direct_ask[0] = { {1000, 1}, 1 }; - direct_ask[1] = { {1100, 1}, 1 }; - direct_ask[2] = { {1200, 1}, 1 }; - direct_ask[3] = { {1300, 1}, 1 }; - - implied_bid[0] = { {400, 1}, 2 }; - implied_bid[1] = { {300, 1}, 2 }; + direct_ask[0] = {{1000, 1}, 1}; + direct_ask[1] = {{1100, 1}, 1}; + direct_ask[2] = {{1200, 1}, 1}; + direct_ask[3] = {{1300, 1}, 1}; - implied_ask[0] = { {1000, 1}, 2 }; - implied_ask[1] = { {1100, 1}, 2 }; + implied_bid[0] = {{400, 1}, 2}; + implied_bid[1] = {{300, 1}, 2}; + implied_ask[0] = {{1000, 1}, 2}; + implied_ask[1] = {{1100, 1}, 2}; - ImpliedTests::test_merge(direct_bid,implied_bid,direct_ask,implied_ask, [=](const vector& consumers) { - const size_t TEST_DEPTH = 4; - for (const auto& c : consumers) { - std::array bids, asks; - int canary = 0; - TimeStamp read_time; - // get_boo returns true becuase this time is after the change - REQUIRE(c.get_direct_book(read_time, TEST_DEPTH, &bids[0], &asks[0]) == HandleReadResult::SUCCESS); - for (size_t x = 0; x < TEST_DEPTH; ++x) { - REQUIRE(bids[x].size() == 1); - REQUIRE(asks[x].size() == 1); - REQUIRE(bids[x].direct_size() == 1); - REQUIRE(bids[x].implied_size() == 0); - REQUIRE(asks[x].direct_size() == 1); - REQUIRE(asks[x].implied_size() == 0); - } - read_time = TimeStamp(); - REQUIRE(c.get_implied_book(read_time, COCONUT_MAX_IMPLIED_DEPTH, &bids[0], &asks[0]) == HandleReadResult::SUCCESS); - for (size_t x = 0; x < COCONUT_MAX_IMPLIED_DEPTH; ++x) { - REQUIRE(bids[x].size() == 2); - REQUIRE(asks[x].size() == 2); - REQUIRE(bids[x].direct_size() == 0); - REQUIRE(bids[x].implied_size() == 2); - REQUIRE(asks[x].direct_size() == 0); - REQUIRE(asks[x].implied_size() == 2); - } - read_time = TimeStamp(); - REQUIRE(c.get_book(read_time, TEST_DEPTH, &bids[0], &asks[0]) == HandleReadResult::SUCCESS); - REQUIRE(bids[0].mantissa() == 500); - REQUIRE(bids[0].size() == 1); - REQUIRE(asks[0].mantissa() == 1000); - REQUIRE(asks[0].size() == 3); - REQUIRE(bids[0].direct_size() == 1); - REQUIRE(bids[0].implied_size() == 0); - REQUIRE(asks[0].direct_size() == 1); - REQUIRE(asks[0].implied_size() == 2); + ImpliedTests::test_merge( + direct_bid, implied_bid, direct_ask, implied_ask, + [=](const vector &consumers) { + const size_t TEST_DEPTH = 4; + for (const auto &c : consumers) { + std::array bids, asks; + int canary = 0; + TimeStamp read_time; + // get_boo returns true becuase this time is after the change + REQUIRE( + c.get_direct_book( + read_time, TEST_DEPTH, &bids[0], &asks[0]) == + HandleReadResult::SUCCESS); + for (size_t x = 0; x < TEST_DEPTH; ++x) { + REQUIRE(bids[x].size() == 1); + REQUIRE(asks[x].size() == 1); + REQUIRE(bids[x].direct_size() == 1); + REQUIRE(bids[x].implied_size() == 0); + REQUIRE(asks[x].direct_size() == 1); + REQUIRE(asks[x].implied_size() == 0); + } + read_time = TimeStamp(); + REQUIRE( + c.get_implied_book( + read_time, COCONUT_MAX_IMPLIED_DEPTH, &bids[0], + &asks[0]) == HandleReadResult::SUCCESS); + for (size_t x = 0; x < COCONUT_MAX_IMPLIED_DEPTH; ++x) { + REQUIRE(bids[x].size() == 2); + REQUIRE(asks[x].size() == 2); + REQUIRE(bids[x].direct_size() == 0); + REQUIRE(bids[x].implied_size() == 2); + REQUIRE(asks[x].direct_size() == 0); + REQUIRE(asks[x].implied_size() == 2); + } + read_time = TimeStamp(); + REQUIRE( + c.get_book(read_time, TEST_DEPTH, &bids[0], &asks[0]) == + HandleReadResult::SUCCESS); + REQUIRE(bids[0].mantissa() == 500); + REQUIRE(bids[0].size() == 1); + REQUIRE(asks[0].mantissa() == 1000); + REQUIRE(asks[0].size() == 3); + REQUIRE(bids[0].direct_size() == 1); + REQUIRE(bids[0].implied_size() == 0); + REQUIRE(asks[0].direct_size() == 1); + REQUIRE(asks[0].implied_size() == 2); - REQUIRE(bids[1].mantissa() == 400); - REQUIRE(bids[1].size() == 3); - REQUIRE(asks[1].mantissa() == 1100); - REQUIRE(asks[1].size() == 3); - REQUIRE(bids[1].direct_size() == 1); - REQUIRE(bids[1].implied_size() == 2); - REQUIRE(asks[1].direct_size() == 1); - REQUIRE(asks[1].implied_size() == 2); + REQUIRE(bids[1].mantissa() == 400); + REQUIRE(bids[1].size() == 3); + REQUIRE(asks[1].mantissa() == 1100); + REQUIRE(asks[1].size() == 3); + REQUIRE(bids[1].direct_size() == 1); + REQUIRE(bids[1].implied_size() == 2); + REQUIRE(asks[1].direct_size() == 1); + REQUIRE(asks[1].implied_size() == 2); - REQUIRE(bids[2].mantissa() == 300); - REQUIRE(bids[2].size() == 3); - REQUIRE(asks[2].mantissa() == 1200); - REQUIRE(asks[2].size() == 1); - REQUIRE(bids[2].direct_size() == 1); - REQUIRE(bids[2].implied_size() == 2); - REQUIRE(asks[2].direct_size() == 1); - REQUIRE(asks[2].implied_size() == 0); - - REQUIRE(bids[3].mantissa() == 200); - REQUIRE(bids[3].size() == 1); - REQUIRE(asks[3].mantissa() == 1300); - REQUIRE(asks[3].size() == 1); - REQUIRE(bids[3].direct_size() == 1); - REQUIRE(bids[3].implied_size() == 0); - REQUIRE(asks[3].direct_size() == 1); - REQUIRE(asks[3].implied_size() == 0); + REQUIRE(bids[2].mantissa() == 300); + REQUIRE(bids[2].size() == 3); + REQUIRE(asks[2].mantissa() == 1200); + REQUIRE(asks[2].size() == 1); + REQUIRE(bids[2].direct_size() == 1); + REQUIRE(bids[2].implied_size() == 2); + REQUIRE(asks[2].direct_size() == 1); + REQUIRE(asks[2].implied_size() == 0); - REQUIRE(canary == 0); - } - }); + REQUIRE(bids[3].mantissa() == 200); + REQUIRE(bids[3].size() == 1); + REQUIRE(asks[3].mantissa() == 1300); + REQUIRE(asks[3].size() == 1); + REQUIRE(bids[3].direct_size() == 1); + REQUIRE(bids[3].implied_size() == 0); + REQUIRE(asks[3].direct_size() == 1); + REQUIRE(asks[3].implied_size() == 0); + + REQUIRE(canary == 0); + } + }); } SECTION("worse_implied_ask") { - direct_bid[0] = { {500, 1}, 1 }; - direct_bid[1] = { {400, 1}, 1 }; - direct_bid[2] = { {300, 1}, 1 }; - direct_bid[3] = { {200, 1}, 1 }; + direct_bid[0] = {{500, 1}, 1}; + direct_bid[1] = {{400, 1}, 1}; + direct_bid[2] = {{300, 1}, 1}; + direct_bid[3] = {{200, 1}, 1}; - direct_ask[0] = { {1000, 1}, 1 }; - direct_ask[1] = { {1100, 1}, 1 }; - direct_ask[2] = { {1200, 1}, 1 }; - direct_ask[3] = { {1300, 1}, 1 }; - - implied_bid[0] = { {500, 1}, 2 }; - implied_bid[1] = { {400, 1}, 2 }; + direct_ask[0] = {{1000, 1}, 1}; + direct_ask[1] = {{1100, 1}, 1}; + direct_ask[2] = {{1200, 1}, 1}; + direct_ask[3] = {{1300, 1}, 1}; - implied_ask[0] = { {1300, 1}, 2 }; - implied_ask[1] = { {1400, 1}, 2 }; + implied_bid[0] = {{500, 1}, 2}; + implied_bid[1] = {{400, 1}, 2}; + implied_ask[0] = {{1300, 1}, 2}; + implied_ask[1] = {{1400, 1}, 2}; - ImpliedTests::test_merge(direct_bid,implied_bid,direct_ask,implied_ask, [=](const vector& consumers) { - const size_t TEST_DEPTH = 4; - for (const auto& c : consumers) { - std::array bids, asks; - int canary = 0; - TimeStamp read_time; - // get_boo returns true becuase this time is after the change - REQUIRE(c.get_direct_book(read_time, TEST_DEPTH, &bids[0], &asks[0]) == HandleReadResult::SUCCESS); - for (size_t x = 0; x < TEST_DEPTH; ++x) { - REQUIRE(bids[x].size() == 1); - REQUIRE(asks[x].size() == 1); - REQUIRE(bids[x].direct_size() == 1); - REQUIRE(bids[x].implied_size() == 0); - REQUIRE(asks[x].direct_size() == 1); - REQUIRE(asks[x].implied_size() == 0); - } - read_time = TimeStamp(); - REQUIRE(c.get_implied_book(read_time, COCONUT_MAX_IMPLIED_DEPTH, &bids[0], &asks[0]) == HandleReadResult::SUCCESS); - for (size_t x = 0; x < COCONUT_MAX_IMPLIED_DEPTH; ++x) { - REQUIRE(bids[x].size() == 2); - REQUIRE(asks[x].size() == 2); - REQUIRE(bids[x].direct_size() == 0); - REQUIRE(bids[x].implied_size() == 2); - REQUIRE(asks[x].direct_size() == 0); - REQUIRE(asks[x].implied_size() == 2); - } - read_time = TimeStamp(); - REQUIRE(c.get_book(read_time, TEST_DEPTH+1, &bids[0], &asks[0]) == HandleReadResult::SUCCESS); - REQUIRE(bids[0].mantissa() == 500); - REQUIRE(bids[0].size() == 3); - REQUIRE(asks[0].mantissa() == 1000); - REQUIRE(asks[0].size() == 1); - REQUIRE(bids[0].direct_size() == 1); - REQUIRE(bids[0].implied_size() == 2); - REQUIRE(asks[0].direct_size() == 1); - REQUIRE(asks[0].implied_size() == 0); + ImpliedTests::test_merge( + direct_bid, implied_bid, direct_ask, implied_ask, + [=](const vector &consumers) { + const size_t TEST_DEPTH = 4; + for (const auto &c : consumers) { + std::array bids, asks; + int canary = 0; + TimeStamp read_time; + // get_boo returns true becuase this time is after the change + REQUIRE( + c.get_direct_book( + read_time, TEST_DEPTH, &bids[0], &asks[0]) == + HandleReadResult::SUCCESS); + for (size_t x = 0; x < TEST_DEPTH; ++x) { + REQUIRE(bids[x].size() == 1); + REQUIRE(asks[x].size() == 1); + REQUIRE(bids[x].direct_size() == 1); + REQUIRE(bids[x].implied_size() == 0); + REQUIRE(asks[x].direct_size() == 1); + REQUIRE(asks[x].implied_size() == 0); + } + read_time = TimeStamp(); + REQUIRE( + c.get_implied_book( + read_time, COCONUT_MAX_IMPLIED_DEPTH, &bids[0], + &asks[0]) == HandleReadResult::SUCCESS); + for (size_t x = 0; x < COCONUT_MAX_IMPLIED_DEPTH; ++x) { + REQUIRE(bids[x].size() == 2); + REQUIRE(asks[x].size() == 2); + REQUIRE(bids[x].direct_size() == 0); + REQUIRE(bids[x].implied_size() == 2); + REQUIRE(asks[x].direct_size() == 0); + REQUIRE(asks[x].implied_size() == 2); + } + read_time = TimeStamp(); + REQUIRE( + c.get_book(read_time, TEST_DEPTH + 1, &bids[0], &asks[0]) == + HandleReadResult::SUCCESS); + REQUIRE(bids[0].mantissa() == 500); + REQUIRE(bids[0].size() == 3); + REQUIRE(asks[0].mantissa() == 1000); + REQUIRE(asks[0].size() == 1); + REQUIRE(bids[0].direct_size() == 1); + REQUIRE(bids[0].implied_size() == 2); + REQUIRE(asks[0].direct_size() == 1); + REQUIRE(asks[0].implied_size() == 0); - REQUIRE(bids[1].mantissa() == 400); - REQUIRE(bids[1].size() == 3); - REQUIRE(asks[1].mantissa() == 1100); - REQUIRE(asks[1].size() == 1); - REQUIRE(bids[1].direct_size() == 1); - REQUIRE(bids[1].implied_size() == 2); - REQUIRE(asks[1].direct_size() == 1); - REQUIRE(asks[1].implied_size() == 0); + REQUIRE(bids[1].mantissa() == 400); + REQUIRE(bids[1].size() == 3); + REQUIRE(asks[1].mantissa() == 1100); + REQUIRE(asks[1].size() == 1); + REQUIRE(bids[1].direct_size() == 1); + REQUIRE(bids[1].implied_size() == 2); + REQUIRE(asks[1].direct_size() == 1); + REQUIRE(asks[1].implied_size() == 0); - REQUIRE(bids[2].mantissa() == 300); - REQUIRE(bids[2].size() == 1); - REQUIRE(asks[2].mantissa() == 1200); - REQUIRE(asks[2].size() == 1); - REQUIRE(bids[2].direct_size() == 1); - REQUIRE(bids[2].implied_size() == 0); - REQUIRE(asks[2].direct_size() == 1); - REQUIRE(asks[2].implied_size() == 0); - - REQUIRE(bids[3].mantissa() == 200); - REQUIRE(bids[3].size() == 1); - REQUIRE(asks[3].mantissa() == 1300); - REQUIRE(asks[3].size() == 3); - REQUIRE(bids[3].direct_size() == 1); - REQUIRE(bids[3].implied_size() == 0); - REQUIRE(asks[3].direct_size() == 1); - REQUIRE(asks[3].implied_size() == 2); - - REQUIRE(bids[4].mantissa() == 0); - REQUIRE(bids[4].size() == 0); - REQUIRE(asks[4].mantissa() == 1400); - REQUIRE(asks[4].size() == 2); - REQUIRE(bids[4].direct_size() == 0); - REQUIRE(bids[4].implied_size() == 0); - REQUIRE(asks[4].direct_size() == 0); - REQUIRE(asks[4].implied_size() == 2); + REQUIRE(bids[2].mantissa() == 300); + REQUIRE(bids[2].size() == 1); + REQUIRE(asks[2].mantissa() == 1200); + REQUIRE(asks[2].size() == 1); + REQUIRE(bids[2].direct_size() == 1); + REQUIRE(bids[2].implied_size() == 0); + REQUIRE(asks[2].direct_size() == 1); + REQUIRE(asks[2].implied_size() == 0); - REQUIRE(canary == 0); - } - }); + REQUIRE(bids[3].mantissa() == 200); + REQUIRE(bids[3].size() == 1); + REQUIRE(asks[3].mantissa() == 1300); + REQUIRE(asks[3].size() == 3); + REQUIRE(bids[3].direct_size() == 1); + REQUIRE(bids[3].implied_size() == 0); + REQUIRE(asks[3].direct_size() == 1); + REQUIRE(asks[3].implied_size() == 2); + + REQUIRE(bids[4].mantissa() == 0); + REQUIRE(bids[4].size() == 0); + REQUIRE(asks[4].mantissa() == 1400); + REQUIRE(asks[4].size() == 2); + REQUIRE(bids[4].direct_size() == 0); + REQUIRE(bids[4].implied_size() == 0); + REQUIRE(asks[4].direct_size() == 0); + REQUIRE(asks[4].implied_size() == 2); + + REQUIRE(canary == 0); + } + }); } SECTION("nan_implied") { - direct_bid[0] = { {500, 1}, 1 }; - direct_bid[1] = { {400, 1}, 1 }; - direct_bid[2] = { {300, 1}, 1 }; - direct_bid[3] = { {200, 1}, 1 }; + direct_bid[0] = {{500, 1}, 1}; + direct_bid[1] = {{400, 1}, 1}; + direct_bid[2] = {{300, 1}, 1}; + direct_bid[3] = {{200, 1}, 1}; - direct_ask[0] = { {1000, 1}, 1 }; - direct_ask[1] = { {1100, 1}, 1 }; - direct_ask[2] = { {1200, 1}, 1 }; - direct_ask[3] = { {1300, 1}, 1 }; - - implied_bid[0] = { INT_NAN, 0 }; - implied_bid[1] = { INT_NAN, 0 }; + direct_ask[0] = {{1000, 1}, 1}; + direct_ask[1] = {{1100, 1}, 1}; + direct_ask[2] = {{1200, 1}, 1}; + direct_ask[3] = {{1300, 1}, 1}; - implied_ask[0] = { INT_NAN, 0 }; - implied_ask[1] = { INT_NAN, 0 }; + implied_bid[0] = {INT_NAN, 0}; + implied_bid[1] = {INT_NAN, 0}; + implied_ask[0] = {INT_NAN, 0}; + implied_ask[1] = {INT_NAN, 0}; - ImpliedTests::test_merge(direct_bid,implied_bid,direct_ask,implied_ask, [=](const vector& consumers) { - const size_t TEST_DEPTH = 4; - for (const auto& c : consumers) { - std::array bids, asks; - int canary = 0; - TimeStamp read_time; - // get_boo returns true becuase this time is after the change - REQUIRE(c.get_direct_book(read_time, TEST_DEPTH, &bids[0], &asks[0]) == HandleReadResult::SUCCESS); - for (size_t x = 0; x < TEST_DEPTH; ++x) { - REQUIRE(bids[x].size() == 1); - REQUIRE(asks[x].size() == 1); - REQUIRE(bids[x].direct_size() == 1); - REQUIRE(bids[x].implied_size() == 0); - REQUIRE(asks[x].direct_size() == 1); - REQUIRE(asks[x].implied_size() == 0); - } - read_time = TimeStamp(); - REQUIRE(c.get_implied_book(read_time, COCONUT_MAX_IMPLIED_DEPTH, &bids[0], &asks[0]) == HandleReadResult::SUCCESS); - for (size_t x = 0; x < COCONUT_MAX_IMPLIED_DEPTH; ++x) { - REQUIRE(bids[x].size() == 0); - REQUIRE(asks[x].size() == 0); - REQUIRE(bids[x].direct_size() == 0); - REQUIRE(bids[x].implied_size() == 0); - REQUIRE(asks[x].direct_size() == 0); - REQUIRE(asks[x].implied_size() == 0); - } - read_time = TimeStamp(); - REQUIRE(c.get_book(read_time, TEST_DEPTH, &bids[0], &asks[0]) == HandleReadResult::SUCCESS); - REQUIRE(bids[0].mantissa() == 500); - REQUIRE(bids[0].size() == 1); - REQUIRE(asks[0].mantissa() == 1000); - REQUIRE(asks[0].size() == 1); - REQUIRE(bids[0].direct_size() == 1); - REQUIRE(bids[0].implied_size() == 0); - REQUIRE(asks[0].direct_size() == 1); - REQUIRE(asks[0].implied_size() == 0); + ImpliedTests::test_merge( + direct_bid, implied_bid, direct_ask, implied_ask, + [=](const vector &consumers) { + const size_t TEST_DEPTH = 4; + for (const auto &c : consumers) { + std::array bids, asks; + int canary = 0; + TimeStamp read_time; + // get_boo returns true becuase this time is after the change + REQUIRE( + c.get_direct_book( + read_time, TEST_DEPTH, &bids[0], &asks[0]) == + HandleReadResult::SUCCESS); + for (size_t x = 0; x < TEST_DEPTH; ++x) { + REQUIRE(bids[x].size() == 1); + REQUIRE(asks[x].size() == 1); + REQUIRE(bids[x].direct_size() == 1); + REQUIRE(bids[x].implied_size() == 0); + REQUIRE(asks[x].direct_size() == 1); + REQUIRE(asks[x].implied_size() == 0); + } + read_time = TimeStamp(); + REQUIRE( + c.get_implied_book( + read_time, COCONUT_MAX_IMPLIED_DEPTH, &bids[0], + &asks[0]) == HandleReadResult::SUCCESS); + for (size_t x = 0; x < COCONUT_MAX_IMPLIED_DEPTH; ++x) { + REQUIRE(bids[x].size() == 0); + REQUIRE(asks[x].size() == 0); + REQUIRE(bids[x].direct_size() == 0); + REQUIRE(bids[x].implied_size() == 0); + REQUIRE(asks[x].direct_size() == 0); + REQUIRE(asks[x].implied_size() == 0); + } + read_time = TimeStamp(); + REQUIRE( + c.get_book(read_time, TEST_DEPTH, &bids[0], &asks[0]) == + HandleReadResult::SUCCESS); + REQUIRE(bids[0].mantissa() == 500); + REQUIRE(bids[0].size() == 1); + REQUIRE(asks[0].mantissa() == 1000); + REQUIRE(asks[0].size() == 1); + REQUIRE(bids[0].direct_size() == 1); + REQUIRE(bids[0].implied_size() == 0); + REQUIRE(asks[0].direct_size() == 1); + REQUIRE(asks[0].implied_size() == 0); - REQUIRE(bids[1].mantissa() == 400); - REQUIRE(bids[1].size() == 1); - REQUIRE(asks[1].mantissa() == 1100); - REQUIRE(asks[1].size() == 1); - REQUIRE(bids[1].direct_size() == 1); - REQUIRE(bids[1].implied_size() == 0); - REQUIRE(asks[1].direct_size() == 1); - REQUIRE(asks[1].implied_size() == 0); + REQUIRE(bids[1].mantissa() == 400); + REQUIRE(bids[1].size() == 1); + REQUIRE(asks[1].mantissa() == 1100); + REQUIRE(asks[1].size() == 1); + REQUIRE(bids[1].direct_size() == 1); + REQUIRE(bids[1].implied_size() == 0); + REQUIRE(asks[1].direct_size() == 1); + REQUIRE(asks[1].implied_size() == 0); - REQUIRE(bids[2].mantissa() == 300); - REQUIRE(bids[2].size() == 1); - REQUIRE(asks[2].mantissa() == 1200); - REQUIRE(asks[2].size() == 1); - REQUIRE(bids[2].direct_size() == 1); - REQUIRE(bids[2].implied_size() == 0); - REQUIRE(asks[2].direct_size() == 1); - REQUIRE(asks[2].implied_size() == 0); - - REQUIRE(bids[3].mantissa() == 200); - REQUIRE(bids[3].size() == 1); - REQUIRE(asks[3].mantissa() == 1300); - REQUIRE(asks[3].size() == 1); - REQUIRE(bids[3].direct_size() == 1); - REQUIRE(bids[3].implied_size() == 0); - REQUIRE(asks[3].direct_size() == 1); - REQUIRE(asks[3].implied_size() == 0); + REQUIRE(bids[2].mantissa() == 300); + REQUIRE(bids[2].size() == 1); + REQUIRE(asks[2].mantissa() == 1200); + REQUIRE(asks[2].size() == 1); + REQUIRE(bids[2].direct_size() == 1); + REQUIRE(bids[2].implied_size() == 0); + REQUIRE(asks[2].direct_size() == 1); + REQUIRE(asks[2].implied_size() == 0); - REQUIRE(canary == 0); - } - }); + REQUIRE(bids[3].mantissa() == 200); + REQUIRE(bids[3].size() == 1); + REQUIRE(asks[3].mantissa() == 1300); + REQUIRE(asks[3].size() == 1); + REQUIRE(bids[3].direct_size() == 1); + REQUIRE(bids[3].implied_size() == 0); + REQUIRE(asks[3].direct_size() == 1); + REQUIRE(asks[3].implied_size() == 0); + + REQUIRE(canary == 0); + } + }); } SECTION("nan_direct") { - direct_bid[0] = { INT_NAN, 0 }; - direct_bid[1] = { INT_NAN, 0 }; - direct_bid[2] = { INT_NAN, 0 }; - direct_bid[3] = { INT_NAN, 0 }; + direct_bid[0] = {INT_NAN, 0}; + direct_bid[1] = {INT_NAN, 0}; + direct_bid[2] = {INT_NAN, 0}; + direct_bid[3] = {INT_NAN, 0}; - direct_ask[0] = { INT_NAN, 0 }; - direct_ask[1] = { INT_NAN, 0 }; - direct_ask[2] = { INT_NAN, 0 }; - direct_ask[3] = { INT_NAN, 0 }; - - implied_bid[0] = { {500, 1}, 2 }; - implied_bid[1] = { {400, 1}, 2 }; + direct_ask[0] = {INT_NAN, 0}; + direct_ask[1] = {INT_NAN, 0}; + direct_ask[2] = {INT_NAN, 0}; + direct_ask[3] = {INT_NAN, 0}; - implied_ask[0] = { {1000, 1}, 2 }; - implied_ask[1] = { {1100, 1}, 2 }; + implied_bid[0] = {{500, 1}, 2}; + implied_bid[1] = {{400, 1}, 2}; + implied_ask[0] = {{1000, 1}, 2}; + implied_ask[1] = {{1100, 1}, 2}; - ImpliedTests::test_merge(direct_bid,implied_bid,direct_ask,implied_ask, [=](const vector& consumers) { - const size_t TEST_DEPTH = 4; - for (const auto& c : consumers) { - std::array bids, asks; - int canary = 0; - TimeStamp read_time; - // get_boo returns true becuase this time is after the change - REQUIRE(c.get_direct_book(read_time, TEST_DEPTH, &bids[0], &asks[0]) == HandleReadResult::SUCCESS); - for (size_t x = 0; x < TEST_DEPTH; ++x) { - REQUIRE(bids[x].size() == 0); - REQUIRE(asks[x].size() == 0); - REQUIRE(bids[x].direct_size() == 0); - REQUIRE(bids[x].implied_size() == 0); - REQUIRE(asks[x].direct_size() == 0); - REQUIRE(asks[x].implied_size() == 0); - } - read_time = TimeStamp(); - REQUIRE(c.get_implied_book(read_time, COCONUT_MAX_IMPLIED_DEPTH, &bids[0], &asks[0]) == HandleReadResult::SUCCESS); - for (size_t x = 0; x < COCONUT_MAX_IMPLIED_DEPTH; ++x) { - REQUIRE(bids[x].size() == 2); - REQUIRE(asks[x].size() == 2); - REQUIRE(bids[x].direct_size() == 0); - REQUIRE(bids[x].implied_size() == 2); - REQUIRE(asks[x].direct_size() == 0); - REQUIRE(asks[x].implied_size() == 2); - } - read_time = TimeStamp(); - REQUIRE(c.get_book(read_time, TEST_DEPTH, &bids[0], &asks[0]) == HandleReadResult::SUCCESS); - REQUIRE(bids[0].mantissa() == 500); - REQUIRE(bids[0].size() == 2); - REQUIRE(asks[0].mantissa() == 1000); - REQUIRE(asks[0].size() == 2); - REQUIRE(bids[0].direct_size() == 0); - REQUIRE(bids[0].implied_size() == 2); - REQUIRE(asks[0].direct_size() == 0); - REQUIRE(asks[0].implied_size() == 2); + ImpliedTests::test_merge( + direct_bid, implied_bid, direct_ask, implied_ask, + [=](const vector &consumers) { + const size_t TEST_DEPTH = 4; + for (const auto &c : consumers) { + std::array bids, asks; + int canary = 0; + TimeStamp read_time; + // get_boo returns true becuase this time is after the change + REQUIRE( + c.get_direct_book( + read_time, TEST_DEPTH, &bids[0], &asks[0]) == + HandleReadResult::SUCCESS); + for (size_t x = 0; x < TEST_DEPTH; ++x) { + REQUIRE(bids[x].size() == 0); + REQUIRE(asks[x].size() == 0); + REQUIRE(bids[x].direct_size() == 0); + REQUIRE(bids[x].implied_size() == 0); + REQUIRE(asks[x].direct_size() == 0); + REQUIRE(asks[x].implied_size() == 0); + } + read_time = TimeStamp(); + REQUIRE( + c.get_implied_book( + read_time, COCONUT_MAX_IMPLIED_DEPTH, &bids[0], + &asks[0]) == HandleReadResult::SUCCESS); + for (size_t x = 0; x < COCONUT_MAX_IMPLIED_DEPTH; ++x) { + REQUIRE(bids[x].size() == 2); + REQUIRE(asks[x].size() == 2); + REQUIRE(bids[x].direct_size() == 0); + REQUIRE(bids[x].implied_size() == 2); + REQUIRE(asks[x].direct_size() == 0); + REQUIRE(asks[x].implied_size() == 2); + } + read_time = TimeStamp(); + REQUIRE( + c.get_book(read_time, TEST_DEPTH, &bids[0], &asks[0]) == + HandleReadResult::SUCCESS); + REQUIRE(bids[0].mantissa() == 500); + REQUIRE(bids[0].size() == 2); + REQUIRE(asks[0].mantissa() == 1000); + REQUIRE(asks[0].size() == 2); + REQUIRE(bids[0].direct_size() == 0); + REQUIRE(bids[0].implied_size() == 2); + REQUIRE(asks[0].direct_size() == 0); + REQUIRE(asks[0].implied_size() == 2); - REQUIRE(bids[1].mantissa() == 400); - REQUIRE(bids[1].size() == 2); - REQUIRE(asks[1].mantissa() == 1100); - REQUIRE(asks[1].size() == 2); - REQUIRE(bids[1].direct_size() == 0); - REQUIRE(bids[1].implied_size() == 2); - REQUIRE(asks[1].direct_size() == 0); - REQUIRE(asks[1].implied_size() == 2); + REQUIRE(bids[1].mantissa() == 400); + REQUIRE(bids[1].size() == 2); + REQUIRE(asks[1].mantissa() == 1100); + REQUIRE(asks[1].size() == 2); + REQUIRE(bids[1].direct_size() == 0); + REQUIRE(bids[1].implied_size() == 2); + REQUIRE(asks[1].direct_size() == 0); + REQUIRE(asks[1].implied_size() == 2); - REQUIRE(bids[2].size() == 0); - REQUIRE(asks[2].size() == 0); - REQUIRE(bids[2].direct_size() == 0); - REQUIRE(bids[2].implied_size() == 0); - REQUIRE(asks[2].direct_size() == 0); - REQUIRE(asks[2].implied_size() == 0); - - REQUIRE(bids[3].size() == 0); - REQUIRE(asks[3].size() == 0); - REQUIRE(bids[3].direct_size() == 0); - REQUIRE(bids[3].implied_size() == 0); - REQUIRE(asks[3].direct_size() == 0); - REQUIRE(asks[3].implied_size() == 0); + REQUIRE(bids[2].size() == 0); + REQUIRE(asks[2].size() == 0); + REQUIRE(bids[2].direct_size() == 0); + REQUIRE(bids[2].implied_size() == 0); + REQUIRE(asks[2].direct_size() == 0); + REQUIRE(asks[2].implied_size() == 0); - REQUIRE(canary == 0); - } - }); + REQUIRE(bids[3].size() == 0); + REQUIRE(asks[3].size() == 0); + REQUIRE(bids[3].direct_size() == 0); + REQUIRE(bids[3].implied_size() == 0); + REQUIRE(asks[3].direct_size() == 0); + REQUIRE(asks[3].implied_size() == 0); + + REQUIRE(canary == 0); + } + }); } } @@ -2304,11 +2468,11 @@ TEST_CASE("IntPrice", "[md]") { SECTION("< different exponent") { auto a = IntPrice_from_double<4>(101.111); // -4 - auto b = IntPrice_from_double<0>(100); // 0 + auto b = IntPrice_from_double<0>(100); // 0 REQUIRE((int)a.exponent() < (int)b.exponent()); REQUIRE(b < a); REQUIRE(!(a < b)); - auto c = std::max(a,b); + auto c = std::max(a, b); REQUIRE(c == a); } @@ -2377,19 +2541,20 @@ TEST_CASE("IntPrice", "[md]") { REQUIRE(sell == IntPrice_from_double<4>(100.50)); } SECTION("round 0.005") { - IntPrice price = { -43595000, -7 }; - IntPrice tick = { 50000, -7 }; + IntPrice price = {-43595000, -7}; + IntPrice tick = {50000, -7}; auto buy = round_to_quote_price(tick, price, api::SIDE_BUY); REQUIRE(buy == IntPrice_from_double<7>(-4.360)); } SECTION("division by double") { - IntPrice price = { -43595000, -7 }; - IntPrice price_div10 = { -43595000, -8 }; + IntPrice price = {-43595000, -7}; + IntPrice price_div10 = {-43595000, -8}; REQUIRE(price / 10.0 == price_div10); } } - -}}} +} // namespace test +} // namespace md +} // namespace bts #endif \ No newline at end of file diff --git a/src/lib/md/test/md_test_utils.cpp b/src/lib/md/test/md_test_utils.cpp index bc2848c16..8bb5b29cf 100644 --- a/src/lib/md/test/md_test_utils.cpp +++ b/src/lib/md/test/md_test_utils.cpp @@ -1,18 +1,19 @@ #include "md_test_utils.h" #include "../MDProducer.h" -#include #include +#include namespace bts { namespace md { namespace test { -std::vector create_test_securities(MDProducer& producer, const char* postfix ="") { +std::vector +create_test_securities(MDProducer &producer, const char *postfix = "") { FixedFutureSecurity ffs; FixedOptionSecurity fos; - ffs.symbol("FOO"+std::string(postfix)); - fos.symbol("FOOX"+std::string(postfix)); + ffs.symbol("FOO" + std::string(postfix)); + fos.symbol("FOOX" + std::string(postfix)); ffs.exchange = api::VENUE_BTS; fos.exchange = api::VENUE_BTS; ffs.key = invalid_security_key; @@ -27,15 +28,20 @@ std::vector create_test_securities(MDProducer& producer, const ffs.expiration_month = fos.expiration_month = x; result.push_back(producer.add_security(ffs)); result.push_back(producer.add_security(fos)); - // In a real app these securities would now be passed to the SecurityIDRecorder + // In a real app these securities would now be passed to the + // SecurityIDRecorder } return result; } -void assign_ids(std::vector::iterator begin, std::vector::iterator end, security_key start_key) { +void assign_ids( + std::vector::iterator begin, + std::vector::iterator end, security_key start_key) { for (; begin != end; ++begin) { (*begin).set_key(++start_key); } } -}}}//namespace \ No newline at end of file +} // namespace test +} // namespace md +} // namespace bts \ No newline at end of file diff --git a/src/lib/md/test/md_test_utils.h b/src/lib/md/test/md_test_utils.h index 7eccddc3c..53a4651eb 100644 --- a/src/lib/md/test/md_test_utils.h +++ b/src/lib/md/test/md_test_utils.h @@ -1,8 +1,8 @@ #pragma once +#include "../MDProducerHandle.h" #include "lib/md/IntPrice.h" #include "lib/md/PriceSize.h" -#include "../MDProducerHandle.h" #include namespace bts { @@ -12,7 +12,7 @@ namespace test { struct PS { double price; Size size; - bool operator == (const PS& other) const { + bool operator==(const PS &other) const { // Convert to IntPrice to avoid double rounding issues auto p1 = IntPrice_from_double<11>(price); auto p2 = IntPrice_from_double<11>(other.price); @@ -25,10 +25,15 @@ struct Book { std::vector asks; }; -Book compute_synthetic_book(const api::Security& security, const std::vector& leg_books); +Book compute_synthetic_book( + const api::Security &security, const std::vector &leg_books); -std::ostream& operator<< (std::ostream& os, const PS& val); +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); +void assign_ids( + std::vector::iterator begin, + std::vector::iterator end, security_key start_key = 1000); -}}}//namespace \ No newline at end of file +} // namespace test +} // namespace md +} // namespace bts \ No newline at end of file diff --git a/src/lib/md/test/synthetic_book_merge_tests.cpp b/src/lib/md/test/synthetic_book_merge_tests.cpp index 63d1914c9..03166e5e0 100644 --- a/src/lib/md/test/synthetic_book_merge_tests.cpp +++ b/src/lib/md/test/synthetic_book_merge_tests.cpp @@ -1,22 +1,21 @@ #ifndef _WIN32 -#include "catch/catch.hpp" #include "../MDConsumerHandle.h" -#include "md_test_utils.h" #include "Co2TestInstrument.h" +#include "catch/catch.hpp" #include "lib/utils/sane_algorithm.h" -#include -#include -#include -#include +#include "md_test_utils.h" #include -#include +#include #include +#include +#include +#include +#include #define ENABLE_BENCHMARK 0 #if ENABLE_BENCHMARK #include #endif - using namespace std; namespace bts { int synthetic_book_merge_tests = 0; @@ -25,49 +24,67 @@ namespace test { // std::tuple is hard to read in the debugger -ostream& operator<< (ostream& os, const PS& val) { +ostream &operator<<(ostream &os, const PS &val) { os << "{ " << val.price << "," << val.size << " }"; return os; } -void setup_market(MDProducerHandle producer, const vector& bids, const vector& asks) { +void setup_market( + MDProducerHandle producer, const vector &bids, const vector &asks) { auto ts = TimeStamp::now(); - std::array bids_a = { }, asks_a = { }; - std::transform(bids.begin(), bids.end(), bids_a.begin(), [](const PS& ps) { return PriceSize_from_double<7>(ps.price, ps.size); }); - std::transform(asks.begin(), asks.end(), asks_a.begin(), [](const PS& ps) { return PriceSize_from_double<7>(ps.price, ps.size); }); + std::array bids_a = {}, asks_a = {}; + std::transform(bids.begin(), bids.end(), bids_a.begin(), [](const PS &ps) { + return PriceSize_from_double<7>(ps.price, ps.size); + }); + std::transform(asks.begin(), asks.end(), asks_a.begin(), [](const PS &ps) { + return PriceSize_from_double<7>(ps.price, ps.size); + }); producer.update_direct(ts, bids_a, asks_a); } -void dump_market(const MDConsumerHandle& handle) { - array raw_bids,raw_asks; +void dump_market(const MDConsumerHandle &handle) { + array raw_bids, raw_asks; TimeStamp t; handle.get_book(t, COCONUT_MAX_DEPTH, raw_bids.data(), raw_asks.data()); vector src_bids, src_asks; - sane::map(raw_bids, src_bids, [](const PriceSize& ps) -> PS {return {ps.price(), ps.size()};}); - sane::map(raw_asks, src_asks, [](const PriceSize& ps) -> PS {return {ps.price(), ps.size()}; }); + sane::map(raw_bids, src_bids, [](const PriceSize &ps) -> PS { + return {ps.price(), ps.size()}; + }); + sane::map(raw_asks, src_asks, [](const PriceSize &ps) -> PS { + return {ps.price(), ps.size()}; + }); std::cout << std::endl << "bid: "; - for (const auto& bid : src_bids) { - if (bid.size != 0) std::cout << bid; + for (const auto &bid : src_bids) { + if (bid.size != 0) + std::cout << bid; } std::cout << std::endl << "ask: "; - for (const auto& ask : src_asks) { - if (ask.size != 0) std::cout << ask; + for (const auto &ask : src_asks) { + if (ask.size != 0) + std::cout << ask; } std::cout << std::endl; } -void expect_market(const MDConsumerHandle& handle, const vector bids, const vector& asks) { - array raw_bids,raw_asks; +void expect_market( + const MDConsumerHandle &handle, const vector bids, + const vector &asks) { + array raw_bids, raw_asks; TimeStamp t; - handle.get_direct_book(t, COCONUT_MAX_DEPTH, raw_bids.data(), raw_asks.data()); + handle.get_direct_book( + t, COCONUT_MAX_DEPTH, raw_bids.data(), raw_asks.data()); vector src_bids, src_asks; - sane::map(raw_bids, src_bids, [](const PriceSize& ps) -> PS {return {ps.price(), ps.size()};}); - sane::map(raw_asks, src_asks, [](const PriceSize& ps) -> PS {return {ps.price(), ps.size()}; }); + sane::map(raw_bids, src_bids, [](const PriceSize &ps) -> PS { + return {ps.price(), ps.size()}; + }); + sane::map(raw_asks, src_asks, [](const PriceSize &ps) -> PS { + return {ps.price(), ps.size()}; + }); - for (size_t x =0; x < bids.size(); ++x) { + for (size_t x = 0; x < bids.size(); ++x) { REQUIRE(src_bids[x] == bids[x]); } for (size_t x = bids.size(); x < src_bids.size(); ++x) { @@ -85,11 +102,12 @@ void expect_market(const MDConsumerHandle& handle, const vector bids, const // Crate some securities with given side // (quantity, multiplier, tick_size, side) -tuple,vector> make_securities(const vector>& leg_descr) { +tuple, vector> make_securities( + const vector> &leg_descr) { vector legs; auto synthetic = make_shared(); uint32_t security_key = 100; - for (const auto& ldesc : leg_descr) { + for (const auto &ldesc : leg_descr) { double quantity, mult, tick_size; api::Side side; std::tie(quantity, mult, tick_size, side) = ldesc; @@ -101,13 +119,15 @@ tuple,vector> make_securities(c instr.producer().set_key(security_key); ++security_key; - auto& s = synthetic->security; - // Set the synthetic tick size equal to the (last) leg. (needs to not be 0) + auto &s = synthetic->security; + // Set the synthetic tick size equal to the (last) leg. (needs to not be + // 0) s.mutable_contract_spec()->set_low_tick(tick_size); s.mutable_contract_spec()->set_high_tick(tick_size); - auto* ps = s.mutable_synthetic(); + auto *ps = s.mutable_synthetic(); auto l = ps->mutable_legs()->Add(); - l->mutable_security()->CopyFrom(instr.consumer().get_normalized_security()); + l->mutable_security()->CopyFrom( + instr.consumer().get_normalized_security()); l->mutable_security()->mutable_contract_spec()->set_low_tick(tick_size); l->mutable_security()->mutable_contract_spec()->set_high_tick(tick_size); l->set_quantity(quantity); @@ -117,37 +137,39 @@ tuple,vector> make_securities(c legs.push_back(instr); } - return { synthetic, legs }; + return {synthetic, legs}; } // tuple = (quantity, tick_size, side) -tuple,vector> make_securities(const vector>& leg_descr) { - std::vector> legs; - for (const auto& t : leg_descr) { +tuple, vector> +make_securities(const vector> &leg_descr) { + std::vector> legs; + for (const auto &t : leg_descr) { double quantity, tick_size; api::Side side; std::tie(quantity, tick_size, side) = t; double mult = quantity * (side == api::SIDE_BUY ? 1.0 : -1); - legs.push_back({ quantity, mult, tick_size, side }); + legs.push_back({quantity, mult, tick_size, side}); } return make_securities(legs); } - -void set_leg_params(SyntheticStrategy& strat, uint32_t security_key, const spark::LegSpreaderParams& params) { +void set_leg_params( + SyntheticStrategy &strat, uint32_t security_key, + const spark::LegSpreaderParams ¶ms) { if (!strat.strategy) { strat.strategy = std::make_unique(); } - auto* map = strat.strategy->mutable_leg_params_map(); - map->insert({ security_key, params }); + auto *map = strat.strategy->mutable_leg_params_map(); + map->insert({security_key, params}); } - -Book compute_synthetic_book(const api::Security& security, const std::vector& leg_books) { +Book compute_synthetic_book( + const api::Security &security, const std::vector &leg_books) { auto synthetic = std::make_shared(); synthetic->security.CopyFrom(security); vector leg_instruments; - for (const auto& leg : synthetic->security.synthetic().legs()) { - const auto& security = leg.security(); + for (const auto &leg : synthetic->security.synthetic().legs()) { + const auto &security = leg.security(); Co2TestInstrument instr(security.symbol(), securitytype_of(security)); convert_security(security, instr.cold().security, true); leg_instruments.push_back(instr); @@ -156,33 +178,34 @@ Book compute_synthetic_book(const api::Security& security, const std::vector bids = {}, asks = {}; + std::array bids = {}, asks = {}; std::transform( - leg_books[x].bids.begin(), - leg_books[x].bids.end(), - bids.begin(), - [](const PS& ps) { - return PriceSize_from_double<7>(ps.price, ps.size); - }); + leg_books[x].bids.begin(), leg_books[x].bids.end(), bids.begin(), + [](const PS &ps) { + return PriceSize_from_double<7>(ps.price, ps.size); + }); std::transform( - leg_books[x].asks.begin(), - leg_books[x].asks.end(), - asks.begin(), - [](const PS& ps) { - return PriceSize_from_double<7>(ps.price, ps.size); - }); + leg_books[x].asks.begin(), leg_books[x].asks.end(), asks.begin(), + [](const PS &ps) { + return PriceSize_from_double<7>(ps.price, ps.size); + }); auto ts = TimeStamp::now(); leg_instruments[x].producer().update_direct(ts, bids, asks); } // Read synthetic book back - MDConsumerHandle synthetic_handle { synthetic }; - std::array raw_bids, raw_asks; + MDConsumerHandle synthetic_handle{synthetic}; + std::array raw_bids, raw_asks; TimeStamp t; - synthetic_handle.get_direct_book(t, COCONUT_MAX_DEPTH, raw_bids.data(), raw_asks.data()); - Book result {}; - sane::map(raw_bids, result.bids, [](PriceSize ps) -> PS { return {ps.price(), ps.size()}; }); - sane::map(raw_asks, result.asks, [](PriceSize ps) -> PS { return {ps.price(), ps.size()}; }); + synthetic_handle.get_direct_book( + t, COCONUT_MAX_DEPTH, raw_bids.data(), raw_asks.data()); + Book result{}; + sane::map(raw_bids, result.bids, [](PriceSize ps) -> PS { + return {ps.price(), ps.size()}; + }); + sane::map(raw_asks, result.asks, [](PriceSize ps) -> PS { + return {ps.price(), ps.size()}; + }); return result; } @@ -194,109 +217,189 @@ Book compute_synthetic_book(const api::Security& security, const std::vector synthetic; vector test_instr; - tie(synthetic, test_instr) = make_securities({ {1.0, 0.25, api::SIDE_BUY}, {1.0, 0.25, api::SIDE_SELL }}); + tie(synthetic, test_instr) = make_securities( + {{1.0, 0.25, api::SIDE_BUY}, {1.0, 0.25, api::SIDE_SELL}}); auto es_buy1 = test_instr[0]; auto es_sell1 = test_instr[1]; MDConsumerHandle synthetic_handle{synthetic}; // Simplest case SECTION("Simple") { - setup_market(es_buy1.producer(), {{2000.0, 10}, {1999.75, 5}, {1999.5,7}}, {{2000.25, 15}, {2000.5, 5}, {2001.0,10}}); - setup_market(es_sell1.producer(), {{2003.0, 5}, {2002.75, 15}, {2002.5,12}}, {{2003.25, 12}, {2003.5, 3}, {2003.75,5}}); + setup_market( + es_buy1.producer(), {{2000.0, 10}, {1999.75, 5}, {1999.5, 7}}, + {{2000.25, 15}, {2000.5, 5}, {2001.0, 10}}); + setup_market( + es_sell1.producer(), {{2003.0, 5}, {2002.75, 15}, {2002.5, 12}}, + {{2003.25, 12}, {2003.5, 3}, {2003.75, 5}}); // Sanity test - expect_market(es_buy1.consumer(), {{2000.0, 10}, {1999.75, 5}, {1999.5,7}}, {{2000.25, 15}, {2000.5, 5}, {2001.0,10}}); - expect_market(es_sell1.consumer(), {{2003.0, 5}, {2002.75, 15}, {2002.5,12}}, {{2003.25, 12}, {2003.5, 3}, {2003.75,5}}); + expect_market( + es_buy1.consumer(), {{2000.0, 10}, {1999.75, 5}, {1999.5, 7}}, + {{2000.25, 15}, {2000.5, 5}, {2001.0, 10}}); + expect_market( + es_sell1.consumer(), {{2003.0, 5}, {2002.75, 15}, {2002.5, 12}}, + {{2003.25, 12}, {2003.5, 3}, {2003.75, 5}}); // Real test - expect_market(synthetic_handle, {{-3.25,10}, {-3.5, 2}, {-3.75,3}, {-4.25,5}}, {{-2.75,5},{-2.5,10},{-2.25,5},{-1.5,10}}); + expect_market( + synthetic_handle, {{-3.25, 10}, {-3.5, 2}, {-3.75, 3}, {-4.25, 5}}, + {{-2.75, 5}, {-2.5, 10}, {-2.25, 5}, {-1.5, 10}}); } SECTION("Full Depth") { // make sure we don't off-by-1 the end of the array - setup_market(es_buy1.producer(), {{90,10}, {89, 5}, {88,5}, {87,5}, {86,5}, {85,5}, {84,5}, {83,5}, {82,5}, {81,10}}, - {{100,10}, {101, 5}, {102,5}, {103,5}, {104,5}, {105,5}, {106,5}, {107,5}, {108,5}, {109,10}}); - setup_market(es_sell1.producer(),{{90,10}, {89, 5}, {88,5}, {87,5}, {86,5}, {85,5}, {84,5}, {83,5}, {82,5}, {81,10}}, - {{100,10}, {101, 5}, {102,5}, {103,5}, {104,5}, {105,5}, {106,5}, {107,5}, {108,5}, {109,10}}); - expect_market(synthetic_handle, {{-10,10}, {-12, 5}, {-14,5}, {-16,5}, {-18,5}, {-20,5}, {-22,5}, {-24,5}, {-26,5}, {-28,10}}, - {{10,10}, {12, 5}, {14,5}, {16,5}, {18,5}, {20,5}, {22,5}, {24,5}, {26,5}, {28,10}}); - } - - // test empty markets - SECTION("Empty market") { - setup_market(es_buy1.producer(), {}, {{2000.25, 15}, {2000.5, 5}, {2001.0,10}}); - setup_market(es_sell1.producer(), {}, {{2003.25, 12}, {2003.5, 3}, {2003.75,5}}); - expect_market(synthetic_handle, {}, {}); + setup_market( + es_buy1.producer(), + {{90, 10}, + {89, 5}, + {88, 5}, + {87, 5}, + {86, 5}, + {85, 5}, + {84, 5}, + {83, 5}, + {82, 5}, + {81, 10}}, + {{100, 10}, + {101, 5}, + {102, 5}, + {103, 5}, + {104, 5}, + {105, 5}, + {106, 5}, + {107, 5}, + {108, 5}, + {109, 10}}); + setup_market( + es_sell1.producer(), + {{90, 10}, + {89, 5}, + {88, 5}, + {87, 5}, + {86, 5}, + {85, 5}, + {84, 5}, + {83, 5}, + {82, 5}, + {81, 10}}, + {{100, 10}, + {101, 5}, + {102, 5}, + {103, 5}, + {104, 5}, + {105, 5}, + {106, 5}, + {107, 5}, + {108, 5}, + {109, 10}}); + expect_market( + synthetic_handle, + {{-10, 10}, + {-12, 5}, + {-14, 5}, + {-16, 5}, + {-18, 5}, + {-20, 5}, + {-22, 5}, + {-24, 5}, + {-26, 5}, + {-28, 10}}, + {{10, 10}, + {12, 5}, + {14, 5}, + {16, 5}, + {18, 5}, + {20, 5}, + {22, 5}, + {24, 5}, + {26, 5}, + {28, 10}}); } + // test empty markets + SECTION("Empty market") { + setup_market( + es_buy1.producer(), {}, {{2000.25, 15}, {2000.5, 5}, {2001.0, 10}}); + setup_market( + es_sell1.producer(), {}, {{2003.25, 12}, {2003.5, 3}, {2003.75, 5}}); + expect_market(synthetic_handle, {}, {}); + } } TEST_CASE("SyntheticBook+1-2", "[md][synthetic]") { shared_ptr synthetic; vector test_instr; - tie(synthetic, test_instr) = make_securities({ {1.0, 0.01, api::SIDE_BUY}, {2.0, 0.01, api::SIDE_SELL }}); + tie(synthetic, test_instr) = make_securities( + {{1.0, 0.01, api::SIDE_BUY}, {2.0, 0.01, api::SIDE_SELL}}); auto es_buy1 = test_instr[0]; auto es_sell2 = test_instr[1]; MDConsumerHandle synthetic_handle{synthetic}; // Test available size=fraction of leg quantity SECTION("buy 1 sell 2") { - setup_market(es_buy1.producer(), - {{190,1}, {180,11}, {170,4}, {160,10}}, - {{200,2}, {210,6}, {220,8}, {230,12}}); - setup_market(es_sell2.producer(), - {{90,5}, {80,9}, {70,11}, {60,10}, {50,1}}, - {{100,16}, {110,8}, {120,12}, {130,5}}); - expect_market(synthetic_handle, - {{-10,1}, {-20,7}, {-40,4}, {-70,4}, {-80,2}, {-100,2}}, - {{20,2}, {50,5}, {70,1}, {80,4}, {100,4}, {110,1}, {130,1}}); - //precise {{20,2}, {40,1}, {50,4}, {70,1}, {80,4}, {90,1}, {100,3}, {110,1}, {120,1}}); + setup_market( + es_buy1.producer(), {{190, 1}, {180, 11}, {170, 4}, {160, 10}}, + {{200, 2}, {210, 6}, {220, 8}, {230, 12}}); + setup_market( + es_sell2.producer(), {{90, 5}, {80, 9}, {70, 11}, {60, 10}, {50, 1}}, + {{100, 16}, {110, 8}, {120, 12}, {130, 5}}); + expect_market( + synthetic_handle, + {{-10, 1}, {-20, 7}, {-40, 4}, {-70, 4}, {-80, 2}, {-100, 2}}, + {{20, 2}, {50, 5}, {70, 1}, {80, 4}, {100, 4}, {110, 1}, {130, 1}}); + // precise {{20,2}, {40,1}, {50,4}, {70,1}, {80,4}, {90,1}, {100,3}, + // {110,1}, {120,1}}); } } TEST_CASE("SyntheticBook+2-2", "[md][synthetic]") { shared_ptr synthetic; vector test_instr; - tie(synthetic, test_instr) = make_securities({ {2.0, 0.25, api::SIDE_BUY}, {2.0, 0.25, api::SIDE_SELL }}); + tie(synthetic, test_instr) = make_securities( + {{2.0, 0.25, api::SIDE_BUY}, {2.0, 0.25, api::SIDE_SELL}}); auto es_buy2 = test_instr[0]; auto es_sell2 = test_instr[1]; MDConsumerHandle synthetic_handle{synthetic}; - setup_market(es_buy2.producer(), - {{2000.0, 10}, {1999.75, 5}, {1999.5,7}}, - {{2000.25, 15}, {2000.5, 5}, {2001.0,10}}); - setup_market(es_sell2.producer(), - {{2003.0, 5}, {2002.75, 15}, {2002.5,12}}, - {{2003.25, 12}, {2003.5, 3}, {2003.75,5}}); + setup_market( + es_buy2.producer(), {{2000.0, 10}, {1999.75, 5}, {1999.5, 7}}, + {{2000.25, 15}, {2000.5, 5}, {2001.0, 10}}); + setup_market( + es_sell2.producer(), {{2003.0, 5}, {2002.75, 15}, {2002.5, 12}}, + {{2003.25, 12}, {2003.5, 3}, {2003.75, 5}}); - expect_market(synthetic_handle, - {{-6.5,5}, {-7.0,1}, {-7.5,1}, {-8.5,3}}, - //precise {{-6.5,5}, {-7.0,1}, {-7.5,1}, {-8.0,1}, {-8.5,2}}, - {{-5.50,2}, {-5.00,5}, {-4.5,3}, {-3.00,5}}); - //precise {{-5.50,2}, {-5.25,1}, {-5.00,4}, {-4.75,1}, {-4.5,2}, {-3.00,5}}); + expect_market( + synthetic_handle, {{-6.5, 5}, {-7.0, 1}, {-7.5, 1}, {-8.5, 3}}, + // precise {{-6.5,5}, {-7.0,1}, {-7.5,1}, {-8.0,1}, {-8.5,2}}, + {{-5.50, 2}, {-5.00, 5}, {-4.5, 3}, {-3.00, 5}}); + // precise {{-5.50,2}, {-5.25,1}, {-5.00,4}, {-4.75,1}, {-4.5,2}, + // {-3.00,5}}); } - TEST_CASE("Synthetic3Legs", "[md][synthetic]") { shared_ptr synthetic; vector test_instr; - tie(synthetic, test_instr) = make_securities({ {1.0, 0.1, api::SIDE_BUY}, {1.0, 0.1, api::SIDE_SELL }, { 1.0, 0.1, api::SIDE_BUY}}); + tie(synthetic, test_instr) = make_securities( + {{1.0, 0.1, api::SIDE_BUY}, + {1.0, 0.1, api::SIDE_SELL}, + {1.0, 0.1, api::SIDE_BUY}}); auto leg1_buy = test_instr[0]; auto leg2_sell = test_instr[1]; auto leg3_buy = test_instr[2]; MDConsumerHandle synthetic_handle(synthetic); SECTION("Simple") { - setup_market(leg1_buy.producer(), - {{1000,2},{1001,11},{1002,4}}, - {{999,8}, {998,15}, {997,3}}); - setup_market(leg2_sell.producer(), - {{2000,9}, {2010,5}, {2020,4} }, - {{1990,3}, {1980,7}, {1970,13} }); - setup_market(leg3_buy.producer(), - {{200,2}, {201,3}, {202,16} }, - {{199,10}, {198,11}, {197,10} }); - expect_market(synthetic_handle, - {{-790,2}, {-788,1}, {-778,2}, {-777,5}, {-767,3}, {-766,4}}, - {{-802,8}, {-803,1}, {-813,1}, {-814,4}, {-824,4}}); + setup_market( + leg1_buy.producer(), {{1000, 2}, {1001, 11}, {1002, 4}}, + {{999, 8}, {998, 15}, {997, 3}}); + setup_market( + leg2_sell.producer(), {{2000, 9}, {2010, 5}, {2020, 4}}, + {{1990, 3}, {1980, 7}, {1970, 13}}); + setup_market( + leg3_buy.producer(), {{200, 2}, {201, 3}, {202, 16}}, + {{199, 10}, {198, 11}, {197, 10}}); + expect_market( + synthetic_handle, + {{-790, 2}, {-788, 1}, {-778, 2}, {-777, 5}, {-767, 3}, {-766, 4}}, + {{-802, 8}, {-803, 1}, {-813, 1}, {-814, 4}, {-824, 4}}); } } @@ -304,46 +407,50 @@ TEST_CASE("AllBlank", "[md][synthetic]") { shared_ptr synthetic; vector test_instr; - tie(synthetic, test_instr) = make_securities({ {1.0, 0.1, api::SIDE_BUY}, {1.0, 0.1, api::SIDE_SELL }, { 1.0, 0.1, api::SIDE_BUY}}); + tie(synthetic, test_instr) = make_securities( + {{1.0, 0.1, api::SIDE_BUY}, + {1.0, 0.1, api::SIDE_SELL}, + {1.0, 0.1, api::SIDE_BUY}}); auto leg1 = test_instr[0]; auto leg2 = test_instr[1]; MDConsumerHandle synthetic_handle(synthetic); - setup_market(leg1.producer(), - {}, - {}); - setup_market(leg2.producer(), - {}, - {}); - expect_market(synthetic_handle, - {}, - {}); - + setup_market(leg1.producer(), {}, {}); + setup_market(leg2.producer(), {}, {}); + expect_market(synthetic_handle, {}, {}); } TEST_CASE("SPARK-955", "[md][synthetic]") { shared_ptr synthetic; vector test_instr; - tie(synthetic, test_instr) = make_securities({ {1.0, 0.25, api::SIDE_BUY}, {2.0, 0.25, api::SIDE_SELL }, { 1.0, 0.25, api::SIDE_BUY}}); + tie(synthetic, test_instr) = make_securities( + {{1.0, 0.25, api::SIDE_BUY}, + {2.0, 0.25, api::SIDE_SELL}, + {1.0, 0.25, api::SIDE_BUY}}); auto esm8 = test_instr[0]; auto esu8 = test_instr[1]; auto esz8 = test_instr[2]; MDConsumerHandle synthetic_handle(synthetic); - setup_market(esm8.producer(), - {{2594.50, 47}, {2594.25,63}, {2594.00,117}, {2593.75,137}}, - {{2594.75, 52}, {2595.00,138}, {2594.25,119}, {2595.50,128}}); - setup_market(esu8.producer(), - {{2598.50, 14}, {2598.25, 15}, {2598.00,16}, {2597.75, 15}}, - {{2599.75, 1}, {2600.00, 16}, {2600.25,15}, {2600.50, 75}}); - setup_market(esz8.producer(), - {{2601.25, 2}, {2600.50, 3}, {2600.25, 10}}, - {{2607.25, 3}, {2607.50, 1}, {2608.25, 9}}); - expect_market(synthetic_handle, - // If we do strict price this is right. If we're pessimistic we get {-4.25,2} - { {-4.25, 2}, { -5.00, 3}, {-5.25, 3}, {-5.75, 7} }, - //precise { {-4.00, 1}, {-4.25, 1}, { -5.00, 3}, {-5.25, 3}, {-5.50,1}, {-5.75, 6} }, - { {5.00, 3}, {5.25, 1}, {6.00,3}, {6.50,6} }); + setup_market( + esm8.producer(), + {{2594.50, 47}, {2594.25, 63}, {2594.00, 117}, {2593.75, 137}}, + {{2594.75, 52}, {2595.00, 138}, {2594.25, 119}, {2595.50, 128}}); + setup_market( + esu8.producer(), + {{2598.50, 14}, {2598.25, 15}, {2598.00, 16}, {2597.75, 15}}, + {{2599.75, 1}, {2600.00, 16}, {2600.25, 15}, {2600.50, 75}}); + setup_market( + esz8.producer(), {{2601.25, 2}, {2600.50, 3}, {2600.25, 10}}, + {{2607.25, 3}, {2607.50, 1}, {2608.25, 9}}); + expect_market( + synthetic_handle, + // If we do strict price this is right. If we're pessimistic we get + // {-4.25,2} + {{-4.25, 2}, {-5.00, 3}, {-5.25, 3}, {-5.75, 7}}, + // precise { {-4.00, 1}, {-4.25, 1}, { -5.00, 3}, {-5.25, 3}, {-5.50,1}, + // {-5.75, 6} }, + {{5.00, 3}, {5.25, 1}, {6.00, 3}, {6.50, 6}}); } TEST_CASE("SPARK-954", "[md][synthetic]") { @@ -351,274 +458,354 @@ TEST_CASE("SPARK-954", "[md][synthetic]") { vector test_instr; SECTION("price multiplier = 0.9,1.1") { - tie(synthetic, test_instr) = make_securities({ {0.9, 0.25, api::SIDE_BUY}, {1.1, 0.25, api::SIDE_SELL } }); + tie(synthetic, test_instr) = make_securities( + {{0.9, 0.25, api::SIDE_BUY}, {1.1, 0.25, api::SIDE_SELL}}); auto leg1 = test_instr[0]; auto leg2 = test_instr[1]; MDConsumerHandle synthetic_handle(synthetic); - setup_market(leg1.producer(), - { {2796.75,22}, {2796.50,38}, {2796.25,57}, {2796.00,59}, {2795.75,60}, {2795.50,67}, {2795.25,68}, {2795.00,84}, {2794.75,115}, {2794.50,98}, }, - { {2797.00,158}, {2797.25,110}, {2797.50,83}, {2797.75,168}, {2798.00,130}, {2798.25,180}, {2798.50,75}, {2798.75,89}, {2799.00,123}, {2799.25,193}, }); - setup_market(leg2.producer(), - { {2800.50,1}, {2800.25,6}, {2800.00,8}, {2799.75,14}, {2799.50,15}, {2799.25,14}, {2799.00,44}, {2798.75,13}, {2798.50,18}, {2798.25,14}, }, - { {2801.00,1}, {2801.25,4}, {2801.50,16}, {2801.75,15}, {2802.00,16}, {2802.25,15}, {2802.50,45}, {2802.75,13}, {2803.00,14}, {2803.25,14}, }); - expect_market(synthetic_handle, - { {-564.50,4}, {-564.75,15}, {-565.00,5}, {-565.25,8}, {-565.50,15}, {-565.75,13}, {-566.00,6}, {-566.25,35}, {-566.50,12}, {-566.75,13}, }, - { {-562.75,6}, {-562.50,7}, {-562.25,13}, {-562.00,13}, {-561.75,13}, {-561.50,40}, {-561.25,12}, {-561.00,16}, {-560.75,13}, }); - + setup_market( + leg1.producer(), + { + {2796.75, 22}, + {2796.50, 38}, + {2796.25, 57}, + {2796.00, 59}, + {2795.75, 60}, + {2795.50, 67}, + {2795.25, 68}, + {2795.00, 84}, + {2794.75, 115}, + {2794.50, 98}, + }, + { + {2797.00, 158}, + {2797.25, 110}, + {2797.50, 83}, + {2797.75, 168}, + {2798.00, 130}, + {2798.25, 180}, + {2798.50, 75}, + {2798.75, 89}, + {2799.00, 123}, + {2799.25, 193}, + }); + setup_market( + leg2.producer(), + { + {2800.50, 1}, + {2800.25, 6}, + {2800.00, 8}, + {2799.75, 14}, + {2799.50, 15}, + {2799.25, 14}, + {2799.00, 44}, + {2798.75, 13}, + {2798.50, 18}, + {2798.25, 14}, + }, + { + {2801.00, 1}, + {2801.25, 4}, + {2801.50, 16}, + {2801.75, 15}, + {2802.00, 16}, + {2802.25, 15}, + {2802.50, 45}, + {2802.75, 13}, + {2803.00, 14}, + {2803.25, 14}, + }); + expect_market( + synthetic_handle, + { + {-564.50, 4}, + {-564.75, 15}, + {-565.00, 5}, + {-565.25, 8}, + {-565.50, 15}, + {-565.75, 13}, + {-566.00, 6}, + {-566.25, 35}, + {-566.50, 12}, + {-566.75, 13}, + }, + { + {-562.75, 6}, + {-562.50, 7}, + {-562.25, 13}, + {-562.00, 13}, + {-561.75, 13}, + {-561.50, 40}, + {-561.25, 12}, + {-561.00, 16}, + {-560.75, 13}, + }); } - + SECTION("price multiplier = 1.0,-1.3") { - tie(synthetic, test_instr) = make_securities({ {1.0, 0.005, api::SIDE_BUY}, {1.3, 0.005, api::SIDE_SELL } }); + tie(synthetic, test_instr) = make_securities( + {{1.0, 0.005, api::SIDE_BUY}, {1.3, 0.005, api::SIDE_SELL}}); auto leg1 = test_instr[0]; auto leg2 = test_instr[1]; MDConsumerHandle synthetic_handle(synthetic); - setup_market(leg1.producer(), - { { 14.185, 1 }, { 14.180, 7 } }, - { { 14.205, 1 }, { 14.210, 5 } }); - setup_market(leg2.producer(), - { { 14.255, 10 }, { 14.250, 42 }, { 14.230, 1 }, { 14.220, 1 }, { 14.215, 1 }, { 14.210, 3 }, { 14.205, 1 }, { 14.200, 2 } }, - { { 14.265, 18 }, { 14.270, 19 } }); - expect_market(synthetic_handle, - { { -4.360, 1 }, { -4.365, 7 } }, - { { -4.325, 1 }, { -4.320, 5 } }); + setup_market( + leg1.producer(), {{14.185, 1}, {14.180, 7}}, + {{14.205, 1}, {14.210, 5}}); + setup_market( + leg2.producer(), + {{14.255, 10}, + {14.250, 42}, + {14.230, 1}, + {14.220, 1}, + {14.215, 1}, + {14.210, 3}, + {14.205, 1}, + {14.200, 2}}, + {{14.265, 18}, {14.270, 19}}); + expect_market( + synthetic_handle, {{-4.360, 1}, {-4.365, 7}}, + {{-4.325, 1}, {-4.320, 5}}); } - } TEST_CASE("AggregationAcrossLevels", "[md][synthetic]") { shared_ptr synthetic; vector test_instr; SECTION("buy 1 sell 3") { - tie(synthetic, test_instr) = make_securities({ {1.0, 0.005, api::SIDE_BUY}, {3, 0.005, api::SIDE_SELL } }); + tie(synthetic, test_instr) = make_securities( + {{1.0, 0.005, api::SIDE_BUY}, {3, 0.005, api::SIDE_SELL}}); auto leg1 = test_instr[0]; auto leg2 = test_instr[1]; MDConsumerHandle synthetic_handle(synthetic); - setup_market(leg1.producer(), - { {16.215, 6} }, - { {16.220, 5} } - ); - setup_market(leg2.producer(), - { {16.500, 2 }, { 16.495, 2 } }, - { {16.505, 1 }, { 16.510, 1 }, { 16.515, 1 }, {16.520,1}, {16.525,1}, {16.530,1}} - ); - expect_market(synthetic_handle, - { {-33.330,1}, {-33.375, 1} }, - { { -33.265,1} } - ); + setup_market(leg1.producer(), {{16.215, 6}}, {{16.220, 5}}); + setup_market( + leg2.producer(), {{16.500, 2}, {16.495, 2}}, + {{16.505, 1}, + {16.510, 1}, + {16.515, 1}, + {16.520, 1}, + {16.525, 1}, + {16.530, 1}}); + expect_market( + synthetic_handle, {{-33.330, 1}, {-33.375, 1}}, {{-33.265, 1}}); } SECTION("buy 1 sell 4") { - tie(synthetic, test_instr) = make_securities({ {1.0, 0.005, api::SIDE_BUY}, {4, 0.005, api::SIDE_SELL } }); + tie(synthetic, test_instr) = make_securities( + {{1.0, 0.005, api::SIDE_BUY}, {4, 0.005, api::SIDE_SELL}}); auto leg1 = test_instr[0]; auto leg2 = test_instr[1]; MDConsumerHandle synthetic_handle(synthetic); - setup_market(leg1.producer(), - { {16.215, 6} }, - { {16.220, 5} } - ); - setup_market(leg2.producer(), - { {16.500, 2 }, { 16.495, 2 } }, - { {16.505, 1 }, { 16.510, 1 }, { 16.515, 1 }, {16.520,1}, {16.525,1}, {16.530,1}, {16.535,2}} - ); - expect_market(synthetic_handle, - { { -49.865,1}, {-49.925,1} }, - { { -49.760,1} } - ); + setup_market(leg1.producer(), {{16.215, 6}}, {{16.220, 5}}); + setup_market( + leg2.producer(), {{16.500, 2}, {16.495, 2}}, + {{16.505, 1}, + {16.510, 1}, + {16.515, 1}, + {16.520, 1}, + {16.525, 1}, + {16.530, 1}, + {16.535, 2}}); + expect_market( + synthetic_handle, {{-49.865, 1}, {-49.925, 1}}, {{-49.760, 1}}); } } TEST_CASE("Synthetic_net_change", "[md][synthetic]") { shared_ptr synthetic; vector test_instr; - // This tick size is what you get when you make up a test and then later have to figure out the tick size because NetChange suddenly depends on tick size - tie(synthetic, test_instr) = make_securities({ {1.0, 10.0, api::SIDE_BUY}, {2.0, 10.0, api::SIDE_SELL }}); + // This tick size is what you get when you make up a test and then later have + // to figure out the tick size because NetChange suddenly depends on tick + // size + tie(synthetic, test_instr) = make_securities( + {{1.0, 10.0, api::SIDE_BUY}, {2.0, 10.0, api::SIDE_SELL}}); // Set to tick in "# ticks" synthetic->security.mutable_contract_spec()->set_low_tick(1.0); synthetic->security.mutable_contract_spec()->set_high_tick(1.0); - synthetic->security.mutable_synthetic()->set_price_calc(api::SyntheticContract::PRICECALC_NET_CHANGE); + synthetic->security.mutable_synthetic()->set_price_calc( + api::SyntheticContract::PRICECALC_NET_CHANGE); auto es_buy1 = test_instr[0]; auto es_sell2 = test_instr[1]; MDConsumerHandle synthetic_handle{synthetic}; // set settlement prices - es_buy1.producer().update_settlement(TimeStamp::now(), { 100, 0 }, datetime::today()); - es_sell2.producer().update_settlement(TimeStamp::now(), { 50, 0 }, datetime::today()); + es_buy1.producer().update_settlement( + TimeStamp::now(), {100, 0}, datetime::today()); + es_sell2.producer().update_settlement( + TimeStamp::now(), {50, 0}, datetime::today()); SECTION("buy 1 sell 2 Net") { - setup_market(es_buy1.producer(), - {{190,1}, {180,11}, {170,4}, {160,10}}, - {{200,2}, {210,6}, {220,8}, {230,12}}); - setup_market(es_sell2.producer(), - {{90,5}, {80,9}, {70,11}, {60,10}, {50,1}}, - {{100,16}, {110,8}, {120,12}, {130,5}}); + setup_market( + es_buy1.producer(), {{190, 1}, {180, 11}, {170, 4}, {160, 10}}, + {{200, 2}, {210, 6}, {220, 8}, {230, 12}}); + setup_market( + es_sell2.producer(), {{90, 5}, {80, 9}, {70, 11}, {60, 10}, {50, 1}}, + {{100, 16}, {110, 8}, {120, 12}, {130, 5}}); - expect_market(synthetic_handle, - {{-1,1}, {-2,7}, {-4,4}, {-7,4}, {-8,2}, {-10,2}}, - {{2,2}, {5,5}, {7,1}, {8,4}, {10,4}, {11,1}, {13,1}}); + expect_market( + synthetic_handle, + {{-1, 1}, {-2, 7}, {-4, 4}, {-7, 4}, {-8, 2}, {-10, 2}}, + {{2, 2}, {5, 5}, {7, 1}, {8, 4}, {10, 4}, {11, 1}, {13, 1}}); } } TEST_CASE("HCL_SP_104", "[md][synthetic]") { shared_ptr synthetic; vector test_instr; - tie(synthetic, test_instr) = make_securities({ - // (quantity, multiplier, tick_size, side) - {1.0, 1.0, 0.01, api::SIDE_BUY}, - {1.0, 1.0, 0.01, api::SIDE_BUY}, - {1.0, -1.0, 0.01, api::SIDE_SELL}, - {1.0, -1.0, 0.01, api::SIDE_SELL } - }); + tie(synthetic, test_instr) = + make_securities({// (quantity, multiplier, tick_size, side) + {1.0, 1.0, 0.01, api::SIDE_BUY}, + {1.0, 1.0, 0.01, api::SIDE_BUY}, + {1.0, -1.0, 0.01, api::SIDE_SELL}, + {1.0, -1.0, 0.01, api::SIDE_SELL}}); auto leg1 = test_instr[0]; // CLQ9-CLU9 auto leg2 = test_instr[1]; // HCLQ9-CLQ9 auto leg3 = test_instr[2]; // HCLQ9-HCLU9 auto leg4 = test_instr[3]; // HCLU9-CLU9 - setup_market(leg1.producer(), - { - { -0.10, 3299 }, - { -0.11, 2885 }, - { -0.12, 2558 }, - { -0.13, 2447 }, - { -0.14, 1540 }, - { -0.15, 2334 }, - { -0.16, 1396 }, - { -0.17, 1190 }, - { -0.18, 1221 }, - { -0.19, 812 } - }, - { - { -0.09, 1318 }, - { -0.08, 2174 }, - { -0.07, 3057 }, - { -0.06, 2331 }, - { -0.05, 2543 }, - { -0.04, 2638 }, - { -0.03, 2232 }, - { -0.02, 3221 }, - { -0.01, 2863 }, - { 0.00, 3327 } - }); - - setup_market(leg2.producer(), - { - { 4.06, 1 }, - { 4.05, 2 }, - { 4.04, 3 }, - { 4.03, 12 }, - { 4.02, 6 }, - { 4.01, 1 } - }, - { - { 4.07, 1 }, - { 4.08, 2 }, - { 4.10, 8 }, - { 4.11, 10 }, - { 4.12, 2 }, - { 4.14, 1 } - }); - - setup_market(leg3.producer(), - { - { 0.20, 2 }, - { 0.19, 6 }, - { 0.18, 5 }, - { 0.17, 18 }, - { 0.16, 2 }, - { 0.15, 3 }, - { 0.14, 2 } - }, - { - { 0.22, 2 }, - { 0.23, 4 }, - { 0.24, 9 }, - { 0.25, 17}, - { 0.26, 5 }, - { 0.27, 5 }, - { 0.28, 4 }, - { 0.29, 2 }, - { 0.30, 2 } - }); + setup_market( + leg1.producer(), + {{-0.10, 3299}, + {-0.11, 2885}, + {-0.12, 2558}, + {-0.13, 2447}, + {-0.14, 1540}, + {-0.15, 2334}, + {-0.16, 1396}, + {-0.17, 1190}, + {-0.18, 1221}, + {-0.19, 812}}, + {{-0.09, 1318}, + {-0.08, 2174}, + {-0.07, 3057}, + {-0.06, 2331}, + {-0.05, 2543}, + {-0.04, 2638}, + {-0.03, 2232}, + {-0.02, 3221}, + {-0.01, 2863}, + {0.00, 3327}}); - setup_market(leg4.producer(), - { - { 3.75, 1 }, - { 3.74, 3 }, - { 3.73, 4 }, - { 3.72, 12 }, - { 3.71, 1 }, - { 3.70, 3 } - }, - { - { 3.78, 1 }, - { 3.79, 2 }, - { 3.80, 6 }, - { 3.81, 1 }, - { 3.82, 10 }, - { 3.83, 1 } - }); + setup_market( + leg2.producer(), + {{4.06, 1}, {4.05, 2}, {4.04, 3}, {4.03, 12}, {4.02, 6}, {4.01, 1}}, + {{4.07, 1}, {4.08, 2}, {4.10, 8}, {4.11, 10}, {4.12, 2}, {4.14, 1}}); - MDConsumerHandle synthetic_handle(synthetic); - // dump_market(synthetic_handle); - expect_market(synthetic_handle, - { { -0.04,1 },{ -0.06,1 },{ -0.07,1 },{ -0.09,3 },{ -0.11,3 },{ -0.12,1 },{ -0.13,5 },{ -0.14,3 },{ -0.15,2 },{ -0.16,1 } }, - { { 0.03,1 },{ 0.05,1 },{ 0.06,1 },{ 0.08,1 },{ 0.09,4 },{ 0.11,3 },{ 0.12,2 },{ 0.13,7 },{ 0.14,1 },{ 0.16,2 } } - ); + setup_market( + leg3.producer(), + {{0.20, 2}, + {0.19, 6}, + {0.18, 5}, + {0.17, 18}, + {0.16, 2}, + {0.15, 3}, + {0.14, 2}}, + {{0.22, 2}, + {0.23, 4}, + {0.24, 9}, + {0.25, 17}, + {0.26, 5}, + {0.27, 5}, + {0.28, 4}, + {0.29, 2}, + {0.30, 2}}); + + setup_market( + leg4.producer(), + {{3.75, 1}, {3.74, 3}, {3.73, 4}, {3.72, 12}, {3.71, 1}, {3.70, 3}}, + {{3.78, 1}, {3.79, 2}, {3.80, 6}, {3.81, 1}, {3.82, 10}, {3.83, 1}}); + + MDConsumerHandle synthetic_handle(synthetic); + // dump_market(synthetic_handle); + expect_market( + synthetic_handle, + {{-0.04, 1}, + {-0.06, 1}, + {-0.07, 1}, + {-0.09, 3}, + {-0.11, 3}, + {-0.12, 1}, + {-0.13, 5}, + {-0.14, 3}, + {-0.15, 2}, + {-0.16, 1}}, + {{0.03, 1}, + {0.05, 1}, + {0.06, 1}, + {0.08, 1}, + {0.09, 4}, + {0.11, 3}, + {0.12, 2}, + {0.13, 7}, + {0.14, 1}, + {0.16, 2}}); } - // // Benchmarks // #if ENABLE_BENCHMARK -void synthetic_get_book_speed2(benchmark::State& state) { +void synthetic_get_book_speed2(benchmark::State &state) { shared_ptr synthetic; vector test_instr; - tie(synthetic, test_instr) = make_securities({ {1.0, 0.25, api::SIDE_BUY}, {2.0, 0.25, api::SIDE_SELL } }); + tie(synthetic, test_instr) = make_securities( + {{1.0, 0.25, api::SIDE_BUY}, {2.0, 0.25, api::SIDE_SELL}}); auto esm8 = test_instr[0]; auto esu8 = test_instr[1]; MDConsumerHandle synthetic_handle(synthetic); - setup_market(esm8.producer(), - {{2594.50, 47}, {2594.25,63}, {2594.00,117}, {2593.75,137}}, - {{2594.75, 52}, {2595.00,138}, {2594.25,119}, {2595.50,128}}); - setup_market(esu8.producer(), - {{2598.50, 14}, {2598.25, 15}, {2598.00,16}, {2597.75, 15}}, - {{2599.75, 1}, {2600.00, 16}, {2600.25,15}, {2600.50, 75}}); + setup_market( + esm8.producer(), + {{2594.50, 47}, {2594.25, 63}, {2594.00, 117}, {2593.75, 137}}, + {{2594.75, 52}, {2595.00, 138}, {2594.25, 119}, {2595.50, 128}}); + setup_market( + esu8.producer(), + {{2598.50, 14}, {2598.25, 15}, {2598.00, 16}, {2597.75, 15}}, + {{2599.75, 1}, {2600.00, 16}, {2600.25, 15}, {2600.50, 75}}); for (auto _ : state) { - array raw_bids,raw_asks; + array raw_bids, raw_asks; TimeStamp t; - synthetic_handle.get_book(t, COCONUT_MAX_DEPTH, raw_bids.data(), raw_asks.data()); + synthetic_handle.get_book( + t, COCONUT_MAX_DEPTH, raw_bids.data(), raw_asks.data()); } } BENCHMARK(synthetic_get_book_speed2); -void synthetic_get_book_speed3(benchmark::State& state) { +void synthetic_get_book_speed3(benchmark::State &state) { shared_ptr synthetic; vector test_instr; - tie(synthetic, test_instr) = make_securities({ {1.0, 0.25, api::SIDE_BUY}, {2.0, 0.25, api::SIDE_SELL }, { 1.0, 0.25, api::SIDE_BUY}}); + tie(synthetic, test_instr) = make_securities( + {{1.0, 0.25, api::SIDE_BUY}, + {2.0, 0.25, api::SIDE_SELL}, + {1.0, 0.25, api::SIDE_BUY}}); auto esm8 = test_instr[0]; auto esu8 = test_instr[1]; auto esz8 = test_instr[2]; MDConsumerHandle synthetic_handle(synthetic); - setup_market(esm8.producer(), - {{2594.50, 47}, {2594.25,63}, {2594.00,117}, {2593.75,137}}, - {{2594.75, 52}, {2595.00,138}, {2594.25,119}, {2595.50,128}}); - setup_market(esu8.producer(), - {{2598.50, 14}, {2598.25, 15}, {2598.00,16}, {2597.75, 15}}, - {{2599.75, 1}, {2600.00, 16}, {2600.25,15}, {2600.50, 75}}); - setup_market(esz8.producer(), - {{2601.25, 20}, {2600.50, 3}, {2600.25, 100}}, - {{2607.25, 3}, {2607.50, 1}, {2608.25, 900}}); + setup_market( + esm8.producer(), + {{2594.50, 47}, {2594.25, 63}, {2594.00, 117}, {2593.75, 137}}, + {{2594.75, 52}, {2595.00, 138}, {2594.25, 119}, {2595.50, 128}}); + setup_market( + esu8.producer(), + {{2598.50, 14}, {2598.25, 15}, {2598.00, 16}, {2597.75, 15}}, + {{2599.75, 1}, {2600.00, 16}, {2600.25, 15}, {2600.50, 75}}); + setup_market( + esz8.producer(), {{2601.25, 20}, {2600.50, 3}, {2600.25, 100}}, + {{2607.25, 3}, {2607.50, 1}, {2608.25, 900}}); for (auto _ : state) { - array raw_bids,raw_asks; + array raw_bids, raw_asks; TimeStamp t; - synthetic_handle.get_book(t, COCONUT_MAX_DEPTH, raw_bids.data(), raw_asks.data()); + synthetic_handle.get_book( + t, COCONUT_MAX_DEPTH, raw_bids.data(), raw_asks.data()); } } BENCHMARK(synthetic_get_book_speed3); #endif -}}}//namespace +} // namespace test +} // namespace md +} // namespace bts #endif diff --git a/src/lib/md/vendor/OnixsUtils.cpp b/src/lib/md/vendor/OnixsUtils.cpp index 8d56d0707..2664fc754 100644 --- a/src/lib/md/vendor/OnixsUtils.cpp +++ b/src/lib/md/vendor/OnixsUtils.cpp @@ -1,43 +1,44 @@ #ifndef WIN32 -#include "OnixsUtils.h" -#include "lib/logging/logging.h" +#include "OnixsUtils.h" #include "lib/config/config.h" #include "lib/config/protos/MarketData.pb.h" +#include "lib/logging/logging.h" -namespace bts { -namespace md { +namespace bts { +namespace md { // The onixs checksum includes the line endings as \r\n // to avoid the possibility of git mangling the line endings we store // an array of lines instead of a single string and restore the lines // when we write it out in MDP3main.cpp -const char * onixs_license[] = { -"", -" production", -" ", -" Blue Trading Systems OF 9420-2", -" ", -" ", -" 2020-05-01", -" 2021-05-12", -" ", -" ", -" ", -" ", -" ", -" ", -" 1C9210495AA3C9C884B7A37A4C7AD8F9", -"" -}; +const char *onixs_license[] = { + "", + " production", + " ", + " Blue Trading Systems OF 9420-2", + " ", + " ", + " 2020-05-01", + " 2021-05-12", + " ", + " ", + " ", + " ", + " ", + " ", + " 1C9210495AA3C9C884B7A37A4C7AD8F9", + ""}; OnixsTemplLicense onixs_create_temporary_license() { - const auto& options = config::get(); + const auto &options = config::get(); OnixsTemplLicense linfo; linfo.path = options.onixs_license(); if (linfo.path == "{default}") { - linfo.path = boost::filesystem::path {os::bts_data_path()} / "licenses"; + linfo.path = boost::filesystem::path{os::bts_data_path()} / "licenses"; auto ident = boost::filesystem::unique_path("%%%%-%%%%-%%%%-%%%%.lic"); - linfo.license = { linfo.path / ident }; + linfo.license = {linfo.path / ident}; } if (linfo.license) { @@ -46,23 +47,27 @@ OnixsTemplLicense onixs_create_temporary_license() { auto temp = linfo.license.value(); std::ofstream out(temp.c_str(), std::ios::out | std::ios::binary); if (out.good()) { - for (const char* line : onixs_license) { - if (line != onixs_license[0]) out << "\r\n"; + for (const char *line : onixs_license) { + if (line != onixs_license[0]) + out << "\r\n"; out << line; } - } - else { - LOG(md,Warn, "Licensing error. Failed to write to '{}'. Please ensure it is writeable.", linfo.path); + } else { + LOG(md, Warn, + "Licensing error. Failed to write to '{}'. Please ensure it is " + "writeable.", + linfo.path); } } return linfo; } -void onixs_destroy_temporary_license(const OnixsTemplLicense& lic) { +void onixs_destroy_temporary_license(const OnixsTemplLicense &lic) { if (lic.license) { boost::system::error_code ignore; boost::filesystem::remove(lic.license.value(), ignore); } } -}} //namespace +} // namespace md +} // namespace bts #endif diff --git a/src/lib/md/vendor/OnixsUtils.h b/src/lib/md/vendor/OnixsUtils.h index 0d46fc357..a760383cf 100644 --- a/src/lib/md/vendor/OnixsUtils.h +++ b/src/lib/md/vendor/OnixsUtils.h @@ -1,9 +1,9 @@ -#pragma once +#pragma once #include "boost/filesystem.hpp" #include "lib/utils/optional.h" -namespace bts { -namespace md { +namespace bts { +namespace md { struct OnixsTemplLicense { boost::filesystem::path path; @@ -11,6 +11,7 @@ struct OnixsTemplLicense { }; OnixsTemplLicense onixs_create_temporary_license(); -void onixs_destroy_temporary_license(const OnixsTemplLicense&); +void onixs_destroy_temporary_license(const OnixsTemplLicense &); -}} //namespace +} // namespace md +} // namespace bts diff --git a/src/lib/mercury/actors/Actor.h b/src/lib/mercury/actors/Actor.h index 61e67cec1..17e520e63 100644 --- a/src/lib/mercury/actors/Actor.h +++ b/src/lib/mercury/actors/Actor.h @@ -3,11 +3,11 @@ #include #include +#include "lib/mercury/actors/ActorBroker.h" #include "lib/mercury/common/mercury_common.h" #include "lib/mercury/events/Stream.h" #include "lib/mercury/events/Update.h" #include "lib/mercury/topics/Topic.h" -#include "lib/mercury/actors/ActorBroker.h" #include "lib/tracing/bts_trace.h" #include "lib/utils/bts_assert.h" @@ -25,7 +25,8 @@ class Actor { public: using SubHandle = LocalSubID; - Actor() : _broker(nullptr), _active_streams(), _active_subs(), _broker_id() {} + Actor() + : _broker(nullptr), _active_streams(), _active_subs(), _broker_id() {} virtual ~Actor() {} // Override this to kick off actor. @@ -37,10 +38,11 @@ class Actor { // Implement if you need special cleanup at actor destruction time virtual void finit(){}; - // Implement this if you want to be called before/after an event is dispatched + // Implement this if you want to be called before/after an event is + // dispatched virtual void before_event() {} virtual void after_event() {} - + // subscribe to events using a specific tag template SubHandle subscribe(typename EV::Tag const &tag, CB const &cb) { @@ -56,21 +58,20 @@ class Actor { auto match = typed_topic->tag() == tag; if (match) LOG(Mercury, Info, "{} on event broker {} matched sub to {}", - name(), _broker_id, - TopicType(tag).to_str()); + name(), _broker_id, TopicType(tag).to_str()); return match; } }; - LocalEventHandler handler = [this, cb, tag](const StreamID &sid, - EventType type, - Notification const *payload) { + LocalEventHandler handler = [this, cb, tag]( + const StreamID &sid, EventType type, + Notification const *payload) { if (!this->_broker) return; - tracepoint(bts_trace, trace_event, utils::type_name(typeid(*this)), - utils::type_name(), _broker_id, sid.value(), - 0); + tracepoint( + bts_trace, trace_event, utils::type_name(typeid(*this)), + utils::type_name(), _broker_id, sid.value(), 0); before_event(); if (payload) cb(UpdateType{sid, type, &(payload->unwrap())}); @@ -99,20 +100,19 @@ class Actor { auto match = typed_topic != nullptr; if (match) LOG(Mercury, Info, "{} on event broker {} matched sub to {}", - name(), _broker_id, - std::string(utils::type_name())); + name(), _broker_id, std::string(utils::type_name())); return match; }; - LocalEventHandler handler = [this, cb](const StreamID &sid, - EventType type, - Notification const *payload) { + LocalEventHandler handler = [this, cb]( + const StreamID &sid, EventType type, + Notification const *payload) { if (!this->_broker) return; - tracepoint(bts_trace, trace_event, utils::type_name(typeid(*this)), - utils::type_name(), _broker_id, sid.value(), - 0); + tracepoint( + bts_trace, trace_event, utils::type_name(typeid(*this)), + utils::type_name(), _broker_id, sid.value(), 0); before_event(); if (payload) cb(UpdateType{sid, type, &(payload->unwrap())}); @@ -146,14 +146,14 @@ class Actor { return user_filter(*typed_topic); }; - LocalEventHandler handler = [this, cb](const StreamID &sid, - EventType type, - Notification const *payload) { + LocalEventHandler handler = [this, cb]( + const StreamID &sid, EventType type, + Notification const *payload) { if (!this->_broker) return; - tracepoint(bts_trace, trace_event, utils::type_name(typeid(*this)), - utils::type_name(), _broker_id, sid.value(), - 0); + tracepoint( + bts_trace, trace_event, utils::type_name(typeid(*this)), + utils::type_name(), _broker_id, sid.value(), 0); before_event(); if (payload) cb(UpdateType{sid, type, &(payload->unwrap())}); @@ -213,9 +213,9 @@ class Actor { void publish(Stream const &stream, Args &&... args) { bts_assert_d(_broker); - tracepoint(bts_trace, trace_event, utils::type_name(typeid(*this)), - utils::type_name(), _broker_id, - stream.sid.value(), 1); + tracepoint( + bts_trace, trace_event, utils::type_name(typeid(*this)), + utils::type_name(), _broker_id, stream.sid.value(), 1); _broker->notify(stream, std::forward(args)...); } @@ -224,7 +224,7 @@ class Actor { template void publish_batch(Stream const &stream, C const &c) { bts_assert(_broker); - _broker->notify_batch(stream,c); + _broker->notify_batch(stream, c); } // destroy a previously created stream @@ -234,7 +234,7 @@ class Actor { _broker->unadvertise(stream.sid); } - void schedule_action (std::function const&action) { + void schedule_action(std::function const &action) { bts_assert(_broker); _broker->schedule_action(action); } diff --git a/src/lib/mercury/actors/ActorBroker.h b/src/lib/mercury/actors/ActorBroker.h index c49e42f8f..427db25b4 100644 --- a/src/lib/mercury/actors/ActorBroker.h +++ b/src/lib/mercury/actors/ActorBroker.h @@ -1,43 +1,40 @@ #pragma once -#include "lib/mercury/common/mercury_common.h" #include "lib/mercury/broker/BrokerProxy.h" +#include "lib/mercury/common/mercury_common.h" #include "lib/mercury/events/Stream.h" namespace bts { namespace mercury { class ActorBroker { -public: - ActorBroker (BrokerProxy &proxy) : _proxy(proxy),_proxy_id(_proxy.id()),_current_suid(0) {} + public: + ActorBroker(BrokerProxy &proxy) + : _proxy(proxy), _proxy_id(_proxy.id()), _current_suid(0) {} - BrokerID id() {return _proxy_id;} + BrokerID id() { return _proxy_id; } - LocalSubID subscribe(TopicFilter const&f, LocalEventHandler const &h) { + LocalSubID subscribe(TopicFilter const &f, LocalEventHandler const &h) { _current_suid = LocalSubID(_current_suid.value() + 1); - _proxy.local_subscribe(_current_suid,f,h); + _proxy.local_subscribe(_current_suid, f, h); return _current_suid; } - void unsubscribe(LocalSubID suid) { - _proxy.local_unsubscribe(suid); - } + void unsubscribe(LocalSubID suid) { _proxy.local_unsubscribe(suid); } - StreamID advertise (TopicPtr const&t) { + StreamID advertise(TopicPtr const &t) { auto sid = gen_stream_id(); - _proxy.advertise(_proxy_id,sid,t); + _proxy.advertise(_proxy_id, sid, t); return sid; } - - void unadvertise (StreamID sid) { - _proxy.unadvertise(_proxy_id,sid); - } - + + void unadvertise(StreamID sid) { _proxy.unadvertise(_proxy_id, sid); } + template - void notify (Stream const &stream, Args &&... args) { + void notify(Stream const &stream, Args &&... args) { BrokerProxy::BrokerMsg *m; Notification *notification; - _proxy.alloc_notify(&m,¬ification); + _proxy.alloc_notify(&m, ¬ification); auto &array = notification->template wrap_in_place(); array.emplace_back(std::forward(args)...); _proxy.send_notify(_proxy_id, stream.sid, SubID(0), *m); @@ -47,7 +44,7 @@ public: void notify_batch(Stream const &stream, C const &c) { BrokerProxy::BrokerMsg *msg; Notification *notification; - _proxy.alloc_notify(&msg,¬ification); + _proxy.alloc_notify(&msg, ¬ification); auto &array = notification->template wrap_in_place(); array.reserve(c.size()); for (auto &item : c) @@ -55,15 +52,15 @@ public: _proxy.send_notify(_proxy_id, stream.sid, SubID(0), *msg); } - void schedule_action (std::function const&action) { + void schedule_action(std::function const &action) { _proxy.schedule_action(action); } -private: + private: BrokerProxy &_proxy; BrokerID _proxy_id; LocalSubID _current_suid; }; - -}} +} // namespace mercury +} // namespace bts diff --git a/src/lib/mercury/actors/ContentSubscription.h b/src/lib/mercury/actors/ContentSubscription.h index 288025de9..aa9f0dad8 100644 --- a/src/lib/mercury/actors/ContentSubscription.h +++ b/src/lib/mercury/actors/ContentSubscription.h @@ -51,26 +51,26 @@ template class ContentSubscription { _pre_sub([](auto const &) {}), _log(log), _name(utils::type_name()), _pre_event([](auto const &) {}) {} - ContentSubscription(Actor &actor, std::function const &pscb, - trace::PerfLog &log) + ContentSubscription( + Actor &actor, std::function const &pscb, 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), _log(log), _name(utils::type_name()), _pre_event([](auto const &) {}) {} - ContentSubscription(Actor &actor, - std::function const &pre_ev, - trace::PerfLog &log) + ContentSubscription( + Actor &actor, 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([](auto const &) {}), _log(log), _name(utils::type_name()), _pre_event(pre_ev) {} - ContentSubscription(Actor &actor, std::function const &pscb, - std::function const &pre_ev, - trace::PerfLog &log) + ContentSubscription( + 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), @@ -86,9 +86,9 @@ template class ContentSubscription { _name(utils::type_name()), _pre_event([](auto const &) {}) {} template - ContentSubscription(Actor &actor, Tag const &tag, - std::function const &pscb, - trace::PerfLog &log) + ContentSubscription( + Actor &actor, Tag const &tag, std::function const &pscb, + trace::PerfLog &log) : _actor(&actor), _sub(_actor->subscribe( tag, [this](auto const &u) { this->on_update(u); })), @@ -97,9 +97,9 @@ template class ContentSubscription { _pre_event([](auto const &) {}) {} template - ContentSubscription(Actor &actor, Tag const &tag, - std::function const &pre_ev, - trace::PerfLog &log) + ContentSubscription( + 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); })), @@ -108,10 +108,9 @@ template class ContentSubscription { _name(utils::type_name()), _pre_event(pre_ev) {} template - ContentSubscription(Actor &actor, Tag const &tag, - std::function const &pscb, - std::function const &pre_ev, - trace::PerfLog &log) + ContentSubscription( + 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/actors/IPollableActor.cpp b/src/lib/mercury/actors/IPollableActor.cpp index 5261f9657..9fb4d07b1 100644 --- a/src/lib/mercury/actors/IPollableActor.cpp +++ b/src/lib/mercury/actors/IPollableActor.cpp @@ -3,6 +3,7 @@ namespace bts { namespace mercury { -IPollableActor::~IPollableActor () {} +IPollableActor::~IPollableActor() {} -}} +} // namespace mercury +} // namespace bts diff --git a/src/lib/mercury/actors/IPollableActor.h b/src/lib/mercury/actors/IPollableActor.h index 7612f6d09..245cf9f14 100644 --- a/src/lib/mercury/actors/IPollableActor.h +++ b/src/lib/mercury/actors/IPollableActor.h @@ -4,17 +4,16 @@ namespace bts { namespace trace { - class PerfLog; +class PerfLog; } namespace mercury { // interface to mark an actor that requires on_poll() calls -class IPollableActor -{ -public: +class IPollableActor { + public: ~IPollableActor(); - virtual void on_poll(trace::PerfLog&) = 0; - + virtual void on_poll(trace::PerfLog &) = 0; }; -}} +} // namespace mercury +} // namespace bts diff --git a/src/lib/mercury/actors/PingPong.h b/src/lib/mercury/actors/PingPong.h index 597335f27..a37e8b847 100644 --- a/src/lib/mercury/actors/PingPong.h +++ b/src/lib/mercury/actors/PingPong.h @@ -32,7 +32,7 @@ class Ping : public Actor, public mercury::IPollableActor { _i++; if (_i % 100000 == 0) { auto now = utils::TimeStamp::now(); - tracepoint(bts_trace, trace_order, "ping_send", 0, now.to_uint64(),0); + tracepoint(bts_trace, trace_order, "ping_send", 0, now.to_uint64(), 0); publish(_stream, now); } } @@ -45,13 +45,15 @@ class Pong : public Actor { public: void init() override { subscribe([](auto const &m) { - if (m.events) { - auto then = (*m.events)[0].src; - auto d = utils::TimeStamp::now() - then; - UNUSED(d); - tracepoint(bts_trace, trace_order, "ping_receive", 0,then.to_uint64(),d.nanoseconds()); - } - }); + if (m.events) { + auto then = (*m.events)[0].src; + auto d = utils::TimeStamp::now() - then; + UNUSED(d); + tracepoint( + bts_trace, trace_order, "ping_receive", 0, then.to_uint64(), + d.nanoseconds()); + } + }); } }; diff --git a/src/lib/mercury/actors/Timer.h b/src/lib/mercury/actors/Timer.h index 793bb49bd..91130d8b1 100644 --- a/src/lib/mercury/actors/Timer.h +++ b/src/lib/mercury/actors/Timer.h @@ -21,7 +21,7 @@ class Timer : public Actor, public mercury::IPollableActor { } private: - void on_poll(trace::PerfLog&) override { + void on_poll(trace::PerfLog &) override { auto now = bts::Timer::now(); if (ms_diff(now, _last_ts) > 10) { _last_ts = now; diff --git a/src/lib/mercury/broker/Broker.cpp b/src/lib/mercury/broker/Broker.cpp index 1aafd9755..bd4316d70 100644 --- a/src/lib/mercury/broker/Broker.cpp +++ b/src/lib/mercury/broker/Broker.cpp @@ -29,8 +29,8 @@ struct Broker::LocalSubFilter { }; struct Broker::StreamRec { - StreamRec(Broker &owner, IRemoteBroker &src, StreamID sid, - TopicPtr const &topic) + StreamRec( + Broker &owner, IRemoteBroker &src, StreamID sid, TopicPtr const &topic) : owner(owner), local(false), src(&src), sid(sid), topic_str(intern_topic_str(topic)), topic(topic), local_subs(), external_subs(), sub_id(), @@ -91,10 +91,12 @@ struct Broker::StreamRec { void add_external_sub(IRemoteBroker *const &node, SubID subid) { auto sender = node->id(); - bts_assert(std::find_if(external_subs.begin(), external_subs.end(), - [sender](auto const &sub_rec) { - return sub_rec.neighbour->id() == sender; - }) == external_subs.end()); + bts_assert( + std::find_if( + external_subs.begin(), external_subs.end(), + [sender](auto const &sub_rec) { + return sub_rec.neighbour->id() == sender; + }) == external_subs.end()); // record wheter we are already active for this stream auto was_active = is_active(); @@ -125,10 +127,11 @@ struct Broker::StreamRec { } void remove_external_sub(BrokerID sender, SubID subid) { - auto it = std::find_if(external_subs.begin(), external_subs.end(), - [sender](auto const &sub_rec) { - return sub_rec.neighbour->id() == sender; - }); + auto it = std::find_if( + external_subs.begin(), external_subs.end(), + [sender](auto const &sub_rec) { + return sub_rec.neighbour->id() == sender; + }); bts_assert(it != external_subs.end()); bts_assert(it->sub_id == subid); external_subs.erase(it); @@ -137,9 +140,9 @@ struct Broker::StreamRec { } void add_local_sub(LocalEventHandler const &handler, LocalSubID sub_id) { - auto it = - std::find_if(local_subs.begin(), local_subs.end(), - [sub_id](auto &sub) { return sub.sub_id == sub_id; }); + auto it = std::find_if( + local_subs.begin(), local_subs.end(), + [sub_id](auto &sub) { return sub.sub_id == sub_id; }); bts_assert(it == local_subs.end()); auto was_active = is_active(); local_subs.push_back(LocalSubRec{sub_id, handler}); @@ -149,9 +152,9 @@ struct Broker::StreamRec { } void remove_local_sub(LocalSubID sub_id) { - auto it = - std::find_if(local_subs.begin(), local_subs.end(), - [sub_id](auto &sub) { return sub.sub_id == sub_id; }); + auto it = std::find_if( + local_subs.begin(), local_subs.end(), + [sub_id](auto &sub) { return sub.sub_id == sub_id; }); bts_assert(it != local_subs.end()); it->on_event(sid, EventType::END_SUB, nullptr); local_subs.erase(it); @@ -347,17 +350,19 @@ void Broker::unadvertise(BrokerID sender, StreamID sid) { } #ifndef NDEBUG -void Broker::notify(BrokerID sender, StreamID sid, SubID ex_subid, - Notification const &payload) { +void Broker::notify( + BrokerID sender, StreamID sid, SubID ex_subid, + Notification const &payload) { NoReenter nr(me->inside); #else -void Broker::notify(BrokerID, StreamID sid, SubID ex_subid, - Notification const &payload) { +void Broker::notify( + BrokerID, StreamID sid, SubID ex_subid, Notification const &payload) { #endif auto &srec = me->streams[sid]; bts_assert_d(srec); - bts_assert_d((srec->is_local() && sender == id()) || - (!srec->is_local() && srec->src->id() == sender)); + bts_assert_d( + (srec->is_local() && sender == id()) || + (!srec->is_local() && srec->src->id() == sender)); if (srec->is_local() || srec->sub_id == ex_subid) { @@ -403,8 +408,8 @@ void Broker::unsubscribe(BrokerID sender, SubID ex_subid, StreamID sid) { _unsubscribe(sender, ex_subid, sid); } -void Broker::local_subscribe(LocalSubID in_subid, TopicFilter const &f, - LocalEventHandler const &cb) { +void Broker::local_subscribe( + LocalSubID in_subid, TopicFilter const &f, LocalEventHandler const &cb) { LOG(Mercury, Info, "Broker {} received local_subscribe (sub_id: {})", id().value(), in_subid.value()); NoReenter nr(me->inside); @@ -466,8 +471,9 @@ void Broker::_unadvertise(BrokerID sender, StreamID sid) { // either the stream is local and therefore the sender is us or the // stream is not local and the sender is in srec - bts_assert((sender == id() && srec->is_local()) || - (!srec->is_local() && sender == srec->src->id())); + bts_assert( + (sender == id() && srec->is_local()) || + (!srec->is_local() && sender == srec->src->id())); // remove from our index me->streams.erase(it); diff --git a/src/lib/mercury/broker/Broker.h b/src/lib/mercury/broker/Broker.h index 1781f42b2..638a24890 100644 --- a/src/lib/mercury/broker/Broker.h +++ b/src/lib/mercury/broker/Broker.h @@ -1,19 +1,18 @@ #pragma once -#include #include "lib/mercury/broker/ILocalBroker.h" +#include namespace bts { namespace mercury { -class Broker : public ILocalBroker -{ -public: +class Broker : public ILocalBroker { + public: Broker(); virtual ~Broker(); BrokerID id() const override; - + void add_neighbour(IRemoteBroker &) override; void remove_neighbour(BrokerID) override; @@ -25,11 +24,11 @@ public: void notify(BrokerID, StreamID, SubID, Notification const &) override; - void local_subscribe(LocalSubID, TopicFilter const &, - LocalEventHandler const &cb) override; + void local_subscribe( + LocalSubID, TopicFilter const &, LocalEventHandler const &cb) override; void local_unsubscribe(LocalSubID) override; -private: + private: struct NoReenter; struct StreamRec; struct LocalSubRec; @@ -38,10 +37,11 @@ private: struct PImpl; SubID gen_remote_sub_id(); - void _unadvertise(BrokerID,StreamID) ; - void _unsubscribe (BrokerID,SubID,StreamID) ; + void _unadvertise(BrokerID, StreamID); + void _unsubscribe(BrokerID, SubID, StreamID); std::unique_ptr me; }; -}} +} // namespace mercury +} // namespace bts diff --git a/src/lib/mercury/broker/BrokerProxy.cpp b/src/lib/mercury/broker/BrokerProxy.cpp index 9968ea385..3d17abf35 100644 --- a/src/lib/mercury/broker/BrokerProxy.cpp +++ b/src/lib/mercury/broker/BrokerProxy.cpp @@ -6,11 +6,9 @@ namespace bts { namespace mercury { BrokerProxy::BrokerProxy(ILocalBroker &real_broker) - : _real_broker(real_broker), _id(real_broker.id()), - _cycles(0), + : _real_broker(real_broker), _id(real_broker.id()), _cycles(0), _outgoing(config::get().queue_size()), - _incoming(config::get().queue_size()), - _action_pool() {} + _incoming(config::get().queue_size()), _action_pool() {} BrokerProxy::~BrokerProxy() {} @@ -63,8 +61,8 @@ void BrokerProxy::unsubscribe(BrokerID bid, SubID sub_id, StreamID sid) { send(*m); } -void BrokerProxy::notify(BrokerID bid, StreamID sid, SubID sub_id, - Notification const &n) { +void BrokerProxy::notify( + BrokerID bid, StreamID sid, SubID sub_id, Notification const &n) { auto m = _action_pool.construct(); m->msg_type = BrokerMsgType::NOTIFY; m->broker_id = bid; @@ -74,8 +72,8 @@ void BrokerProxy::notify(BrokerID bid, StreamID sid, SubID sub_id, send(*m); } -void BrokerProxy::local_subscribe(LocalSubID lsid, TopicFilter const &tf, - LocalEventHandler const &handler) { +void BrokerProxy::local_subscribe( + LocalSubID lsid, TopicFilter const &tf, LocalEventHandler const &handler) { auto m = _action_pool.construct(); m->msg_type = BrokerMsgType::LOCAL_SUBSCRIBE; m->local_sub_id = lsid; diff --git a/src/lib/mercury/broker/BrokerProxy.h b/src/lib/mercury/broker/BrokerProxy.h index 34abb5d05..e2a4dc011 100644 --- a/src/lib/mercury/broker/BrokerProxy.h +++ b/src/lib/mercury/broker/BrokerProxy.h @@ -3,8 +3,8 @@ #include "lib/mercury/broker/ILocalBroker.h" #include "lib/mercury/common/mercury_common.h" #include "lib/mercury/topics/Topic.h" -#include "lib/utils/GrowableSPSCQueue.h" #include "lib/tracing/PerfLog.h" +#include "lib/utils/GrowableSPSCQueue.h" #include #include @@ -55,8 +55,8 @@ class BrokerProxy : public ILocalBroker { void subscribe(BrokerID, SubID, StreamID) override; void unsubscribe(BrokerID, SubID, StreamID) override; void notify(BrokerID, StreamID, SubID, Notification const &) override; - void local_subscribe(LocalSubID, TopicFilter const &, - LocalEventHandler const &cb) override; + void local_subscribe( + LocalSubID, TopicFilter const &, LocalEventHandler const &cb) override; void local_unsubscribe(LocalSubID) override; // ILocalBroker @@ -80,9 +80,9 @@ class BrokerProxy : public ILocalBroker { send(m); } - void do_work(trace::PerfLog& log) { + void do_work(trace::PerfLog &log) { _cycles++; - _outgoing.consume_all([this,&log](BrokerMsg *m) { + _outgoing.consume_all([this, &log](BrokerMsg *m) { switch (m->msg_type) { case BrokerMsgType::ADD_NEIGHBOUR: _real_broker.add_neighbour(*m->neighbour); @@ -105,14 +105,14 @@ class BrokerProxy : public ILocalBroker { case BrokerMsgType::NOTIFY: { LOG(Latency, Diag, "Notify broker {}. Cycles: {}", _id.value(), _cycles); - auto scoped_do_work = trace::log_scope(log, {}, "BrokerProxy::notify"); - _real_broker.notify(m->broker_id, m->stream_id, m->sub_id, - m->notification); - } - break; + auto scoped_do_work = + trace::log_scope(log, {}, "BrokerProxy::notify"); + _real_broker.notify( + m->broker_id, m->stream_id, m->sub_id, m->notification); + } break; case BrokerMsgType::LOCAL_SUBSCRIBE: - _real_broker.local_subscribe(m->local_sub_id, m->filter, - m->local_handler); + _real_broker.local_subscribe( + m->local_sub_id, m->filter, m->local_handler); break; case BrokerMsgType::LOCAL_UNSUBSCRIBE: _real_broker.local_unsubscribe(m->local_sub_id); diff --git a/src/lib/mercury/broker/ILocalBroker.cpp b/src/lib/mercury/broker/ILocalBroker.cpp index 73d8624b0..0b929b082 100644 --- a/src/lib/mercury/broker/ILocalBroker.cpp +++ b/src/lib/mercury/broker/ILocalBroker.cpp @@ -3,4 +3,5 @@ namespace bts { namespace mercury { ILocalBroker::~ILocalBroker() {} -}} +} // namespace mercury +} // namespace bts diff --git a/src/lib/mercury/broker/ILocalBroker.h b/src/lib/mercury/broker/ILocalBroker.h index e46c0166d..086847b8b 100644 --- a/src/lib/mercury/broker/ILocalBroker.h +++ b/src/lib/mercury/broker/ILocalBroker.h @@ -6,8 +6,8 @@ namespace mercury { class ILocalBroker : public IRemoteBroker { public: - virtual void local_subscribe(LocalSubID, TopicFilter const &, - LocalEventHandler const &cb) = 0; + virtual void local_subscribe( + LocalSubID, TopicFilter const &, LocalEventHandler const &cb) = 0; virtual void local_unsubscribe(LocalSubID) = 0; virtual ~ILocalBroker(); }; diff --git a/src/lib/mercury/broker/IRemoteBroker.cpp b/src/lib/mercury/broker/IRemoteBroker.cpp index f1602c12a..8a739b120 100644 --- a/src/lib/mercury/broker/IRemoteBroker.cpp +++ b/src/lib/mercury/broker/IRemoteBroker.cpp @@ -3,4 +3,5 @@ namespace bts { namespace mercury { IRemoteBroker::~IRemoteBroker() {} -}} +} // namespace mercury +} // namespace bts diff --git a/src/lib/mercury/broker/IRemoteBroker.h b/src/lib/mercury/broker/IRemoteBroker.h index c151edbdd..b4ec41b17 100644 --- a/src/lib/mercury/broker/IRemoteBroker.h +++ b/src/lib/mercury/broker/IRemoteBroker.h @@ -11,7 +11,7 @@ class IRemoteBroker { public: virtual BrokerID id() const = 0; - virtual void add_neighbour(IRemoteBroker &) = 0; + virtual void add_neighbour(IRemoteBroker &) = 0; virtual void remove_neighbour(BrokerID) = 0; virtual void advertise(BrokerID, StreamID, TopicPtr const &) = 0; diff --git a/src/lib/mercury/common/FatWrapper.h b/src/lib/mercury/common/FatWrapper.h index b9ef24219..42eda2ecb 100644 --- a/src/lib/mercury/common/FatWrapper.h +++ b/src/lib/mercury/common/FatWrapper.h @@ -2,31 +2,29 @@ #include #include - + #include "lib/utils/bts_assert.h" namespace bts { namespace mercury { -template -void fat_wrapper_copy(std::array *dst, - std::array const &src) -{ - if (sizeof(T) <= N) - new (dst->data()) T(*((T*) src.data())); +template +void fat_wrapper_copy( + std::array *dst, std::array const &src) { + if (sizeof(T) <= N) + new (dst->data()) T(*((T *)src.data())); else { - auto heap_cpy = new T(**((T**) src.data())); - *((T**) dst->data()) = heap_cpy; + auto heap_cpy = new T(**((T **)src.data())); + *((T **)dst->data()) = heap_cpy; } } -template -void fat_wrapper_destroy(std::array &dst) -{ +template +void fat_wrapper_destroy(std::array &dst) { if (sizeof(T) <= N) - ((T*) dst.data())->~T(); + ((T *)dst.data())->~T(); else { - auto heap_ptr = *((T**) dst.data()); + auto heap_ptr = *((T **)dst.data()); delete heap_ptr; } } @@ -35,90 +33,72 @@ void fat_wrapper_destroy(std::array &dst) // use small object optimization to avoid heap allocations. This would // not be needed if boost::variant wasn't a slow, complex // POS. std::variant might do trick when its widely available. -template -class FatWrapper -{ -public: - static const auto Overhead = 3*sizeof(void*); - static const auto BufferSize = SZ - Overhead; - static_assert( SZ>= (Overhead + sizeof(void*)), "Size is too small to hold FatWrapper" ); - - FatWrapper() : - _copy(), - _destroy(), - _wrapped_type(), - _buffer() - { - } - - FatWrapper(FatWrapper const &src) : - _copy(src._copy), - _destroy(src._destroy), - _wrapped_type(src._wrapped_type), - _buffer() - { +template class FatWrapper { + public: + static const auto Overhead = 3 * sizeof(void *); + static const auto BufferSize = SZ - Overhead; + static_assert( + SZ >= (Overhead + sizeof(void *)), + "Size is too small to hold FatWrapper"); + + FatWrapper() : _copy(), _destroy(), _wrapped_type(), _buffer() {} + + FatWrapper(FatWrapper const &src) + : _copy(src._copy), _destroy(src._destroy), + _wrapped_type(src._wrapped_type), _buffer() { if (!empty()) - _copy(&_buffer,src._buffer); + _copy(&_buffer, src._buffer); } - - template - T& wrap(T&& t) - { - using RealT = typename std::remove_reference::type ; + + template T &wrap(T &&t) { + using RealT = typename std::remove_reference::type; if (!empty()) _destroy(_buffer); - - _copy = fat_wrapper_copy; - _destroy = fat_wrapper_destroy; + + _copy = fat_wrapper_copy; + _destroy = fat_wrapper_destroy; _wrapped_type = &typeid(RealT); - if (sizeof(T) <= BufferSize) + if (sizeof(T) <= BufferSize) new (_buffer.data()) RealT(std::forward(t)); else { auto heap_cpy = new RealT(std::forward(t)); - *((RealT**) _buffer.data()) = heap_cpy; + *((RealT **)_buffer.data()) = heap_cpy; } return unwrap(); } - template - T& wrap_in_place(Args&&... args) - { + template T &wrap_in_place(Args &&... args) { if (!empty()) _destroy(_buffer); - _copy = fat_wrapper_copy; - _destroy = fat_wrapper_destroy; + _copy = fat_wrapper_copy; + _destroy = fat_wrapper_destroy; _wrapped_type = &typeid(T); - if (sizeof(T) <= BufferSize) + if (sizeof(T) <= BufferSize) new (_buffer.data()) T(std::forward(args)...); else { auto heap_cpy = new T(std::forward(args)...); - *((T**) _buffer.data()) = heap_cpy; + *((T **)_buffer.data()) = heap_cpy; } return unwrap(); } - template - T &unwrap() - { + template T &unwrap() { bts_assert_d(!empty()); bts_assert_d(*_wrapped_type == typeid(T)); - if (sizeof(T) <= BufferSize) - return *((T*) _buffer.data()); + if (sizeof(T) <= BufferSize) + return *((T *)_buffer.data()); else - return **((T**)_buffer.data()); + return **((T **)_buffer.data()); } - template - T const &unwrap() const - { - return ((FatWrapper*)this)->unwrap(); + template T const &unwrap() const { + return ((FatWrapper *)this)->unwrap(); } - FatWrapper& operator=(const FatWrapper &src) - { + FatWrapper &operator=(const FatWrapper &src) { if (!empty()) _destroy(_buffer); @@ -126,40 +106,34 @@ public: _destroy = src._destroy; _wrapped_type = src._wrapped_type; - if (!empty()) - _copy(&_buffer,src._buffer); + if (!empty()) + _copy(&_buffer, src._buffer); return *this; } - bool empty() const { - return _destroy == nullptr; - } + bool empty() const { return _destroy == nullptr; } - std::type_info const& wrapped_type() - { + std::type_info const &wrapped_type() { bts_assert(!empty()); return *_wrapped_type; } - void clear() - { + void clear() { if (!empty()) { _destroy(_buffer); _destroy = nullptr; } } - ~FatWrapper() - { - clear(); - } + ~FatWrapper() { clear(); } -private: - using Buffer = std::array; - void (*_copy) (Buffer *dst, Buffer const&src); - void (*_destroy) (Buffer &dst); - const std::type_info* _wrapped_type; + private: + using Buffer = std::array; + void (*_copy)(Buffer *dst, Buffer const &src); + void (*_destroy)(Buffer &dst); + const std::type_info *_wrapped_type; Buffer _buffer; }; -}} +} // namespace mercury +} // namespace bts diff --git a/src/lib/mercury/common/mercury_common.cpp b/src/lib/mercury/common/mercury_common.cpp index ed110b5f6..5530cb6c7 100644 --- a/src/lib/mercury/common/mercury_common.cpp +++ b/src/lib/mercury/common/mercury_common.cpp @@ -5,9 +5,7 @@ namespace mercury { std::atomic _sid(0); -StreamID gen_stream_id() -{ - return StreamID(++_sid); -} +StreamID gen_stream_id() { return StreamID(++_sid); } -}} +} // namespace mercury +} // namespace bts diff --git a/src/lib/mercury/common/mercury_common.h b/src/lib/mercury/common/mercury_common.h index 493b0780d..cc744bd25 100644 --- a/src/lib/mercury/common/mercury_common.h +++ b/src/lib/mercury/common/mercury_common.h @@ -1,33 +1,32 @@ #pragma once -#include -#include -#include #include "lib/mercury/common/FatWrapper.h" #include "lib/utils/ValueWrapper.h" +#include +#include +#include namespace bts { namespace mercury { class ITopic; -using TopicFilter = std::function ; +using TopicFilter = std::function; -using StreamID = utils::ValueWrapper; -using SubID = utils::ValueWrapper; +using StreamID = utils::ValueWrapper; +using SubID = utils::ValueWrapper; using Notification = FatWrapper<112>; -using LocalSubID = utils::ValueWrapper; -using BrokerID = utils::ValueWrapper; +using LocalSubID = utils::ValueWrapper; +using BrokerID = utils::ValueWrapper; -enum class EventType { - BEGIN_STREAM, - END_STREAM, - NEW_EVENT, - END_SUB -}; -using LocalEventHandler = std::function; +enum class EventType { BEGIN_STREAM, END_STREAM, NEW_EVENT, END_SUB }; +using LocalEventHandler = + std::function; StreamID gen_stream_id(); -using TimeStampStr = utils::ValueWrapper> ; +using TimeStampStr = utils::ValueWrapper< + struct TimeStampStrTag, + std::array>; -}} +} // namespace mercury +} // namespace bts diff --git a/src/lib/mercury/events/Event.h b/src/lib/mercury/events/Event.h index cec8f05d9..d0b45c27a 100644 --- a/src/lib/mercury/events/Event.h +++ b/src/lib/mercury/events/Event.h @@ -13,8 +13,9 @@ namespace mercury { // Used to make it easier to define the event array dependent type for // any given event. User events should derive from Event and use the // curiously recurrent template pattern (yeah, its a thing, google it). -template > +template < + typename BaseEvent, + typename TArray = boost::container::small_vector> class Event { public: using Array = TArray; diff --git a/src/lib/mercury/events/TimerEvent.cpp b/src/lib/mercury/events/TimerEvent.cpp index 7e865274d..0bfbf6af4 100644 --- a/src/lib/mercury/events/TimerEvent.cpp +++ b/src/lib/mercury/events/TimerEvent.cpp @@ -1,5 +1,5 @@ #include "TimerEvent.h" namespace bts { -namespace mercury { -}} +namespace mercury {} +} // namespace bts diff --git a/src/lib/mercury/events/TimerEvent.h b/src/lib/mercury/events/TimerEvent.h index 41a55d691..f1b7c9228 100644 --- a/src/lib/mercury/events/TimerEvent.h +++ b/src/lib/mercury/events/TimerEvent.h @@ -1,23 +1,22 @@ #pragma once -#include -#include "lib/mercury/events/Event.h" #include "lib/mercury/common/mercury_common.h" -#include "lib/utils/bts_chrono.h" +#include "lib/mercury/events/Event.h" #include "lib/mercury/synopsis/NoSynopsis.h" +#include "lib/utils/bts_chrono.h" +#include namespace bts { namespace mercury { // Events published by Timer actor at a fixed frequency. -class TimerEvent : public Event -{ -public: +class TimerEvent : public Event { + public: using SynopsisPolicy = NoSynopsis; TimerEvent(TimeStamp ts, TimeStampStr ts_str) : ts(ts), ts_str(ts_str) {} TimeStamp ts; TimeStampStr ts_str; }; -}} - +} // namespace mercury +} // namespace bts diff --git a/src/lib/mercury/events/Update.h b/src/lib/mercury/events/Update.h index 86dfaa553..f3b769058 100644 --- a/src/lib/mercury/events/Update.h +++ b/src/lib/mercury/events/Update.h @@ -1,19 +1,19 @@ #pragma once -#include #include "lib/mercury/common/mercury_common.h" #include +#include namespace bts { namespace mercury { // Event update dependent type -template -class Update { -public: +template class Update { + public: StreamID sid; EventType event_type; - typename Event::Array const*events; + typename Event::Array const *events; }; -}} +} // namespace mercury +} // namespace bts diff --git a/src/lib/mercury/executor/Executor.cpp b/src/lib/mercury/executor/Executor.cpp index 3f2a307fb..b5db4d648 100644 --- a/src/lib/mercury/executor/Executor.cpp +++ b/src/lib/mercury/executor/Executor.cpp @@ -1,45 +1,38 @@ #include "lib/mercury/executor/Executor.h" -#include "lib/mercury/broker/Broker.h" -#include "lib/mercury/broker/BrokerProxy.h" #include "lib/mercury/actors/Actor.h" #include "lib/mercury/actors/IPollableActor.h" +#include "lib/mercury/broker/Broker.h" +#include "lib/mercury/broker/BrokerProxy.h" namespace bts { namespace mercury { -Executor::Executor() : - _broker(), - _incoming_proxies(), - _my_proxy(make_proxy()), - _actor_broker(_my_proxy), - _actors() {} +Executor::Executor() + : _broker(), _incoming_proxies(), _my_proxy(make_proxy()), + _actor_broker(_my_proxy), _actors() {} Executor::~Executor() { for (auto &a : _actors) a->deactivate(); } - -void Executor::init_neighbours(std::vector const&neighbours) -{ + +void Executor::init_neighbours(std::vector const &neighbours) { for (auto e : neighbours) - if (e != this) + if (e != this) _outgoing_proxies.push_back(&e->make_proxy()); for (auto n : _outgoing_proxies) _broker.add_neighbour(*n); } - -void Executor::activate(Actor *actor) -{ - _actors.push_back(std::unique_ptr (actor)); - auto pollable = dynamic_cast (actor); +void Executor::activate(Actor *actor) { + _actors.push_back(std::unique_ptr(actor)); + auto pollable = dynamic_cast(actor); if (pollable) _pollable_actors.push_back(pollable); - actor->activate(_actor_broker);} - + actor->activate(_actor_broker); +} -BrokerProxy& Executor::make_proxy() -{ +BrokerProxy &Executor::make_proxy() { _incoming_proxies.push_back(std::make_unique(_broker)); return *_incoming_proxies.back(); } diff --git a/src/lib/mercury/executor/Executor.h b/src/lib/mercury/executor/Executor.h index cf2f4404b..4e8e5d14a 100644 --- a/src/lib/mercury/executor/Executor.h +++ b/src/lib/mercury/executor/Executor.h @@ -1,9 +1,9 @@ #pragma once +#include "lib/mercury/actors/ActorBroker.h" #include "lib/mercury/actors/IPollableActor.h" #include "lib/mercury/broker/Broker.h" #include "lib/mercury/broker/BrokerProxy.h" -#include "lib/mercury/actors/ActorBroker.h" #include "lib/tracing/PerfLog.h" #include @@ -24,7 +24,7 @@ class Executor { activate(new A(std::forward(args)...)); } - void do_work(trace::PerfLog& log) { + void do_work(trace::PerfLog &log) { for (auto p : _pollable_actors) { p->on_poll(log); } @@ -39,11 +39,11 @@ class Executor { void activate(Actor *actor); BrokerProxy &make_proxy(); - private: + private: Broker _broker; std::vector> _incoming_proxies; - std::vector _outgoing_proxies; + std::vector _outgoing_proxies; BrokerProxy &_my_proxy; ActorBroker _actor_broker; std::vector _pollable_actors; diff --git a/src/lib/mercury/synopsis/MergeByKey.h b/src/lib/mercury/synopsis/MergeByKey.h index 8de729cea..7603c536c 100644 --- a/src/lib/mercury/synopsis/MergeByKey.h +++ b/src/lib/mercury/synopsis/MergeByKey.h @@ -1,8 +1,8 @@ #pragma once +#include "lib/mercury/synopsis/ISynopsisBuilder.h" #include #include -#include "lib/mercury/synopsis/ISynopsisBuilder.h" namespace bts { namespace mercury { diff --git a/src/lib/metrics/metrics.cpp b/src/lib/metrics/metrics.cpp index 6c51ababa..98b5350a3 100644 --- a/src/lib/metrics/metrics.cpp +++ b/src/lib/metrics/metrics.cpp @@ -2,16 +2,14 @@ #include "lib/utils/ConcurrentAppendCollection.h" #include -using std::vector; using std::shared_ptr; +using std::vector; namespace bts { namespace metrics { -Metric::Metric(const std::string& cname, const std::vector