Made SecurityDB ignore expired securities.
This commit is contained in:
1 parent
9ca4f85ea1
commit
8274cd72d8
2 files changed
+18
-3
No files matched your search
@@ -145,4 +145,8 @@ message CMETradingSchedule {
|
||||
// we can elaborate later, but for now it's very simple:
|
||||
// this is "hours after midnight, in Central Time"
|
||||
optional double gen_open_hour = 1 [default = 8.5]; // 8:30 am CT
|
||||
}
|
||||
|
||||
message SecurityExpirationCutoff {
|
||||
optional uint32 max_days_after_expiration =1 [default = 7];
|
||||
}
|
||||
@@ -5,9 +5,12 @@
|
||||
#include "lib/config/config.h"
|
||||
#include "lib/config/protos/system.pb.h"
|
||||
#include "lib/md/Shm/FixedSecurity.h"
|
||||
#include "lib/config/protos/MarketData.pb.h"
|
||||
|
||||
#include <boost/container/flat_set.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
#include <boost/date_time/gregorian/gregorian.hpp>
|
||||
#include <string>
|
||||
|
||||
using std::string;
|
||||
@@ -46,6 +49,15 @@ sqlite3_ptr open_db() {
|
||||
return dbptr;
|
||||
}
|
||||
|
||||
datetime::Date sec_expiration_cut_off()
|
||||
{
|
||||
boost::gregorian::date_duration max_exp_age
|
||||
(config::get<SecurityExpirationCutoff>().max_days_after_expiration());
|
||||
|
||||
auto pt = (datetime::now() - max_exp_age);
|
||||
return datetime::Date(pt.date().year(),pt.date().month(),pt.date().day());
|
||||
}
|
||||
|
||||
size_t load_securities(
|
||||
const std::set<UserSymbol>& symbols,
|
||||
const std::function<void(const api::Security&)>& callback) {
|
||||
@@ -57,8 +69,7 @@ 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, 0);
|
||||
sqlite3_bind_int(select, 1, sec_expiration_cut_off().to_short());
|
||||
auto result = sqlite3_step(select);
|
||||
Security security;
|
||||
while (result == SQLITE_ROW) {
|
||||
@@ -207,4 +218,4 @@ datetime::Date expiration(const api::Security& security) {
|
||||
}
|
||||
}
|
||||
|
||||
}}}//namespace
|
||||
}}}//namespace
|
||||
Reference in new issue
Block a user