Spark-552 Synthetic Securities not restored from DB

This commit is contained in:
Eric Harding committed 2018-02-26 16:05:24 -05:00
1 parent bde83aa111
commit 51bf57eff4
4 files changed
+18 -7

No files matched your search

-3
View File
@@ -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:
+3 -2
View File
@@ -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<Security*>& 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());
+1 -1
View File
@@ -52,7 +52,7 @@ SecurityIDRecorder::SecurityIDRecorder():
SecurityIDRecorder::~SecurityIDRecorder() { }
void SecurityIDRecorder::init() {
string db_dir = config::get<config::System>().data_path() + "/md/";
string db_dir = config::get<config::System>().data_path() + "databases/md/";
string db_path = db_dir + "/security_keys.sqlite";
if (!boost::filesystem::exists(db_dir)) {
+14 -1
View File
@@ -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<bts::datetime::Date> {
// static bts::datetime::Date min() { return bts::datetime::Date(1970,1,1); }
// static bts::datetime::Date max() { return bts::datetime::Date(2097,12,31); }
// };
// }