From da927adef4469a0bc0208a1d25428cc0cc239cc9 Mon Sep 17 00:00:00 2001 From: John Colvin Date: Tue, 25 Jul 2023 11:56:55 -0400 Subject: [PATCH] fix: Check price is within ladder's range before rendering Bugs (fixed): The render routine was indirectly asserting that each item's price was >= the ladder's min price. That seems like an inappropriate burden to put on the caller. Now we filter these items out in the routine. --- .../spark/Modules/Trading/Ladder/View/LadderRender.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/client/spark/Modules/Trading/Ladder/View/LadderRender.cs b/src/client/spark/Modules/Trading/Ladder/View/LadderRender.cs index baaf98c90..6c896fc1d 100644 --- a/src/client/spark/Modules/Trading/Ladder/View/LadderRender.cs +++ b/src/client/spark/Modules/Trading/Ladder/View/LadderRender.cs @@ -373,11 +373,13 @@ namespace mbts.spark { using (_draw_with_clip(dc, settings, row_height, prices.Count)) { if (data.is_null_or_empty()) return; + var min_price = prices[prices.Count - 1]; + var max_price = prices[0]; + Log.assert(min_price.is_real() && max_price.is_real() && min_price <= max_price); + data = data.Where(item => item.price.is_real() && item.price.is_within_range(min_price, max_price)); int curr_index = 0; - double curr_price = prices[curr_index]; + double curr_price = max_price; foreach (var (price, value) in data) { - if (double.IsNaN(price)) - continue; // prices are in descending order, so get diff from curr_price - price. var tick_diff = spec.tickdiff(curr_price, price); if (!tick_diff.HasValue) {