From 23e13846c66ea17cefa1951594b4e44a7b3a2ea5 Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Thu, 12 Dec 2019 10:13:40 -0500 Subject: [PATCH] botched order priority when only reducing size --- .../spark_historical/FillModel/MBOBook.cs | 33 ++++++++++--------- tools/cpp.build.props | 2 +- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/src/client/spark_historical/FillModel/MBOBook.cs b/src/client/spark_historical/FillModel/MBOBook.cs index b127f2505..fc5de97a6 100644 --- a/src/client/spark_historical/FillModel/MBOBook.cs +++ b/src/client/spark_historical/FillModel/MBOBook.cs @@ -118,24 +118,27 @@ namespace bts.history if (!_myorders.TryGetValue(order_id, out OrderEntry myorder)) return null; - myorder.price = price; - if (size > uint.MinValue) + if(price == myorder.price && size <= myorder.size && size > uint.MinValue) { - if (size > myorder.size) - { - var mbo = get_mbo(myorder.side); - if (mbo.TryGetValue(price, out QueueType queue)) - { - var key = queue.LastOrDefault(kvp => kvp.Value.timestamp.less_or_equal(asof), new KeyValuePair(0u, null)); - if (key.Value != null) - myorder.order_priority = key.Key; - else - myorder.order_priority = _first_in_q; - Log.Testing.info($"update myorder {order_id} at price { price } piq { queue.Count } "); - } - } myorder.size = size; } + else + { + myorder.price = price; + if (size > uint.MinValue) + myorder.size = size; + var mbo = get_mbo(myorder.side); + if (mbo.TryGetValue(price, out QueueType queue)) + { + var key = queue.LastOrDefault(kvp => kvp.Value.timestamp.less_or_equal(asof), new KeyValuePair(0u, null)); + if (key.Value != null) + myorder.order_priority = key.Key; + else + myorder.order_priority = _first_in_q; + Log.Testing.info($"update myorder {order_id} at price { price } piq { queue.Count } "); + } + } + if (_mystatus.TryGetValue(order_id, out OrderStatus status)) { status.last_change = asof; diff --git a/tools/cpp.build.props b/tools/cpp.build.props index 825392428..9dac68785 100644 --- a/tools/cpp.build.props +++ b/tools/cpp.build.props @@ -26,7 +26,7 @@ /> - +