diff --git a/src/lib/md/MDConsumer.cpp b/src/lib/md/MDConsumer.cpp index 3ed48ed9e..593a73eac 100644 --- a/src/lib/md/MDConsumer.cpp +++ b/src/lib/md/MDConsumer.cpp @@ -368,9 +368,6 @@ private: // called by subscription if (iter != _data.end()) { iter->second->strategy.CopyFrom(m.strategy()); } - else { - LOG(md, Error, "Got metadata for unknown security key={}. This should not be possible. key=", m.security_key()); - } } private: diff --git a/src/lib/md/SecurityDB.cpp b/src/lib/md/SecurityDB.cpp index 19cc376dd..d6d5184f6 100644 --- a/src/lib/md/SecurityDB.cpp +++ b/src/lib/md/SecurityDB.cpp @@ -57,7 +57,8 @@ size_t load_securities( auto db = dbptr.get(); auto select_stmt = prepare_query(db, "select key,symbol,venue,type,security_blob from securities where expiration > ?"); auto select = select_stmt.get(); - sqlite3_bind_int(select, 1, datetime::today().to_short()); + // sqlite3_bind_int(select, 1, datetime::today().to_short()); + sqlite3_bind_int(select, 1, 0); auto result = sqlite3_step(select); Security security; while (result == SQLITE_ROW) { @@ -98,7 +99,7 @@ void store_if_new(const std::vector& securities) { SQLITE_CHK(sqlite3_bind_int(insert.get(), 3, psecurity->exchange()), dbptr); SQLITE_CHK(sqlite3_bind_int(insert.get(), 4, securitytype_of(*psecurity)), dbptr); SQLITE_CHK(sqlite3_bind_blob(insert.get(), 5, buffer.c_str(), buffer.size(), SQLITE_STATIC), dbptr); - SQLITE_CHK(sqlite3_bind_int(insert.get(), 6, datetime::today().to_short()), dbptr); + SQLITE_CHK(sqlite3_bind_int(insert.get(), 6, expiration(*psecurity).to_short()), dbptr); auto result = sqlite3_step(insert.get()); if (result != SQLITE_DONE) { LOG(md, Warn, "Failed to insert security into security db. key={}", psecurity->id()); diff --git a/src/lib/md/SecurityIDRecorder.cpp b/src/lib/md/SecurityIDRecorder.cpp index 4fead601b..7676627f2 100644 --- a/src/lib/md/SecurityIDRecorder.cpp +++ b/src/lib/md/SecurityIDRecorder.cpp @@ -52,7 +52,7 @@ SecurityIDRecorder::SecurityIDRecorder(): SecurityIDRecorder::~SecurityIDRecorder() { } void SecurityIDRecorder::init() { - string db_dir = config::get().data_path() + "/md/"; + string db_dir = config::get().data_path() + "databases/md/"; string db_path = db_dir + "/security_keys.sqlite"; if (!boost::filesystem::exists(db_dir)) { diff --git a/src/lib/utils/datetime.h b/src/lib/utils/datetime.h index 210202f58..e733df76c 100755 --- a/src/lib/utils/datetime.h +++ b/src/lib/utils/datetime.h @@ -20,7 +20,12 @@ struct Date { uint16_t year; uint8_t month; uint8_t day; - bool operator<(const Date& other) const { return !(*this == other) && !(year > other.year) && !(month > other.month) && !(day > other.day); } + bool operator<(const Date& other) const { + if (year < other.year) return true; + if (year == other.year && month < other.month) return true; + if (year == other.year && month == other.month && day < other.day) return true; + return false; + } bool operator>(const Date& other) const { return !(*this == other) && !(*this < other); } bool operator==(const Date& other) const { return day == other.day && month == other.month && year == other.year; @@ -82,3 +87,11 @@ extern "C" BTS_EXPORT LLDateTime ll_yesterday(); }} +// namespace std { +// template <> +// struct numeric_limits { +// static bts::datetime::Date min() { return bts::datetime::Date(1970,1,1); } +// static bts::datetime::Date max() { return bts::datetime::Date(2097,12,31); } +// }; +// } +