refactor: Get rid of 'TimeStamp' typedef in MDStructure.h
Before this commit, we had 4 different TimeStamp types/identifiers, which is confusing enough as it is: * bts::core::TimeStamp - in system/time_stamp.h * bts::utils::TimeStamp - in spark/utils/TimeStamp.h * bts::TimeStamp - in system/bts_chrono.h - alias for std::chrono::system_clock::time_point * bts::md::TimeStamp - in spark/md/Shm/MDStructure.h - alias for bts::utils::TimeStamp - removed in this commit Additional aliases for these TimeStamps only adds to the confusion (esp when the alias comes from a nested include).
This commit is contained in:
1 parent
7598d9a237
commit
c8a7cd0961
16 files changed
+109
-96
No files matched your search
@@ -92,7 +92,7 @@ md::Size convert_qty(double qty) { return static_cast<Size>(qty); }
|
||||
|
||||
inline bts::utils::TimeStamp convert_timestamp(
|
||||
emumba::market_data::exchange_timestamp ts) {
|
||||
return TimeStamp(ts.get_timestamp());
|
||||
return utils::TimeStamp(ts.get_timestamp());
|
||||
}
|
||||
|
||||
bts::api::Venue convert_venue(emumba::market_data::venue venue) {
|
||||
|
||||
@@ -267,7 +267,7 @@ void ICEListener::onOrderBookUpdated(
|
||||
ask.price, denominator, ask.impliedQuantity);
|
||||
}
|
||||
data->handle.update_books(
|
||||
TimeStamp::now(), dbids, dasks, ibids, iasks,
|
||||
utils::TimeStamp::now(), dbids, dasks, ibids, iasks,
|
||||
(uint32_t)msg_info.sequenceNumber);
|
||||
}
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ void MDP3Listener::onEndOfTcpRecovery(
|
||||
// Mark the start/end of a packet
|
||||
void MDP3Listener::onPacket(onixs::Handler &, const onixs::PacketArgs &args) {
|
||||
// Mark the arrival of the packet
|
||||
_packet_arrived = TimeStamp::now();
|
||||
_packet_arrived = utils::TimeStamp::now();
|
||||
auto seq = args.seqNumber();
|
||||
if (!_book_updates.empty()) {
|
||||
if (_latest_sequence != seq) {
|
||||
|
||||
@@ -96,10 +96,10 @@ void copy_misc(IntPrice settlement, MiscData &misc, co2::MiscMessage *pmisc) {
|
||||
struct MDRecordingSecEntry {
|
||||
SecurityKey key;
|
||||
MDConsumerHandle handle;
|
||||
TimeStamp direct_book_ts = {};
|
||||
TimeStamp implied_book_ts = {};
|
||||
TimeStamp trade_ts = {};
|
||||
TimeStamp misc_ts = {};
|
||||
utils::TimeStamp direct_book_ts = {};
|
||||
utils::TimeStamp implied_book_ts = {};
|
||||
utils::TimeStamp trade_ts = {};
|
||||
utils::TimeStamp misc_ts = {};
|
||||
MDRecordingSecEntry(SecurityKey key, MDConsumerHandle handle)
|
||||
: key(key), handle(handle) {}
|
||||
};
|
||||
@@ -238,7 +238,7 @@ void MDRecorder::_scan_securities() {
|
||||
}
|
||||
|
||||
void MDRecorder::_poll_books(MDRecordingSecEntry &md_entry) {
|
||||
TimeStamp ts;
|
||||
utils::TimeStamp ts;
|
||||
bool md_change = false;
|
||||
co2::TotalBook book;
|
||||
me->reusables.clean_books();
|
||||
@@ -276,7 +276,7 @@ void MDRecorder::_poll_books(MDRecordingSecEntry &md_entry) {
|
||||
}
|
||||
|
||||
void MDRecorder::_poll_trades(MDRecordingSecEntry &md_entry) {
|
||||
TimeStamp ts;
|
||||
utils::TimeStamp ts;
|
||||
PriceSize t_ps;
|
||||
datetime::LLDateTime trade_ts;
|
||||
size_t total_volume;
|
||||
|
||||
@@ -198,7 +198,7 @@ void run_periodic_dumper(
|
||||
auto sequence = e.handle.sequence();
|
||||
if (sequence != e.seq && sequence % seq_mod == 0) {
|
||||
e.seq = sequence;
|
||||
auto tread = TimeStamp::now();
|
||||
auto tread = utils::TimeStamp::now();
|
||||
utils::TimeStamp twrite;
|
||||
e.handle.get_book(
|
||||
twrite, COCONUT_MAX_DEPTH, bid.data(), ask.data());
|
||||
|
||||
@@ -21,7 +21,9 @@ ShmDumper::ShmDumper(const string &name) : _name(name) {}
|
||||
|
||||
ShmDumper::~ShmDumper() {}
|
||||
|
||||
double dump(TimeStamp time) { return (TimeStamp::now() - time).seconds(); }
|
||||
double dump(utils::TimeStamp time) {
|
||||
return (utils::TimeStamp::now() - time).seconds();
|
||||
}
|
||||
|
||||
string dump(IntPrice price) {
|
||||
stringstream res;
|
||||
|
||||
@@ -150,8 +150,8 @@ struct MBOProcessorImpl {
|
||||
|
||||
// If the queue is still empty sleep briefly
|
||||
if (incremental_input.empty()) {
|
||||
if (last_pool_print != TimeStamp::invalid()) {
|
||||
auto now = TimeStamp::now();
|
||||
if (last_pool_print != utils::TimeStamp::invalid()) {
|
||||
auto now = utils::TimeStamp::now();
|
||||
if ((now - last_pool_print).seconds() > 600) {
|
||||
last_pool_print = now;
|
||||
print_pool_stats(pool);
|
||||
|
||||
@@ -71,9 +71,9 @@ struct MDClientImpl {
|
||||
|
||||
size_t scan_securities() {
|
||||
if (_consumer.all_heartbeats_ok()) {
|
||||
TimeStamp start = TimeStamp::now();
|
||||
const auto start = utils::TimeStamp::now();
|
||||
auto count = _consumer.scan_securities();
|
||||
auto delta = (TimeStamp::now() - start);
|
||||
const auto delta = (utils::TimeStamp::now() - start);
|
||||
if (delta.milliseconds() > 10) {
|
||||
LOG(md, Diag, "Scanned handles: {}ms found: {} securities. ",
|
||||
delta.milliseconds(), count);
|
||||
|
||||
@@ -460,7 +460,7 @@ class SyntheticConsumerInst {
|
||||
auto updated = std::make_unique<spark::ExecutionStrategy>();
|
||||
updated->CopyFrom(m.strategy());
|
||||
iter->second->strategy.swap(updated);
|
||||
iter->second->updated = TimeStamp::now();
|
||||
iter->second->updated = utils::TimeStamp::now();
|
||||
// Keep the old strategy alive because it could be in use.
|
||||
// metadata is changed so seldomly this is not a significant use of
|
||||
// memory
|
||||
@@ -525,7 +525,7 @@ class SyntheticConsumerInst {
|
||||
s->strategy = std::make_unique<spark::ExecutionStrategy>(
|
||||
strategy.strategy);
|
||||
s->legs = legs;
|
||||
s->updated = TimeStamp::now();
|
||||
s->updated = utils::TimeStamp::now();
|
||||
result.insert(make_pair(strategy.security->id(), s));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,13 +57,13 @@ void MDConsumerHandle::init(
|
||||
set_mbo(mbo);
|
||||
}
|
||||
|
||||
TimeStamp copy_bbo(
|
||||
utils::TimeStamp copy_bbo(
|
||||
const HotEntry &hot, PriceSize &out_bid, PriceSize &out_ask) {
|
||||
// We expect the time, in_bid and in_ask to be changing (rapidly)
|
||||
//
|
||||
TimeStamp t;
|
||||
utils::TimeStamp t;
|
||||
int attempts = 0;
|
||||
// If the publisher crashed and left TimeStamp::invalid() in memory we need
|
||||
// If the publisher crashed and left utils::TimeStamp::invalid() in memory we need
|
||||
// to be able to escape the loop This max_attempts allows get_bbo() to return
|
||||
// 'false' in this case so the calling thread can continue and hopefully
|
||||
// check the heartbeat.
|
||||
@@ -73,17 +73,17 @@ TimeStamp copy_bbo(
|
||||
out_bid = hot.book.bid();
|
||||
out_ask = hot.book.ask();
|
||||
++attempts;
|
||||
} while ((t != hot.time() || t == TimeStamp::invalid()) &&
|
||||
} while ((t != hot.time() || t == utils::TimeStamp::invalid()) &&
|
||||
attempts < max_attempts);
|
||||
if (attempts >= max_attempts) {
|
||||
return TimeStamp::invalid();
|
||||
return utils::TimeStamp::invalid();
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
TimeStamp copy_depth(
|
||||
utils::TimeStamp copy_depth(
|
||||
const HotDepthEntry &hot, size_t count, PriceSize *bid, PriceSize *ask) {
|
||||
TimeStamp t;
|
||||
utils::TimeStamp t;
|
||||
int attempts = 0;
|
||||
const int max_attempts = 1619200;
|
||||
do {
|
||||
@@ -92,10 +92,10 @@ TimeStamp copy_depth(
|
||||
hot.read_direct(x, &bid[x], &ask[x]);
|
||||
}
|
||||
++attempts;
|
||||
} while ((t != hot.time() || t == TimeStamp::invalid()) &&
|
||||
} while ((t != hot.time() || t == utils::TimeStamp::invalid()) &&
|
||||
attempts < max_attempts);
|
||||
if (attempts >= max_attempts) {
|
||||
return TimeStamp::invalid();
|
||||
return utils::TimeStamp::invalid();
|
||||
}
|
||||
return t;
|
||||
}
|
||||
@@ -268,7 +268,7 @@ const spark::LegSpreaderParams &get_spreader_params(
|
||||
return spark::LegSpreaderParams::default_instance();
|
||||
}
|
||||
|
||||
TimeStamp copy_synthetic_depth(
|
||||
utils::TimeStamp copy_synthetic_depth(
|
||||
const SyntheticStrategy &synth,
|
||||
size_t count,
|
||||
PriceSize *bid,
|
||||
@@ -277,10 +277,10 @@ TimeStamp copy_synthetic_depth(
|
||||
small_vector<DepthTraversal> ask_leg_travs;
|
||||
bid_leg_travs.reserve(synth.legs.size());
|
||||
ask_leg_travs.reserve(synth.legs.size());
|
||||
TimeStamp rv = std::numeric_limits<TimeStamp>::min();
|
||||
auto rv = std::numeric_limits<utils::TimeStamp>::min();
|
||||
for (size_t x = 0; x < synth.legs.size(); ++x) {
|
||||
std::array<PriceSize, COCONUT_MAX_DEPTH> bids, asks;
|
||||
TimeStamp t;
|
||||
utils::TimeStamp t;
|
||||
const spark::LegSpreaderParams &leg_params =
|
||||
get_spreader_params(synth, synth.legs[x].key());
|
||||
auto mdtype = leg_params.market_data_type();
|
||||
@@ -290,8 +290,8 @@ TimeStamp copy_synthetic_depth(
|
||||
} else {
|
||||
r = synth.legs[x].get_book(t, count, &bids[0], &asks[0]);
|
||||
}
|
||||
if (r == HandleReadResult::BUSY || t == TimeStamp::invalid())
|
||||
return TimeStamp::invalid();
|
||||
if (r == HandleReadResult::BUSY || t == utils::TimeStamp::invalid())
|
||||
return utils::TimeStamp::invalid();
|
||||
|
||||
// NET Change
|
||||
if (synth.security.synthetic().price_calc() ==
|
||||
@@ -335,7 +335,7 @@ TimeStamp copy_synthetic_depth(
|
||||
/////////////////////////////
|
||||
|
||||
bool MDConsumerHandle::get_last_trade(
|
||||
TimeStamp &time,
|
||||
utils::TimeStamp &time,
|
||||
PriceSize &trade,
|
||||
datetime::LLDateTime &trade_timestamp,
|
||||
size_t *total_volume,
|
||||
@@ -365,11 +365,11 @@ bool MDConsumerHandle::get_last_trade(
|
||||
never;
|
||||
}
|
||||
|
||||
TimeStamp MDConsumerHandle::misc_timestamp() const {
|
||||
utils::TimeStamp MDConsumerHandle::misc_timestamp() const {
|
||||
switch (_type) {
|
||||
case HANDLETYPE_SYNTHETIC:
|
||||
case HANDLETYPE_VOID:
|
||||
return std::numeric_limits<TimeStamp>::min();
|
||||
return std::numeric_limits<utils::TimeStamp>::min();
|
||||
case HANDLETYPE_DEPTH:
|
||||
return book.cdata->misc.misc_timestamp;
|
||||
case HANDLETYPE_BBO:
|
||||
@@ -406,16 +406,16 @@ bool MDConsumerHandle::is_heart_beating() const {
|
||||
}
|
||||
never;
|
||||
}
|
||||
TimeStamp MDConsumerHandle::heartbeat() const {
|
||||
utils::TimeStamp MDConsumerHandle::heartbeat() const {
|
||||
switch (_type) {
|
||||
case HANDLETYPE_VOID:
|
||||
return TimeStamp::now();
|
||||
return utils::TimeStamp::now();
|
||||
case HANDLETYPE_DEPTH:
|
||||
return book.cheader->heartbeat;
|
||||
case HANDLETYPE_BBO:
|
||||
return bbo.cheader->heartbeat;
|
||||
case HANDLETYPE_SYNTHETIC:
|
||||
return sane::min<TimeStamp>(
|
||||
return sane::min<utils::TimeStamp>(
|
||||
synthetic.def->legs,
|
||||
[](const MDConsumerHandle &h) { return h.heartbeat(); });
|
||||
}
|
||||
|
||||
@@ -21,13 +21,14 @@ struct SyntheticStrategy {
|
||||
std::unique_ptr<spark::ExecutionStrategy> strategy;
|
||||
api::Security security;
|
||||
std::vector<MDConsumerHandle> legs;
|
||||
TimeStamp updated;
|
||||
utils::TimeStamp updated;
|
||||
};
|
||||
|
||||
TimeStamp copy_bbo(const HotEntry &src, PriceSize &out_bid, PriceSize &out_ask);
|
||||
TimeStamp copy_depth(
|
||||
utils::TimeStamp copy_bbo(
|
||||
const HotEntry &src, PriceSize &out_bid, PriceSize &out_ask);
|
||||
utils::TimeStamp copy_depth(
|
||||
const HotDepthEntry &, size_t count, PriceSize *bid, PriceSize *ask);
|
||||
TimeStamp copy_synthetic_depth(
|
||||
utils::TimeStamp copy_synthetic_depth(
|
||||
const SyntheticStrategy &, size_t count, PriceSize *bid, PriceSize *ask);
|
||||
|
||||
enum class HandleReadResult { NO_CHANGE, BUSY, SUCCESS };
|
||||
@@ -111,23 +112,23 @@ inline void read_combined(
|
||||
}
|
||||
|
||||
template <class Read>
|
||||
TimeStamp optimistic_copy(
|
||||
utils::TimeStamp optimistic_copy(
|
||||
Read read,
|
||||
const HotDepthEntry &hot,
|
||||
size_t count,
|
||||
PriceSize *bid,
|
||||
PriceSize *ask) {
|
||||
TimeStamp t;
|
||||
utils::TimeStamp t;
|
||||
int attempts = 0;
|
||||
const int max_attempts = 1619200;
|
||||
do {
|
||||
t = hot.time();
|
||||
read(hot, count, bid, ask);
|
||||
++attempts;
|
||||
} while ((t != hot.time() || t == TimeStamp::invalid()) &&
|
||||
} while ((t != hot.time() || t == utils::TimeStamp::invalid()) &&
|
||||
attempts < max_attempts);
|
||||
if (attempts >= max_attempts) {
|
||||
return TimeStamp::invalid();
|
||||
return utils::TimeStamp::invalid();
|
||||
}
|
||||
return t;
|
||||
}
|
||||
@@ -161,7 +162,7 @@ class BTS_EXPORT MDConsumerHandle {
|
||||
// bool has_depth() const { return _type == HANDLETYPE_DEPTH || _type ==
|
||||
// HANDLETYPE_SYNTHETIC; };
|
||||
bool is_heart_beating() const;
|
||||
TimeStamp heartbeat() const;
|
||||
utils::TimeStamp heartbeat() const;
|
||||
CoconutSecurityStatus status() const;
|
||||
uint32_t sequence() const {
|
||||
switch (_type) {
|
||||
@@ -173,7 +174,7 @@ class BTS_EXPORT MDConsumerHandle {
|
||||
return bbo.hot->sequence;
|
||||
case HANDLETYPE_SYNTHETIC:
|
||||
bts_assert(!synthetic.def->legs.empty());
|
||||
return sane::min_by<MDConsumerHandle, TimeStamp>(
|
||||
return sane::min_by<MDConsumerHandle, utils::TimeStamp>(
|
||||
synthetic.def->legs,
|
||||
[](const MDConsumerHandle &h) {
|
||||
return h.last_market_update();
|
||||
@@ -270,10 +271,10 @@ class BTS_EXPORT MDConsumerHandle {
|
||||
}
|
||||
}
|
||||
|
||||
TimeStamp last_market_update() const {
|
||||
utils::TimeStamp last_market_update() const {
|
||||
switch (_type) {
|
||||
case HANDLETYPE_VOID:
|
||||
return TimeStamp::invalid();
|
||||
return utils::TimeStamp::invalid();
|
||||
case HANDLETYPE_DEPTH:
|
||||
return book.hot->time();
|
||||
case HANDLETYPE_BBO:
|
||||
@@ -281,7 +282,7 @@ class BTS_EXPORT MDConsumerHandle {
|
||||
case HANDLETYPE_SYNTHETIC:
|
||||
return std::max(
|
||||
synthetic.def->updated,
|
||||
sane::max<TimeStamp>(
|
||||
sane::max<utils::TimeStamp>(
|
||||
synthetic.def->legs, [](const MDConsumerHandle &h) {
|
||||
return h.last_market_update();
|
||||
}));
|
||||
@@ -290,21 +291,21 @@ class BTS_EXPORT MDConsumerHandle {
|
||||
}
|
||||
|
||||
HandleReadResult get_direct_book(
|
||||
TimeStamp &time,
|
||||
utils::TimeStamp &time,
|
||||
uint32_t copydepth,
|
||||
PriceSize *bids,
|
||||
PriceSize *asks) const {
|
||||
return get_book(read_direct, time, copydepth, bids, asks);
|
||||
}
|
||||
HandleReadResult get_implied_book(
|
||||
TimeStamp &time,
|
||||
utils::TimeStamp &time,
|
||||
uint32_t copydepth,
|
||||
PriceSize *bids,
|
||||
PriceSize *asks) const {
|
||||
return get_book(read_implied, time, copydepth, bids, asks);
|
||||
}
|
||||
HandleReadResult get_book(
|
||||
TimeStamp &time,
|
||||
utils::TimeStamp &time,
|
||||
uint32_t copydepth,
|
||||
PriceSize *bids,
|
||||
PriceSize *asks) const {
|
||||
@@ -312,7 +313,7 @@ class BTS_EXPORT MDConsumerHandle {
|
||||
}
|
||||
|
||||
bool get_last_trade(
|
||||
TimeStamp &time,
|
||||
utils::TimeStamp &time,
|
||||
PriceSize &out_trade,
|
||||
datetime::LLDateTime &out_trade_timestamp,
|
||||
size_t *total_volume = nullptr,
|
||||
@@ -332,7 +333,7 @@ class BTS_EXPORT MDConsumerHandle {
|
||||
return this->misc().settlement_date;
|
||||
}
|
||||
|
||||
TimeStamp misc_timestamp() const;
|
||||
utils::TimeStamp misc_timestamp() const;
|
||||
MiscData misc() const;
|
||||
|
||||
MDConsumerHandle &operator=(const MDConsumerHandle &other) {
|
||||
@@ -362,7 +363,7 @@ class BTS_EXPORT MDConsumerHandle {
|
||||
template <class Read>
|
||||
HandleReadResult get_book(
|
||||
Read read,
|
||||
TimeStamp &time,
|
||||
utils::TimeStamp &time,
|
||||
uint32_t copydepth,
|
||||
PriceSize *bids,
|
||||
PriceSize *asks) const {
|
||||
@@ -374,10 +375,10 @@ class BTS_EXPORT MDConsumerHandle {
|
||||
return HandleReadResult::NO_CHANGE;
|
||||
case HANDLETYPE_DEPTH:
|
||||
if (book.hot->time() > time ||
|
||||
book.hot->time() == TimeStamp::invalid()) {
|
||||
TimeStamp temp =
|
||||
book.hot->time() == utils::TimeStamp::invalid()) {
|
||||
utils::TimeStamp temp =
|
||||
optimistic_copy(read, *book.hot, copydepth, bids, asks);
|
||||
if (temp == TimeStamp::invalid()) {
|
||||
if (temp == utils::TimeStamp::invalid()) {
|
||||
return HandleReadResult::BUSY;
|
||||
}
|
||||
time = temp;
|
||||
@@ -389,11 +390,11 @@ class BTS_EXPORT MDConsumerHandle {
|
||||
return HandleReadResult::NO_CHANGE;
|
||||
case HANDLETYPE_SYNTHETIC:
|
||||
auto t = last_market_update();
|
||||
if (t > time || t == TimeStamp::invalid()) {
|
||||
TimeStamp temp = copy_synthetic_depth(
|
||||
if (t > time || t == utils::TimeStamp::invalid()) {
|
||||
utils::TimeStamp temp = copy_synthetic_depth(
|
||||
*synthetic.def, std::min(copydepth, COCONUT_MAX_DEPTH), bids,
|
||||
asks);
|
||||
if (temp == TimeStamp::invalid()) {
|
||||
if (temp == utils::TimeStamp::invalid()) {
|
||||
return HandleReadResult::BUSY;
|
||||
}
|
||||
time = temp;
|
||||
|
||||
@@ -9,6 +9,8 @@ namespace md {
|
||||
using namespace datetime;
|
||||
using namespace co2;
|
||||
|
||||
using bts::utils::TimeStamp;
|
||||
|
||||
#define TRADING_STATUS(x) bts::domain::protobufs::TRADINGSTATUS_##x
|
||||
|
||||
using bts::domain::protobufs::AggressorSide;
|
||||
|
||||
@@ -44,12 +44,12 @@ class BTS_EXPORT MDProducerHandle {
|
||||
}
|
||||
|
||||
void update_bbo(
|
||||
TimeStamp time,
|
||||
utils::TimeStamp time,
|
||||
const PriceSize bid_price,
|
||||
const PriceSize ask_price,
|
||||
uint16_t seq = 0);
|
||||
void update_direct(
|
||||
TimeStamp time,
|
||||
utils::TimeStamp time,
|
||||
const std::array<PriceSize, COCONUT_MAX_DEPTH> &bids,
|
||||
const std::array<PriceSize, COCONUT_MAX_DEPTH> &asks,
|
||||
uint32_t seq = 0) {
|
||||
@@ -57,7 +57,7 @@ class BTS_EXPORT MDProducerHandle {
|
||||
update_bbo(time, bids[0], asks[0], seq);
|
||||
} else {
|
||||
auto &book = hdepth();
|
||||
book.set_time(TimeStamp::invalid());
|
||||
book.set_time(utils::TimeStamp::invalid());
|
||||
for (size_t x = 0; x < COCONUT_MAX_DEPTH; ++x) {
|
||||
book.write_direct(x, bids[x], asks[x]);
|
||||
}
|
||||
@@ -69,13 +69,13 @@ class BTS_EXPORT MDProducerHandle {
|
||||
}
|
||||
|
||||
void update_implied(
|
||||
TimeStamp time,
|
||||
utils::TimeStamp time,
|
||||
const std::array<PriceSize, COCONUT_MAX_IMPLIED_DEPTH> &bids,
|
||||
const std::array<PriceSize, COCONUT_MAX_IMPLIED_DEPTH> &asks,
|
||||
uint32_t seq = 0) {
|
||||
if (has_depth()) {
|
||||
auto &book = hdepth();
|
||||
book.set_time(TimeStamp::invalid());
|
||||
book.set_time(utils::TimeStamp::invalid());
|
||||
for (size_t x = 0; x < COCONUT_MAX_IMPLIED_DEPTH; ++x) {
|
||||
book.write_implied(x, bids[x], asks[x]);
|
||||
}
|
||||
@@ -87,7 +87,7 @@ class BTS_EXPORT MDProducerHandle {
|
||||
}
|
||||
|
||||
void update_books(
|
||||
TimeStamp time,
|
||||
utils::TimeStamp time,
|
||||
const std::array<PriceSize, COCONUT_MAX_DEPTH> &bid,
|
||||
const std::array<PriceSize, COCONUT_MAX_DEPTH> &ask,
|
||||
const std::array<PriceSize, COCONUT_MAX_IMPLIED_DEPTH> &implied_bid,
|
||||
@@ -96,7 +96,7 @@ class BTS_EXPORT MDProducerHandle {
|
||||
|
||||
if (has_depth()) {
|
||||
auto &book = hdepth();
|
||||
book.set_time(TimeStamp::invalid());
|
||||
book.set_time(utils::TimeStamp::invalid());
|
||||
for (size_t x = 0; x < COCONUT_MAX_DEPTH; ++x) {
|
||||
if (x < COCONUT_MAX_IMPLIED_DEPTH) {
|
||||
book.write_implied(x, implied_bid[x], implied_ask[x]);
|
||||
@@ -115,7 +115,7 @@ class BTS_EXPORT MDProducerHandle {
|
||||
|
||||
// Updates trade log and last trade
|
||||
void add_trade(
|
||||
TimeStamp time,
|
||||
utils::TimeStamp time,
|
||||
const PriceSize pricesize,
|
||||
datetime::LLDateTime date,
|
||||
domain::protobufs::AggressorSide agside,
|
||||
@@ -123,30 +123,32 @@ class BTS_EXPORT MDProducerHandle {
|
||||
bool from_spread = false); // cold
|
||||
// Update last_trade without updating trade log
|
||||
void set_last_trade(
|
||||
TimeStamp time,
|
||||
utils::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
|
||||
void add_rfq(
|
||||
utils::TimeStamp time, const co2::QuoteRequestMessage &rfq); // cold
|
||||
|
||||
void update_exchange_status(TimeStamp time, TradingStatus status); // cold
|
||||
void update_exchange_status(
|
||||
utils::TimeStamp time, TradingStatus status); // cold
|
||||
|
||||
// Misc fields
|
||||
void update_settlement(
|
||||
TimeStamp time, IntPrice price, datetime::Date date); // cold
|
||||
utils::TimeStamp time, IntPrice price, datetime::Date date); // cold
|
||||
void update_previous_settlement(
|
||||
TimeStamp time, IntPrice price, datetime::Date date); // cold
|
||||
utils::TimeStamp time, IntPrice price, datetime::Date date); // cold
|
||||
void update_opening(
|
||||
TimeStamp time, Price price, datetime::Date date); // cold
|
||||
utils::TimeStamp time, Price price, datetime::Date date); // cold
|
||||
void update_closing(
|
||||
TimeStamp time, Price price, datetime::Date date); // cold
|
||||
void update_session_high(TimeStamp time, Price price); // cold
|
||||
void update_session_low(TimeStamp time, Price price); // cold
|
||||
void update_session_high_bid(TimeStamp time, Price price); // cold
|
||||
void update_session_low_offer(TimeStamp time, Price price); // cold
|
||||
void update_fixing_price(TimeStamp time, Price price); // cold
|
||||
utils::TimeStamp time, Price price, datetime::Date date); // cold
|
||||
void update_session_high(utils::TimeStamp time, Price price); // cold
|
||||
void update_session_low(utils::TimeStamp time, Price price); // cold
|
||||
void update_session_high_bid(utils::TimeStamp time, Price price); // cold
|
||||
void update_session_low_offer(utils::TimeStamp time, Price price); // cold
|
||||
void update_fixing_price(utils::TimeStamp time, Price price); // cold
|
||||
|
||||
void mark_deleted(); // cold
|
||||
|
||||
|
||||
@@ -31,8 +31,6 @@ namespace md {
|
||||
// HOT Data
|
||||
///////////////////////
|
||||
|
||||
using utils::TimeStamp;
|
||||
|
||||
const uint32_t shm_version = 107;
|
||||
|
||||
struct ALIGNED_(CACHE_LINE) HotHeader {
|
||||
@@ -47,10 +45,10 @@ struct ALIGNED_(CACHE_LINE) HotHeader {
|
||||
// These should not be cache line aligned because they are small enough for
|
||||
// multiple to fit on one line easily
|
||||
class HotEntry {
|
||||
std::atomic<TimeStamp> timestamp; // 8
|
||||
std::atomic<utils::TimeStamp> timestamp; // 8
|
||||
public:
|
||||
HotEntry()
|
||||
: timestamp(TimeStamp(0)), book(), key(invalid_security_key),
|
||||
: timestamp(utils::TimeStamp(0)), book(), key(invalid_security_key),
|
||||
sequence(0), status(co2::COCONUTSECURITYSTATUS_OK) {}
|
||||
uint32_t size() const { return sizeof(HotEntry); }
|
||||
PriceLevel book; // 24
|
||||
@@ -58,10 +56,12 @@ class HotEntry {
|
||||
uint32_t sequence; // 4
|
||||
IntPrice settlement; // 8
|
||||
uint8_t status; // 1
|
||||
void set_time(const TimeStamp &t) {
|
||||
void set_time(const utils::TimeStamp &t) {
|
||||
timestamp.store(t, std::memory_order_release);
|
||||
}
|
||||
TimeStamp time() const { return timestamp.load(std::memory_order_acquire); }
|
||||
utils::TimeStamp time() const {
|
||||
return timestamp.load(std::memory_order_acquire);
|
||||
}
|
||||
};
|
||||
static_assert(sizeof(HotEntry) <= CACHE_LINE, "HotEntry should be small");
|
||||
|
||||
@@ -73,10 +73,10 @@ void to_json(nlohmann::json &j, const HotEntry &h);
|
||||
const uint32_t COCONUT_MAX_DEPTH = 10;
|
||||
const uint32_t COCONUT_MAX_IMPLIED_DEPTH = 2;
|
||||
class HotDepthEntry {
|
||||
std::atomic<TimeStamp> timestamp; // 8
|
||||
std::atomic<utils::TimeStamp> timestamp; // 8
|
||||
public:
|
||||
HotDepthEntry()
|
||||
: timestamp(TimeStamp(0)), key(invalid_security_key), sequence(0),
|
||||
: timestamp(utils::TimeStamp(0)), key(invalid_security_key), sequence(0),
|
||||
direct(), implied(), status(co2::COCONUTSECURITYSTATUS_OK) {}
|
||||
uint32_t size() const { return sizeof(HotDepthEntry); }
|
||||
security_key
|
||||
@@ -116,10 +116,12 @@ class HotDepthEntry {
|
||||
return false;
|
||||
}
|
||||
|
||||
void set_time(const TimeStamp &t) {
|
||||
void set_time(const utils::TimeStamp &t) {
|
||||
timestamp.store(t, std::memory_order_release);
|
||||
}
|
||||
TimeStamp time() const { return timestamp.load(std::memory_order_acquire); }
|
||||
utils::TimeStamp time() const {
|
||||
return timestamp.load(std::memory_order_acquire);
|
||||
}
|
||||
};
|
||||
static_assert(sizeof(HotDepthEntry) <= 320, "HotDepthEntry should be small");
|
||||
|
||||
@@ -133,7 +135,7 @@ void to_json(nlohmann::json &j, const HotDepthEntry &h);
|
||||
struct ALIGNED_(CACHE_LINE) ColdHeader {
|
||||
ColdHeader()
|
||||
: version(shm_version), count(0), segment_count(0),
|
||||
create_time(TimeStamp::now()), heartbeat(),
|
||||
create_time(utils::TimeStamp::now()), heartbeat(),
|
||||
disable_heartbeat(
|
||||
config::get<md::PublisherOptions>().disable_heartbeat()),
|
||||
heartbeat_ms(config::get<md::PublisherOptions>().heartbeat_ms()),
|
||||
@@ -145,8 +147,8 @@ struct ALIGNED_(CACHE_LINE) ColdHeader {
|
||||
uint32_t version;
|
||||
size_t count;
|
||||
size_t segment_count;
|
||||
TimeStamp create_time;
|
||||
TimeStamp heartbeat;
|
||||
utils::TimeStamp create_time;
|
||||
utils::TimeStamp heartbeat;
|
||||
bool disable_heartbeat;
|
||||
uint32_t heartbeat_ms;
|
||||
uint32_t heartbeat_boot_seconds;
|
||||
@@ -176,7 +178,7 @@ struct MiscData {
|
||||
session_high(NO_PRICE), session_low(NO_PRICE),
|
||||
session_high_bid(NO_PRICE), session_low_offer(NO_PRICE),
|
||||
fixing_price(NO_PRICE) {}
|
||||
TimeStamp misc_timestamp;
|
||||
utils::TimeStamp misc_timestamp;
|
||||
// Settlement
|
||||
datetime::Date settlement_date;
|
||||
IntPrice previous_settlement_price;
|
||||
|
||||
@@ -55,6 +55,8 @@ namespace test {
|
||||
using namespace api;
|
||||
using namespace co2;
|
||||
|
||||
using bts::utils::TimeStamp;
|
||||
|
||||
//
|
||||
// Helper functions for Producer/Consumer tests
|
||||
//
|
||||
|
||||
@@ -22,6 +22,8 @@ int synthetic_book_merge_tests = 0;
|
||||
namespace md {
|
||||
namespace test {
|
||||
|
||||
using bts::utils::TimeStamp;
|
||||
|
||||
// std::tuple is hard to read in the debugger
|
||||
|
||||
ostream &operator<<(ostream &os, const PS &val) {
|
||||
|
||||
Reference in new issue
Block a user