Fixed bugs in handling of CME fixed sized strings.
This commit is contained in:
1 parent
e741b33810
commit
f1c5ba93d3
6 files changed
+69
-33
No files matched your search
+3
-3
@@ -59,7 +59,7 @@ enum class Verbosity { Minimal = 0, Normal = 1, Verbose = 2 };
|
||||
inline std::string _log_header() { return "MatcherValidationObserver"; }
|
||||
|
||||
inline bool _is_interesting_sec(const InstrumentSnapshot& s) {
|
||||
return strcmp(s.definition().asset(), "GC") == 0;
|
||||
return s.definition().asset() == "GC";
|
||||
//return strcmp(s.definition().asset(), "SI") == 0;
|
||||
}
|
||||
|
||||
@@ -173,7 +173,7 @@ struct _SecurityData {
|
||||
Orders current_orders, previous_orders;
|
||||
size_t last_observed_event = NO_EVENT;
|
||||
const InstrumentSnapshot* snapshot = nullptr;
|
||||
const char* symbol() const {
|
||||
std::string symbol() const {
|
||||
return snapshot == nullptr ? "N/A" : snapshot->symbol();
|
||||
}
|
||||
MDP3SecurityID security_id() const {
|
||||
@@ -555,4 +555,4 @@ void MatcherValidationObserver::on_real_time_event(MDP3Event const& ev) {
|
||||
}
|
||||
|
||||
void MatcherValidationObserver::on_real_time_channel_loss() { bts_assert(false); }
|
||||
} // namespace bts::spartan::mdp3
|
||||
} // namespace bts::spartan::mdp3
|
||||
@@ -15,8 +15,7 @@ double InstrumentDefinition::get_cash_per_point() const {
|
||||
} else {
|
||||
auto it = cpp_map.cpp_entry().find(asset_str);
|
||||
if (it == cpp_map.cpp_entry().end()) {
|
||||
LOG(Spartan,Error,"Cannot find CPP for {}. Returning 0",
|
||||
log::CharPtrWrapper{asset_str});
|
||||
LOG(Spartan,Error,"Cannot find CPP for {}. Returning 0", asset_str);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -22,8 +22,9 @@ struct LegDef {
|
||||
MDP3Quantity ratio;
|
||||
};
|
||||
|
||||
inline std::ostream& operator <<(std::ostream& out, const LegDef& l) {
|
||||
out << "sec: " << l.security_id << ", side: " << l.side << ", ratio: " << l.ratio;
|
||||
inline std::ostream &operator<<(std::ostream &out, const LegDef &l) {
|
||||
out << "sec: " << l.security_id << ", side: " << l.side
|
||||
<< ", ratio: " << l.ratio;
|
||||
return out;
|
||||
}
|
||||
|
||||
@@ -60,6 +61,19 @@ class InstrumentDefinition {
|
||||
}};
|
||||
visit(visitor);
|
||||
|
||||
_symbol = get([&](auto const &m) {
|
||||
return str_from_fixed_array(m.symbol(), m.symbolEncodingLength());
|
||||
});
|
||||
|
||||
_security_group = get([&](auto const &m) {
|
||||
return str_from_fixed_array(m.securityGroup(),
|
||||
m.securityGroupEncodingLength());
|
||||
});
|
||||
|
||||
_asset = get([&](auto const &m) {
|
||||
return str_from_fixed_array(m.asset(), m.assetEncodingLength());
|
||||
});
|
||||
|
||||
_display_factor = get([](auto m) {
|
||||
return md::IntPrice(m.displayFactor().mantissa(),
|
||||
m.displayFactor().exponent())
|
||||
@@ -90,30 +104,23 @@ class InstrumentDefinition {
|
||||
MDP3SecurityID security_id() const {
|
||||
return MDP3SecurityID{get([](auto const &m) { return m.securityID(); })};
|
||||
}
|
||||
const char *symbol() const {
|
||||
return get([](auto const &m) { return m.symbol(); });
|
||||
}
|
||||
|
||||
std::string const &symbol() const { return _symbol; }
|
||||
|
||||
::mdp3::MatchEventIndicator match_event_indicator() const {
|
||||
return get([](auto m) { return m.matchEventIndicator(); });
|
||||
}
|
||||
|
||||
const char *security_group() const {
|
||||
return get([](auto const &m) { return m.securityGroup(); });
|
||||
}
|
||||
std::string const &security_group() const { return _security_group; }
|
||||
|
||||
const char *asset() const {
|
||||
return get([](auto const &m) { return m.asset(); });
|
||||
}
|
||||
std::string const &asset() const { return _asset; }
|
||||
|
||||
std::string match_algorithm() const {
|
||||
return get(
|
||||
[](auto const &m) { return std::string(1, m.matchAlgorithm()); });
|
||||
}
|
||||
|
||||
double display_factor() const {
|
||||
return _display_factor;
|
||||
}
|
||||
double display_factor() const { return _display_factor; }
|
||||
|
||||
double min_price_increment() const {
|
||||
return get([](auto m) {
|
||||
@@ -228,6 +235,9 @@ class InstrumentDefinition {
|
||||
double get_cash_per_point() const;
|
||||
double _display_factor;
|
||||
double _cash_per_point;
|
||||
std::string _symbol;
|
||||
std::string _security_group;
|
||||
std::string _asset;
|
||||
};
|
||||
|
||||
inline std::ostream &operator<<(std::ostream &out,
|
||||
|
||||
@@ -32,7 +32,7 @@ class InstrumentSnapshot {
|
||||
// Queries ------------------------------------------------------------
|
||||
MDP3SecurityID security_id() const;
|
||||
InstrumentDefinition const& definition() const;
|
||||
const char *symbol() const { return definition().symbol(); }
|
||||
std::string const&symbol() const { return definition().symbol(); }
|
||||
::mdp3::SecurityTradingStatus::Value trading_status() const;
|
||||
bool implied_matching_status() const;
|
||||
size_t last_processed_sn() const;
|
||||
|
||||
@@ -36,6 +36,17 @@ class MDP3Event {
|
||||
}
|
||||
};
|
||||
|
||||
inline std::string str_from_fixed_array(const char *ptr, size_t max_len) {
|
||||
std::string result;
|
||||
result.reserve(max_len);
|
||||
for (size_t i = 0; i < max_len; i++)
|
||||
if (ptr[i] != 0)
|
||||
result.append(1, ptr[i]);
|
||||
else
|
||||
break;
|
||||
return result;
|
||||
}
|
||||
|
||||
inline std::ostream &operator<<(std::ostream &s, MDP3Event const &ev) {
|
||||
s << "Event : " << ev.event_id
|
||||
<< " ------------------------------------------------------------"
|
||||
@@ -113,7 +124,8 @@ inline const char *change_name(OrderChange::ChangeType ct) {
|
||||
return "";
|
||||
}
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& out, const OrderChange::ChangeType ct) {
|
||||
inline std::ostream &operator<<(std::ostream &out,
|
||||
const OrderChange::ChangeType ct) {
|
||||
out << change_name(ct);
|
||||
return out;
|
||||
}
|
||||
@@ -148,7 +160,7 @@ inline std::ostream &operator<<(std::ostream &s, OrderChange const &ch) {
|
||||
return s;
|
||||
}
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& out, const SmallOrderChange& ch) {
|
||||
inline std::ostream &operator<<(std::ostream &out, const SmallOrderChange &ch) {
|
||||
out << ch.change << " " << ch.order;
|
||||
return out;
|
||||
}
|
||||
@@ -252,7 +264,7 @@ inline std::ostream &operator<<(std::ostream &s, ImpliedBook const &b) {
|
||||
return s;
|
||||
}
|
||||
|
||||
void merge_books(api::Side, Book const&,ImpliedBook const&, Book *out);
|
||||
void merge_books(api::Side, Book const &, ImpliedBook const &, Book *out);
|
||||
|
||||
inline std::string to_str(std::string const &s) { return s; }
|
||||
|
||||
@@ -260,18 +272,31 @@ inline std::string to_str(const char *s) { return std::string(s); }
|
||||
|
||||
template <class T> std::string to_str(T t) { return std::to_string(t); }
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& out, const MDP3Fill::Aggressor& ag) {
|
||||
inline std::ostream &operator<<(std::ostream &out,
|
||||
const MDP3Fill::Aggressor &ag) {
|
||||
out << aggressor_name(ag);
|
||||
return out;
|
||||
}
|
||||
inline std::ostream& operator<<(std::ostream& ostr, const api::Side& side) {
|
||||
inline std::ostream &operator<<(std::ostream &ostr, const api::Side &side) {
|
||||
switch (side) {
|
||||
case api::Side::SIDE_BUY: ostr << "Buy"; break;
|
||||
case api::Side::SIDE_SELL: ostr << "Sell"; break;
|
||||
case api::Side::SIDE_UNDEFINED: ostr << "Undef"; break;
|
||||
case api::Side::Side_INT_MIN_SENTINEL_DO_NOT_USE_: ostr << "MinSen"; break;
|
||||
case api::Side::Side_INT_MAX_SENTINEL_DO_NOT_USE_: ostr << "MaxSen"; break;
|
||||
default: ostr << "SIDE_" << static_cast<int>(side); break;
|
||||
case api::Side::SIDE_BUY:
|
||||
ostr << "Buy";
|
||||
break;
|
||||
case api::Side::SIDE_SELL:
|
||||
ostr << "Sell";
|
||||
break;
|
||||
case api::Side::SIDE_UNDEFINED:
|
||||
ostr << "Undef";
|
||||
break;
|
||||
case api::Side::Side_INT_MIN_SENTINEL_DO_NOT_USE_:
|
||||
ostr << "MinSen";
|
||||
break;
|
||||
case api::Side::Side_INT_MAX_SENTINEL_DO_NOT_USE_:
|
||||
ostr << "MaxSen";
|
||||
break;
|
||||
default:
|
||||
ostr << "SIDE_" << static_cast<int>(side);
|
||||
break;
|
||||
}
|
||||
return ostr;
|
||||
}
|
||||
|
||||
@@ -542,7 +542,8 @@ void RealTimeHandler::operator()(::mdp3::SecurityStatus30 &ss) {
|
||||
for (auto &p : me->instruments) {
|
||||
auto &iptr = p.second;
|
||||
auto def = iptr->definition();
|
||||
if (strcmp(def.security_group(), ss.securityGroup()) == 0) {
|
||||
auto sgroup = str_from_fixed_array(ss.securityGroup(),ss.securityGroupEncodingLength());
|
||||
if (def.security_group() == sgroup) {
|
||||
ev.record_security_change(iptr.get());
|
||||
update_trading_status(*iptr);
|
||||
update_implied_matching(*iptr);
|
||||
@@ -556,7 +557,8 @@ void RealTimeHandler::operator()(::mdp3::SecurityStatus30 &ss) {
|
||||
for (auto &p : me->instruments) {
|
||||
auto &iptr = p.second;
|
||||
auto def = iptr->definition();
|
||||
if (strcmp(def.asset(), ss.asset()) == 0) {
|
||||
auto sasset = str_from_fixed_array(ss.asset(), ss.assetEncodingLength()) ;
|
||||
if (def.asset() == sasset) {
|
||||
ev.record_security_change(iptr.get());
|
||||
update_trading_status(*iptr);
|
||||
update_implied_matching(*iptr);
|
||||
|
||||
Reference in new issue
Block a user