Fixed a few bugs in the ticker api code.

This commit is contained in:
Pedro Pinto committed 2019-01-17 10:48:11 -05:00
1 parent bea0e5ced7
commit ee66ddf9a6
2 files changed
+6 -4

No files matched your search

+5 -3
View File
@@ -67,6 +67,7 @@ class MDSource : public mercury::Actor, public mercury::IPollableActor {
_stats.publish(ticker_channel_cout_metric);
_book_update = make_stream<BookUpdateEvent>();
_ticker_update = make_stream<TickerUpdateEvent>();
subscribe<MDRequestEvent>(
[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;
+1 -1
View File
@@ -24,7 +24,7 @@ class TickerUpdateEvent : public mercury::Event<TickerUpdateEvent> {
Price price;
Quantity quantity;
Quantity total_volume;
co2::AggressorSide agressor_side;
co2::AggressorSide aggressor_side;
};
boost::container::small_vector<Trade,5> trades;