AB-CE / abcFinance

Agent-based computational Finance
Apache License 2.0
37 stars 13 forks source link

floating point arithmetic related errors #41

Open CKnoppe opened 2 years ago

CKnoppe commented 2 years ago

Not sure if this is still an open project that you are willing to put more work into, but if yes:

Due to the naturally imprecise representation of decimals in binary (e.g. 0.1 + 0.1 + 0.1 == 0.3 yields False), emptying an account does not always leave the account balanced. That is, if you have amount x on account A of a ledger, and you withdraw amount x, the balance is not always (BALANCED, 0) and even throws an assertion error in the booking operation, if the AccounSide ends on the wrong side. An option would be to use Decimal types from the decimals module.