Add security_id/name fns to ExecutionReport for convenience
So callers don't need to check if security is a nullptr
This commit is contained in:
1 parent
a0f77f92a3
commit
77e5c1481b
3 files changed
+23
No files matched your search
@@ -101,6 +101,12 @@ namespace bts::securities {
|
||||
const std::string &descriptor(
|
||||
const api::Security &sec, const std::string &default_rv = "UNDEFINED");
|
||||
|
||||
/**
|
||||
* Gets a descriptor string for a security (should be unique within a particular exchange).
|
||||
*/
|
||||
const std::string &descriptor(
|
||||
const api::Security *sec, const std::string &default_rv = "UNDEFINED");
|
||||
|
||||
/**
|
||||
* Gets a descriptor string for a security that is unique within the entire
|
||||
* system (not just exchange).
|
||||
@@ -358,6 +364,12 @@ inline const std::string &descriptor(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline const std::string &descriptor(
|
||||
const api::Security *sec, const std::string &default_rv) {
|
||||
return sec == nullptr ? default_rv : descriptor(*sec, default_rv);
|
||||
}
|
||||
|
||||
// Looking to round md::IntPrice? Look in IntPrice.h
|
||||
|
||||
// computes price_2 - price_1 in ticks
|
||||
|
||||
@@ -34,6 +34,14 @@ void ExecutionReport::get_ts(
|
||||
transact_time);
|
||||
}
|
||||
|
||||
uint32_t ExecutionReport::security_id() const {
|
||||
return security == nullptr ? security->id() : 0;
|
||||
}
|
||||
|
||||
const string &ExecutionReport::security_name() const {
|
||||
return bts::securities::descriptor(security);
|
||||
}
|
||||
|
||||
string ExecutionReport::to_string() const {
|
||||
ostringstream rv;
|
||||
rv << "account_name: " << to_trim_strn(account_name)
|
||||
|
||||
@@ -42,6 +42,9 @@ class ExecutionReport {
|
||||
orderman::ExchangeTimeStampStr *ts_str,
|
||||
ExchangeTimeStamp64 *ts_64) const;
|
||||
|
||||
std::uint32_t security_id() const;
|
||||
const std::string &security_name() const;
|
||||
|
||||
std::string to_string() const;
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user