This commit is contained in:
Taha Afzal committed 2024-12-26 07:01:30 +00:00
1 parent 187894ca84
commit ce96d42db8
11 files changed
+777 -13057

No files matched your search

@@ -31,10 +31,10 @@ namespace bts::md::DatabentoHandler {
#define SEC_TYPE(name) bts::api::domain::SECURITY_TYPE_##name
using bts::domain::SecurityID;
using bts::api::domain::CallPut;
using bts::api::domain::SecurityType;
using bts::api::domain::Venue;
using bts::domain::SecurityID;
std::string remove_spaces(const std::string_view &str) {
std::string result;
@@ -68,29 +68,31 @@ void DatabentoDatahandler::run(
const std::string &dataset,
const bool filter_securities,
const bool load_reference_data,
const std::chrono::duration<long double> sleep_duration ) {
const std::chrono::duration<long double> sleep_duration) {
(void)filter_securities;
auto sleep_duration_updated = sleep_duration;
if (!use_file) {
sleep_duration_updated = std::chrono::duration<long double>::zero(); // Set to zero for live data
sleep_duration_updated = std::chrono::duration<
long double>::zero(); // Set to zero for live data
}
auto process_security = [&](const databento::Record &record) {
const auto &msg = record.Get<databento::InstrumentDefMsg>();
std::string id = remove_spaces(msg.RawSymbol());
std::string symbol;
switch (venue) {
case api::domain::Venue::VENUE_CBOE:{
symbol = remove_spaces(std::string(msg.underlying.data(),msg.underlying.size()));
case api::domain::Venue::VENUE_CBOE: {
symbol = remove_spaces(
std::string(msg.underlying.data(), msg.underlying.size()));
break;
}
case api::domain::Venue::VENUE_GLBX:
if (id.length() > 5)
return databento::KeepGoing::Continue;
symbol = id.substr(0, 2);
// sec.security_common.cpp = msg.unit_of_measure_qty;
// sec.security_common.cpp = msg.unit_of_measure_qty;
break;
default:
@@ -115,7 +117,8 @@ void DatabentoDatahandler::run(
parse_sec_type({msg.security_type.data(), msg.security_type.size()});
const auto exp_nanos = msg.expiration;
std::string exp_string = databento::ToIso8601(exp_nanos);
const auto expiration_time = bts::core::TimeStamp::from_iso_string(exp_string);
const auto expiration_time =
bts::core::TimeStamp::from_iso_string(exp_string);
switch (sec_type) {
case SEC_TYPE(FUTURE):
@@ -162,7 +165,8 @@ void DatabentoDatahandler::run(
}
sleep_for(sleep_duration_updated);
bts::domain::SecurityID sec_id = bts::domain::SecurityID(sec_id_opt.value());
bts::domain::SecurityID sec_id =
bts::domain::SecurityID(sec_id_opt.value());
domain::Book book;
book.set_security_id(sec_id);
@@ -183,9 +187,7 @@ void DatabentoDatahandler::run(
return databento::KeepGoing::Continue;
};
if (use_file) {
auto client = databento::HistoricalBuilder{}
.SetKey(key)
.Build();
auto client = databento::HistoricalBuilder{}.SetKey(key).Build();
databento::DbnFileStore dbn_file_store(securities_path);
dbn_file_store.Replay(process_security);
databento::DbnFileStore dbn_file_store2(books_path);