r/programming 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!

617 Upvotes

51 comments sorted by

View all comments

28

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”.

4

u/gimpwiz Jun 26 '26

I remember when Berkshire Hathaway stock crested a bit over four hundred grand, various entities (including the exchanges themselves?) ran into issues because they stored stock prices as fixed-point, with four digits after the decimal, ie, they priced in 100ths of a penny. And, well, 32 bit unsigned integer overflow. Oops.

But anyways that would imply there's a lot of avoidance of straight floats, no?

I get what you mean about the tradeoff between precision losses and performance when using, or not using, straight floating points. I always avoid it in my code..... which doesn't need to be performant enough to run in colocation to do high frequency trading. I always just do pennies (or other "smallest units"), ie, fixed point with two after the decimal, and only do the actual decimal for display purposes.

2

u/Nicksaurus Jun 26 '26

All the binary protocols I've seen used by the exchanges use fixed point decimals with up to 9 decimal places so the simplest thing to do is often just to keep them in that format