From ee66ddf9a65bcb0cecbff3da8080a3bd9ee6378d Mon Sep 17 00:00:00 2001 From: Pedro Pinto Date: Thu, 17 Jan 2019 10:48:11 -0500 Subject: [PATCH] Fixed a few bugs in the ticker api code. --- src/lib/orderman/actors/MDSource.h | 8 +++++--- src/lib/orderman/events/TickerUpdateEvent.h | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/lib/orderman/actors/MDSource.h b/src/lib/orderman/actors/MDSource.h index c8012b5f2..b175722fd 100644 --- a/src/lib/orderman/actors/MDSource.h +++ b/src/lib/orderman/actors/MDSource.h @@ -67,6 +67,7 @@ class MDSource : public mercury::Actor, public mercury::IPollableActor { _stats.publish(ticker_channel_cout_metric); _book_update = make_stream(); + _ticker_update = make_stream(); subscribe( [this, security_count_metric, synthetic_count_metric, ticker_channel_cout_metric](auto const &update) { @@ -116,7 +117,7 @@ class MDSource : public mercury::Actor, public mercury::IPollableActor { for (auto const &trade : _trades_buffer) { size_t trade_count = 0; for (auto &per_sec_ev : c.securities) { - if (trade.key() == per_sec_ev.key.value()) { + if (trade.key() == per_sec_ev.key().value()) { trade_count++; per_sec_ev.trades.emplace_back(TickerUpdateEvent::Trade{ Timer::now(), @@ -178,14 +179,14 @@ class MDSource : public mercury::Actor, public mercury::IPollableActor { if (ch.user_symbol == user_symbol) { auto it = std::find_if(ch.securities.begin(), ch.securities.end(), - [sk](auto const &ev) { return ev.key == sk; }); + [sk](auto const &ev) { return ev.key() == sk; }); if (it == ch.securities.end()) { // first time we are asked for this security, we will // publish the trades for it next time next round LOG(OrderMan, Warn, "Starting to publish ticker updates on user symbol {} for " "security key: {} (sec count for the symbol: {} )", - user_symbol.to_string(), sk.value(), ch.securities.size()); + user_symbol.to_string(), sk.value(), ch.securities.size()+1); ch.securities.push_back(sk); } return; @@ -199,6 +200,7 @@ class MDSource : public mercury::Actor, public mercury::IPollableActor { user_symbol.to_string(), sk.value()); _channels.push_back( {0, _md_consumer.get_channel(user_symbol), {}, user_symbol}); + _channels.back().securities.push_back(sk); } struct HandleRecord { utils::TimeStamp last; diff --git a/src/lib/orderman/events/TickerUpdateEvent.h b/src/lib/orderman/events/TickerUpdateEvent.h index 2bead2e50..d34522d48 100644 --- a/src/lib/orderman/events/TickerUpdateEvent.h +++ b/src/lib/orderman/events/TickerUpdateEvent.h @@ -24,7 +24,7 @@ class TickerUpdateEvent : public mercury::Event { Price price; Quantity quantity; Quantity total_volume; - co2::AggressorSide agressor_side; + co2::AggressorSide aggressor_side; }; boost::container::small_vector trades;