cleanup: Get rid of another Security type aliases
This commit is contained in:
1 parent
298290550e
commit
5bc5515b78
15 files changed
+66
-52
No files matched your search
@@ -55,7 +55,7 @@ md::PriceSize coerce_precision(const co2::PriceSizeMessage &p) {
|
||||
struct MDPlayer : md::IRelayWriter {
|
||||
MDPlayer(
|
||||
IMDPlayerObserver &obs,
|
||||
std::map<uint32_t, md::Security> &known_securities)
|
||||
std::map<uint32_t, api::Security> &known_securities)
|
||||
: obs(obs), known_securities(known_securities),
|
||||
forward_implied(config::get<config::ExchangeSim>().forward_implied()) {
|
||||
}
|
||||
@@ -128,7 +128,7 @@ struct MDPlayer : md::IRelayWriter {
|
||||
}
|
||||
}
|
||||
IMDPlayerObserver &obs;
|
||||
std::map<uint32_t, md::Security> &known_securities;
|
||||
std::map<uint32_t, api::Security> &known_securities;
|
||||
bool forward_implied;
|
||||
};
|
||||
|
||||
@@ -170,7 +170,7 @@ int start_exchange_sim(bts::api::Venue venue, md::MBOWriter *mbo) {
|
||||
|
||||
acceptor.start();
|
||||
|
||||
std::map<uint32_t, md::Security> known_securities;
|
||||
std::map<uint32_t, api::Security> known_securities;
|
||||
const auto &conf = config::get<config::ExchangeSim>();
|
||||
while (true) {
|
||||
MDPlayer player(application, known_securities);
|
||||
|
||||
@@ -619,7 +619,7 @@ void ExchangeSimApplication::on_new_security(api::Security const &s) {
|
||||
}
|
||||
|
||||
void ExchangeSimApplication::on_settlement(
|
||||
md::Security const &sec, md::IntPrice price) {
|
||||
api::Security const &sec, md::IntPrice price) {
|
||||
auto sec_desc = get_sim_sec_desc(sec);
|
||||
auto iter = me->md_producer_handles.find(sec_desc);
|
||||
if (iter != me->md_producer_handles.end()) {
|
||||
@@ -629,7 +629,8 @@ void ExchangeSimApplication::on_settlement(
|
||||
}
|
||||
}
|
||||
|
||||
void ExchangeSimApplication::on_high(md::Security const &sec, md::Price price) {
|
||||
void ExchangeSimApplication::on_high(
|
||||
api::Security const &sec, md::Price price) {
|
||||
auto sec_desc = get_sim_sec_desc(sec);
|
||||
auto iter = me->md_producer_handles.find(sec_desc);
|
||||
if (iter != me->md_producer_handles.end()) {
|
||||
@@ -638,7 +639,7 @@ void ExchangeSimApplication::on_high(md::Security const &sec, md::Price price) {
|
||||
}
|
||||
}
|
||||
|
||||
void ExchangeSimApplication::on_low(md::Security const &sec, md::Price price) {
|
||||
void ExchangeSimApplication::on_low(api::Security const &sec, md::Price price) {
|
||||
auto sec_desc = get_sim_sec_desc(sec);
|
||||
auto iter = me->md_producer_handles.find(sec_desc);
|
||||
if (iter != me->md_producer_handles.end()) {
|
||||
@@ -647,7 +648,8 @@ void ExchangeSimApplication::on_low(md::Security const &sec, md::Price price) {
|
||||
}
|
||||
}
|
||||
|
||||
void ExchangeSimApplication::on_open(md::Security const &sec, md::Price price) {
|
||||
void ExchangeSimApplication::on_open(
|
||||
api::Security const &sec, md::Price price) {
|
||||
auto sec_desc = get_sim_sec_desc(sec);
|
||||
auto iter = me->md_producer_handles.find(sec_desc);
|
||||
if (iter != me->md_producer_handles.end()) {
|
||||
@@ -657,7 +659,7 @@ void ExchangeSimApplication::on_open(md::Security const &sec, md::Price price) {
|
||||
}
|
||||
|
||||
void ExchangeSimApplication::on_close(
|
||||
md::Security const &sec, md::Price price) {
|
||||
api::Security const &sec, md::Price price) {
|
||||
auto sec_desc = get_sim_sec_desc(sec);
|
||||
auto iter = me->md_producer_handles.find(sec_desc);
|
||||
if (iter != me->md_producer_handles.end()) {
|
||||
@@ -667,7 +669,7 @@ void ExchangeSimApplication::on_close(
|
||||
}
|
||||
|
||||
void ExchangeSimApplication::on_depth(
|
||||
md::Security const &sec,
|
||||
api::Security const &sec,
|
||||
md::PriceSize bids[md::COCONUT_MAX_DEPTH],
|
||||
md::PriceSize asks[md::COCONUT_MAX_DEPTH],
|
||||
std::array<md::PriceSize, md::COCONUT_MAX_IMPLIED_DEPTH> *implied_bids,
|
||||
|
||||
@@ -69,7 +69,8 @@ class ExchangeSimApplication : public sim::IMDPlayerObserver,
|
||||
void onLogon(const FIX::SessionID &sessionID) override;
|
||||
void onLogout(const FIX::SessionID &sessionID) override;
|
||||
void toAdmin(FIX::Message &, const FIX::SessionID &) override;
|
||||
void toApp(FIX::Message &, const FIX::SessionID &) EXCEPT(FIX::DoNotSend) override;
|
||||
void toApp(FIX::Message &, const FIX::SessionID &)
|
||||
EXCEPT(FIX::DoNotSend) override;
|
||||
void fromAdmin(const FIX::Message &, const FIX::SessionID &) EXCEPT(
|
||||
FIX::FieldNotFound,
|
||||
FIX::IncorrectDataFormat,
|
||||
@@ -117,14 +118,14 @@ class ExchangeSimApplication : public sim::IMDPlayerObserver,
|
||||
void update_md(std::string const &sec_desc);
|
||||
void persist_book(OrderBook const &b);
|
||||
|
||||
void on_new_security(md::Security const &) override;
|
||||
void on_high(md::Security const &sec, md::Price price) override;
|
||||
void on_low(md::Security const &sec, md::Price price) override;
|
||||
void on_open(md::Security const &sec, md::Price price) override;
|
||||
void on_close(md::Security const &sec, md::Price price) override;
|
||||
void on_settlement(md::Security const &, md::IntPrice) override;
|
||||
void on_new_security(api::Security const &) override;
|
||||
void on_high(api::Security const &sec, md::Price price) override;
|
||||
void on_low(api::Security const &sec, md::Price price) override;
|
||||
void on_open(api::Security const &sec, md::Price price) override;
|
||||
void on_close(api::Security const &sec, md::Price price) override;
|
||||
void on_settlement(api::Security const &, md::IntPrice) override;
|
||||
void on_depth(
|
||||
md::Security const &s,
|
||||
api::Security const &s,
|
||||
md::PriceSize bids[md::COCONUT_MAX_DEPTH],
|
||||
md::PriceSize asks[md::COCONUT_MAX_DEPTH],
|
||||
std::array<md::PriceSize, md::COCONUT_MAX_IMPLIED_DEPTH> *implied_bids,
|
||||
|
||||
@@ -10,14 +10,14 @@ class Security;
|
||||
namespace sim {
|
||||
|
||||
struct IMDPlayerObserver {
|
||||
virtual void on_new_security(md::Security const &) = 0;
|
||||
virtual void on_high(const md::Security &, md::Price) = 0;
|
||||
virtual void on_low(const md::Security &, md::Price) = 0;
|
||||
virtual void on_open(const md::Security &, md::Price) = 0;
|
||||
virtual void on_close(const md::Security &, md::Price) = 0;
|
||||
virtual void on_settlement(const md::Security &, md::IntPrice) = 0;
|
||||
virtual void on_new_security(api::Security const &) = 0;
|
||||
virtual void on_high(const api::Security &, md::Price) = 0;
|
||||
virtual void on_low(const api::Security &, md::Price) = 0;
|
||||
virtual void on_open(const api::Security &, md::Price) = 0;
|
||||
virtual void on_close(const api::Security &, md::Price) = 0;
|
||||
virtual void on_settlement(const api::Security &, md::IntPrice) = 0;
|
||||
virtual void on_depth(
|
||||
md::Security const &s,
|
||||
api::Security const &s,
|
||||
md::PriceSize bids[md::COCONUT_MAX_DEPTH],
|
||||
md::PriceSize asks[md::COCONUT_MAX_DEPTH],
|
||||
std::array<md::PriceSize, md::COCONUT_MAX_IMPLIED_DEPTH> *implied_bids,
|
||||
|
||||
@@ -219,7 +219,7 @@ class BTS_EXPORT MDConsumerHandle {
|
||||
}
|
||||
return UserSymbol();
|
||||
}
|
||||
Security get_normalized_security() const {
|
||||
api::Security get_normalized_security() const {
|
||||
switch (_type) {
|
||||
case HANDLETYPE_VOID:
|
||||
bts_assert_msg(false, "Handle not initialized");
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
namespace bts {
|
||||
namespace md {
|
||||
|
||||
using bts::api::Security;
|
||||
|
||||
struct SecurityCacheImpl {
|
||||
utils::LockBox<btree::map<SecurityKey, SecurityPtr>> cache;
|
||||
utils::LockBox<btree::map<ExchangeSecurityKey, SecurityPtr>> ex_cache;
|
||||
@@ -57,7 +59,7 @@ const Security *SecurityCache::try_get_security(SecurityKey key) const {
|
||||
if (iter != t.end()) {
|
||||
return iter->second.get();
|
||||
}
|
||||
return (const api::Security *)nullptr;
|
||||
return (const Security *)nullptr;
|
||||
});
|
||||
}
|
||||
const Security *SecurityCache::try_get_security(ExchangeSecurityKey key) const {
|
||||
@@ -67,7 +69,7 @@ const Security *SecurityCache::try_get_security(ExchangeSecurityKey key) const {
|
||||
if (iter != t.end()) {
|
||||
return iter->second.get();
|
||||
}
|
||||
return (const api::Security *)nullptr;
|
||||
return (const Security *)nullptr;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -86,8 +88,8 @@ const Security *SecurityCache::get_security(SecurityKey key) {
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<api::Security const *> SecurityCache::get_securities() {
|
||||
std::vector<api::Security const *> result;
|
||||
std::vector<Security const *> SecurityCache::get_securities() {
|
||||
std::vector<Security const *> result;
|
||||
result.reserve(100000);
|
||||
|
||||
_me->cache.lock([&result](auto &cache) {
|
||||
|
||||
@@ -21,19 +21,20 @@ class SecurityCache {
|
||||
~SecurityCache();
|
||||
|
||||
// Load security from cache with fallback to database
|
||||
const Security *get_security(SecurityKey key);
|
||||
const api::Security *get_security(SecurityKey key);
|
||||
|
||||
// Load all securities from cache, no fallback to database
|
||||
std::vector<api::Security const *> get_securities();
|
||||
|
||||
// Get the security if it's in the cache otherwise return nullptr. Does not
|
||||
// query security database.
|
||||
const Security *try_get_security(SecurityKey key) const;
|
||||
const Security *try_get_security(ExchangeSecurityKey key) const;
|
||||
const api::Security *try_get_security(SecurityKey key) const;
|
||||
const api::Security *try_get_security(ExchangeSecurityKey key) const;
|
||||
|
||||
// returns true if the cache was updated
|
||||
bool add_live_security(const SecurityPtr &security);
|
||||
const Security *add_db_security(const SecurityPtr &security);
|
||||
bool add_live_security(const std::shared_ptr<const api::Security> &security);
|
||||
const api::Security *add_db_security(
|
||||
const std::shared_ptr<const api::Security> &security);
|
||||
|
||||
void flush_to_disk();
|
||||
};
|
||||
|
||||
@@ -25,6 +25,7 @@ namespace bts {
|
||||
namespace md {
|
||||
namespace db {
|
||||
|
||||
using bts::api::Security;
|
||||
using bts::system::protobufs::SystemConfig;
|
||||
|
||||
/*
|
||||
@@ -75,7 +76,7 @@ size_t load_securities(
|
||||
"expiration > :exp");
|
||||
select_stmt.bind(":exp", sec_expiration_cut_off().to_short());
|
||||
|
||||
Security security;
|
||||
api::Security security;
|
||||
while (select_stmt.tryExecuteStep() == SQLITE_ROW) {
|
||||
security_key security_key = select_stmt.getColumn("key");
|
||||
std::string symbol = select_stmt.getColumn("symbol");
|
||||
@@ -115,7 +116,7 @@ size_t load_securities(
|
||||
callback);
|
||||
}
|
||||
|
||||
SecurityPtr find_security(SecurityKey key) {
|
||||
std::shared_ptr<const Security> find_security(SecurityKey key) {
|
||||
LOG(md, Info, "SecurityDB::find_security key: {}", key);
|
||||
try {
|
||||
auto db = open_db();
|
||||
@@ -136,7 +137,8 @@ SecurityPtr find_security(SecurityKey key) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Result insert_or_replace(const std::vector<SecurityPtr> &securities) {
|
||||
Result insert_or_replace(
|
||||
const std::vector<std::shared_ptr<const Security>> &securities) {
|
||||
std::string log_str = "";
|
||||
for (const auto &s : securities) {
|
||||
log_str += bts::securities::descriptor(*s) + ", ";
|
||||
@@ -223,10 +225,11 @@ size_t load_securities(
|
||||
const std::function<void(const api::Security &)> &callback) {
|
||||
return 0;
|
||||
}
|
||||
Result insert_or_replace(const std::vector<SecurityPtr> &handles) {
|
||||
Result insert_or_replace(
|
||||
const std::vector<std::shared_ptr<const Security>> &handles) {
|
||||
return Result::error;
|
||||
}
|
||||
SecurityPtr find_security(SecurityKey) { return nullptr; }
|
||||
std::shared_ptr<const Security> find_security(SecurityKey) { return nullptr; }
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -20,13 +20,12 @@ typedef uint32_t security_key;
|
||||
const security_key invalid_security_key = 0;
|
||||
|
||||
// Bring in o2 types
|
||||
using api::Security;
|
||||
using api::SecurityType;
|
||||
using api::Venue;
|
||||
using bts::api::Side;
|
||||
using bts::co2::CoconutSecurityStatus;
|
||||
using domain::protobufs::TradingStatus;
|
||||
|
||||
SecurityType securitytype_of(const Security &);
|
||||
SecurityType securitytype_of(const api::Security &);
|
||||
|
||||
} // namespace bts::md
|
||||
@@ -56,7 +56,7 @@ class MDConsumerInst {
|
||||
if (entry.security.key != invalid_security_key &&
|
||||
(entry.security.type == type || type == api::SECURITYTYPE_UNSET) &&
|
||||
(symbol.empty() || entry.security.symbol() == symbol)) {
|
||||
auto psec = std::make_shared<Security>();
|
||||
auto psec = std::make_shared<api::Security>();
|
||||
convert_security(entry.security, psec.get());
|
||||
// cb(convert_psecurity(entry.security));
|
||||
++result;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
namespace bts::md {
|
||||
|
||||
using bts::api::Security;
|
||||
using bts::co2::ChannelReply;
|
||||
using bts::co2::ChannelUpdate;
|
||||
using bts::co2::ExpirationNameList;
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
#include "system/logging/logging.h"
|
||||
#include "system/protobufs/config/system_config.pb.h"
|
||||
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <google/protobuf/text_format.h>
|
||||
#include <memory>
|
||||
@@ -26,6 +25,7 @@ using namespace bts::co2;
|
||||
|
||||
namespace bts::md {
|
||||
|
||||
using bts::api::Security;
|
||||
using bts::system::protobufs::SystemConfig;
|
||||
|
||||
const char *magic = "Co2";
|
||||
|
||||
@@ -208,11 +208,14 @@ typedef FixedSpreadSecurity<512> FixedSpreadSecurityXL;
|
||||
|
||||
// Convert a fixedsecurity to a normal Security - caveat: spreads will be
|
||||
// normalized
|
||||
Security convert_security(const FixedSecurity &);
|
||||
void convert_security(const FixedSecurity &, Security *);
|
||||
api::Security convert_security(const FixedSecurity &);
|
||||
void convert_security(const FixedSecurity &, api::Security *);
|
||||
void convert_security(
|
||||
const Security &src, FixedSecurity &dest, bool set_security_key = false);
|
||||
const api::Security &src,
|
||||
FixedSecurity &dest,
|
||||
bool set_security_key = false);
|
||||
|
||||
SecurityType securitytype_of_contractcase(api::Security::ContractCase cc);
|
||||
SecurityType securitytype_of(const api::Security &);
|
||||
size_t num_legs(const api::Security &);
|
||||
uint64_t exchange_id(const api::Security &security);
|
||||
|
||||
@@ -6,9 +6,11 @@
|
||||
namespace bts {
|
||||
namespace md {
|
||||
|
||||
using bts::api::Security;
|
||||
|
||||
#ifdef _WIN32
|
||||
# pragma warning (push)
|
||||
# pragma warning (disable : 4316)
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4316)
|
||||
#endif
|
||||
|
||||
Co2TestInstrument::Co2TestInstrument(
|
||||
@@ -59,9 +61,9 @@ MDConsumerHandle Co2TestInstrument::consumer() {
|
||||
|
||||
Co2TestInstrument::~Co2TestInstrument() {}
|
||||
|
||||
# ifdef _WIN32
|
||||
# pragma warning (pop)
|
||||
# endif
|
||||
#ifdef _WIN32
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
} // namespace md
|
||||
} // namespace bts
|
||||
@@ -10,7 +10,7 @@ namespace md {
|
||||
struct Co2TestInstrument {
|
||||
Co2TestInstrument(const std::string &symbol, SecurityType type);
|
||||
Co2TestInstrument(
|
||||
const Security &security,
|
||||
const api::Security &security,
|
||||
std::shared_ptr<ColdHeader>,
|
||||
std::shared_ptr<HotHeader>);
|
||||
~Co2TestInstrument();
|
||||
|
||||
Reference in new issue
Block a user