Fintech Engineering Handbook

(w.pitula.me)

67 points | by signa11 1 hour ago

5 comments

  • lxgr 29 minutes ago
    Word of advice to anyone considering the "minor-units precision" strategy for representing monetary amounts: Don't (or at least, don't use it as an interchange/API data format).

    It seems like a clever idea (fast integer math, no rounding problems for addition and subtraction), but it'll bite you incredibly hard if you ever stumble upon an edge case such as working with a partner that has a different implied number of digits for a given currency. This is especially relevant for stablecoins, which often have a different number of implied decimal digits than the "fiat" currency they represent.

    Also, consider representing amounts as a string type in JSON-based APIs. JSON does not specify decimal precision, so you (and all your users/vendors) will always have to make sure your parser/serializer doesn't internally lose precision by going via floating point. This can get ugly fast, and while a string seems conceptually less neat, it completely bypasses that problem. (Some will call this an anti-pattern [1], but I'd rather not fight this particular battle for ideological purity on the shoulders of my users or shareholders.)

    [1] https://blog.json-everything.net/posts/numbers-are-numbers-n...

    • denismenace 23 minutes ago
      > but it'll bite you incredibly hard if you ever stumble upon an edge case such as working with a partner that has a different implied number of digits for a given currency

      Why would that be a problem? You just transform the values when interacting with their API.

      • lxgr 22 minutes ago
        Sure, but are all your (and your users' and vendors') engineers and LLM agents going to remember that? When in doubt, always be explicit.
    • gucci-on-fleek 23 minutes ago
      What do you recommend instead? Standard floating-point ("float"/"double"), fixed-point arithmetic with thousandths (or smaller) of the minor unit, arbitrary-precision decimal numbers, or something else entirely?
      • lxgr 12 minutes ago
        I think what matters most is your database and API representation, as well as having consistent and well-defined rounding rules.

        I largely agree with TFA: Round explicitly and consistently whenever you cross a boundary, i.e. database persistence and internal API calls.

        Use whatever works for your required business case internally (i.e. inside of procedures calculating some function of one or more input amounts). This can be regular old floats/doubles if you absolutely know what you're doing, or BigDecimal if you aren't and would rather suffer slightly slower performance than having to talk to an auditor about IEEE 754 rounding modes, or even minor-amount integers (yes, even though I just said to not use them – but you'll want to ABSOLUTELY NEVER leak them outside of your system, including your data/analytics pipeline, which might have different ideas about financial amounts than your business logic implementing a nice custom monetary type).

      • ivanmontillam 11 minutes ago
        A string type. As parent says: it completely bypasses the problem. Save the numbers between double quotes and be done with it.
  • danielabinav160 51 minutes ago
    The idempotency keys section alone is worth the read most devs learn that lesson the hard way.
    • __natty__ 22 minutes ago
      Also audit trails. Good audit trail can save company (and you) in emergency as well. Useful for debugging and last resort of compliance data source.
    • pards 18 minutes ago
      100%. It deserves more detail, too.

      I've spent many hours explaining how idempotency is supposed to work, and why it's important. Most teams understand the need for it, but very few thought about it up front.

  • ricardobayes 10 minutes ago
    Does anyone have more learning resources in this field? Any model implementations, pet projects, anything to get going?
  • dapperdrake 17 minutes ago
    First half didn’t sound so bad.
  • dc_giant 49 minutes ago
    Sorry have to ask these days. Is this carefully written down information from years of experience in the field or AI slop?
    • jagged-chisel 36 minutes ago
      Appears that the author got some help organizing the document, but wrote it all themselves.
    • thewisenerd 44 minutes ago
      from the author's mastodon post [0]

          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. 
          Tell me what you think!
      
      other than that, peruse the commits on the source [1], or wait for the author to respond.

      [0]: https://mas.to/@krever/116814803588993437

      [1]: https://github.com/Krever/fintech-engineering-handbook/commi...

    • zipy124 35 minutes ago
      Whilst I wouldn't say anything in it requires years of experience to know, this would be helpful for someone who hasn't considered anything about monetary systems. It doesn't read like slop, but I could be wrong but even so it all seems fairly reasonable (I've only fully read about 50% before realising there's nothing new here for me, and then skimmed to rest).
    • manwithopinions 30 minutes ago
      Skimmed it and based on my experience in fintech, it looks good, accurately represents the real world. I guess there’s still a chance it is AI generated but it doesn’t seem like vacuous slop, it has substance!