{"repo":"alpacahq/alpacadecimal","free":true,"listed":false,"github":"https://github.com/alpacahq/alpacadecimal","clone":"git clone https://github.com/alpacahq/alpacadecimal.git","description":"Arbitrary-precision fixed-point decimal numbers in go. Similar and compatible with shopspring's decimal.Decimal, but optimized for Alpaca's data sets.","language":"Go","stars":64,"topics":["currency","decimals","go","golang","math","money","precision","trading"],"license":"MIT","category":"trading","readme_excerpt":"alpacadecimal Similar and compatible with decimal.Decimal, but optimized for Alpaca's data sets. Goal - optimize for Alpaca data sets (99% of decimals are within 10 millions with up to 12 precisions). - compatible with decimal.Decimal so that it could be a drop-in replacement for current decimal.Decimal usage. Key Ideas The original decimal.Decimal package has bottleneck on big.Int operations, e.g. sql serialization / deserialization, addition, multiplication etc. These operations took fair amount cpu and memory during our profiling / monitoring. The optimization this library is to represent most decimal numbers with int64 instead of big.Int . To keep this library to be compatible with original decimal.Decimal package, we use original as a fallback solution when int64 is not enough (e.g. number is too big / small, too many precisions). The core data struct is like following: We pick 12 precisions because it could cover 99% of Alpaca common cases. Compatibility In general, alpacadecimal.Decimal is fully compatible with decimal.Decimal package, as decimal.Decimal is used as a fallback solution for overflow cases. There are a few special cases / APIs that alpacadecimal.Decimal behaves different from decimal.Decimal (behaviour is still correct / valid, just different). Affected APIs: - Decimal.Exponent() - Decimal.Coefficient() - Decimal.CoefficientInt64() - Decimal.NumDigits() For optimized case, alpacadecimal.Decimal always assume that exponent is 12, which results in a valid b","default_branch":null,"files":null,"tree":[],"storefront":"/r/alpacahq","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/alpacahq/alpacadecimal/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."}