From 9b137c2873d0b361173c72fbcb42d6f54565a867 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Thu, 3 Apr 2025 11:53:47 +0200 Subject: [PATCH] Fix in Calculator::GetPriceForTimeStep(): Allow some tolerance (of 3 minutes) when looking up the current time-step value in the duration-array. Otherwise, when corossing a minute-boundary, it can happen to not find the match and returning a price of 0 (which is almost always wrong). --- library/src/calculator_functions.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/library/src/calculator_functions.cpp b/library/src/calculator_functions.cpp index 98693a3..40bb0c9 100644 --- a/library/src/calculator_functions.cpp +++ b/library/src/calculator_functions.cpp @@ -3584,7 +3584,9 @@ uint32_t Calculator::GetPriceForTimeStep(Configuration *cfg, int timeStep, int p qCritical() << "(" << __func__ << ":" << __LINE__ << ") timeStep" << timeStep; } - if (timeStep == pun_duration) { + // allow some tolerance when searching for [timeStep == pun_duration]: + // this might happen when crossing minute boundaries + if (std::abs(timeStep - pun_duration) < 4) { qCritical() << "(" << __func__ << ":" << __LINE__ << ") return price" << price; return price; }