refactor: Normalize sec key indexing for new (domain) md sources
This is part of a larger effort to unify the way we index securities in order to generate unique ids. Older md sources (e.g., MDP3Listener) use SecurityIDRecorder to generate ids, which uses a different database and different key-string formatting than the IDGenerator used by the newer md sources (e.g., GeneralMarketDataListener and various ccapi-based sources).
This commit is contained in:
1 parent
6e12c5b895
commit
979b2ccb6f
33 files changed
+425
-208
No files matched your search
@@ -20,6 +20,14 @@ class PyBook {
|
||||
const std::string &venue() const;
|
||||
void set_venue(std::string value);
|
||||
|
||||
/**
|
||||
* @brief Gets the security type
|
||||
*
|
||||
* @return const std::string& The security type
|
||||
*/
|
||||
const std::string &security_type() const;
|
||||
void set_security_type(std::string value);
|
||||
|
||||
/**
|
||||
* @brief Gets the exchange security id. This is typically the security's name
|
||||
* (e.g., "BTS-PERPETUAL", or "ESH5").
|
||||
@@ -57,6 +65,7 @@ class PyBook {
|
||||
|
||||
private:
|
||||
std::string venue_;
|
||||
std::string security_type_;
|
||||
std::string exchange_security_id_;
|
||||
PyBookSide bids_;
|
||||
PyBookSide asks_;
|
||||
@@ -69,6 +78,13 @@ class PyBook {
|
||||
inline const std::string &PyBook::venue() const { return venue_; }
|
||||
inline void PyBook::set_venue(std::string value) { venue_ = std::move(value); }
|
||||
|
||||
inline const std::string &PyBook::security_type() const {
|
||||
return security_type_;
|
||||
}
|
||||
inline void PyBook::set_security_type(std::string value) {
|
||||
security_type_ = std::move(value);
|
||||
}
|
||||
|
||||
inline const std::string &PyBook::exchange_security_id() const {
|
||||
return exchange_security_id_;
|
||||
}
|
||||
|
||||
@@ -64,6 +64,7 @@ PYBIND11_MODULE(python_md_module, m) {
|
||||
.PROP(PySecurity, id)
|
||||
.PROP(PySecurity, exchange_id)
|
||||
.PROP(PySecurity, venue)
|
||||
.def("type", &PySecurity::type)
|
||||
.PROP(PySecurity, name)
|
||||
.PROP(PySecurity, currency)
|
||||
.PROP(PySecurity, group)
|
||||
@@ -93,6 +94,7 @@ PYBIND11_MODULE(python_md_module, m) {
|
||||
py::class_<bts::md::py_interop::PyBook>(m, "PyBook")
|
||||
.def(py::init<>())
|
||||
.PROP(PyBook, venue)
|
||||
.PROP(PyBook, security_type)
|
||||
.PROP(PyBook, exchange_security_id)
|
||||
.EXPLICIT_DEF(PyBook, bids, BookSideGetter)
|
||||
.DEF(PyBook, set_bids)
|
||||
@@ -110,6 +112,7 @@ PYBIND11_MODULE(python_md_module, m) {
|
||||
py::class_<PyTrade>(m, "PyTrade")
|
||||
.def(py::init<>())
|
||||
.PROP(PyTrade, venue)
|
||||
.PROP(PyTrade, security_type)
|
||||
.PROP(PyTrade, exchange_security_id)
|
||||
.PROP(PyTrade, price)
|
||||
.PROP(PyTrade, quantity)
|
||||
@@ -143,4 +146,5 @@ PYBIND11_MODULE(python_md_module, m) {
|
||||
|
||||
#undef PROP
|
||||
#undef DEF
|
||||
#undef EXPLICIT_DEF
|
||||
#undef _STR
|
||||
@@ -22,6 +22,8 @@ class PySecurity {
|
||||
const std::string &venue() const;
|
||||
void set_venue(std::string value);
|
||||
|
||||
const std::string &type() const;
|
||||
|
||||
const std::string ¤cy() const;
|
||||
void set_currency(std::string value);
|
||||
|
||||
@@ -78,6 +80,23 @@ inline void PySecurity::set_venue(std::string value) {
|
||||
venue_ = std::move(value);
|
||||
}
|
||||
|
||||
inline const std::string &PySecurity::type() const {
|
||||
if (is_spot()) {
|
||||
static std::string SPOT = "SPOT";
|
||||
return SPOT;
|
||||
}
|
||||
if (is_future()) {
|
||||
static std::string FUTURE = "FUTURE";
|
||||
return FUTURE;
|
||||
}
|
||||
if (is_option()) {
|
||||
static std::string OPTION = "OPTION";
|
||||
return OPTION;
|
||||
}
|
||||
static std::string UNDEFINED = "UNDEFINED";
|
||||
return UNDEFINED;
|
||||
}
|
||||
|
||||
inline const std::string &PySecurity::currency() const { return currency_; }
|
||||
inline void PySecurity::set_currency(std::string value) {
|
||||
currency_ = std::move(value);
|
||||
|
||||
@@ -12,6 +12,9 @@ class PyTrade {
|
||||
const std::string &venue() const;
|
||||
void set_venue(std::string value);
|
||||
|
||||
const std::string &security_type() const;
|
||||
void set_security_type(std::string value);
|
||||
|
||||
const std::string &exchange_security_id() const;
|
||||
void set_exchange_security_id(std::string value);
|
||||
|
||||
@@ -37,6 +40,7 @@ class PyTrade {
|
||||
|
||||
private:
|
||||
std::string venue_;
|
||||
std::string security_type_;
|
||||
std::string exchange_security_id_;
|
||||
double price_;
|
||||
double quantity_;
|
||||
@@ -51,6 +55,13 @@ class PyTrade {
|
||||
inline const std::string &PyTrade::venue() const { return venue_; }
|
||||
inline void PyTrade::set_venue(std::string value) { venue_ = std::move(value); }
|
||||
|
||||
inline const std::string &PyTrade::security_type() const {
|
||||
return security_type_;
|
||||
}
|
||||
inline void PyTrade::set_security_type(std::string value) {
|
||||
security_type_ = std::move(value);
|
||||
}
|
||||
|
||||
inline const std::string &PyTrade::exchange_security_id() const {
|
||||
return exchange_security_id_;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user