AnalyticsServiceServer's archive vol request now respects the symbol in the arguments
This commit is contained in:
1 parent
cd576793f7
commit
e8dfbe1d01
2 files changed
+29
-8
No files matched your search
@@ -363,20 +363,41 @@ void AnalyticsServiceServer::archive_theos(
|
||||
void AnalyticsServiceServer::get_archived_theos(
|
||||
const bts::api::analytics::ArchivedTheoRetrieval &ret,
|
||||
const bts::api::Response<bts::api::analytics::ArchivedTheoList> &resp) {
|
||||
auto contains_st = [&](const ArchivedTheoList &tl) {
|
||||
for (const auto &st : tl.sec_tups()) {
|
||||
// TODO: compare all, just not symbol
|
||||
if (st.symbol() == ret.sec_tup().symbol()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
ArchivedTheoList rv = {};
|
||||
const auto &rows = me->theos_store->retrieve_all();
|
||||
uint64_t max_diff = std::numeric_limits<uint64_t>::max();
|
||||
std::string key = "";
|
||||
// this is rather slow, we can speed up by sorting the keys
|
||||
// and searching based on distance from ret.save_time()
|
||||
for (const auto &ns : rows) {
|
||||
for (const auto &kv : ns.second) {
|
||||
uint64_t ts = std::stoull(kv.first);
|
||||
int diff = ts - ret.save_time();
|
||||
uint64_t abs_diff = std::abs(diff);
|
||||
if (abs_diff < max_diff) {
|
||||
max_diff = abs_diff;
|
||||
utils::pb::from_string(kv.second, &rv);
|
||||
ArchivedTheoList tl;
|
||||
utils::pb::from_string(kv.second, &tl);
|
||||
if (contains_st(tl)) {
|
||||
uint64_t ts = std::stoull(kv.first);
|
||||
int diff = ts - ret.save_time();
|
||||
uint64_t abs_diff = std::abs(diff);
|
||||
if (abs_diff < max_diff) {
|
||||
key = kv.first;
|
||||
max_diff = abs_diff;
|
||||
rv = tl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
LOG(Gen, Info,
|
||||
"AnalyticsServiceServer::get_archived_theo save_time: {} symbol: {} "
|
||||
"key: {}",
|
||||
ret.save_time(), ret.sec_tup().symbol(), key);
|
||||
resp(rv);
|
||||
}
|
||||
|
||||
|
||||
@@ -449,11 +449,11 @@ void EmMDListener::on_security_state(
|
||||
void EmMDListener::on_trades(
|
||||
const std::vector<emumba::market_data::trade_record const *> &trades,
|
||||
__attribute__((unused)) const void *ptr) {
|
||||
LOG(md, Diag, "EmMDListener::on_trades n_trades:{}", trades.size());
|
||||
LOG(md, Info, "EmMDListener::on_trades n_trades:{}", trades.size());
|
||||
for (const auto &t : trades) {
|
||||
EmumbaSecurityData *sec_data = _find_security(t->sec_id);
|
||||
if (sec_data != nullptr) {
|
||||
LOG(md, Diag, "EmMDListener::on_trades sec: {} ts: {} pr: {} qty: {}",
|
||||
LOG(md, Info, "EmMDListener::on_trades sec: {} ts: {} pr: {} qty: {}",
|
||||
std::string(sec_data->handle.security().security_desc()),
|
||||
t->timestamp.get_timestamp(), t->trade_price.to_double(),
|
||||
t->trade_quantity);
|
||||
|
||||
Reference in new issue
Block a user