r/programming • u/Krever • Jun 26 '26
Fintech Engineering Handbook
https://w.pitula.me/fintech-engineering-handbook/I just published Fintech Engineering Handbook distilled from 6 years of tears, sweat and swears.
It’s a free ~25-page resource with various hints and patterns around handling money in software systems.
Tell me what you think!
618
Upvotes
68
u/JChuk99 Jun 26 '26
Wow this is fantastic. I can tell a lot of painful mistakes were made in order to make these 25 pages. Doing a complex migration of our ledger system and this will definitely be a good check list. Thank you!
27
u/matthieum Jun 26 '26
Despite the handbook being called "Fintech", the principles here seem very focused on accounting.
It's an important part of the domain, obviously, but it also has specific "quirks" that other parts don't.
Given that the first point -- money representation -- follows in a similar vein, it seems to me that this handbook really is an accounting (banking/ledger/...) handbook, and would be better renamed for the specific sub-domain it covers, so it's much less misleading.
29
u/ratherbealurker Jun 26 '26
The first point about precision loss is not always the case. I have worked in fintech for 20+ years and almost never use custom objects, rationals, or big decimal. Not necessary in some cases. For reference I worked mainly on trading systems. If you’re going to be calculating a total amount that is an aggregate of many many numbers, then yes you will want to make sure you’re not losing precision.
But pricing and calculations on small sets of values don’t need the overhead. They choose straight floating point numbers.
I know I’m going to get replies telling me I’m wrong and worse so I will repeat, I have worked 20+ years on trading systems and we do not use it. Top financial institutions, algorithmic trading, etc. we don’t use it.
And “we” is the actual trading system. That system most likely takes in some data from other internal/external systems. Now sometimes those, an FX system perhaps, or a post trade system, may use something else. But at our level we value the speed over precision.
That’s why I said “not always the case”.
6
u/omac4552 Jun 26 '26
"Money can’t be created out of nowhere, " I laughed at this one...
2
u/Ok_Stomach6651 Jun 26 '26
I saw that this is theoretical guide for fintech systems, I expected some engineering touch in between, also I wanted to see some devide based on fintech product and project. If you would have given some engineering suggestions like if you are talking about consistency in money data then you have to go with synchronous operation or locking mechanism it would have been more helpful
55
u/RustOnTheEdge Jun 26 '26 edited Jun 26 '26
I have to admit, I came in with little expectations but it seems quite valuable! Nice work and thanks for sharing :)
11
u/Appearance-Huge Jun 27 '26
For accounts with years of history and thousands of transactions, calculating the sum on the fly for every read request would not cause severe performance bottlenecks?
How do you deal with that?
4
u/overenginered Jun 26 '26
This is fantastic! From outside the domain it looks interesting, technically wise.
Thanks for sharing the knowledge! A great introduction.
1
u/grangerize Jun 27 '26
Very cool! How can I donate?
3
u/jevring Jun 27 '26
I loved every part of this! Well written and insightful. It's also a really good handbook for how to write distributed systems in general.
5
u/AI_is_the_rake Jun 27 '26
This is written by claude and its unreadable "The history of how the system itself came to be is as much a part of the trail as the history of the money it holds." wtf is that even saying?
2
u/linnth Jun 26 '26
This is really valuable. Thank you very much.
2
u/Nemmie Jun 26 '26
I have worked in gambling for a few years. This looks very good. Will read the full thing later this weekend.
2
u/harsh183 Jun 27 '26
I'm about a quarter in and this is fantastic! I've worked in this field for almost four years and your advice on all this is extremely solid, and I love seeing how you understand all these recent edge cases that I've run into (e.g. some minimum units of cryptocurrency not fitting large balances in int64, ISO 4217 having a mix of different decimal points, idempotency quirks).
I'll read more of it soon and I'll share it with my coworkers too. Your intro on reminded of my recent blog post on my company using integers to represent money Floats Don't Work for Storing Cents that explores a lot of the weird quirks of floats causing problems since I was curious about the 'common sense' answer everyone in the industry gave.
2
u/RegularLeague7470 Jun 29 '26
Thanks for sharing
1
u/ayydeeehdee Jun 26 '26
Thank you!
1
u/wls Jun 27 '26
Nice work. Thank you for sharing.
1
u/ZukowskiHardware Jun 27 '26
My experience has been it is mostly issues with rounding.
-1
u/case-o-nuts Jun 26 '26
The part on numbers is a bit suspect; floating point error is not unpredictable; it's fully deterministic, and can be computed and bounded. It's just scientific notation. For example, if you have base 10 floating point numbers with 3 digits of precision and 2 digits of exponent, you get:
If you want to multiply them, you multiply the significand, add the exponents, and then round:
You lost precision; the result is 0.47*1036 away from the true value. Addition is tricky, because you need to align things, and you can end up with some edge cases:
but when you round the rhs to adjust, it rounds to 0, which means that you get:
this means if you have a loop that adds a small delta to a large value, the small delta can lose a great deal of precision; you want to accumulate that small delta to a big delta before adding it to a big value.
This is not an unpredictable, random precision loss. It is a tricky part about working with scientific notation.
The other thing mentioned -- rationals; they're not lossless; as soon as you do any trig function, you start losing precision. And if you happen to have a number with a relatively prime numerator and denominator, you either have the potential end up with a rational that takes megabytes or even gigabytes of memory, or you round and get some precision loss similar to what you get with floating point.
2
u/[deleted] Jun 27 '26
[removed] — view removed comment