FIX: CHnaged databanto symbol source to asset

This commit is contained in:
Mohammad Arham committed 2024-09-24 11:31:49 +00:00
1 parent b4a5d5c832
commit 68e04cb3f5
1 file changed
+23 -19
@@ -8,6 +8,7 @@
#include "lib/domain/Quantity.h"
#include "lib/domain/Security.h"
#include "lib/domain/SecurityID.h"
#include "lib/domain_model/Security.pb.h"
#include "lib/utils/TimeStamp.h"
#include "lib/utils/bts_assert.h"
#include "lib/utils/bts_chrono.h"
@@ -48,21 +49,6 @@ void DatabentoDatahandler::run(
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 = id.substr(0, 3);
break;
case api::domain::Venue::VENUE_GLBX:
if (id.length() > 5)
return databento::KeepGoing::Continue;
symbol = id.substr(0, 2);
break;
default:
bts_assert_msg(false, "Exchange not supported on databento");
return databento::KeepGoing::Stop;
}
bts::domain::SecurityID sec_id{sec_id_store->get_or_add(
venue, std::to_string(msg.hd.instrument_id))};
bts::domain::Security sec;
@@ -71,13 +57,14 @@ void DatabentoDatahandler::run(
sec.security_common.id = sec_id;
sec.security_common.exchange_sec_id = msg.hd.instrument_id;
sec.security_common.desc = msg.RawSymbol();
sec.security_common.symbol = symbol;
sec.security_common.asset = symbol;
sec.security_common.group = symbol;
sec.security_common.symbol = msg.Asset();
sec.security_common.asset = msg.Asset();
sec.security_common.group = msg.Group();
sec.security_common.min_price_increment = 0.01;
sec.security_common.min_quantity = 0.01;
sec.security_common.min_quantity_increment = 0.01;
sec.security_common.currency = {msg.currency.data(), msg.currency.size()};
// sec.security_common.cpp = msg.hd.
const std::string_view sec_type = {msg.security_type.data(), msg.security_type.size()};
const auto exp_nanos = msg.expiration;
@@ -85,8 +72,15 @@ void DatabentoDatahandler::run(
const auto expiration_time = bts::core::TimeStamp::from_iso_string(exp_string);
if (sec_type.find("OPT") != std::string::npos) {
auto call_put = api::domain::CallPut::PUT;
if(msg.instrument_class == 'C' ){
call_put=api::domain::CallPut::CALL;
}
else{
bts_assert(msg.instrument_class == 'P');
}
sec.security.emplace<bts::domain::OptionSecurity>(
expiration_time, bts::domain::Price::from_double(msg.strike_price));
expiration_time, bts::domain::Price(msg.strike_price, -9),call_put);
} else if (sec_type.find("FUT") != std::string::npos) {
sec.security.emplace<bts::domain::FutureSecurity>(expiration_time);
} else {
@@ -106,6 +100,16 @@ void DatabentoDatahandler::run(
return databento::KeepGoing::Continue;
sleep_for(sleep_duration);
// switch (venue) {
// case api::domain::Venue::VENUE_GLBX:
// // sleep_for(sleep_duration);
// break;
// case api::domain::Venue::VENUE_CBOE:
// break;
// default:
// bts_assert_msg(false, "Exchange not supported on databento");
// return databento::KeepGoing::Stop;
// }
bts::domain::SecurityID sec_id = bts::domain::SecurityID(sec_id_opt.value());
domain::Book book;
book.set_security_id(sec_id);