Refactor security.
This commit is contained in:
1 parent
edbb80fd82
commit
be1eb00d7d
10 files changed
+152
-166
No files matched your search
@@ -2,108 +2,94 @@ syntax='proto3' ;
|
||||
package bts.orderman ;
|
||||
import "lib/domain_model/Security.proto";
|
||||
|
||||
message OrderStatus
|
||||
enum OrderStatus
|
||||
{
|
||||
enum Type {
|
||||
UNACKNOWLEDGED = 0 ;
|
||||
NEW = 48 ;
|
||||
PARTIALLY_FILLED = 49 ;
|
||||
FILLED = 50 ;
|
||||
DONE = 51 ;
|
||||
CANCELED = 52 ;
|
||||
REPLACED = 53 ;
|
||||
PENDING_CANCEL = 54 ;
|
||||
STOPPED = 55 ;
|
||||
REJECTED = 56 ;
|
||||
SUSPENDED = 57 ;
|
||||
PENDING_NEW = 65 ;
|
||||
CALCULATED = 66 ;
|
||||
EXPIRED = 67 ;
|
||||
ACCEPTED_FOR_BIDDING = 68 ;
|
||||
PENDING_REPLACE = 69 ;
|
||||
CANCEL_ACK = 72 ;
|
||||
UNDEFINED = 85 ;
|
||||
ORDER_NOT_FOUND = 89 ;
|
||||
}
|
||||
OS_UNACKNOWLEDGED = 0 ;
|
||||
OS_NEW = 48 ;
|
||||
OS_PARTIALLY_FILLED = 49 ;
|
||||
OS_FILLED = 50 ;
|
||||
OS_DONE = 51 ;
|
||||
OS_CANCELED = 52 ;
|
||||
OS_REPLACED = 53 ;
|
||||
OS_PENDING_CANCEL = 54 ;
|
||||
OS_STOPPED = 55 ;
|
||||
OS_REJECTED = 56 ;
|
||||
OS_SUSPENDED = 57 ;
|
||||
OS_PENDING_NEW = 65 ;
|
||||
OS_CALCULATED = 66 ;
|
||||
OS_EXPIRED = 67 ;
|
||||
OS_ACCEPTED_FOR_BIDDING = 68 ;
|
||||
OS_PENDING_REPLACE = 69 ;
|
||||
OS_CANCEL_ACK = 72 ;
|
||||
OS_UNDEFINED = 85 ;
|
||||
OS_ORDER_NOT_FOUND = 89 ;
|
||||
}
|
||||
|
||||
message TimeInForce
|
||||
enum TimeInForce
|
||||
{
|
||||
enum Type {
|
||||
UNDEFINED = 0 ;
|
||||
DAY = 48 ;
|
||||
GTC = 49 ;
|
||||
OPG = 50 ;
|
||||
IOC = 51 ;
|
||||
}
|
||||
TIF_UNDEFINED = 0 ;
|
||||
TIF_DAY = 48 ;
|
||||
TIF_GTC = 49 ;
|
||||
TIF_OPG = 50 ;
|
||||
TIF_IOC = 51 ;
|
||||
}
|
||||
|
||||
message CustomerOrFirm
|
||||
enum CustomerOrFirm
|
||||
{
|
||||
enum Type {
|
||||
CUSTOMER = 0;
|
||||
FIRM = 1;
|
||||
UNDEFINED = 2;
|
||||
}
|
||||
COF_CUSTOMER = 0 ;
|
||||
COF_FIRM = 1 ;
|
||||
COF_UNDEFINED = 2 ;
|
||||
}
|
||||
|
||||
message OrderType
|
||||
enum OrderType
|
||||
{
|
||||
enum Type {
|
||||
UNDEFINED = 0 ;
|
||||
MARKET = 49 ; // 1
|
||||
LIMIT = 50 ; // 2
|
||||
STOP = 51 ; // 3
|
||||
STOP_LIMIT = 52 ; // 4
|
||||
MARKET_LIMIT = 75 ; // K
|
||||
}
|
||||
OT_UNDEFINED = 0 ;
|
||||
OT_MARKET = 49 ; // 1
|
||||
OT_LIMIT = 50 ; // 2
|
||||
OT_STOP = 51 ; // 3
|
||||
OT_STOP_LIMIT = 52 ; // 4
|
||||
OT_MARKET_LIMIT = 75 ; // K
|
||||
}
|
||||
|
||||
message OrderError
|
||||
enum OrderError
|
||||
{
|
||||
enum Type {
|
||||
OK = 0 ;
|
||||
UNSUPPORTED_ORDER_TYPE = 1;
|
||||
VENUE_NOT_READY = 2;
|
||||
DUPLICATE_ORDER = 4;
|
||||
UNKNOWN_ORDER = 5;
|
||||
UNKNOWN_SECURITY = 6;
|
||||
ORDER_NOT_ACK = 7;
|
||||
}
|
||||
OE_OK = 0 ;
|
||||
OE_UNSUPPORTED_ORDER_TYPE = 1 ;
|
||||
OE_VENUE_NOT_READY = 2 ;
|
||||
OE_DUPLICATE_ORDER = 4 ;
|
||||
OE_UNKNOWN_ORDER = 5 ;
|
||||
OE_UNKNOWN_SECURITY = 6 ;
|
||||
OE_ORDER_NOT_ACK = 7 ;
|
||||
}
|
||||
|
||||
message CTICode
|
||||
enum CTICode
|
||||
{
|
||||
enum Type {
|
||||
UNDEFINED = 0 ;
|
||||
CTI1 = 49 ;
|
||||
CTI2 = 50 ;
|
||||
CTI3 = 51 ;
|
||||
CTI4 = 52 ;
|
||||
}
|
||||
CTI_UNDEFINED = 0 ;
|
||||
CTI_CTI1 = 49 ;
|
||||
CTI_CTI2 = 50 ;
|
||||
CTI_CTI3 = 51 ;
|
||||
CTI_CTI4 = 52 ;
|
||||
}
|
||||
|
||||
message ExecType
|
||||
enum ExecType
|
||||
{
|
||||
enum Type {
|
||||
UNDEFINED = 0 ;
|
||||
NEW = 48 ;
|
||||
PARTIAL_FILL = 49 ;
|
||||
FILL = 50 ;
|
||||
DONE = 51 ;
|
||||
CANCELED = 52 ;
|
||||
REPLACED = 53 ;
|
||||
PENDING_CANCEL = 54 ;
|
||||
STOPPED = 55 ;
|
||||
REJECTED = 56 ;
|
||||
SUSPENDED = 57 ;
|
||||
PENDING_NEW = 65 ;
|
||||
CALCULATED = 66 ;
|
||||
EXPIRED = 67 ;
|
||||
RESTATED = 68 ;
|
||||
PENDING_REPLACE = 69 ;
|
||||
CANCEL_ACK = 72 ;
|
||||
}
|
||||
ET_UNDEFINED = 0 ;
|
||||
ET_NEW = 48 ;
|
||||
ET_PARTIAL_FILL = 49 ;
|
||||
ET_FILL = 50 ;
|
||||
ET_DONE = 51 ;
|
||||
ET_CANCELED = 52 ;
|
||||
ET_REPLACED = 53 ;
|
||||
ET_PENDING_CANCEL = 54 ;
|
||||
ET_STOPPED = 55 ;
|
||||
ET_REJECTED = 56 ;
|
||||
ET_SUSPENDED = 57 ;
|
||||
ET_PENDING_NEW = 65 ;
|
||||
ET_CALCULATED = 66 ;
|
||||
ET_EXPIRED = 67 ;
|
||||
ET_RESTATED = 68 ;
|
||||
ET_PENDING_REPLACE = 69 ;
|
||||
ET_CANCEL_ACK = 72 ;
|
||||
}
|
||||
|
||||
message OrderStatePB {
|
||||
@@ -114,12 +100,12 @@ message OrderStatePB {
|
||||
uint32 security_key = 4;
|
||||
|
||||
api.BuySell side = 5;
|
||||
TimeInForce.Type time_in_force = 6;
|
||||
OrderType.Type order_type = 20;
|
||||
TimeInForce time_in_force = 6;
|
||||
OrderType order_type = 20;
|
||||
|
||||
// Immutable once available, might not always be available
|
||||
CustomerOrFirm.Type customer_or_firm = 7;
|
||||
CTICode.Type cti_code = 8;
|
||||
CustomerOrFirm customer_or_firm = 7;
|
||||
CTICode cti_code = 8;
|
||||
string user_login = 9;
|
||||
string exchange_order_id = 10;
|
||||
|
||||
@@ -127,10 +113,10 @@ message OrderStatePB {
|
||||
bool manual_order_indicator = 11;
|
||||
double price = 12;
|
||||
uint32 quantity = 13;
|
||||
OrderStatus.Type status= 14;
|
||||
OrderStatus status= 14;
|
||||
double avg_fill_price = 15;
|
||||
uint32 filled_quantity=16;
|
||||
uint32 remaining_quantity=17;
|
||||
string reject_msg=18;
|
||||
string transact_time=19;
|
||||
}
|
||||
}
|
||||
@@ -68,10 +68,10 @@ orderman::OrderCreate make_order_create(orderman::OrderStore &store,
|
||||
store.generate_order_keys(1),
|
||||
orderman::SecurityKey(1),
|
||||
side,
|
||||
orderman::TimeInForce::DAY,
|
||||
orderman::OrderType::LIMIT,
|
||||
orderman::CustomerOrFirm::FIRM,
|
||||
orderman::CTICode::CTI1,
|
||||
orderman::TIF_DAY,
|
||||
orderman::OT_LIMIT,
|
||||
orderman::COF_FIRM,
|
||||
orderman::CTI_CTI1,
|
||||
orderman::UserLogin("BTS"),
|
||||
orderman::ManualOrderIndicator(true),
|
||||
price,
|
||||
@@ -92,8 +92,8 @@ orderman::OrderUpdate make_order_update(orderman::OrderKey order_key,
|
||||
sec,
|
||||
order_key,
|
||||
orderman::SecurityKey(1),
|
||||
orderman::CustomerOrFirm::FIRM,
|
||||
orderman::CTICode::CTI1,
|
||||
orderman::COF_FIRM,
|
||||
orderman::CTI_CTI1,
|
||||
orderman::UserLogin("BTS"),
|
||||
orderman::ManualOrderIndicator(true),
|
||||
price,
|
||||
@@ -112,8 +112,8 @@ orderman::OrderCancel make_order_cancel(orderman::OrderKey order_key)
|
||||
sec,
|
||||
order_key,
|
||||
orderman::SecurityKey(1),
|
||||
orderman::CustomerOrFirm::FIRM,
|
||||
orderman::CTICode::CTI1,
|
||||
orderman::COF_FIRM,
|
||||
orderman::CTI_CTI1,
|
||||
orderman::UserLogin("BTS"),
|
||||
orderman::ManualOrderIndicator(true),
|
||||
get_ts()
|
||||
|
||||
@@ -11,8 +11,8 @@ public:
|
||||
const api::Security *security;
|
||||
OrderKey order_key;
|
||||
SecurityKey security_key;
|
||||
CustomerOrFirm::Type customer_or_firm;
|
||||
CTICode::Type cti_code;
|
||||
CustomerOrFirm customer_or_firm;
|
||||
CTICode cti_code;
|
||||
UserLogin user_login;
|
||||
ManualOrderIndicator manual_order_indicator;
|
||||
OrderTimeStamp transact_time;
|
||||
|
||||
@@ -20,10 +20,10 @@ public:
|
||||
OrderKey order_key;
|
||||
SecurityKey security_key;
|
||||
api::BuySell side;
|
||||
TimeInForce::Type time_in_force;
|
||||
OrderType::Type order_type;
|
||||
CustomerOrFirm::Type customer_or_firm;
|
||||
CTICode::Type cti_code;
|
||||
TimeInForce time_in_force;
|
||||
OrderType order_type;
|
||||
CustomerOrFirm customer_or_firm;
|
||||
CTICode cti_code;
|
||||
UserLogin user_login;
|
||||
ManualOrderIndicator manual_order_indicator;
|
||||
OrderPrice price;
|
||||
|
||||
@@ -53,40 +53,40 @@ OrderMan::~OrderMan () {}
|
||||
OrderMan::CreateResult OrderMan::create_order(OrderCreate const &create)
|
||||
{
|
||||
LOG(OrderMan,Diag, "create_order: {}", create.order_key.value());
|
||||
if (create.order_type != OrderType::LIMIT) {
|
||||
if (create.order_type != OT_LIMIT) {
|
||||
LOG(OrderMan,Warn,
|
||||
"Cannot create order: {} on venue {} because its order type {}"
|
||||
" is unsupported",
|
||||
create.order_key.value(),
|
||||
me->gw.name(),
|
||||
create.order_type);
|
||||
return CreateResult { OrderError::UNSUPPORTED_ORDER_TYPE};
|
||||
return CreateResult { OE_UNSUPPORTED_ORDER_TYPE};
|
||||
}
|
||||
|
||||
if (me->state != State::READY) {
|
||||
LOG(OrderMan,Info,
|
||||
"Cannot create order: {} because venue {} is not ready",
|
||||
create.order_key.value(),me->gw.name());
|
||||
return CreateResult { OrderError::VENUE_NOT_READY};
|
||||
return CreateResult { OE_VENUE_NOT_READY};
|
||||
}
|
||||
|
||||
if (me->order_map.find(create.order_key) != me->order_map.end()) {
|
||||
LOG(OrderMan,Error,
|
||||
"Cannot create order: {} on venue {}. There is already an order with that ID.",
|
||||
create.order_key.value(),me->gw.name());
|
||||
return CreateResult { OrderError::DUPLICATE_ORDER};
|
||||
return CreateResult { OE_DUPLICATE_ORDER};
|
||||
}
|
||||
|
||||
auto ord = std::make_unique<WorkingOrder> (create);
|
||||
auto fix_buffer = me->gw.make_outfix_buffer();
|
||||
auto error = ord->encode_create(create,&fix_buffer->fix[0]);
|
||||
if (error == OrderError::OK) {
|
||||
if (error == OE_OK) {
|
||||
fix_buffer->fix[0].close();
|
||||
me->gw.send(fix_buffer);
|
||||
auto ord_ptr = ord.get();
|
||||
me->order_map[create.order_key] = std::move(ord);
|
||||
me->order_observer.on_order_create(ord_ptr->state());
|
||||
return CreateResult {OrderError::OK};
|
||||
return CreateResult {OE_OK};
|
||||
}
|
||||
else {
|
||||
LOG(OrderMan,Warn,
|
||||
@@ -103,7 +103,7 @@ OrderMan::UpdateResult OrderMan::update_order(OrderUpdate const&update)
|
||||
LOG(OrderMan,Info,
|
||||
"Cannot update order: {} because venue {} is not ready",
|
||||
update.order_key.value(),me->gw.name());
|
||||
return UpdateResult {OrderError::VENUE_NOT_READY};
|
||||
return UpdateResult {OE_VENUE_NOT_READY};
|
||||
}
|
||||
|
||||
auto it = me->order_map.find(update.order_key);
|
||||
@@ -111,16 +111,16 @@ OrderMan::UpdateResult OrderMan::update_order(OrderUpdate const&update)
|
||||
LOG(OrderMan,Error,
|
||||
"Cannot update order: {} on venue {} because no such order exists",
|
||||
update.order_key.value(),me->gw.name());
|
||||
return UpdateResult {OrderError::UNKNOWN_ORDER};
|
||||
return UpdateResult {OE_UNKNOWN_ORDER};
|
||||
}
|
||||
|
||||
auto &o = it->second;
|
||||
auto fix_buffer = me->gw.make_outfix_buffer();
|
||||
auto error = o->encode_update(update,&fix_buffer->fix[0]);
|
||||
if (error == OrderError::OK) {
|
||||
if (error == OE_OK) {
|
||||
fix_buffer->fix[0].close();
|
||||
me->gw.send(fix_buffer);
|
||||
return UpdateResult {OrderError::OK};
|
||||
return UpdateResult {OE_OK};
|
||||
}
|
||||
else {
|
||||
LOG(OrderMan,Warn,
|
||||
@@ -137,7 +137,7 @@ OrderMan::CancelResult OrderMan::cancel_order(OrderCancel const &cancel)
|
||||
LOG(OrderMan,Info,
|
||||
"Cannot cancel order: {} because venue {} is not ready",
|
||||
cancel.order_key.value(),me->gw.name());
|
||||
return CancelResult {OrderError::VENUE_NOT_READY};
|
||||
return CancelResult {OE_VENUE_NOT_READY};
|
||||
}
|
||||
|
||||
auto it = me->order_map.find(cancel.order_key);
|
||||
@@ -145,16 +145,16 @@ OrderMan::CancelResult OrderMan::cancel_order(OrderCancel const &cancel)
|
||||
LOG(OrderMan,Error,
|
||||
"Cannot cancel order: {} on venue {} because no such order exists",
|
||||
cancel.order_key.value(),me->gw.name());
|
||||
return CancelResult {OrderError::UNKNOWN_ORDER};
|
||||
return CancelResult {OE_UNKNOWN_ORDER};
|
||||
}
|
||||
|
||||
auto &o = it->second;
|
||||
auto fix_buffer = me->gw.make_outfix_buffer();
|
||||
auto error = o->encode_cancel(cancel,&fix_buffer->fix[0]);
|
||||
if (error == OrderError::OK) {
|
||||
if (error == OE_OK) {
|
||||
fix_buffer->fix[0].close();
|
||||
me->gw.send(fix_buffer);
|
||||
return CancelResult {OrderError::OK};
|
||||
return CancelResult {OE_OK};
|
||||
}
|
||||
else {
|
||||
LOG(OrderMan,Warn,
|
||||
@@ -206,8 +206,8 @@ void OrderMan::on_exe_report(jetfix::fix::ExecutionReportMsg const&msg)
|
||||
auto it = me->order_map.find(order_key);
|
||||
bool is_new_order = it == me->order_map.end();
|
||||
if (is_new_order) {
|
||||
if (msg.get<fix::ExecType>() == ExecType::NEW ||
|
||||
msg.get<fix::ExecType>() == ExecType::REJECTED) {
|
||||
if (msg.get<fix::ExecType>() == ET_NEW ||
|
||||
msg.get<fix::ExecType>() == ET_REJECTED) {
|
||||
LOG(OrderMan,Error,
|
||||
"Received execution report for unknown order {} on {}. This should be investigated."
|
||||
" Will try to recreate the order from the execution report",
|
||||
|
||||
@@ -22,9 +22,9 @@ class OrderState;
|
||||
class OrderMan
|
||||
{
|
||||
public:
|
||||
struct CreateResult {OrderError::Type error;};
|
||||
struct UpdateResult {OrderError::Type error;};
|
||||
struct CancelResult {OrderError::Type error;};
|
||||
struct CreateResult {OrderError error;};
|
||||
struct UpdateResult {OrderError error;};
|
||||
struct CancelResult {OrderError error;};
|
||||
|
||||
OrderMan (std::vector<OrderState> const &working_orders,
|
||||
IOrderObserver &order_observer,
|
||||
|
||||
@@ -19,12 +19,12 @@ public:
|
||||
OrderKey order_key;
|
||||
SecurityKey security_key;
|
||||
api::BuySell side;
|
||||
TimeInForce::Type time_in_force;
|
||||
OrderType::Type order_type;
|
||||
TimeInForce time_in_force;
|
||||
OrderType order_type;
|
||||
|
||||
// Immutable once available, might not always be available
|
||||
CustomerOrFirm::Type customer_or_firm;
|
||||
CTICode::Type cti_code;
|
||||
CustomerOrFirm customer_or_firm;
|
||||
CTICode cti_code;
|
||||
UserLogin user_login;
|
||||
ExchangeOrderID exchange_order_id;
|
||||
|
||||
@@ -32,7 +32,7 @@ public:
|
||||
ManualOrderIndicator manual_order_indicator;
|
||||
OrderPrice price;
|
||||
OrderQuantity quantity;
|
||||
OrderStatus::Type status;
|
||||
OrderStatus status;
|
||||
OrderPrice avg_fill_price;
|
||||
OrderQuantity filled_quantity;
|
||||
OrderQuantity remaining_quantity;
|
||||
|
||||
@@ -11,8 +11,8 @@ public:
|
||||
const api::Security *security;
|
||||
OrderKey order_key;
|
||||
SecurityKey security_key;
|
||||
CustomerOrFirm::Type customer_or_firm;
|
||||
CTICode::Type cti_code;
|
||||
CustomerOrFirm customer_or_firm;
|
||||
CTICode cti_code;
|
||||
UserLogin user_login;
|
||||
ManualOrderIndicator manual_order_indicator;
|
||||
OrderPrice price;
|
||||
|
||||
@@ -99,7 +99,7 @@ WorkingOrder::WorkingOrder(OrderCreate const&c)
|
||||
c.manual_order_indicator ,
|
||||
c.price ,
|
||||
c.quantity,
|
||||
OrderStatus::UNACKNOWLEDGED,
|
||||
OS_UNACKNOWLEDGED,
|
||||
OrderPrice(0),
|
||||
OrderQuantity(0),
|
||||
OrderQuantity(c.quantity),
|
||||
@@ -115,15 +115,15 @@ WorkingOrder::WorkingOrder(OrderCreate const&c)
|
||||
WorkingOrder::WorkingOrder(fix::ExecutionReportMsg const&msg)
|
||||
: me (new PImpl())
|
||||
{
|
||||
bts_assert(msg.get<fix::ExecType>() == ExecType::NEW ||
|
||||
msg.get<fix::ExecType>() == ExecType::REJECTED);
|
||||
bts_assert(msg.get<fix::ExecType>() == ET_NEW ||
|
||||
msg.get<fix::ExecType>() == ET_REJECTED);
|
||||
|
||||
auto const &ts_str = msg.get<fix::TransactTimeStr>();
|
||||
OrderTimeStamp ts;
|
||||
std::copy(ts_str.begin(),ts_str.end(),&ts[0]);
|
||||
|
||||
std::string reject_reason;
|
||||
if (msg.get<fix::ExecType>() == ExecType::REJECTED && msg.has<fix::Text>())
|
||||
if (msg.get<fix::ExecType>() == ET_REJECTED && msg.has<fix::Text>())
|
||||
reject_reason = msg.get<fix::Text>();
|
||||
else
|
||||
reject_reason = std::string();
|
||||
@@ -138,16 +138,16 @@ WorkingOrder::WorkingOrder(fix::ExecutionReportMsg const&msg)
|
||||
ok,
|
||||
sk,
|
||||
api::BuySell(msg.get<fix::Side>()),
|
||||
TimeInForce::Type(msg.get<fix::TimeInForce>()),
|
||||
OrderType::Type(msg.get<fix::OrdType>()),
|
||||
CustomerOrFirm::UNDEFINED,
|
||||
CTICode::UNDEFINED,
|
||||
TimeInForce(msg.get<fix::TimeInForce>()),
|
||||
OrderType(msg.get<fix::OrdType>()),
|
||||
COF_UNDEFINED,
|
||||
CTI_UNDEFINED,
|
||||
UserLogin(),
|
||||
ExchangeOrderID(msg.get<fix::OrderID>()),
|
||||
ManualOrderIndicator(msg.get<fix::ManualOrderIndicator>()),
|
||||
OrderPrice (msg.get<fix::Price>()),
|
||||
OrderQuantity (msg.get<fix::OrderQty>()),
|
||||
OrderStatus::Type(msg.get<fix::OrdStatus>()),
|
||||
OrderStatus(msg.get<fix::OrdStatus>()),
|
||||
OrderPrice(0),
|
||||
OrderQuantity(0),
|
||||
OrderQuantity(msg.get<fix::OrderQty>()),
|
||||
@@ -171,7 +171,7 @@ OrderKey WorkingOrder::order_key() const
|
||||
OrderState const &WorkingOrder::state() const
|
||||
{return me->order_data;}
|
||||
|
||||
OrderError::Type WorkingOrder::encode_create(OrderCreate const&create,jetfix::FIXEncodingStream *stream)
|
||||
OrderError WorkingOrder::encode_create(OrderCreate const&create,jetfix::FIXEncodingStream *stream)
|
||||
{
|
||||
bts_assert(me->internal_state == InternalState::UNACKNOWLEDGED);
|
||||
|
||||
@@ -193,14 +193,14 @@ OrderError::Type WorkingOrder::encode_create(OrderCreate const&create,jetfix::FI
|
||||
encoding.add<fix::CustomerOrFirm> (create.customer_or_firm);
|
||||
encoding.add<fix::CtiCode> (create.cti_code);
|
||||
encoding.add<fix::SecurityDesc> (create.security->glbx().security_desc());
|
||||
return OrderError::OK;
|
||||
return OE_OK;
|
||||
}
|
||||
|
||||
OrderError::Type WorkingOrder::encode_update(OrderUpdate const&update,jetfix::FIXEncodingStream *stream)
|
||||
OrderError WorkingOrder::encode_update(OrderUpdate const&update,jetfix::FIXEncodingStream *stream)
|
||||
{
|
||||
switch (me->internal_state) {
|
||||
case InternalState::UNACKNOWLEDGED:
|
||||
return OrderError::ORDER_NOT_ACK;
|
||||
return OE_ORDER_NOT_ACK;
|
||||
case InternalState::PARTIAL:
|
||||
me->order_data.customer_or_firm = update.customer_or_firm;
|
||||
me->order_data.cti_code = update.cti_code;
|
||||
@@ -212,7 +212,7 @@ OrderError::Type WorkingOrder::encode_update(OrderUpdate const&update,jetfix::FI
|
||||
transition(InternalState::READY);
|
||||
else {
|
||||
transition(InternalState::UNACKNOWLEDGED);
|
||||
return OrderError::ORDER_NOT_ACK;
|
||||
return OE_ORDER_NOT_ACK;
|
||||
}
|
||||
break;
|
||||
case InternalState::READY:
|
||||
@@ -227,14 +227,14 @@ OrderError::Type WorkingOrder::encode_update(OrderUpdate const&update,jetfix::FI
|
||||
update_encoding();
|
||||
auto &f = stream->new_msg(MessageTypes::CancelReplace);
|
||||
f.append(me->cancel_replace_encoding);
|
||||
return OrderError::OK;
|
||||
return OE_OK;
|
||||
}
|
||||
|
||||
OrderError::Type WorkingOrder::encode_cancel(OrderCancel const&cancel,jetfix::FIXEncodingStream *stream)
|
||||
OrderError WorkingOrder::encode_cancel(OrderCancel const&cancel,jetfix::FIXEncodingStream *stream)
|
||||
{
|
||||
switch (me->internal_state) {
|
||||
case InternalState::UNACKNOWLEDGED:
|
||||
return OrderError::ORDER_NOT_ACK;
|
||||
return OE_ORDER_NOT_ACK;
|
||||
case InternalState::PARTIAL:
|
||||
me->order_data.customer_or_firm = cancel.customer_or_firm;
|
||||
me->order_data.cti_code = cancel.cti_code;
|
||||
@@ -246,7 +246,7 @@ OrderError::Type WorkingOrder::encode_cancel(OrderCancel const&cancel,jetfix::FI
|
||||
transition(InternalState::READY);
|
||||
else {
|
||||
transition(InternalState::UNACKNOWLEDGED);
|
||||
return OrderError::ORDER_NOT_ACK;
|
||||
return OE_ORDER_NOT_ACK;
|
||||
}
|
||||
break;
|
||||
case InternalState::READY:
|
||||
@@ -270,14 +270,14 @@ OrderError::Type WorkingOrder::encode_cancel(OrderCancel const&cancel,jetfix::FI
|
||||
encoding.add<fix::TransactTimeStr>(&state.transact_time[0],state.transact_time.size());
|
||||
encoding.add<fix::ManualOrderIndicator> (state.manual_order_indicator.value());
|
||||
encoding.add<fix::SecurityDesc> (cancel.security->glbx().security_desc());
|
||||
return OrderError::OK;
|
||||
return OE_OK;
|
||||
}
|
||||
|
||||
void WorkingOrder::init_encoding()
|
||||
{
|
||||
bts_assert(me->order_data.exchange_order_id.value().size());
|
||||
bts_assert(me->order_data.cti_code != CTICode::UNDEFINED);
|
||||
bts_assert(me->order_data.customer_or_firm != CustomerOrFirm::UNDEFINED);
|
||||
bts_assert(me->order_data.cti_code != CTI_UNDEFINED);
|
||||
bts_assert(me->order_data.customer_or_firm != COF_UNDEFINED);
|
||||
bts_assert(me->security);
|
||||
|
||||
auto &encoding = me->cancel_replace_encoding;
|
||||
@@ -315,8 +315,8 @@ void WorkingOrder::init_encoding()
|
||||
void WorkingOrder::update_encoding()
|
||||
{
|
||||
bts_assert(me->order_data.exchange_order_id.value().size());
|
||||
bts_assert(me->order_data.cti_code != CTICode::UNDEFINED);
|
||||
bts_assert(me->order_data.customer_or_firm != CustomerOrFirm::UNDEFINED);
|
||||
bts_assert(me->order_data.cti_code != CTI_UNDEFINED);
|
||||
bts_assert(me->order_data.customer_or_firm != COF_UNDEFINED);
|
||||
|
||||
auto &encoding = me->cancel_replace_encoding;
|
||||
auto &state = me->order_data;
|
||||
@@ -355,15 +355,15 @@ bool WorkingOrder::on_exe_report (jetfix::fix::ExecutionReportMsg const&msg)
|
||||
{
|
||||
switch (msg.get<fix::ExecType>()) {
|
||||
|
||||
case ExecType::PENDING_NEW:
|
||||
case ExecType::PENDING_REPLACE:
|
||||
case ExecType::PENDING_CANCEL:
|
||||
case ExecType::CANCEL_ACK:
|
||||
case ET_PENDING_NEW:
|
||||
case ET_PENDING_REPLACE:
|
||||
case ET_PENDING_CANCEL:
|
||||
case ET_CANCEL_ACK:
|
||||
// no ops
|
||||
return false;
|
||||
default: {
|
||||
me->order_data.order_type = OrderType::Type (msg.get<fix::OrdType>());
|
||||
me->order_data.status = OrderStatus::Type(msg.get<fix::OrdStatus>());
|
||||
me->order_data.order_type = OrderType (msg.get<fix::OrdType>());
|
||||
me->order_data.status = OrderStatus(msg.get<fix::OrdStatus>());
|
||||
me->order_data.avg_fill_price = OrderPrice(msg.get<fix::AvgPx> ());
|
||||
me->order_data.filled_quantity = OrderQuantity(msg.get<fix::CumQty> ());
|
||||
me->order_data.remaining_quantity = OrderQuantity(msg.get<fix::LeavesQty> ());
|
||||
@@ -433,10 +433,10 @@ void WorkingOrder::transition(InternalState new_state)
|
||||
bts_assert(me->security);
|
||||
bts_assert(me->order_data.exchange_order_id.value().empty());
|
||||
bts_assert(me->cancel_replace_encoding.size() == 0);
|
||||
bts_assert(me->order_data.customer_or_firm != CustomerOrFirm::UNDEFINED);
|
||||
bts_assert(me->order_data.cti_code != CTICode::UNDEFINED);
|
||||
bts_assert(me->order_data.customer_or_firm != COF_UNDEFINED);
|
||||
bts_assert(me->order_data.cti_code != CTI_UNDEFINED);
|
||||
bts_assert(me->order_data.user_login.value().size());
|
||||
bts_assert(me->order_data.status == OrderStatus::UNACKNOWLEDGED);
|
||||
bts_assert(me->order_data.status == OS_UNACKNOWLEDGED);
|
||||
break;
|
||||
case InternalState::PARTIAL:
|
||||
bts_assert(me->cancel_replace_encoding.size() == 0);
|
||||
@@ -446,8 +446,8 @@ void WorkingOrder::transition(InternalState new_state)
|
||||
bts_assert(me->security);
|
||||
bts_assert(me->order_data.exchange_order_id.value().size());
|
||||
bts_assert(me->cancel_replace_encoding.size());
|
||||
bts_assert(me->order_data.customer_or_firm != CustomerOrFirm::UNDEFINED);
|
||||
bts_assert(me->order_data.cti_code != CTICode::UNDEFINED);
|
||||
bts_assert(me->order_data.customer_or_firm != COF_UNDEFINED);
|
||||
bts_assert(me->order_data.cti_code != CTI_UNDEFINED);
|
||||
bts_assert(me->order_data.user_login.value().size());
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -26,9 +26,9 @@ public:
|
||||
OrderKey order_key() const;
|
||||
OrderState const &state() const ;
|
||||
|
||||
OrderError::Type encode_create(OrderCreate const&,jetfix::FIXEncodingStream *) ;
|
||||
OrderError::Type encode_update(OrderUpdate const&,jetfix::FIXEncodingStream *) ;
|
||||
OrderError::Type encode_cancel(OrderCancel const&,jetfix::FIXEncodingStream *) ;
|
||||
OrderError encode_create(OrderCreate const&,jetfix::FIXEncodingStream *) ;
|
||||
OrderError encode_update(OrderUpdate const&,jetfix::FIXEncodingStream *) ;
|
||||
OrderError encode_cancel(OrderCancel const&,jetfix::FIXEncodingStream *) ;
|
||||
|
||||
// return wheter the execution report caused the order to change
|
||||
bool on_exe_report (jetfix::fix::ExecutionReportMsg const&);
|
||||
|
||||
Reference in new issue
Block a user