this should do it for bust / adjust
This commit is contained in:
1 parent
54dd30245f
commit
c4eeaf2ec8
4 files changed
+30
-6
No files matched your search
@@ -274,7 +274,8 @@ message Fill {
|
||||
|
||||
enum FillStatus {
|
||||
FILL_STATUS_ACTIVE = 0;
|
||||
FILL_STATUS_BUSTED = 1;
|
||||
FILL_STATUS_CORRECTED = 1;
|
||||
FILL_STATUS_BUSTED = 2;
|
||||
}
|
||||
FillStatus fill_status = 20;
|
||||
}
|
||||
|
||||
@@ -91,8 +91,7 @@ void FillStore::on_execution_report(
|
||||
to_str(er.exchange_fill_id));
|
||||
auto is_known = me->known_fills.count(fk);
|
||||
if (er.exec_type == api::orderman::EXEC_TYPE_PARTIAL_FILL ||
|
||||
er.exec_type == api::orderman::EXEC_TYPE_FILL ||
|
||||
er.exec_type == api::orderman::EXEC_TYPE_TRADE_CORRECT) {
|
||||
er.exec_type == api::orderman::EXEC_TYPE_FILL) {
|
||||
|
||||
api::orderman::Fill fill;
|
||||
if (!is_known) {
|
||||
@@ -134,7 +133,6 @@ void FillStore::on_execution_report(
|
||||
} // if partial_fill or fill
|
||||
else if(er.exec_type == api::orderman::EXEC_TYPE_TRADE_CANCEL)
|
||||
{
|
||||
//TODO SOD
|
||||
auto data = me->store->retrieve_one(fills_ns, fk);
|
||||
Fill existing_fill;
|
||||
if(is_known && data.first && utils::pb::from_string(data.second, &existing_fill))
|
||||
@@ -146,7 +144,26 @@ void FillStore::on_execution_report(
|
||||
}
|
||||
else
|
||||
LOG(OrderMan, Warn, "Received bust for unknown fill {}", fk);
|
||||
}
|
||||
}
|
||||
else if(er.exec_type == api::orderman::EXEC_TYPE_TRADE_CORRECT)
|
||||
{
|
||||
auto data = me->store->retrieve_one(fills_ns, fk);
|
||||
Fill existing_fill;
|
||||
if(is_known && data.first && utils::pb::from_string(data.second, &existing_fill))
|
||||
{
|
||||
existing_fill.set_fill_status(api::orderman::Fill::FILL_STATUS_CORRECTED);
|
||||
existing_fill.set_last_price(er.last_price.value());
|
||||
existing_fill.set_avg_price(er.avg_price.value());
|
||||
existing_fill.set_side(er.side);
|
||||
existing_fill.set_last_shares(er.last_shares.value());
|
||||
|
||||
auto fv = utils::pb::to_string(existing_fill);
|
||||
me->store->update(fills_ns, fk, fv);
|
||||
publish(me->fill_stream, existing_fill, *er.security);
|
||||
}
|
||||
else
|
||||
LOG(OrderMan, Warn, "Received correction for unknown fill {}", fk);
|
||||
}
|
||||
} // for loop
|
||||
} // if u.events
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ void SODPosition::_zero_pos(Fill &pos, const Fill &fill, api::Side side) {
|
||||
}
|
||||
|
||||
bool SODPosition::add_fill_to_sod_pos(const Fill &fill) {
|
||||
if (_enabled && fill.fill_status() == api::orderman::Fill::FILL_STATUS_ACTIVE && fill.timestamp().seconds() < _sod_time.tv_sec) {
|
||||
if (_enabled && fill.fill_status() != api::orderman::Fill::FILL_STATUS_BUSTED && fill.timestamp().seconds() < _sod_time.tv_sec) {
|
||||
uint32_t seckey = fill.security_key();
|
||||
const std::string &acct = fill.account();
|
||||
auto acct_it = _sod_map.find(acct);
|
||||
|
||||
@@ -777,6 +777,12 @@ void ICENativeOrder::on_exe_report(const NewExecutionReportEvent &er)
|
||||
|
||||
auto &state = me->state;
|
||||
auto &native_state = get_native_state(state);
|
||||
if(er.data->exec_type == api::orderman::ExecType::EXEC_TYPE_TRADE_CANCEL ||
|
||||
er.data->exec_type == api::orderman::ExecType::EXEC_TYPE_TRADE_CORRECT)
|
||||
{
|
||||
LOG(OrderMan, Info, "ICENativeOrder ignoring Cancel or Correct execution report {} in order {}", er.data->msg_seq_num, key().value());
|
||||
return;
|
||||
}
|
||||
|
||||
// if we have a previous state we want to ensure this execution
|
||||
// report was not already considered.
|
||||
|
||||
Reference in new issue
Block a user