fix: Report internal reject msgs to ExecutionReport
For Binance execution gateways (spots and usds futures)
This commit is contained in:
1 parent
01e90c2497
commit
24f0eef2eb
2 files changed
+32
-28
No files matched your search
@@ -288,16 +288,16 @@ struct ExecutionGateway::PImpl {
|
||||
res.ok() ? bts::Info : bts::Error, "create_order",
|
||||
"{} {} {} @ {} (id={}, type={}, tif={}, err={})", m.side, m.quantity,
|
||||
sec_desc, m.price, m.key, m.order_type, m.time_in_force, res.error);
|
||||
CreateOrderRequest req;
|
||||
req.newClientOrderId = std::to_string(m.key.value());
|
||||
req.symbol = bts::securities::descriptor(*m.security);
|
||||
req.side = m.side == bts::api::SIDE_BUY ? Side::BUY : Side::SELL;
|
||||
req.price = m.price.value();
|
||||
req.quantity = m.quantity.full_value();
|
||||
req.type = convert_order_type(m.order_type);
|
||||
req.timeInForce = convert_time_in_force(m.time_in_force);
|
||||
req.timestamp = convert_time_stamp(bts::core::TimeStamp::now());
|
||||
if (res.ok()) {
|
||||
CreateOrderRequest req;
|
||||
req.newClientOrderId = std::to_string(m.key.value());
|
||||
req.symbol = bts::securities::descriptor(*m.security);
|
||||
req.side = m.side == bts::api::SIDE_BUY ? Side::BUY : Side::SELL;
|
||||
req.price = m.price.value();
|
||||
req.quantity = m.quantity.full_value();
|
||||
req.type = convert_order_type(m.order_type);
|
||||
req.timeInForce = convert_time_in_force(m.time_in_force);
|
||||
req.timestamp = convert_time_stamp(bts::core::TimeStamp::now());
|
||||
res = rest_api_client.create_order(req);
|
||||
LOG_FN(
|
||||
res.ok() ? bts::Info : bts::Error, "create_order", "id={}; {}",
|
||||
@@ -478,7 +478,7 @@ void ExecutionGateway::dispatch_incoming_fix_messages() {
|
||||
{
|
||||
RestApiResult<OrderRecord> curr;
|
||||
while (me_->incoming_new_orders.pop(curr)) {
|
||||
if (!curr.ok() || !curr.response) {
|
||||
if (!curr.response) {
|
||||
ERROR_FN(
|
||||
"dispatch_incoming_fix_messages",
|
||||
"Failed to generate exe report due to invalid REST response. "
|
||||
@@ -518,14 +518,16 @@ void ExecutionGateway::dispatch_incoming_fix_messages() {
|
||||
}
|
||||
er.security = me_->sec_oracle.get_security(
|
||||
VENUE, bts::api::SECURITYTYPE_SPOT, curr.response->symbol);
|
||||
string error;
|
||||
if (!validate(er, error)) {
|
||||
er.msg = curr.error;
|
||||
if (!validate(er, er.msg)) {
|
||||
ERROR_FN(
|
||||
"dispatch_incoming_fix_messages",
|
||||
"Generated invalid ExecutionReport. {}", error);
|
||||
"Generated invalid ExecutionReport. {}", er.msg);
|
||||
continue;
|
||||
}
|
||||
if (!IGNORE_CREATE_ORDER_RESPONSE) {
|
||||
// Always propagate ExecutionReport if there are errors
|
||||
const bool has_error = !er.msg.empty();
|
||||
if (!IGNORE_CREATE_ORDER_RESPONSE || has_error) {
|
||||
INFO_FN(
|
||||
"dispatch_incoming_fix_messages",
|
||||
"Dispatching ExecutionReport. bts_id: {}, exch_id: {}",
|
||||
|
||||
@@ -273,16 +273,16 @@ struct ExecutionGateway::PImpl {
|
||||
res.ok() ? bts::Info : bts::Error, "create_order",
|
||||
"{} {} {} @ {} (id={}, type={}, tif={}, err={})", m.side, m.quantity,
|
||||
sec_desc, m.price, m.key, m.order_type, m.time_in_force, res.error);
|
||||
CreateOrderRequest req;
|
||||
req.newClientOrderId = std::to_string(m.key.value());
|
||||
req.symbol = bts::securities::descriptor(*m.security);
|
||||
req.side = m.side == bts::api::SIDE_BUY ? Side::BUY : Side::SELL;
|
||||
req.price = m.price.value();
|
||||
req.quantity = m.quantity.full_value();
|
||||
req.type = convert_order_type(m.order_type);
|
||||
req.timeInForce = convert_time_in_force(m.time_in_force);
|
||||
req.timestamp = convert_time_stamp(bts::core::TimeStamp::now());
|
||||
if (res.ok()) {
|
||||
CreateOrderRequest req;
|
||||
req.newClientOrderId = std::to_string(m.key.value());
|
||||
req.symbol = bts::securities::descriptor(*m.security);
|
||||
req.side = m.side == bts::api::SIDE_BUY ? Side::BUY : Side::SELL;
|
||||
req.price = m.price.value();
|
||||
req.quantity = m.quantity.full_value();
|
||||
req.type = convert_order_type(m.order_type);
|
||||
req.timeInForce = convert_time_in_force(m.time_in_force);
|
||||
req.timestamp = convert_time_stamp(bts::core::TimeStamp::now());
|
||||
res = rest_api_client.create_order(req);
|
||||
LOG_FN(
|
||||
res.ok() ? bts::Info : bts::Error, "create_order", "id={}; {}",
|
||||
@@ -452,7 +452,7 @@ void ExecutionGateway::dispatch_incoming_fix_messages() {
|
||||
{
|
||||
RestApiResult<CreateOrderResponse> r;
|
||||
while (me_->callbacks.exe_report && me_->incoming_new_orders.pop(r)) {
|
||||
if (!r.ok() || !r.response) {
|
||||
if (!r.response) {
|
||||
ERROR_FN(
|
||||
"dispatch_incoming_fix_messages",
|
||||
"Cannot generate exe report from BinanceCreateOrderResult. {}",
|
||||
@@ -470,14 +470,16 @@ void ExecutionGateway::dispatch_incoming_fix_messages() {
|
||||
continue;
|
||||
}
|
||||
er.security = me_->sec_oracle.get_security(VENUE, r.response->symbol);
|
||||
string error;
|
||||
if (!validate(er, error)) {
|
||||
er.msg = r.error;
|
||||
if (!validate(er, er.msg)) {
|
||||
ERROR_FN(
|
||||
"dispatch_incoming_fix_messages",
|
||||
"Generated invalid ExecutionReport. {}", error);
|
||||
"Generated invalid ExecutionReport. {}", er.msg);
|
||||
continue;
|
||||
}
|
||||
if (!IGNORE_CREATE_ORDER_RESPONSE) {
|
||||
// Always propagate ExecutionReport if there are errors
|
||||
const bool has_error = !er.msg.empty();
|
||||
if (!IGNORE_CREATE_ORDER_RESPONSE || has_error) {
|
||||
me_->callbacks.exe_report(
|
||||
std::make_shared<bts::orderman::ExecutionReport>(std::move(er)),
|
||||
{});
|
||||
|
||||
Reference in new issue
Block a user