Removing temporary security creation from CCMarketDataListener
This commit is contained in:
1 parent
1fff7d5bcd
commit
3a6bda4e08
2 files changed
+35
-44
No files matched your search
@@ -6,6 +6,7 @@
|
||||
#include "lib/core/TimeStamp.h"
|
||||
#include "lib/domain/AggressorSide.h"
|
||||
#include "lib/domain/Book.h"
|
||||
#include "lib/domain/FutureSecurity.h"
|
||||
#include "lib/domain/OptionSecurity.h"
|
||||
#include "lib/domain/Price.h"
|
||||
#include "lib/domain/Security.h"
|
||||
@@ -14,7 +15,10 @@
|
||||
#include "lib/domain/SecurityMarketDataStatistics.h"
|
||||
#include "lib/domain/SecurityState.h"
|
||||
#include "lib/domain/Side.h"
|
||||
#include "lib/domain/SpotSecurity.h"
|
||||
#include "lib/domain/SpreadSecurity.h"
|
||||
#include "lib/domain/TradeRecord.h"
|
||||
#include "lib/domain/Venue.h"
|
||||
#include "lib/domain_model/Security.pb.h"
|
||||
#include "lib/logging/logging.h"
|
||||
#include "lib/md/IntPrice.h"
|
||||
@@ -153,7 +157,17 @@ CCMarketDataListener::CCMarketDataListener(
|
||||
void CCMarketDataListener::on_securities(
|
||||
const std::vector<domain::Security const *> &complete_security_list) {
|
||||
for (auto s_ptr : complete_security_list) {
|
||||
const auto &sec = *s_ptr;
|
||||
domain::Security sec = *s_ptr;
|
||||
{
|
||||
sec.security_common.venue = api::domain::Venue::FTX;
|
||||
// TODO, adjusting the data while its gettign fixed
|
||||
if (sec.security_common.desc == "BTC-PERP") {
|
||||
domain::FutureSecurity fsec = {};
|
||||
fsec.expiration = get_ts_from_date(2022, 12, 25);
|
||||
sec.security = fsec;
|
||||
sec.security_common.min_price_increment_ammount = 1.0;
|
||||
}
|
||||
}
|
||||
const auto &s_comm = sec.security_common;
|
||||
auto search_result = _find_sec(sec, true);
|
||||
if (search_result.existed_before) {
|
||||
@@ -172,9 +186,13 @@ void CCMarketDataListener::on_securities(
|
||||
"CCMarketDataListener::on_securities added new security, exchange: "
|
||||
"{} type: {} desc: {} id: {}",
|
||||
bts::api::domain::Venue_Name(s_comm.venue),
|
||||
bts::api::domain::SecurityType_Name(s_comm.type), s_comm.desc,
|
||||
search_result.key);
|
||||
switch (s_ptr->security_type()) {
|
||||
bts::api::domain::SecurityType_Name(sec.security_type()), s_comm.desc,
|
||||
search_result.key,
|
||||
std::holds_alternative<bts::domain::SpotSecurity>(sec.security),
|
||||
std::holds_alternative<bts::domain::FutureSecurity>(sec.security),
|
||||
std::holds_alternative<bts::domain::SpreadSecurity>(sec.security),
|
||||
std::holds_alternative<bts::domain::OptionSecurity>(sec.security));
|
||||
switch (sec.security_type()) {
|
||||
case bts::api::domain::SecurityType::SPOT:
|
||||
_add_spot(sec);
|
||||
break;
|
||||
@@ -209,11 +227,13 @@ void CCMarketDataListener::on_security_statistics(
|
||||
}
|
||||
|
||||
void CCMarketDataListener::on_book(const bts::domain::Book &book) {
|
||||
_temp_add_security();
|
||||
me->n_bk_updates++;
|
||||
auto handle = _find_handle(book.security_id());
|
||||
bts_assert_msg(
|
||||
handle != nullptr, "CCMarketDataListener::on_book null handle");
|
||||
if (handle == nullptr) {
|
||||
LOG(md, Error, "CCMarketDataListener::on_book, could not find sec_id: {}",
|
||||
book.security_id());
|
||||
return;
|
||||
}
|
||||
copy_books(book, me->bids, bts::domain::Side::Value::Buy);
|
||||
copy_books(book, me->asks, bts::domain::Side::Value::Sell);
|
||||
handle->handle.update_direct(utils::TimeStamp::now(), me->bids, me->asks);
|
||||
@@ -296,7 +316,7 @@ SecSearchResult CCMarketDataListener::_find_sec(
|
||||
CCSecurityData *CCMarketDataListener::_find_handle(
|
||||
bts::domain::SecurityID cc_id) {
|
||||
// TODO: temp
|
||||
cc_id = me->cc_sec_id_map.begin()->first;
|
||||
// cc_id = me->cc_sec_id_map.begin()->first;
|
||||
auto it = me->cc_sec_id_map.find(cc_id);
|
||||
if (it != me->cc_sec_id_map.end()) {
|
||||
auto id = it->second;
|
||||
@@ -346,6 +366,11 @@ void CCMarketDataListener::_add_option(const bts::domain::Security &sec) {
|
||||
}
|
||||
|
||||
void CCMarketDataListener::_add_spot(const bts::domain::Security &sec) {
|
||||
LOG(md, Info,
|
||||
"CCMarketDataListener::_add_spot (spots are disabled) ignoring spot: "
|
||||
"{}",
|
||||
sec.security_common.desc);
|
||||
return;
|
||||
bts_assert(sec.security_type() == bts::api::domain::SecurityType::SPOT);
|
||||
auto search_result = _find_sec(sec, false);
|
||||
bts_assert(search_result.existed_before);
|
||||
@@ -374,45 +399,13 @@ void CCMarketDataListener::_copy_security_common(
|
||||
auto symbol = from.security_common.symbol;
|
||||
to.symbol(symbol);
|
||||
to.security_desc(from.security_common.desc);
|
||||
// TODO
|
||||
to.exchange = Venue::VENUE_FTX;
|
||||
to.display_factor = 1.0;
|
||||
to.display_factor = 0.0;
|
||||
to.price_break = 0.0;
|
||||
to.low_tick = to.high_tick =
|
||||
from.security_common.min_price_increment_ammount;
|
||||
}
|
||||
|
||||
// just adds the BTC perp
|
||||
void CCMarketDataListener::_temp_add_security() {
|
||||
if (!me->cc_sec_id_map.empty()) {
|
||||
return;
|
||||
}
|
||||
bts::domain::Security sec = {};
|
||||
// common
|
||||
auto &scomm = sec.security_common;
|
||||
scomm.venue = api::domain::FTX;
|
||||
std::string desc = "BTC-PERPETUAL";
|
||||
scomm.exchange_sec_id = desc;
|
||||
auto id = me->id_gen.get_id(me->cc_name_prefix, desc, true);
|
||||
bts_assert(id.has_value());
|
||||
scomm.id = domain::SecurityID(id.value());
|
||||
scomm.type = api::domain::SecurityType::FUTURE;
|
||||
scomm.currency = api::domain::USD;
|
||||
scomm.display_factor = 1;
|
||||
scomm.cash_per_point = 1;
|
||||
scomm.symbol = "BTC";
|
||||
scomm.desc = scomm.exchange_sec_id;
|
||||
scomm.min_price_increment_ammount = 0.01;
|
||||
scomm.min_quantity_increment = 0.0001;
|
||||
// future
|
||||
bts::domain::FutureSecurity fs = {};
|
||||
fs.expiration = // core::TimeStamp(0);
|
||||
get_ts_from_date(2022, 12, 25);
|
||||
sec.security = fs;
|
||||
|
||||
std::vector<domain::Security const *> temp_list;
|
||||
temp_list.push_back(&sec);
|
||||
on_securities(temp_list);
|
||||
}
|
||||
|
||||
} // namespace bts::md
|
||||
#endif
|
||||
@@ -38,8 +38,6 @@ class CCMarketDataListener : public IMarketDataListener {
|
||||
std::unique_ptr<PImpl> me;
|
||||
|
||||
private:
|
||||
// temporary functions to get things going
|
||||
void _temp_add_security();
|
||||
SecSearchResult _find_sec(
|
||||
const bts::domain::Security &sec, bool add_if_absent);
|
||||
// given a cc id, returns the bts persisted id, if it can find one
|
||||
|
||||
Reference in new issue
Block a user