fix: Remove bad assert abt tickdiff in LadderRender
* The test condition was wrong in the first place * Instead of assert/crashing, log a warning
This commit is contained in:
1 parent
9e4354fb55
commit
cf587e26d5
1 file changed
+17
-6
@@ -378,12 +378,23 @@ namespace mbts.spark {
|
||||
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) ?? 0;
|
||||
Log.assert(
|
||||
tick_diff > (int.MaxValue - curr_index),
|
||||
$"Unable to index ladder row for price {price}: tick count exceeds int.MaxValue");
|
||||
curr_index += (int)tick_diff;
|
||||
// prices are in descending order, so get diff from curr_price - price.
|
||||
var tick_diff = spec.tickdiff(curr_price, price);
|
||||
if (!tick_diff.HasValue) {
|
||||
Log.Ui.warn(
|
||||
$"Unable to compute tick-diff between prices ${curr_price} and ${price}");
|
||||
break;
|
||||
}
|
||||
if (tick_diff.Value < 0) {
|
||||
Log.Ui.error(
|
||||
"Expected positive tick-diff (prices should be in descending order, and we " +
|
||||
"compute diff between prices at idx 'i-1' and 'i')");
|
||||
}
|
||||
Log.assert(tick_diff.Value >= 0);
|
||||
if (tick_diff.Value >= prices.Count) {
|
||||
break;
|
||||
}
|
||||
curr_index += (int)tick_diff.Value;
|
||||
curr_price = price;
|
||||
if (curr_index >= 0 && curr_index < prices.Count) {
|
||||
render_cell(dc, curr_index, value);
|
||||
|
||||
Reference in new issue
Block a user