sum_decimal#

API documentation for tradeexecutor.utils.accuracy.sum_decimal Python function.

sum_decimal(numbers, epsilon=Decimal('1.00000000000000007154242405462192450852805618492324772617063644020163337700068950653076171875E-18'))[source]#

Decimal safe sum().

Looks like Python will fail to sum plus and minus decimals together even if they cancel each out:

57602384161.6838278325398013034137975573193695174227082184047361995798525240101
-57602384161.6838278325398013034137975573193695174227082184047361995798525240101

0E-67
Parameters:

numbers (Iterable[Decimal]) – Incoming Decimals to sum.

Returns:

Decimal value that is rounded to zero if it is too close to zero.

Return type:

Decimal