@@ -196,17 +196,16 @@ void TradeBox::on_trade(const FIX44::MarketDataIncrementalRefresh& msg) {
196196 std::optional<binance::SymbolEnum> symbol;
197197 FIX::MDEntryPx e_px;
198198 FIX::MDEntrySize e_sz;
199- uint64_t price, size;
200199 FIX::MDEntryType e_type;
201- FIX::TransactTime time;
200+ FIX::TransactTime e_time;
201+ uint64_t price, size;
202202 FIX::TradeID trade_id;
203203 std::string trade_id_str;
204204 uint64_t trade_id_uint;
205205 // Binance's "side" field ("AggressorSide") is a custom field, not part of the FIX spec
206206 constexpr int AGGRESSOR_TAG = 2446 ;
207207 FIX::CharField side_field (AGGRESSOR_TAG);
208208 binance::SideEnum side{};
209- //
210209 std::string raw_time;
211210 std::string time_only;
212211 for (int i = 1 ; i <= num_entries; i++) {
@@ -237,30 +236,33 @@ void TradeBox::on_trade(const FIX44::MarketDataIncrementalRefresh& msg) {
237236 switch (e_type.getValue ()) {
238237 case FIX::MDEntryType_TRADE: {
239238 if (group.isSetField (AGGRESSOR_TAG)) {
240- group.getField (side_field);
241- side = binance::Side::from_str (side_field.getValue ());
242239 price = utils::Double::toUint64 (
243240 group.get (e_px).getValue (),
244241 binance_config_.get_price_ticks_per_unit (symbol.value ()));
242+
245243 size = utils::Double::toUint64 (
246244 group.get (e_sz).getValue (),
247245 binance_config_.get_size_ticks_per_unit (symbol.value ()));
246+
248247 group.getField (trade_id);
249248 trade_id_str = trade_id.getValue ();
250249 std::from_chars (trade_id_str.data (), trade_id_str.data () + trade_id_str.size (),
251250 trade_id_uint);
252251
252+ group.getField (side_field);
253+ side = binance::Side::from_str (side_field.getValue ());
254+
253255 std::array<char , 16 > tm_arr = {};
254256 if (group.isSetField (FIX::FIELD::TransactTime)) {
255- group.getField (time );
256- FIX::UtcTimeStamp tval = time .getValue ();
257- int microseconds = tval.getMillisecond () * 1000 ;
257+ group.getField (e_time );
258+ FIX::UtcTimeStamp tval = e_time .getValue ();
259+ int microseconds = tval.getMillisecond () * 1000 + tval. getMicroecond () ;
258260 std::snprintf (tm_arr.data (), tm_arr.size (), " %02d:%02d:%02d.%06d" ,
259261 tval.getHour (), tval.getMinute (), tval.getSecond (),
260262 microseconds);
261263 }
262264
263- trade_ring_.push_back (core::Trade (side, price, size, trade_id_uint, tm_arr));
265+ trade_ring_.push_back (core::Trade (price, size, trade_id_uint, side , tm_arr));
264266 screen_.post_event (ftxui::Event::Custom);
265267 } else {
266268 spdlog::error (" trade with no side. message [{}]" , msg.toString ());
0 commit comments