#1 by PimPim
Dear all, I would like to round the final payoff (in currency unit) to 50 cents or 1 dollar, but cannot find any in the document. For example payoff = $24.2 would be $24.5. Could you please let me know your suggestions? Thank you very much. Kind regards, Pim
#2 by gr0ssmann
Have you considered using from math import ceil def roundup(x, u=0.5): return ceil(x/u)*u # example: print(roundup(24.2))
#3 by PimPim
Dear gr0ssmann, Thank you very much. It works! However, we cannot have the rounded payoff shown in the Payments tab, right? Kind regards, Pim
#4 by gr0ssmann
I believe oTree currency values must be whole numbers. Not so sure though. (This is one of the most difficult and perplexing issues in oTree.)
#5 by Chris_oTree
Currency rounding is described in the section "Decimal places" here: https://otree.readthedocs.io/en/latest/currency.html#decimal-places Is there some specific issue with it?