SPARK-1191 security list api

This commit is contained in:
Eric Harding committed 2018-06-01 17:05:52 -04:00
1 parent fdefad6a73
commit 0e29a141bf
3 files changed
+15 -5

No files matched your search

+1 -1
View File
@@ -16,7 +16,7 @@ message ExpirationNameList {
}
message ExpirationNameListReply {
repeated ExpirationNameList securities = 1;
repeated ExpirationNameList securities = 2;
}
service MarketDataRelay {
+8
View File
@@ -40,6 +40,14 @@ struct UserSymbol {
return symbol() + "-" + SecurityType_Name(type());
}
bts::api::Product to_product() const {
bts::api::Product p;
p.set_exchange(_exchange);
p.set_type(_type);
p.set_symbol(_symbol);
return p;
}
// No move constructor -
// because in this case the std::string will be a stock symbol which should be
// small enough to be inlined in both msvsc and gcc/clang
+6 -4
View File
@@ -313,14 +313,16 @@ public:
}
}
void get_names(ExpirationNameList* reply) const {
void get_names(ExpirationNameListReply* reply) const {
bts_assert(reply != nullptr);
Security security;
for (auto& groupiter : _groups) {
const auto& group = groupiter.second;
ExpirationNameList* psec = reply->add_securities();
psec->mutable_product()->CopyFrom(group->symbol.to_product());
for(const auto& h : *(group->handles)) {
security.CopyFrom(h.handle.get_normalized_security());
auto x = reply->mutable_names();
auto x = psec->mutable_names();
if (security.ExchangeData_case() == Security::kGlbx) {
google::protobuf::MapPair<uint32_t,std::string> v(h.handle.key(), security.glbx().security_desc());
x->insert(v);
@@ -369,10 +371,10 @@ struct MDRelayServer : bts::co2::MarketDataRelayBase {
reply(list);
}
virtual void request_names(const api::VoidMessage&, const std::function<void(const ExpirationNameList&)>& reply) override {
virtual void request_names(const api::VoidMessage&, const std::function<void(const ExpirationNameListReply&)>& reply) override {
_threadpool.post([=]() {
google::protobuf::Arena arena;
ExpirationNameList* preply = google::protobuf::Arena::CreateMessage<ExpirationNameList>(&arena);
ExpirationNameListReply* preply = google::protobuf::Arena::CreateMessage<ExpirationNameListReply>(&arena);
_db.get_names(preply);
reply(*preply);
});