Files
spark/src/lib/orderman/actors/gateway/GatewayProxy.cpp
T
2020-04-23 17:57:13 -04:00

113 lines
3.1 KiB
C++

#include "GatewayProxy.h"
#include "lib/mercury/broker/BrokerProxy.h"
#include "lib/mercury/events/Update.h"
#include "lib/mercury/events/Stream.h"
#include "lib/orderman/events/NewSecuritiesEvent.h"
#include "lib/orderman/events/NewAdminDataEvent.h"
#include "lib/orderman/events/SendFixEvent.h"
#include "lib/orderman/events/SendOrderMsgsEvent.h"
#include "lib/orderman/events/GatewayStatusChangeEvent.h"
#include "lib/orderman/events/CancelRejectEvent.h"
#include "lib/orderman/events/NewExecutionReportEvent.h"
#include "lib/orderman/orderman_utils/ExecutionReport.h"
#include "lib/orderman/orderman_utils/orderman_common.h"
#include "lib/jetfix/common/OutFIXPtr.h"
#include "lib/jetfix/common/OutFIX.h"
#include "lib/utils/helper_macros.h"
#include "lib/utils/bts_assert.h"
#include "lib/config/config.h"
#include "lib/config/protos/mercury_cfg.pb.h"
#include <variant>
#include <tuple>
namespace bts {
namespace orderman {
struct GatewayProxy::PImpl
{
PImpl(const config::JetFIX::Connection &cfg, trace::PerfLog &l, md::SecurityOracle o)
: cfg(cfg), perf_log(l), sec_oracle(o), gateway_name(cfg.name())
{
}
config::JetFIX::Connection cfg;
trace::PerfLog& perf_log;
md::SecurityOracle sec_oracle;
GatewayName gateway_name;
mercury::Stream<SendFixEvent> send_fix_pub;
mercury::Stream<SendOrderMsgsEvent> send_ordermsgs_pub;
OnExeReport on_exe_report;
OnGwStatusChange on_gw_status_change;
OnCancelReject on_cancel_reject;
};
GatewayProxy::GatewayProxy(const config::JetFIX::Connection& conn, trace::PerfLog& pl, md::SecurityOracle md)
: me(new PImpl(conn, pl, md))
{
}
GatewayProxy::~GatewayProxy() { }
//actor init
void GatewayProxy::init()
{
me->send_fix_pub = make_stream<SendFixEvent>(me->gateway_name);
me->send_ordermsgs_pub = make_stream<SendOrderMsgsEvent>(me->gateway_name);
}
//start the gateway
void GatewayProxy::start()
{
}
void GatewayProxy::dispatch_incoming_fix_messages()
{
//called on GW thread and sent back through queue
}
void GatewayProxy::on_securities(const mercury::Update<NewSecuritiesEvent>& )
{
//the actual gateway subscribes to these, no-op here
}
void GatewayProxy::on_admin_data(const mercury::Update<NewAdminDataEvent>& )
{
//the actual gateway subscribes to these, no-op here
}
void GatewayProxy::send_fix(const jetfix::OutFIXPtr& fixptr, trace::CorID corid)
{
//jetfix::OutFIXPtr copy(new jetfix::OutFIX(*fixptr)); //copy not necessary see OrderManager::reload_fix_buffer
publish<SendFixEvent>(me->send_fix_pub, fixptr, corid);
}
void GatewayProxy::send_msgs(const std::vector<OrderMsg>& msgs, trace::CorID corid)
{
SendOrderMsgsEvent::MsgsPtr copy(new SendOrderMsgsEvent::Msgs(msgs));
publish<SendOrderMsgsEvent>(me->send_ordermsgs_pub, copy, corid);
}
OnExeReport& GatewayProxy::on_exe_report()
{
bts_assert_msg(false, "GatewayProxy");
return me->on_exe_report;
}
OnGwStatusChange& GatewayProxy::on_gw_status_change()
{
bts_assert_msg(false, "GatewayProxy");
return me->on_gw_status_change;
}
OnCancelReject& GatewayProxy::on_cancel_reject()
{
bts_assert_msg(false, "GatewayProxy");
return me->on_cancel_reject;
}
}}