From d7518cffe1e9b5090572c491effbdcdbfe81fee4 Mon Sep 17 00:00:00 2001 From: John Colvin Date: Fri, 14 Apr 2023 04:56:19 +0000 Subject: [PATCH] fix: Don't round ccapi book qtys to int --- src/lib/md/CCApiDepthWalker.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/lib/md/CCApiDepthWalker.cpp b/src/lib/md/CCApiDepthWalker.cpp index 598f77638..3fd673b84 100644 --- a/src/lib/md/CCApiDepthWalker.cpp +++ b/src/lib/md/CCApiDepthWalker.cpp @@ -5,6 +5,8 @@ namespace bts::md { +using bts::domain::Quantity; + bool CCApiDepthWalker::parse_field( const std::string &name, const std::string &value) { bts_assert(depth_ptr); @@ -22,15 +24,8 @@ bool CCApiDepthWalker::parse_field( if (qty_idx < depth.size()) { double qty_dbl = stod(value); bts_assert(qty_dbl > 0); - bts_assert(qty_dbl < std::numeric_limits::max()); - bts::domain::Quantity qty{static_cast(qty_dbl)}; - // Since we still haven't converted our [underlying] Quantity type to - // double, this hack is neccessary to prevent legitimate book levels - // from having a quantity of 0. Many places in the code assume that - // quantity == 0 means 'this level, and all those after it, are empty.' - if (qty < 1) { - qty.value() = 1; - } + bts_assert(qty_dbl < std::numeric_limits::max()); + Quantity qty{static_cast(qty_dbl)}; depth[qty_idx].direct_quantity = qty; depth[qty_idx].total_quantity = qty; qty_idx++;