diff --git a/src/client/spark/Modules/Market/MarketView/MarketViewRow.cs b/src/client/spark/Modules/Market/MarketView/MarketViewRow.cs index 0813e8011..d779329b9 100644 --- a/src/client/spark/Modules/Market/MarketView/MarketViewRow.cs +++ b/src/client/spark/Modules/Market/MarketView/MarketViewRow.cs @@ -26,6 +26,7 @@ namespace mbts.spark { readonly ObservableFilterCollection _working_orders, _working_bids, _working_asks; readonly string _security_text, _security_key_text; readonly Property _bid_price, _ask_price, _last_price, _day_change, _settlement, _session_high, _session_low; + readonly Property _last_price_from_spread; readonly CellProperty _position; readonly CellProperty _last_size; readonly CellProperty _volume; @@ -53,6 +54,7 @@ namespace mbts.spark { _day_change = backing(nameof(day_change), double.NaN); _session_low = backing(nameof(session_low), double.NaN); _session_high = backing(nameof(session_high), double.NaN); + _last_price_from_spread = backing(nameof(last_price_from_spread), false); _settlement = backing(nameof(settlement), double.NaN); _volume = new CellProperty(this, nameof(volume), 0); _inside_bids = new CellProperty(this, nameof(inside_bids)); @@ -103,6 +105,7 @@ namespace mbts.spark { public bool inside_asks => _inside_asks.value; public int position => _position.value; public double last_price => _last_price.Value; + public bool last_price_from_spread => _last_price_from_spread.Value; public uint last_size => _last_size.value; public double bid_price => _bid_price.Value; public uint bid_direct_size => _bid_direct_size.Value; @@ -161,8 +164,9 @@ namespace mbts.spark { _inside_bids.on_next_distinct(_bid_price.Value >= _working_best_bid.value, ref dirty); _inside_asks.on_next_distinct(_ask_price.Value <= _working_best_ask.value, ref dirty); } - if (md.md.get_last_trade(ref _last_ref, out NativePriceSize ps, out DateTime ts, out ulong v)) { + if (md.md.get_last_trade(ref _last_ref, out NativePriceSize ps, out DateTime ts, out ulong v, out bool from_spread)) { _last_price.set(ps.price); + _last_price_from_spread.set(from_spread); _last_size.on_next_distinct(ps.size, ref dirty); _volume.on_next_distinct(v, ref dirty); } diff --git a/src/client/spark/Modules/Market/MarketView/MarketViewVM.cs b/src/client/spark/Modules/Market/MarketView/MarketViewVM.cs index ff0b789b1..bd0f93da4 100644 --- a/src/client/spark/Modules/Market/MarketView/MarketViewVM.cs +++ b/src/client/spark/Modules/Market/MarketView/MarketViewVM.cs @@ -39,7 +39,8 @@ namespace mbts.spark { IMultiValueConverter price_converter = new ui.spark.converters.TickDisplayConverter(); add_col(Columns.Security, "Security", r => r.security.ToString(), nameof(Row.security), DefaultColumnWidths.Security, security_filter, DataGridFilterKnownTemplates.Regex); add_col(Columns.Volume, "Volume", r => r.volume.ToString(), nameof(Row.volume), DefaultColumnWidths.Volume, volume_filter, DataGridFilterKnownTemplates.ULongMinMax); - add_col(Columns.Last, "Last", r => r.format_price(r.last_price), nameof(Row.last_price), DefaultColumnWidths.Price, last_price_filter, DataGridFilterKnownTemplates.DoubleMinMax); + add_col(Columns.LastSpd, "Spd", r => r.last_price_from_spread ? "S" : "", nameof(Row.last_price_from_spread), DefaultColumnWidths.Side, last_price_from_spread_filter, DataGridFilterKnownTemplates.Regex); + add_col(Columns.Last, "Last", r => r.format_price(r.last_price), nameof(Row.last_price), DefaultColumnWidths.Price, last_price_filter, DataGridFilterKnownTemplates.DoubleMinMax); add_col(Columns.LastSize, merged_size_col_header, r => r.last_size.ToString(), nameof(Row.last_size), DefaultColumnWidths.Size, last_size_filter, DataGridFilterKnownTemplates.UIntMinMax, h_alignment: System.Windows.HorizontalAlignment.Right); add_col(Columns.Position, "Pos", r => r.position.ToString(), nameof(Row.position), DefaultColumnWidths.Size, position_filter, DataGridFilterKnownTemplates.IntMinMax, true, h_alignment: System.Windows.HorizontalAlignment.Right); add_hl_working_orders_col(Columns.WorkingBids, working_col_header, nameof(Row.working_bids_text), nameof(Row.working_best_bid), nameof(Row.working_bids_click), working_bid_volume_filter, BTSColors.MarketData.bid, System.Windows.HorizontalAlignment.Right); @@ -145,6 +146,7 @@ namespace mbts.spark { ask_direct_size_filter.load_state(filters.ask_direct_size); ask_implied_size_filter.load_state(filters.ask_implied_size); last_price_filter.load_state(filters.last_price); + last_price_from_spread_filter.load_state(filters.last_price_from_spread); last_size_filter.load_state(filters.last_size); day_change_filter.load_state(filters.day_change); settlement_filter.load_state(filters.settlement); @@ -161,7 +163,7 @@ namespace mbts.spark { }), DataGridFilterHelper.hook_filters(rows_view, security_filter, bid_price_filter, bid_merged_size_filter, bid_direct_size_filter, bid_implied_size_filter, ask_price_filter, ask_merged_size_filter, ask_direct_size_filter, ask_implied_size_filter, - last_price_filter, last_size_filter, day_change_filter, settlement_filter, + last_price_filter, last_price_from_spread_filter, last_size_filter, day_change_filter, settlement_filter, session_low_filter, session_high_filter, position_filter, working_bid_volume_filter, working_ask_volume_filter, volume_filter, security_key_filter), securities_connectable.Connect(), settings_manager.subscribe_current().OnDispatcher().Subscribe(grid_settings_manager), @@ -191,6 +193,7 @@ namespace mbts.spark { public IDataGridColumnPersistentFilter ask_direct_size_filter { get; } = new UIntMinMax(r => r.ask_direct_size, nameof(Row.ask_direct_size)); public IDataGridColumnPersistentFilter ask_implied_size_filter { get; } = new UIntMinMax(r => r.ask_implied_size, nameof(Row.ask_implied_size)); public IDataGridColumnPersistentFilter last_price_filter { get; } = new DoubleMinMax(r => r.last_price, nameof(Row.last_price)); + public IDataGridColumnPersistentFilter last_price_from_spread_filter { get; } = new RegexFilterVM(r => r.last_price_from_spread.ToString(), nameof(Row.last_price_from_spread)); public IDataGridColumnPersistentFilter last_size_filter { get; } = new UIntMinMax(r => r.last_size, nameof(Row.last_size)); public IDataGridColumnPersistentFilter day_change_filter { get; } = new DoubleMinMax(r => r.day_change, nameof(Row.day_change)); public IDataGridColumnPersistentFilter settlement_filter { get; } = new DoubleMinMax(r => r.settlement, nameof(Row.settlement)); @@ -222,6 +225,7 @@ namespace mbts.spark { ask_direct_size = ask_direct_size_filter.get_state(), ask_implied_size = ask_implied_size_filter.get_state(), last_price = last_price_filter.get_state(), + last_price_from_spread = last_price_from_spread_filter.get_state(), last_size = last_size_filter.get_state(), day_change = day_change_filter.get_state(), settlement = settlement_filter.get_state(), diff --git a/src/client/spark/Modules/Market/MarketView/MarketViewView.xaml.cs b/src/client/spark/Modules/Market/MarketView/MarketViewView.xaml.cs index edbea884b..14dfdb626 100644 --- a/src/client/spark/Modules/Market/MarketView/MarketViewView.xaml.cs +++ b/src/client/spark/Modules/Market/MarketView/MarketViewView.xaml.cs @@ -8,7 +8,7 @@ namespace mbts.ui.spark { /// Interaction logic for MarketSheetsView.xaml /// partial class MarketViewView : UserControl { - public enum Columns { Security, Volume, Last, LastSize, Position, WorkingBids, Bid, BidMergedSize, BidDirectSize, BidImpliedSize, Ask, AskMergedSize, AskDirectSize, AskImpliedSize, WorkingAsks, Settlement, DayChange, SessionLow, SessionHigh, SecurityKey, + public enum Columns { Security, Volume, Last, LastSpd, LastSize, Position, WorkingBids, Bid, BidMergedSize, BidDirectSize, BidImpliedSize, Ask, AskMergedSize, AskDirectSize, AskImpliedSize, WorkingAsks, Settlement, DayChange, SessionLow, SessionHigh, SecurityKey, MarketDescription, ClearedAlias, ProductDescription, HubAlias, StripName, MicCode } diff --git a/src/client/spark/Modules/Market/MarketView/MarketViewWindowFactory.cs b/src/client/spark/Modules/Market/MarketView/MarketViewWindowFactory.cs index 38931a3eb..da1b23358 100644 --- a/src/client/spark/Modules/Market/MarketView/MarketViewWindowFactory.cs +++ b/src/client/spark/Modules/Market/MarketView/MarketViewWindowFactory.cs @@ -80,6 +80,7 @@ namespace bts.shell { public static GridColumnSettings security => new GridColumnSettings(col_id(Columns.Security), DefaultColumnHeaders.Security, width: DefaultColumnWidths.Security); public static GridColumnSettings volume => new GridColumnSettings(col_id(Columns.Volume), DefaultColumnHeaders.Volume, width: DefaultColumnWidths.Volume); public static GridColumnSettings last => new GridColumnSettings(col_id(Columns.Last), DefaultColumnHeaders.Last, width: DefaultColumnWidths.Price); + public static GridColumnSettings last_from_spread => new GridColumnSettings(col_id(Columns.LastSpd), DefaultColumnHeaders.S, width: DefaultColumnWidths.Price, is_visible: false); public static GridColumnSettings last_size => new GridColumnSettings(col_id(Columns.LastSize), DefaultColumnHeaders.Size, width: DefaultColumnWidths.Size, horizontal_alignment: System.Windows.HorizontalAlignment.Right); public static GridColumnSettings position => new GridColumnSettings(col_id(Columns.Position), DefaultColumnHeaders.Pos, width: DefaultColumnWidths.Size, horizontal_alignment: System.Windows.HorizontalAlignment.Right); public static GridColumnSettings working_bids => new GridColumnSettings(col_id(Columns.WorkingBids), DefaultColumnHeaders.Working, font_color_override: BTSColors.MarketData.bid, width: DefaultColumnWidths.Working, horizontal_alignment: System.Windows.HorizontalAlignment.Right); @@ -117,6 +118,7 @@ namespace bts.shell { yield return security; yield return volume; yield return last; + yield return last_from_spread; yield return last_size; yield return position; yield return working_bids; @@ -200,6 +202,8 @@ namespace bts.shell { [ProtoMember(25)] public string strip_name; [ProtoMember(26)] + public string last_price_from_spread; + [ProtoMember(27)] public string mic_code; } } diff --git a/src/client/spark/view/Controls/DIYGrid/Columns/ColumnBase.cs b/src/client/spark/view/Controls/DIYGrid/Columns/ColumnBase.cs index d0d2c98f7..4bf15f346 100644 --- a/src/client/spark/view/Controls/DIYGrid/Columns/ColumnBase.cs +++ b/src/client/spark/view/Controls/DIYGrid/Columns/ColumnBase.cs @@ -86,6 +86,7 @@ namespace mbts.ui.controls { Aggressor = "Aggressor", Volume = "Volume", Last = "Last", + S = "S", Pos = "Pos", Working = "Working", Bid = "Bid", diff --git a/src/client/spark_api/Co2/MDConsumerHandle.cs b/src/client/spark_api/Co2/MDConsumerHandle.cs index 4a12f2f99..4a0b37f16 100644 --- a/src/client/spark_api/Co2/MDConsumerHandle.cs +++ b/src/client/spark_api/Co2/MDConsumerHandle.cs @@ -133,6 +133,12 @@ namespace mbts.co2 { total_volume = _cold->total_volume; return (_cold->last_trade.load_if_new(ref time, out ps)); } + public bool get_last_trade(ref ulong time, out NativePriceSize ps, out DateTime timestamp, out ulong total_volume, out bool from_spread) { + timestamp = _cold->last_trade_time; + total_volume = _cold->total_volume; + from_spread = (_cold->from_spread != 0); + return (_cold->last_trade.load_if_new(ref time, out ps)); + } public ulong misc_timestamp { get { return _cold->misc_timestamp; } } public ulong total_volume { get { return _cold->total_volume; } } @@ -250,7 +256,7 @@ namespace mbts.co2 { // Last trade public AtomicPriceSize last_trade; public ulong total_volume; - public utils.LLDateTime last_trade_time; + public utils.LLDateTime last_trade_time; //// Settlement public UInt64 misc_timestamp; @@ -271,6 +277,7 @@ namespace mbts.co2 { public double session_low_offer; public double fixing_price; + public int from_spread; public int deleted; // FixedSecurity will not be directly addressable. Instead the security is available through the callback public Int64 security_size; diff --git a/src/client/spark_test/Co2/Co2Tests.cs b/src/client/spark_test/Co2/Co2Tests.cs index a5f1b292a..af5edc856 100644 --- a/src/client/spark_test/Co2/Co2Tests.cs +++ b/src/client/spark_test/Co2/Co2Tests.cs @@ -142,7 +142,8 @@ namespace mbts.co2.tests Assert.IsTrue(entry.session_low_offer == 5.5); Assert.IsTrue(entry.fixing_price == 6.6); - Assert.IsTrue(entry.deleted == 1); + Assert.IsTrue(entry.from_spread == 0); + Assert.IsTrue(entry.deleted == 1); } [Test] diff --git a/src/lib/md/MDConsumerHandle.cpp b/src/lib/md/MDConsumerHandle.cpp index 40efeded5..35f43f54d 100644 --- a/src/lib/md/MDConsumerHandle.cpp +++ b/src/lib/md/MDConsumerHandle.cpp @@ -293,7 +293,7 @@ TimeStamp copy_synthetic_depth(const SyntheticStrategy& synth, size_t count, Pri // END SYNTHETIC DEPTH ///////////////////////////// -bool MDConsumerHandle::get_last_trade(TimeStamp& time, PriceSize& trade, datetime::LLDateTime& trade_timestamp, size_t* total_volume) const { +bool MDConsumerHandle::get_last_trade(TimeStamp& time, PriceSize& trade, datetime::LLDateTime& trade_timestamp, size_t* total_volume, int* from_spread) const { switch(_type) { case HANDLETYPE_VOID: return false; case HANDLETYPE_DEPTH: @@ -303,6 +303,7 @@ bool MDConsumerHandle::get_last_trade(TimeStamp& time, PriceSize& trade, datetim if (result) { trade_timestamp = pcold->last_trade_time; if (total_volume) { *total_volume = pcold->total_volume; } + if (from_spread) { *from_spread = pcold->from_spread; } } return result; } diff --git a/src/lib/md/MDConsumerHandle.h b/src/lib/md/MDConsumerHandle.h index 506e64f7b..66581f7d1 100644 --- a/src/lib/md/MDConsumerHandle.h +++ b/src/lib/md/MDConsumerHandle.h @@ -239,7 +239,7 @@ public: return get_book(read_combined, time, copydepth, bids, asks); } - bool get_last_trade(TimeStamp& time, PriceSize& out_trade, datetime::LLDateTime& out_trade_timestamp, size_t* total_volume=nullptr) const; + bool get_last_trade(TimeStamp& time, PriceSize& out_trade, datetime::LLDateTime& out_trade_timestamp, size_t* total_volume=nullptr,int* from_spread=nullptr) const; IntPrice settlement_price() const { switch(_type) { diff --git a/src/lib/md/MDProducerHandle.cpp b/src/lib/md/MDProducerHandle.cpp index 08b29f40a..362e988d5 100644 --- a/src/lib/md/MDProducerHandle.cpp +++ b/src/lib/md/MDProducerHandle.cpp @@ -101,9 +101,11 @@ void MDProducerHandle::set_status(CoconutSecurityStatus status) { } } -void MDProducerHandle::add_trade(TimeStamp time, const PriceSize price, LLDateTime tradetime, co2::AggressorSide agside, uint32_t volume) { +void MDProducerHandle::add_trade(TimeStamp time, const PriceSize price, LLDateTime tradetime, + co2::AggressorSide agside, uint32_t volume, bool from_spread) { cdata().last_trade.store(price, time); cdata().last_trade_time = tradetime; + cdata().from_spread = (from_spread ? 1 : 0); if (volume > 0) cdata().total_volume = volume; @@ -119,9 +121,10 @@ void MDProducerHandle::add_trade(TimeStamp time, const PriceSize price, LLDateTi _channel.add_trade(trade); } } -void MDProducerHandle::set_last_trade(TimeStamp time, const PriceSize ps, datetime::LLDateTime tradetime, uint32_t total_volume) { +void MDProducerHandle::set_last_trade(TimeStamp time, const PriceSize ps, datetime::LLDateTime tradetime, uint32_t total_volume, bool from_spread) { cdata().last_trade.store(ps,time); cdata().last_trade_time = tradetime; + cdata().from_spread = (from_spread ? 1 : 0); if(total_volume > 0) cdata().total_volume = total_volume; } diff --git a/src/lib/md/MDProducerHandle.h b/src/lib/md/MDProducerHandle.h index 4fea16972..78466987a 100644 --- a/src/lib/md/MDProducerHandle.h +++ b/src/lib/md/MDProducerHandle.h @@ -92,9 +92,10 @@ public: void set_status(co2::CoconutSecurityStatus status); // hot // Updates trade log and last trade - void add_trade(TimeStamp time, const PriceSize pricesize, datetime::LLDateTime date, co2::AggressorSide agside, uint32_t total_volume=0); // cold + void add_trade(TimeStamp time, const PriceSize pricesize, datetime::LLDateTime date, + co2::AggressorSide agside, uint32_t total_volume=0, bool from_spread=false); // cold // Update last_trade without updating trade log - void set_last_trade(TimeStamp time, const PriceSize ps, datetime::LLDateTime date, uint32_t total_volume=0); + void set_last_trade(TimeStamp time, const PriceSize ps, datetime::LLDateTime date, uint32_t total_volume=0,bool from_spread=false); void set_total_volume(uint32_t total_volume); void add_rfq(TimeStamp time, const co2::QuoteRequestMessage& rfq); // cold diff --git a/src/lib/md/Shm/MDStructure.h b/src/lib/md/Shm/MDStructure.h index 3553b71d8..2bad7f6ee 100644 --- a/src/lib/md/Shm/MDStructure.h +++ b/src/lib/md/Shm/MDStructure.h @@ -26,7 +26,7 @@ namespace md { using utils::TimeStamp; -const uint32_t shm_version = 102; +const uint32_t shm_version = 107; struct ALIGNED_(CACHE_LINE) HotHeader { size_t count; @@ -213,9 +213,10 @@ struct ColdEntry { exchange_status(co2::TRADINGSTATUS_UNKNOWN), last_trade(), total_volume(0), - last_trade_time(), + last_trade_time(), misc(), - deleted(false) + from_spread(0), + deleted(0) { this->security.size = security_size; } @@ -227,12 +228,13 @@ struct ColdEntry { // Last Trade AtomicPriceSize last_trade; - size_t total_volume; + size_t total_volume; datetime::LLDateTime last_trade_time; - + MiscData misc; - bool deleted; + int from_spread; + int deleted; FixedSecurity security; }; diff --git a/src/lib/md/protos/co2.proto b/src/lib/md/protos/co2.proto index 8d5355be6..82c88df3a 100644 --- a/src/lib/md/protos/co2.proto +++ b/src/lib/md/protos/co2.proto @@ -151,6 +151,7 @@ message TradeMessage { uint32 total_volume = 7; bool gap = 8; AggressorSide aggressor_side = 9; + bool from_spread = 10; } message QuoteRequestMessage { enum Side { diff --git a/src/lib/md/relay/QueryServer.cpp b/src/lib/md/relay/QueryServer.cpp index 248491942..d6555847a 100644 --- a/src/lib/md/relay/QueryServer.cpp +++ b/src/lib/md/relay/QueryServer.cpp @@ -306,12 +306,13 @@ public: TimeStamp time(snapshot ? 0 : chan.time()); PriceSize price; datetime::LLDateTime trade_time; - size_t volume; - if (handle.get_last_trade(time, price, trade_time, &volume)) { + size_t volume; int from_spread; + if (handle.get_last_trade(time, price, trade_time, &volume, &from_spread)) { auto* trade = pupd->mutable_last_trade(); trade->set_key(handle.key()); trade->set_time(trade_time); trade->set_total_volume(volume); + trade->set_from_spread(from_spread); set_price(price, trade); } } diff --git a/src/lib/md/relay/RelayClient.cpp b/src/lib/md/relay/RelayClient.cpp index 9830a6cc7..bf04c11d2 100644 --- a/src/lib/md/relay/RelayClient.cpp +++ b/src/lib/md/relay/RelayClient.cpp @@ -86,7 +86,7 @@ class RelayProducer : public IRelayWriter { handle.update_fixing_price(updated, misc.fixing_price()); } if (update.has_last_trade()) { - handle.set_last_trade(updated, trade_pricesize(update.last_trade()), update.last_trade().time(), update.last_trade().total_volume()); + handle.set_last_trade(updated, trade_pricesize(update.last_trade()), update.last_trade().time(), update.last_trade().total_volume(), update.last_trade().from_spread()); } } diff --git a/src/lib/md/test/Co2ManagedTestHelper.cpp b/src/lib/md/test/Co2ManagedTestHelper.cpp index 30caf3bde..90462dfcd 100644 --- a/src/lib/md/test/Co2ManagedTestHelper.cpp +++ b/src/lib/md/test/Co2ManagedTestHelper.cpp @@ -87,7 +87,8 @@ extern "C" BTS_EXPORT void co2_get_sample_cold(size_t& size, ColdEntry& entry) { entry.misc.session_high_bid = 4.4; entry.misc.session_low_offer = 5.5; entry.misc.fixing_price = 6.6; - entry.deleted = true; + entry.deleted = 1; + entry.from_spread = 0; } extern "C" BTS_EXPORT void co2_get_sample_cold_header(ColdHeader& header) { diff --git a/src/lib/orderman/actors/ICEExecutionGateway.cpp b/src/lib/orderman/actors/ICEExecutionGateway.cpp index 1b69e8a8d..8fd446604 100644 --- a/src/lib/orderman/actors/ICEExecutionGateway.cpp +++ b/src/lib/orderman/actors/ICEExecutionGateway.cpp @@ -53,6 +53,7 @@ struct ICEExecutionGateway::PImpl api::admin::AdminData admin_data; std::atomic nusers; TimeStamp connection_time; + std::unordered_map exec_id_to_memo; //for the bullshit adjusts }; ICEExecutionGateway::ICEExecutionGateway(const config::JetFIX::Connection &cfg, trace::PerfLog &log) @@ -252,21 +253,54 @@ OnCancelReject &ICEExecutionGateway::on_cancel_reject() return me->on_cancel_reject; } +bool ICEExecutionGateway::process_memo(const jetfix::fix::ICEExecutionReportMsg &msg, OrderKey* ok, SecurityKey* sk) +{ + if(msg.has()) + { + decode_memo(msg.get(), ok, sk); + return true; + } + else + { + if (msg.get() == api::orderman::EXEC_TYPE_TRADE_CORRECT && msg.has()) + { + std::string ref_exec_id = msg.get(); + auto found = me->exec_id_to_memo.find(ref_exec_id); + if(found == me->exec_id_to_memo.end()) + { + auto new_price = Price(0); + if(msg.has()) + new_price = Price(msg.get()); + + LOG(OrderMan, Error, + "Received unsupported trade correction msg. This correction will not be forwarded. The trader should be alerted. " + "Partial original fill id: {}. New price: {}", ref_exec_id, new_price.value()); + return false; + } + else + { + decode_memo(found->second, ok, sk); + return true; + } + } + } + return false; +} + void ICEExecutionGateway::on_exe_report(const jetfix::fix::ICEExecutionReportMsg &msg) { OrderKey ok; SecurityKey sk; - if(!msg.has()) + if(!process_memo(msg, &ok, &sk)) { + std::string execid = ""; + if(msg.has()) + execid = msg.get(); LOG(OrderMan, Error, - "Received execution report with no memo {}. Will not be able to process this report. This is likely a bug that could lead " - "to lost fills. Please investigate.", - sk.value()); - return; + "Received execution report with no memo execid: {}. Will not be able to process this report. This is likely a bug that could lead " + "to lost fills. Please investigate.", execid); + return; } - else - decode_memo(msg.get(), &ok, &sk); - auto scoped_log = trace::log_scope(me->perf_log, msg.trace(), "ICEExecutionGateway::on_exe_report", ok.value()); LOG(Latency, Info, "Started handling of execution report for order {}", ok.value()); @@ -279,32 +313,6 @@ void ICEExecutionGateway::on_exe_report(const jetfix::fix::ICEExecutionReportMsg sk.value()); else { - // Ignore trade correction messages. - if (msg.get() == api::orderman::EXEC_TYPE_TRADE_CORRECT) - { - auto new_price = Price(0); - if(msg.has()) - new_price = securities::decode_exchange_price(*sec, Price(msg.get())); - std::string ref_exec_id = ""; - if(msg.has()) - ref_exec_id = msg.get(); - LOG(OrderMan, Error, - "Received unsupported trade correction msg. This correction will not be forwarded. The trader should be alerted. " - "Order: {} SecKey: {} Partial original fill id: {}. New price: {}", - ok.value(), sk.value(), ref_exec_id, new_price.value()); - return; - } - - // Ignore unsupported trade cancelation messages. - if (msg.get() == api::orderman::EXEC_TYPE_TRADE_CANCEL) - { - LOG(OrderMan, Error, - "Received unsupported trade cancel msg. This correction will not be forwarded. The trader should be alerted. " - "Order: {} SecKey: {} ", - ok.value(), sk.value()); - return; - } - api::Security const *leg_security = nullptr; if (msg.has() && msg.get() == 2) { @@ -383,6 +391,7 @@ void ICEExecutionGateway::on_exe_report(const jetfix::fix::ICEExecutionReportMsg data->quantity = Quantity(0); data->filled_quantity = Quantity(msg.get()); + data->last_shares = msg.has() ? Quantity(msg.get()) : Quantity(0); @@ -394,9 +403,12 @@ void ICEExecutionGateway::on_exe_report(const jetfix::fix::ICEExecutionReportMsg ? securities::decode_exchange_price(*last_px_sec, Price(msg.get())) : Price(0); if (msg.has()) - str_to(msg.get(), &data->exchange_fill_id); - - + { + auto execid = msg.get(); + str_to(execid, &data->exchange_fill_id); + me->exec_id_to_memo[execid] = msg.get(); + } + if (msg.has()) { std::string stamp = msg.get(); diff --git a/src/lib/orderman/actors/ICEExecutionGateway.h b/src/lib/orderman/actors/ICEExecutionGateway.h index b7cb5dd72..8c453ab71 100644 --- a/src/lib/orderman/actors/ICEExecutionGateway.h +++ b/src/lib/orderman/actors/ICEExecutionGateway.h @@ -36,6 +36,8 @@ class ICEExecutionGateway : public IExecutionGateway { void on_connection_status_change(bool connected); void on_business_reject(const jetfix::fix::BusinessMessageRejectMsg&); void on_session_reject(const jetfix::fix::RejectMsg&); + + bool process_memo(const jetfix::fix::ICEExecutionReportMsg &msg, OrderKey*, SecurityKey*); }; } // namespace orderman diff --git a/src/lib/orderman/orders/ICENativeOrder.cpp b/src/lib/orderman/orders/ICENativeOrder.cpp index 1292b4802..bfbe967e4 100644 --- a/src/lib/orderman/orders/ICENativeOrder.cpp +++ b/src/lib/orderman/orders/ICENativeOrder.cpp @@ -835,6 +835,11 @@ void ICENativeOrder::on_exe_report(const NewExecutionReportEvent &er) { // terminal states, nothing can change them case ORDER_STATUS_COMPLETED: + { + if(external_status == ORDER_STATUS_CANCELED) //BUSTS + transition(external_status); + } + break; case ORDER_STATUS_CANCELED: break; diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp b/src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp index 19c19d599..3fce386d9 100644 --- a/src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp +++ b/src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp @@ -230,12 +230,13 @@ AggressorSide map_aggressor(onixs_ice::AggressorSide::Enum agside) } } -void on_trade(ICESecurityData* data, const onixs_ice::Price& price, int size, onixs_ice::AggressorSide::Enum agside, const onixs_ice::DateTime& onixs_date) +void on_trade(ICESecurityData* data, const onixs_ice::Price& price, int size, + onixs_ice::AggressorSide::Enum agside, const onixs_ice::DateTime& onixs_date, bool from_spread) { auto ts = utils::TimeStamp::now(); PriceSize ps = pricesize_of_price_size(price, data->handle.security().ice_deal_denominator, size); auto date = ll_of_timestamp(onixs_date); - data->handle.add_trade(ts, ps, date, map_aggressor(agside), size); + data->handle.add_trade(ts, ps, date, map_aggressor(agside), 0u, from_spread); } void ICEListener::onTrade(const onixs_ice::Trade& msg, const onixs_ice::MessageInfo& ) @@ -247,8 +248,7 @@ void ICEListener::onTrade(const onixs_ice::Trade& msg, const onixs_ice::MessageI auto size = msg.quantity; auto price = msg.price; onixs_ice::AggressorSide::Enum agside = msg.aggressorSide; - if(!msg.isSystemPricedLeg) - on_trade(data, price, size, agside, msg.transactDateTime); + on_trade(data, price, size, agside, msg.transactDateTime, msg.isSystemPricedLeg); } }