Improved test harness for order manager.

This commit is contained in:
Pedro Pinto committed 2018-01-10 11:39:09 -05:00
1 parent 0c48b7f0b2
commit 5d97bde3bf
1 file changed
+15 -6
+15 -6
View File
@@ -97,6 +97,17 @@ api::orderman2::Cancel make_cancel(OrderKey k) {
std::atomic<bool> display_order_updates(true);
std::string summarize_order_state(api::orderman2::OrderRecord const&rec)
{
auto const&st = rec.state();
return fmt::format("{} ({}): {}/{} @ {} {}",
rec.key(), rec.parent_key(),
st.filled_quantity(), st.quantity(),
st.avg_price(),
OrderStatus_Name(st.status()));
}
int TestOrderman::execute(std::vector<std::string> const &) {
OrderKey current_order(null_order_key());
@@ -113,18 +124,16 @@ int TestOrderman::execute(std::vector<std::string> const &) {
[](const api::orderman2::OrdersUpdate &update) {
std::ostringstream msg;
msg << "TestOrderman update. Added: (";
bool first = true;
for (auto const &os : update.added())
if (!first)
msg << "," << os->key();
msg << ",\n" << summarize_order_state(*os);
else {
msg << os->key();
msg << summarize_order_state(*os);
first = false;
}
msg << ")\n";
LOG(OrderMan, Info, "{}", msg.str());
LOG(OrderMan, Info, "TestOrderman update. Added ({})", msg.str());
std::cout << msg.str() << "\n";
msg = std::ostringstream();
msg << "TestOrderman update. Removed: (";
first = true;