{"repo":"antonagestam/immoney","free":true,"listed":false,"github":"https://github.com/antonagestam/immoney","clone":"git clone https://github.com/antonagestam/immoney.git","description":"A better standard for representing money in Python.","language":"Python","stars":20,"topics":["finance","fintech","monetary","money","python","currency","pydantic","type-driven-development"],"license":"BSD-3-Clause","category":"trading","readme_excerpt":"immoney Installation Design goals These core aspects of this library each eliminate entire classes of bugs: - Exposed and internal data types are either immutable or faux immutable. - Invalid amounts of money cannot be represented. There is no such thing as 0.001 US dollars, and there is no such thing as negative money. - Builtin operations never implicitly lose precision. - Built from the ground-up with support for static type checking in mind. This means that bugs that attempt to mix currencies can be found by a static type checker. - A comprehensive test suite with 100% coverage, including property tests that assert random [sequences of operations][sequence-test] behave as expected. [sequence-test]: https://github.com/antonagestam/immoney/blob/cc8ad48713fcf5c843e9832de9f722366b17a404/tests/test arithmetic.py#L190 Features Safe division In real life we cannot split the subunit of a currency, and so for our abstractions to safely reflect reality, we shouldn't be able to do that in code either. Therefore instead of defining division to return a value with precision loss, the implementation of division for Money returns a tuple of new instances with the value split up as even as possible. This is implemented as Money. floordiv . This method of division will always be safe, as it has the guaranteed property that the sum of the instances returned by the operation always equal the original numerator. Subunit fractions Sometimes we do need to represent fractions of monetary values","default_branch":null,"files":null,"tree":[],"storefront":"/r/antonagestam","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/antonagestam/immoney/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}