Adding IOC to SimExecution
This commit is contained in:
1 parent
60362a4c95
commit
cb2b15f10b
1 file changed
+24
-5
@@ -14,6 +14,8 @@
|
||||
#include "lib/md/MDProducer.h"
|
||||
#include "lib/md/PriceSize.h"
|
||||
#include "lib/md/Shm/MDStructure.h"
|
||||
#include "lib/orderman/CancelOrderMsg.h"
|
||||
#include "lib/orderman/CreateOrderMsg.h"
|
||||
#include "lib/orderman/OrderMsg.h"
|
||||
#include "lib/orderman/events/NewAdminDataEvent.h"
|
||||
#include "lib/orderman/events/NewSecuritiesEvent.h"
|
||||
@@ -180,6 +182,10 @@ struct SEGOrderState {
|
||||
last_filled_qty = 0;
|
||||
last_filled_price = Price(os::nan());
|
||||
}
|
||||
bool is_ioc() const {
|
||||
return crt_msg.time_in_force ==
|
||||
api::orderman::TimeInForce::TIME_IN_FORCE_IOC;
|
||||
}
|
||||
};
|
||||
|
||||
struct SEGTradeEntry {
|
||||
@@ -226,8 +232,10 @@ struct SEGSecurityData {
|
||||
const CancelReplaceOrderMsg &cxlr_msg =
|
||||
std::get<CancelReplaceOrderMsg>(msg);
|
||||
SEGOrderState *seg_os = find_order(cxlr_msg.create_fields.key);
|
||||
if(seg_os == nullptr){
|
||||
LOG(OrderMan, Info, "SimExecutionGateway::apply_order_action tried updating unkown order");
|
||||
if (seg_os == nullptr) {
|
||||
LOG(OrderMan, Info,
|
||||
"SimExecutionGateway::apply_order_action tried updating unkown "
|
||||
"order");
|
||||
return {ActionResult::NoOp, nullptr};
|
||||
}
|
||||
auto action_result = seg_os->apply_change(cxlr_msg);
|
||||
@@ -235,8 +243,10 @@ struct SEGSecurityData {
|
||||
} else if (std::holds_alternative<CancelOrderMsg>(msg)) {
|
||||
const CancelOrderMsg &cxl_msg = std::get<CancelOrderMsg>(msg);
|
||||
SEGOrderState *seg_os = find_order(cxl_msg.key);
|
||||
if(seg_os == nullptr){
|
||||
LOG(OrderMan, Info, "SimExecutionGateway::apply_order_action tried canceling unkown order");
|
||||
if (seg_os == nullptr) {
|
||||
LOG(OrderMan, Info,
|
||||
"SimExecutionGateway::apply_order_action tried canceling "
|
||||
"unkown order");
|
||||
return {ActionResult::NoOp, nullptr};
|
||||
}
|
||||
auto action_result = seg_os->apply_cxl(cxl_msg);
|
||||
@@ -578,6 +588,14 @@ bts::orderman::Book SimExecutionGateway::_match_order(
|
||||
if (crosses_opp_side) {
|
||||
return _cross_order(book, seg_os);
|
||||
} else {
|
||||
if (seg_os.is_ioc()) {
|
||||
CancelOrderMsg cxl_msg;
|
||||
cxl_msg.key = seg_os.ord_key();
|
||||
seg_os.apply_cxl(cxl_msg);
|
||||
_push_execution_report(seg_os);
|
||||
// generate cancel execution report
|
||||
return book;
|
||||
}
|
||||
return _work_order(book, seg_os);
|
||||
}
|
||||
}
|
||||
@@ -651,7 +669,8 @@ SEGSecurityData *SimExecutionGateway::_find_add_security_entry(
|
||||
void SimExecutionGateway::_push_execution_report(const SEGOrderState &seg_os) {
|
||||
ExecutionReport er;
|
||||
fill_execution_report(seg_os, er);
|
||||
me->buffered_exec_reps.push(std::make_shared<ExecutionReport>(std::move(er)));
|
||||
me->buffered_exec_reps.push(
|
||||
std::make_shared<ExecutionReport>(std::move(er)));
|
||||
}
|
||||
|
||||
void SimExecutionGateway::_write_book(SecurityKey key) {
|
||||
|
||||
Reference in new issue
Block a user