SPARK-1514, Server side SDK code complete.

This commit is contained in:
Pedro Pinto committed 2018-09-12 18:43:17 +00:00
1 parent 2885d929a8
commit e29ea5d89b
39 files changed
+936 -234

No files matched your search

+27 -7
View File
@@ -16,7 +16,10 @@
#include "lib/orderman/actors/SecuritySrc.h"
#include "lib/orderman/actors/ServiceBridge.h"
#include "lib/orderman/actors/order_manager/OrderManager.h"
#include "lib/orderman/order_factory/DynamicOrderRegistry.h"
#include "lib/utils/bts_chrono.h"
#include "lib/plugin/plugin.h"
#include "lib/plugin/SparkServices.h"
namespace bts {
namespace orderman {
@@ -24,6 +27,7 @@ namespace orderman {
struct OrderServiceServer::PImpl {
PImpl(bts::api::ServiceContext &ctx,
std::shared_ptr<api::ISyntheticSecurityService> &ss,
DynamicOrderRegistry const &d,
metrics::MetricsContainer &stats)
: fast_broker(std::make_shared<mercury::AsyncEventBroker>()),
slow_broker(std::make_shared<mercury::AsyncEventBroker>()),
@@ -31,7 +35,7 @@ struct OrderServiceServer::PImpl {
fast_thread(), slow_thread(), service_ready(false), known_orders(),
known_fills(), publish_orders(), publish_fills(),
admin_service(ctx.locate<api::admin::AdminService>()), md_consumer(ss),
stats(stats) {}
stats(stats), dyn_order_registry(d) {}
std::shared_ptr<mercury::AsyncEventBroker> fast_broker;
std::shared_ptr<mercury::AsyncEventBroker> slow_broker;
@@ -49,14 +53,16 @@ struct OrderServiceServer::PImpl {
api::admin::AdminService admin_service;
bts::md::MDConsumer md_consumer;
metrics::MetricsContainer &stats;
DynamicOrderRegistry const &dyn_order_registry;
};
OrderServiceServer::OrderServiceServer(
bts::api::ServiceContext &ctx,
std::shared_ptr<api::ISyntheticSecurityService> &ss,
DynamicOrderRegistry const&d,
metrics::MetricsContainer &stats)
: api::orderman::OrderServiceBase(ctx), me(new PImpl(ctx, ss, stats)) {
: api::orderman::OrderServiceBase(ctx), me(new PImpl(ctx, ss, d,stats)) {
me->publish_orders = make_orders_publisher();
me->publish_fills = make_fills_publisher();
@@ -69,18 +75,20 @@ OrderServiceServer::OrderServiceServer(
[this, &ctx](auto const &fill) {
ctx.post([this, fill] { this->on_fills(fill); });
});
},
me->dyn_order_registry);
me->fast_broker->init_neighbours({me->slow_broker});
me->slow_broker->init_neighbours({me->fast_broker});
// fast actors
me->fast_exe.spawn<MDSource>(me->md_consumer, me->stats);
me->fast_exe.spawn<OrderManager>();
me->fast_exe.spawn<OrderManager>(me->dyn_order_registry);
auto &all_connections = config::get<config::JetFIX>().connection();
for (auto const &c : all_connections)
me->fast_exe.spawn<ExecutionGateway>(c,stats);
me->fast_exe.spawn<ExecutionGateway>(c, stats);
me->fast_thread = std::thread([this]() {
os::set_thread_name("fast_exe");
@@ -105,7 +113,7 @@ OrderServiceServer::OrderServiceServer(
// slow actors
me->slow_exe.activate(me->service_bridge);
me->slow_exe.spawn<mercury::Timer>();
me->slow_exe.spawn<AsyncFactory>();
me->slow_exe.spawn<AsyncFactory>(me->dyn_order_registry);
me->slow_exe.spawn<OrderStore>();
me->slow_exe.spawn<FillStore>();
me->slow_exe.spawn<SecuritySrc>(me->md_consumer);
@@ -225,5 +233,17 @@ void OrderServiceServer::crack_order(
response = me->service_bridge->crack_order(crack);
r(response);
}
void OrderServiceServer::get_registered_dynamic_order_types(
const api::VoidMessage &,
const api::Response<api::orderman::RegisteredDynamicOrderTypes> &r) {
api::orderman::RegisteredDynamicOrderTypes response;
auto all_orders = me->dyn_order_registry.get_all_dynamic_order_types();
for (auto const &desc : all_orders)
*response.add_dynamic_order_desc() = desc;
r(response);
}
} // namespace orderman
} // namespace bts