about to send a login message
This commit is contained in:
1 parent
a44d3a2c26
commit
5591c8316d
8 files changed
+64
-47
No files matched your search
@@ -45,8 +45,10 @@ JetFIX {
|
||||
platform: ICE
|
||||
use_cme_secure_logon: false
|
||||
|
||||
socket_connect_host_ip: "63.247.113.154"
|
||||
socket_connect_port: 443 #80
|
||||
#socket_connect_host_ip: "63.247.113.154"
|
||||
#socket_connect_port: 443 #80
|
||||
socket_connect_host_ip: "127.0.0.1"
|
||||
socket_connect_port: 800
|
||||
sender_compid: "51239"
|
||||
target_compid: "ICE"
|
||||
|
||||
|
||||
+19
-19
@@ -1,4 +1,4 @@
|
||||
#include "ExecutionGateway.h"
|
||||
#include "GLBXExecutionGateway.h"
|
||||
#include "lib/jetfix/codec/MessageDefinitions.h"
|
||||
#include "lib/jetfix/common/OutFIX.h"
|
||||
#include "lib/jetfix/gateway/JetFIXGateway.h"
|
||||
@@ -23,7 +23,7 @@ using JFGw =
|
||||
JetFIXGateway<fix::ExecutionReportMsg, fix::BusinessMessageRejectMsg,
|
||||
fix::RejectMsg, fix::CancelRejectMsg>;
|
||||
|
||||
struct ExecutionGateway::PImpl {
|
||||
struct GLBXExecutionGateway::PImpl {
|
||||
PImpl(config::JetFIX::Connection const &cfg, trace::PerfLog &l)
|
||||
: gw(cfg, l), exe_report_pool(), state(State::WAITING_FOR_SECURITIES),
|
||||
securities(), securities_by_descriptor(), gw_name(cfg.name()),
|
||||
@@ -43,16 +43,16 @@ struct ExecutionGateway::PImpl {
|
||||
trace::PerfLog &perf_log;
|
||||
};
|
||||
|
||||
ExecutionGateway::ExecutionGateway(config::JetFIX::Connection const &cfg,
|
||||
GLBXExecutionGateway::GLBXExecutionGateway(config::JetFIX::Connection const &cfg,
|
||||
trace::PerfLog &log)
|
||||
: me(new PImpl(cfg, log)) {
|
||||
me->state = State::WAITING_FOR_SECURITIES;
|
||||
}
|
||||
ExecutionGateway::~ExecutionGateway() {}
|
||||
GLBXExecutionGateway::~GLBXExecutionGateway() {}
|
||||
|
||||
void ExecutionGateway::on_admin_data(const mercury::Update<NewAdminDataEvent> &) {}
|
||||
void GLBXExecutionGateway::on_admin_data(const mercury::Update<NewAdminDataEvent> &) {}
|
||||
|
||||
void ExecutionGateway::on_securities(
|
||||
void GLBXExecutionGateway::on_securities(
|
||||
const mercury::Update<NewSecuritiesEvent> &update) {
|
||||
if (update.events) {
|
||||
|
||||
@@ -95,25 +95,25 @@ void ExecutionGateway::on_securities(
|
||||
}
|
||||
}
|
||||
|
||||
void ExecutionGateway::start() { me->gw.start(); }
|
||||
void GLBXExecutionGateway::start() { me->gw.start(); }
|
||||
|
||||
OnExeReport &ExecutionGateway::on_exe_report() { return me->on_exe_report; }
|
||||
OnExeReport &GLBXExecutionGateway::on_exe_report() { return me->on_exe_report; }
|
||||
|
||||
OnGwStatusChange &ExecutionGateway::on_gw_status_change() {
|
||||
OnGwStatusChange &GLBXExecutionGateway::on_gw_status_change() {
|
||||
return me->on_gw_status_change;
|
||||
}
|
||||
|
||||
OnCancelReject &ExecutionGateway::on_cancel_reject() {
|
||||
OnCancelReject &GLBXExecutionGateway::on_cancel_reject() {
|
||||
return me->on_cancel_reject;
|
||||
}
|
||||
|
||||
void ExecutionGateway::on_exe_report(
|
||||
void GLBXExecutionGateway::on_exe_report(
|
||||
const jetfix::fix::ExecutionReportMsg &msg) {
|
||||
OrderKey ok;
|
||||
SecurityKey sk;
|
||||
decode_clorid(msg.get<fix::ClOrdID>(), &ok, &sk);
|
||||
|
||||
auto scoped_log = trace::log_scope(me->perf_log, msg.trace(), "ExecutionGateway::on_exe_report", ok.value());
|
||||
auto scoped_log = trace::log_scope(me->perf_log, msg.trace(), "GLBXExecutionGateway::on_exe_report", ok.value());
|
||||
|
||||
LOG(Latency, Info, "Started handling of execution report for order {}",
|
||||
ok.value());
|
||||
@@ -254,7 +254,7 @@ void ExecutionGateway::on_exe_report(
|
||||
}
|
||||
}
|
||||
|
||||
void ExecutionGateway::on_cancel_reject(
|
||||
void GLBXExecutionGateway::on_cancel_reject(
|
||||
const jetfix::fix::CancelRejectMsg &msg) {
|
||||
OrderKey ok;
|
||||
SecurityKey sk;
|
||||
@@ -269,7 +269,7 @@ void ExecutionGateway::on_cancel_reject(
|
||||
me->on_cancel_reject(ok, reject_msg);
|
||||
}
|
||||
|
||||
void ExecutionGateway::on_connection_status_change(bool is_connected) {
|
||||
void GLBXExecutionGateway::on_connection_status_change(bool is_connected) {
|
||||
LOG(OrderMan, Info, "Connection state of {} changed to {}",
|
||||
me->gw_name.value(),
|
||||
is_connected ? std::string("connected") : std::string("disconnected"));
|
||||
@@ -277,7 +277,7 @@ void ExecutionGateway::on_connection_status_change(bool is_connected) {
|
||||
me->on_gw_status_change(is_connected);
|
||||
}
|
||||
|
||||
void ExecutionGateway::on_business_reject(
|
||||
void GLBXExecutionGateway::on_business_reject(
|
||||
jetfix::fix::BusinessMessageRejectMsg const &m) {
|
||||
LOG(OrderMan, Error,
|
||||
"Unexpected business reject in {} gateway . Reason: "
|
||||
@@ -286,7 +286,7 @@ void ExecutionGateway::on_business_reject(
|
||||
m.has<fix::Text>() ? m.get<fix::Text>() : std::string("Unknown"));
|
||||
}
|
||||
|
||||
void ExecutionGateway::on_session_reject(jetfix::fix::RejectMsg const &m) {
|
||||
void GLBXExecutionGateway::on_session_reject(jetfix::fix::RejectMsg const &m) {
|
||||
LOG(OrderMan, Error,
|
||||
"Unexpected reject message in {} gateway . Reason: {}. "
|
||||
"This should be investigated",
|
||||
@@ -294,13 +294,13 @@ void ExecutionGateway::on_session_reject(jetfix::fix::RejectMsg const &m) {
|
||||
m.has<fix::Text>() ? m.get<fix::Text>() : std::string("Unknown"));
|
||||
}
|
||||
|
||||
void ExecutionGateway::dispatch_incoming_fix_messages() {
|
||||
void GLBXExecutionGateway::dispatch_incoming_fix_messages() {
|
||||
me->gw.dispatch_events();
|
||||
}
|
||||
|
||||
void ExecutionGateway::send_fix(jetfix::OutFIXPtr const &fix,
|
||||
void GLBXExecutionGateway::send_fix(jetfix::OutFIXPtr const &fix,
|
||||
trace::CorID trace) {
|
||||
auto scoped_log = trace::log_scope(me->perf_log,trace,"ExecutionGateway::send_fix");
|
||||
auto scoped_log = trace::log_scope(me->perf_log,trace,"GLBXExecutionGateway::send_fix");
|
||||
me->gw.send(fix,trace);
|
||||
me->gw.dispatch_events();
|
||||
}
|
||||
+4
-4
@@ -7,10 +7,10 @@ namespace orderman {
|
||||
|
||||
|
||||
// fix execution gateway for a single FIX session
|
||||
class ExecutionGateway : public IExecutionGateway {
|
||||
class GLBXExecutionGateway : public IExecutionGateway {
|
||||
public:
|
||||
ExecutionGateway(config::JetFIX::Connection const &, trace::PerfLog &);
|
||||
virtual ~ExecutionGateway();
|
||||
GLBXExecutionGateway(config::JetFIX::Connection const &, trace::PerfLog &);
|
||||
virtual ~GLBXExecutionGateway();
|
||||
|
||||
void start() override;
|
||||
void dispatch_incoming_fix_messages() override;
|
||||
@@ -23,7 +23,7 @@ class ExecutionGateway : public IExecutionGateway {
|
||||
OnCancelReject &on_cancel_reject() override;
|
||||
|
||||
private:
|
||||
BTS_NO_COPY(ExecutionGateway);
|
||||
BTS_NO_COPY(GLBXExecutionGateway);
|
||||
enum class State { WAITING_FOR_SECURITIES, READY };
|
||||
struct PImpl;
|
||||
std::unique_ptr<PImpl> me;
|
||||
@@ -127,6 +127,9 @@ void ICEExecutionGateway::on_trader_login_timeout_expired()
|
||||
buffer.add<fix::UserName>(ice.authorized_trader());
|
||||
buffer.add<fix::RawData>(ice.password());
|
||||
//TODO MIFID Defaults
|
||||
|
||||
trace::CorID trace;
|
||||
send_fix(result, trace);
|
||||
}
|
||||
}
|
||||
LOG(OrderMan, Warn, "{} traders identified as ICE traders {}", nusers, me->gw_name.value());
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
#include "IExecutionGateway.h"
|
||||
#include "ICEExecutionGateway.h"
|
||||
#include "ExecutionGateway.h"
|
||||
#include "GLBXExecutionGateway.h"
|
||||
|
||||
namespace bts {
|
||||
namespace orderman {
|
||||
@@ -13,7 +13,7 @@ ExecutionGatewayFactory::create_gateway(const config::JetFIX::Connection& conn,
|
||||
conn.platform() == bts::config::JetFIX_Connection_JetFIXPlatform_SIMICE)
|
||||
return std::make_unique<ICEExecutionGateway>(conn, pl);
|
||||
else
|
||||
return std::make_unique<ExecutionGateway>(conn, pl);
|
||||
return std::make_unique<GLBXExecutionGateway>(conn, pl);
|
||||
}
|
||||
|
||||
} // namespace orderman
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
#include "lib/mercury/events/TimerEvent.h"
|
||||
#include "lib/md/SecurityOracle.h"
|
||||
#include "lib/orderman/actors/ExecutionGateway.h"
|
||||
#include "lib/orderman/actors/IExecutionGateway.h"
|
||||
#include "lib/orderman/events/ActivateOrderEvent.h"
|
||||
#include "lib/orderman/events/BookUpdateEvent.h"
|
||||
#include "lib/orderman/events/TickerUpdateEvent.h"
|
||||
|
||||
@@ -51,6 +51,7 @@ struct ICENativeOrder::PImpl
|
||||
jetfix::FIXFragment::Bookmark<jetfix::fix::Price> update_price_bm;
|
||||
jetfix::FIXFragment::Bookmark<jetfix::fix::OrderQty> update_quantity_bm;
|
||||
jetfix::FIXFragment::Bookmark<jetfix::fix::TransactTimeStr> update_transact_time_bm;
|
||||
jetfix::FIXFragment::Bookmark<jetfix::fix::Int_ClOrdID> update_clordid_bm;
|
||||
|
||||
jetfix::FIXFragment create_encoding;
|
||||
jetfix::FIXFragment::Bookmark<jetfix::fix::Price> create_price_bm;
|
||||
@@ -58,7 +59,7 @@ struct ICENativeOrder::PImpl
|
||||
jetfix::FIXFragment::Bookmark<jetfix::fix::TransactTimeStr> create_transact_time_bm;
|
||||
|
||||
jetfix::FIXFragment cancel_encoding;
|
||||
//jetfix::FIXFragment::Bookmark<jetfix::fix::TransactTimeStr> cancel_transact_time_bm;
|
||||
jetfix::FIXFragment::Bookmark<jetfix::fix::Int_ClOrdID> cancel_clordid_bm;
|
||||
|
||||
OrderServices::ExeReportSubID exe_report_sid;
|
||||
OrderServices::CancelRejectSubID cancel_reject_sid;
|
||||
@@ -580,6 +581,9 @@ OrderOpResult ICENativeOrder::on_update(Price p, Quantity q)
|
||||
|
||||
auto const &ts = me->services->get_time_str();
|
||||
me->update_transact_time_bm = encoding.overwrite( me->update_transact_time_bm, &ts.value()[0], ts.value().size() );
|
||||
|
||||
static uint32_t update_id = 10000; //TODO Pedro please look
|
||||
me->update_clordid_bm = encoding.overwrite( me->update_clordid_bm, get_clordid(update_id++), ice_orderid_sz() );
|
||||
|
||||
me->services->queue_fix(*me->session_services,
|
||||
jetfix::MessageTypes::CancelReplace,
|
||||
@@ -685,10 +689,10 @@ OrderOpResult ICENativeOrder::on_cancel()
|
||||
{
|
||||
case ORDER_STATUS_WORKING:
|
||||
{
|
||||
//auto &encoding = me->cancel_encoding;
|
||||
//auto const &ts = me->services->get_time_str();
|
||||
//me->cancel_transact_time_bm = encoding.overwrite( me->cancel_transact_time_bm, &ts.value()[0], ts.value().size() );
|
||||
|
||||
auto &encoding = me->cancel_encoding;
|
||||
static uint32_t cancel_id = 0; //TODO Pedro please look
|
||||
me->cancel_clordid_bm = encoding.overwrite( me->cancel_clordid_bm, get_clordid(cancel_id++), ice_orderid_sz() );
|
||||
|
||||
me->services->queue_fix(*me->session_services,
|
||||
jetfix::MessageTypes::Cancel,
|
||||
me->cancel_encoding);
|
||||
@@ -970,6 +974,20 @@ void ICENativeOrder::report_state()
|
||||
me->services->report_state(me->state);
|
||||
}
|
||||
|
||||
int ICENativeOrder::get_clordid(uint32_t bts_id)
|
||||
{
|
||||
std::string orderid(ice_orderid_sz(), ' ');
|
||||
u32_toa(bts_id, &orderid[0]); // order id
|
||||
int totalsz = me->sender_comp_id.size() + orderid.size();
|
||||
if(totalsz < 9) //9 is min size
|
||||
orderid = std::string(9-totalsz, '0').append(orderid);
|
||||
else if(totalsz > 12) //12 is max
|
||||
orderid = orderid.substr(totalsz-12, orderid.size() - (totalsz-12));
|
||||
std::string combined_clorid = me->sender_comp_id + orderid;
|
||||
int id = std::atoi(combined_clorid.c_str());
|
||||
return id;
|
||||
}
|
||||
|
||||
void ICENativeOrder::init_fix()
|
||||
{
|
||||
bts_assert(me->sec);
|
||||
@@ -987,20 +1005,12 @@ void ICENativeOrder::init_fix()
|
||||
std::string memo(memo_sz(), ' ');
|
||||
encode_memo(key(), SecurityKey(sec.id()), &memo);
|
||||
|
||||
std::string orderid(ice_orderid_sz(), ' ');
|
||||
u32_toa(key().value(), &orderid[0]); // order id
|
||||
int totalsz = me->sender_comp_id.size() + orderid.size();
|
||||
if(totalsz < 9) //9 is min size
|
||||
orderid = std::string(9-totalsz, '0').append(orderid);
|
||||
else if(totalsz > 12) //12 is max
|
||||
orderid = orderid.substr(totalsz-12, orderid.size() - (totalsz-12));
|
||||
std::string combined_clorid = me->sender_comp_id + orderid;
|
||||
|
||||
int combined_clorid = get_clordid(key().value());
|
||||
// initialize create FIX
|
||||
auto &create_encoding = me->create_encoding;
|
||||
|
||||
create_encoding.add<fix::Memo>(memo);
|
||||
create_encoding.add<fix::Int_ClOrdID>(std::atoi(combined_clorid.c_str()));
|
||||
create_encoding.add<fix::Int_ClOrdID>(combined_clorid);
|
||||
create_encoding.add<fix::CompanyID>(std::atoi(rr.company_id().c_str()));
|
||||
//create_encoding.add<fix::OnBehalfOfCompID>(""); //optional, unclear if we need
|
||||
create_encoding.add<fix::SenderSubID>(rr.operator_id());
|
||||
@@ -1026,8 +1036,8 @@ void ICENativeOrder::init_fix()
|
||||
|
||||
// initialize update FIX
|
||||
auto &update_encoding = me->update_encoding;
|
||||
update_encoding.add<fix::Int_ClOrdID>(std::atoi(combined_clorid.c_str()));
|
||||
update_encoding.add<fix::Int_OrigClOrdID>(std::atoi(combined_clorid.c_str()));
|
||||
update_encoding.add<fix::Int_ClOrdID>(combined_clorid);
|
||||
update_encoding.add<fix::Int_OrigClOrdID>(combined_clorid);
|
||||
update_encoding.add<fix::CompanyID>(std::atoi(rr.company_id().c_str()));
|
||||
//update_encoding.add<fix::OnBehalfOfCompID>(""); //optional, unclear if we need
|
||||
update_encoding.add<fix::SenderSubID>(rr.operator_id());
|
||||
@@ -1054,8 +1064,8 @@ void ICENativeOrder::init_fix()
|
||||
|
||||
// initialize cancel FIX
|
||||
auto &cancel_encoding = me->cancel_encoding;
|
||||
cancel_encoding.add<fix::Int_ClOrdID>(std::atoi(combined_clorid.c_str()));
|
||||
cancel_encoding.add<fix::Int_OrigClOrdID>(std::atoi(combined_clorid.c_str()));
|
||||
cancel_encoding.add<fix::Int_ClOrdID>(combined_clorid);
|
||||
cancel_encoding.add<fix::Int_OrigClOrdID>(combined_clorid);
|
||||
cancel_encoding.add<fix::CompanyID>(std::atoi(rr.company_id().c_str()));
|
||||
cancel_encoding.add<fix::OriginatorUserID>(rr.authorized_trader());
|
||||
cancel_encoding.add<fix::Int_Symbol>(sec.ice().exchange_id());
|
||||
|
||||
@@ -66,6 +66,8 @@ class ICENativeOrder : public NativeOrder {
|
||||
bool terminal_state(api::orderman::OrderStatus status) const;
|
||||
api::orderman::NativeOrderState &
|
||||
get_native_state(api::orderman::OrderState &);
|
||||
|
||||
int get_clordid(uint32_t);
|
||||
};
|
||||
|
||||
} // namespace orderman
|
||||
|
||||
Reference in new issue
Block a user