Added time to ticker update.

This commit is contained in:
Pedro Pinto committed 2019-01-17 11:44:37 -05:00
1 parent ee66ddf9a6
commit ce8d27bb71
1 file changed
+17 -2
+17 -2
View File
@@ -15,6 +15,8 @@
#include "lib/tracing/bts_trace.h"
#include "lib/utils/TimeStamp.h"
#include <date/date.h>
namespace bts {
namespace orderman {
@@ -120,7 +122,7 @@ class MDSource : public mercury::Actor, public mercury::IPollableActor {
if (trade.key() == per_sec_ev.key().value()) {
trade_count++;
per_sec_ev.trades.emplace_back(TickerUpdateEvent::Trade{
Timer::now(),
ll_to_timestamp(trade.time()),
Price(md::IntPrice(trade.mantissa(),
(int8_t)trade.exponent())
.price()),
@@ -143,6 +145,18 @@ class MDSource : public mercury::Actor, public mercury::IPollableActor {
_loop_timer->observe((start - stop).nanoseconds());
}
TimeStamp ll_to_timestamp(uint64_t lldt) {
return Timer::now();
using namespace date;
using namespace std::chrono;
int Y, M, D, h, m, s, ms;
datetime::ll_to_parts(lldt,Y,M,D,h,m,s,ms);
system_clock::time_point tp = sys_days{year{Y} / M / D} + hours{h} +
minutes{m} + seconds{s} + milliseconds{ms};
return tp;
}
void on_book_sub(SecurityKey sk,
metrics::CounterMetric<int> &synthetic_count_metric) {
auto k = sk.value();
@@ -186,7 +200,8 @@ class MDSource : public mercury::Actor, public mercury::IPollableActor {
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()+1);
user_symbol.to_string(), sk.value(),
ch.securities.size() + 1);
ch.securities.push_back(sk);
}
return;