<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
    <title>Cristata Technologies</title>
    <subtitle>Data platforms and quantitative software for credit, capital markets, and financial services.</subtitle>
    <link rel="self" type="application/atom+xml" href="https://cristata.tech/atom.xml"/>
    <link rel="alternate" type="text/html" href="https://cristata.tech"/>
    <generator uri="https://www.getzola.org/">Zola</generator>
    <updated>2026-03-16T00:00:00+00:00</updated>
    <id>https://cristata.tech/atom.xml</id>
    <entry xml:lang="en">
        <title>You don&#39;t hate Python. You hate other people&#39;s Python.</title>
        <published>2026-03-16T00:00:00+00:00</published>
        <updated>2026-03-16T00:00:00+00:00</updated>
        
        <author>
          <name>Unknown</name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://cristata.tech/writing/you-dont-hate-python/"/>
        <id>https://cristata.tech/writing/you-dont-hate-python/</id>
        
        <content type="html" xml:base="https://cristata.tech/writing/you-dont-hate-python/">&lt;p&gt;I apologize for using the forbidden sentence structure, but it’s true. If you
haven’t written Python since like 2016, you might not have been paying
attention to the ongoing &lt;em&gt;engoodening&lt;/em&gt; of the language. In the last 5-10 years
Python has matured from a scripting language appropriate short-lived glue code
to a powerful, expressive, fully-featured language for Serious software
engineering.&lt;/p&gt;
&lt;h2 id=&quot;the-dark-times&quot;&gt;The dark times&lt;a class=&quot;zola-anchor&quot; href=&quot;#the-dark-times&quot; aria-label=&quot;Anchor link for: the-dark-times&quot;&gt;
  &lt;span class=&quot;content-icon content-icon-sm&quot; aria-hidden=&quot;true&quot;&gt;
    &lt;svg focusable=&quot;false&quot; class=&quot;social-icon&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.5.5l3-3a5 5 0 0 0-7-7l-1.5 1.5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.5-.5l-3 3a5 5 0 0 0 7 7l1.5-1.5&quot;&gt;&lt;/path&gt;&lt;/svg&gt;

  &lt;/span&gt;
&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Python 2 was bad. Enough ink has been spilled over this that we don’t have to
relitigate the question here (&lt;code&gt;UnicodeDecodeError: &#39;ascii&#39; codec can&#39;t decode byte 0xc3&lt;/code&gt;). It had to go for the language to have a future. And so you may
remember the Python 2 to 3 migration as the most painful software update since
Y2K: chaos and destruction, rivers of blood, bodies piled in the streets, etc.&lt;/p&gt;
&lt;p&gt;Even more than other languages, Python lives and dies by its ecosystem, so the
library ecosystem was the real chokepoint: NumPy didn’t support 3 until 2010,
Django until 2013, countless smaller libraries never. The &lt;code&gt;2to3&lt;/code&gt; tool handled
syntax but not semantics - every piece of I/O code had to decide “is this text
or bytes?” and no tool could decide that for you. The &lt;code&gt;six&lt;/code&gt; compatibility
library became load-bearing infrastructure. Python 2.7’s EOL extended from 2015
to 2020, killing any urgency. In the end, Python 2 died through attrition -
library authors dropped support and holdouts had no choice. It took a decade.
“We don’t want a Python 3 situation” is now the universal shorthand in other
language communities for how not to evolve a language.&lt;/p&gt;
&lt;h2 id=&quot;the-type-system&quot;&gt;The Type system&lt;a class=&quot;zola-anchor&quot; href=&quot;#the-type-system&quot; aria-label=&quot;Anchor link for: the-type-system&quot;&gt;
  &lt;span class=&quot;content-icon content-icon-sm&quot; aria-hidden=&quot;true&quot;&gt;
    &lt;svg focusable=&quot;false&quot; class=&quot;social-icon&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.5.5l3-3a5 5 0 0 0-7-7l-1.5 1.5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.5-.5l-3 3a5 5 0 0 0 7 7l1.5-1.5&quot;&gt;&lt;/path&gt;&lt;/svg&gt;

  &lt;/span&gt;
&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;The first shred of light appeared in 2015-2016 with Python 3.5 and 3.6. PEP 484
added type hints. They were optional and they left a lot to be desired, but
they established a foundation.&lt;/p&gt;
&lt;p&gt;Early type hints required ugly imports for basic things (&lt;code&gt;List[int]&lt;/code&gt;,
&lt;code&gt;Optional[str]&lt;/code&gt;, &lt;code&gt;Union[X, Y]&lt;/code&gt;) and forward references had to be quoted
strings. Each release filed this down. 3.9: &lt;code&gt;list[int]&lt;/code&gt; natively, no imports.
3.10: &lt;code&gt;X | Y&lt;/code&gt; instead of &lt;code&gt;Union&lt;/code&gt;. 3.11: &lt;code&gt;Self&lt;/code&gt; for return types. 3.12: native
generics on functions and classes (&lt;code&gt;def first[T](items: list[T]&lt;/code&gt;) -&amp;gt; T:), plus
&lt;code&gt;@override&lt;/code&gt; and the &lt;code&gt;type&lt;/code&gt; keyword. 3.14 finally, &lt;em&gt;finally,&lt;/em&gt; adds lazy
evaluation to fix the circular dependency issues and we can all stop invoking
&lt;code&gt;from __future__ import annotations&lt;/code&gt; for things that should Just Work.&lt;/p&gt;
&lt;h2 id=&quot;other-people-s-code&quot;&gt;Other people’s code&lt;a class=&quot;zola-anchor&quot; href=&quot;#other-people-s-code&quot; aria-label=&quot;Anchor link for: other-people-s-code&quot;&gt;
  &lt;span class=&quot;content-icon content-icon-sm&quot; aria-hidden=&quot;true&quot;&gt;
    &lt;svg focusable=&quot;false&quot; class=&quot;social-icon&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.5.5l3-3a5 5 0 0 0-7-7l-1.5 1.5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.5-.5l-3 3a5 5 0 0 0 7 7l1.5-1.5&quot;&gt;&lt;/path&gt;&lt;/svg&gt;

  &lt;/span&gt;
&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;So as I have now deftly convinced you, Python is a good language with good
features, and I’m sure you’re eager to use them. This gets us to the last
problem. People. Python’s type system is optional and incremental - you don’t
&lt;em&gt;have&lt;/em&gt; to use it consistently (or at all), and many programmers choose not to.
You can still get away with:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot; &gt;&lt;code data-lang=&quot;python&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt; process&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;data&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; flag&lt;/span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;False&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; extra&lt;/span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;None&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; **&lt;/span&gt;&lt;span&gt;kwargs&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    result&lt;/span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; =&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;    for&lt;/span&gt;&lt;span&gt; k&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; v&lt;/span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; in&lt;/span&gt;&lt;span&gt; data&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;items&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;        if&lt;/span&gt;&lt;span&gt; flag&lt;/span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; and&lt;/span&gt;&lt;span&gt; extra&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;            result&lt;/span&gt;&lt;span&gt;[&lt;/span&gt;&lt;span&gt;k&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; =&lt;/span&gt;&lt;span&gt; v&lt;/span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; *&lt;/span&gt;&lt;span&gt; extra&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;get&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;multiplier&lt;/span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt; 1&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;        else&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;            result&lt;/span&gt;&lt;span&gt;[&lt;/span&gt;&lt;span&gt;k&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; =&lt;/span&gt;&lt;span&gt; v&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;    return&lt;/span&gt;&lt;span&gt; result&lt;/span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; or&lt;/span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt; None&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;What’s &lt;code&gt;data&lt;/code&gt;? A dict of what to what? What’s &lt;code&gt;flag&lt;/code&gt; actually controlling? Why
does it return None sometimes? What’s in &lt;code&gt;kwargs&lt;/code&gt; and does anything even use
it? No one will stop you from writing **kwargs-in, dict-out, bare-except,
mutable-default-argument garbage with no annotations and no docstrings.&lt;/p&gt;
&lt;p&gt;And this is a &lt;strong&gt;good thing.&lt;/strong&gt; This is why Python won. Sometimes you just need
to get the job done. You want the tool to get out of your way and simply
manipulate some data, run a process, do an experiment. Not everything is meant
to be long-lived and maintained, but when it is, you have simply to use the
convenient tools at your disposal:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot; &gt;&lt;code data-lang=&quot;python&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;from&lt;/span&gt;&lt;span&gt; dataclasses&lt;/span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; import&lt;/span&gt;&lt;span&gt; dataclass&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;@&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;dataclass&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt; ScalingConfig&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    multiplier&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt; float&lt;/span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt; 1.0&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt; scale_values&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    values&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span&gt; dict&lt;/span&gt;&lt;span&gt;[&lt;/span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;str&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt; float&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    config&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span&gt; ScalingConfig&lt;/span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; |&lt;/span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt; None&lt;/span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt; None&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; -&amp;gt;&lt;/span&gt;&lt;span&gt; dict&lt;/span&gt;&lt;span&gt;[&lt;/span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;str&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt; float&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;    if&lt;/span&gt;&lt;span&gt; config&lt;/span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; is&lt;/span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt; None&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;        return&lt;/span&gt;&lt;span&gt; values&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;    return&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span&gt;k&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span&gt; v&lt;/span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; *&lt;/span&gt;&lt;span&gt; config&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;multiplier&lt;/span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; for&lt;/span&gt;&lt;span&gt; k&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; v&lt;/span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; in&lt;/span&gt;&lt;span&gt; values&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;items&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Pyright catches type errors at edit time. Ruff handles linting and formatting
fast enough to run on save. Pydantic enforces types at runtime at API
boundaries. Dataclasses replace formless dicts. Enums and &lt;code&gt;Literal&lt;/code&gt; kill
stringly-typed dispatch. &lt;code&gt;Protocol&lt;/code&gt; gives you Go-style structural interfaces.
&lt;code&gt;pre-commit&lt;/code&gt; gates all of it in CI. None of this existed in usable form in 2016. The gap between “Python lets you write good code” and “your team actually
writes good code” is closeable now, if you close it.&lt;/p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Decimal is sometimes wrong</title>
        <published>2025-11-28T00:00:00+00:00</published>
        <updated>2025-11-28T00:00:00+00:00</updated>
        
        <author>
          <name>Unknown</name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://cristata.tech/writing/dropping-decimal/"/>
        <id>https://cristata.tech/writing/dropping-decimal/</id>
        
        <content type="html" xml:base="https://cristata.tech/writing/dropping-decimal/">&lt;p&gt;&lt;a rel=&quot;external&quot; href=&quot;https://github.com/jt-hill/credkit&quot;&gt;Credkit&lt;/a&gt; is dropping its usage of the
Python Decimal class. I thought it was the solution to all my problems, but it
was not.&lt;/p&gt;
&lt;h2 id=&quot;decimal-is-always-right&quot;&gt;Decimal is always right&lt;a class=&quot;zola-anchor&quot; href=&quot;#decimal-is-always-right&quot; aria-label=&quot;Anchor link for: decimal-is-always-right&quot;&gt;
  &lt;span class=&quot;content-icon content-icon-sm&quot; aria-hidden=&quot;true&quot;&gt;
    &lt;svg focusable=&quot;false&quot; class=&quot;social-icon&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.5.5l3-3a5 5 0 0 0-7-7l-1.5 1.5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.5-.5l-3 3a5 5 0 0 0 7 7l1.5-1.5&quot;&gt;&lt;/path&gt;&lt;/svg&gt;

  &lt;/span&gt;
&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Every quant dev, financial data engineer, and fintech developer will learn
early: &lt;em&gt;never use floating point for money&lt;/em&gt;. The classic example gets trotted
out in every intro CS course:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot; &gt;&lt;code data-lang=&quot;python&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt; 0.1&lt;/span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt; 0.2&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;0.30000000000000004&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Whoops! You can imagine how that’s a problem. There are cautionary tales about
trading systems accumulating factional penny rounding errors into significant
discrepancies.&lt;/p&gt;
&lt;p&gt;If you are working on a Python codebase, you may be pointed to the &lt;code&gt;Decimal&lt;/code&gt;
class to &lt;a rel=&quot;external&quot; href=&quot;https://docs.python.org/3/library/decimal.html&quot;&gt;solve this problem&lt;/a&gt;.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot; &gt;&lt;code data-lang=&quot;python&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; from&lt;/span&gt;&lt;span&gt; decimal&lt;/span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; import&lt;/span&gt;&lt;span&gt; Decimal&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span&gt; Decimal&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;0.1&lt;/span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; +&lt;/span&gt;&lt;span&gt; Decimal&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;0.2&lt;/span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Decimal&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;0.3&lt;/span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So when I started building credkit, a Python library for credit
modeling, I did the Responsible Thing and used Python’s &lt;code&gt;Decimal&lt;/code&gt; type
throughout. Exact arithmetic. No rounding errors. A Serious tool for Serious
Professionals.&lt;/p&gt;
&lt;p&gt;That was a mistake.&lt;/p&gt;
&lt;h2 id=&quot;the-ecosystem-problem&quot;&gt;The Ecosystem Problem&lt;a class=&quot;zola-anchor&quot; href=&quot;#the-ecosystem-problem&quot; aria-label=&quot;Anchor link for: the-ecosystem-problem&quot;&gt;
  &lt;span class=&quot;content-icon content-icon-sm&quot; aria-hidden=&quot;true&quot;&gt;
    &lt;svg focusable=&quot;false&quot; class=&quot;social-icon&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.5.5l3-3a5 5 0 0 0-7-7l-1.5 1.5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.5-.5l-3 3a5 5 0 0 0 7 7l1.5-1.5&quot;&gt;&lt;/path&gt;&lt;/svg&gt;

  &lt;/span&gt;
&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Here’s the thing about the &lt;code&gt;Decimal&lt;/code&gt; Python object: &lt;a rel=&quot;external&quot; href=&quot;https://github.com/python/cpython/blob/main/Lib/_pydecimal.py&quot;&gt;it’s a &lt;em&gt;Python&lt;/em&gt;
object&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;This sounds tautological of course, but the entire Python scientific computing
ecosystem (NumPy, SciPy, pandas, Polars, PyArrow) exists precisely by
&lt;em&gt;escaping&lt;/em&gt; Python objects. These libraries are thin Python wrappers around C,
C++, or Rust code operating on contiguous arrays of IEEE 754 floats. That’s the
whole crux - it’s where the speed comes from.&lt;/p&gt;
&lt;p&gt;A &lt;code&gt;Decimal&lt;/code&gt; cannot participate in this, because it is implemented as a Python
object. There is no underlying C object to drop in to. When you put
Decimals in a NumPy array or pandas DataFrame, you get &lt;code&gt;dtype=object&lt;/code&gt;, which is
just a column of arbitrary Python pointers. No vectorization. No SIMD. Just a
for-loop with all the overhead that implies.&lt;/p&gt;
&lt;p&gt;But it’s not just performance. Many libraries simply &lt;em&gt;refuse&lt;/em&gt; to work with Decimal:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot; &gt;&lt;code data-lang=&quot;python&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6A737D, #6A737D);&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6A737D, #6A737D);&quot;&gt; scipy.optimize expects float64&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;from&lt;/span&gt;&lt;span&gt; scipy&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;optimize&lt;/span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; import&lt;/span&gt;&lt;span&gt; newton&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;from&lt;/span&gt;&lt;span&gt; decimal&lt;/span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; import&lt;/span&gt;&lt;span&gt; Decimal&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;cfs&lt;/span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; =&lt;/span&gt;&lt;span&gt; [&lt;/span&gt;&lt;span&gt;Decimal&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;-100000&lt;/span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; Decimal&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;30000&lt;/span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; Decimal&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;35000&lt;/span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;newton&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;lambda&lt;/span&gt;&lt;span&gt; r&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt; sum&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;cf&lt;/span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;/&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;+&lt;/span&gt;&lt;span&gt;Decimal&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;str&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;r&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;**&lt;/span&gt;&lt;span&gt;i&lt;/span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; for&lt;/span&gt;&lt;span&gt; i&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt;cf&lt;/span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; in&lt;/span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt; enumerate&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;cfs&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; Decimal&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;0.1&lt;/span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6A737D, #6A737D);&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6A737D, #6A737D);&quot;&gt; TypeError: unsupported operand type(s) for *: &amp;#39;decimal.Decimal&amp;#39; and &amp;#39;float&amp;#39;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And here’s where it can get insidious: some libraries &lt;em&gt;appear&lt;/em&gt; to support
Decimal but don’t really. PyXIRR’s type hints show &lt;code&gt;Amount = Union[int, float, Decimal]&lt;/code&gt;, which looks like full Decimal support. But watch what happens:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot; &gt;&lt;code data-lang=&quot;python&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;from&lt;/span&gt;&lt;span&gt; pyxirr&lt;/span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; import&lt;/span&gt;&lt;span&gt; xirr&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;from&lt;/span&gt;&lt;span&gt; decimal&lt;/span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; import&lt;/span&gt;&lt;span&gt; Decimal&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;from&lt;/span&gt;&lt;span&gt; datetime&lt;/span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; import&lt;/span&gt;&lt;span&gt; date&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;dates&lt;/span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; =&lt;/span&gt;&lt;span&gt; [&lt;/span&gt;&lt;span&gt;date&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;2020&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt; 1&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt; 1&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; date&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;2021&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt; 1&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt; 1&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; date&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;2022&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt; 1&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt; 1&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;amounts&lt;/span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; =&lt;/span&gt;&lt;span&gt; [&lt;/span&gt;&lt;span&gt;Decimal&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;-1000.00&lt;/span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; Decimal&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;500.00&lt;/span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; Decimal&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;600.00&lt;/span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;result&lt;/span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; =&lt;/span&gt;&lt;span&gt; xirr&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;dates&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; amounts&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;print&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;type&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;amounts&lt;/span&gt;&lt;span&gt;[&lt;/span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;0&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6A737D, #6A737D);&quot;&gt;  #&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6A737D, #6A737D);&quot;&gt; &amp;lt;class &amp;#39;decimal.Decimal&amp;#39;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;print&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;type&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;result&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6A737D, #6A737D);&quot;&gt;      #&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6A737D, #6A737D);&quot;&gt; &amp;lt;class &amp;#39;float&amp;#39;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;NumPy Financial and PyXIRR both accept your Decimals, convert them to C/Rust
floats at the boundary, do all the math in float64, and hand you back a float.
Your precision was silently discarded. The API gives you the illusion of exact
arithmetic while quietly not providing it.&lt;/p&gt;
&lt;p&gt;But even if the library supports it perfectly, &lt;em&gt;you&lt;/em&gt; might not.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot; &gt;&lt;code data-lang=&quot;python&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; from&lt;/span&gt;&lt;span&gt; decimal&lt;/span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; import&lt;/span&gt;&lt;span&gt; Decimal&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span&gt; Decimal&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;100.10&lt;/span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Decimal&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;100.10&lt;/span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span&gt; Decimal&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;100.10&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Decimal&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;100.0999999999999943156581139191985130310058593750&lt;/span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Miss the quotes and you’ve embedded the float representation error into your
“exact” Decimal. The whole point of using Decimal was to avoid this, and now
you have to be paranoid about string quoting every single numeric literal. Sure
hope you never forget!&lt;/p&gt;
&lt;p&gt;I was paying the cost of &lt;code&gt;Decimal&lt;/code&gt; everywhere (the slow arithmetic, the clunky
constructors, the constant &lt;code&gt;Decimal(&quot;300000.00&quot;)&lt;/code&gt; instead of just &lt;code&gt;300000.0&lt;/code&gt;)
while losing the precision at every boundary where I actually needed to &lt;em&gt;do&lt;/em&gt;
something with the numbers.&lt;/p&gt;
&lt;h2 id=&quot;do-i-really-need-it&quot;&gt;Do I really need it?&lt;a class=&quot;zola-anchor&quot; href=&quot;#do-i-really-need-it&quot; aria-label=&quot;Anchor link for: do-i-really-need-it&quot;&gt;
  &lt;span class=&quot;content-icon content-icon-sm&quot; aria-hidden=&quot;true&quot;&gt;
    &lt;svg focusable=&quot;false&quot; class=&quot;social-icon&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.5.5l3-3a5 5 0 0 0-7-7l-1.5 1.5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.5-.5l-3 3a5 5 0 0 0 7 7l1.5-1.5&quot;&gt;&lt;/path&gt;&lt;/svg&gt;

  &lt;/span&gt;
&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;At this point you might reasonably ask: okay, but does float64 actually work
for financial calculations? Don’t you get horrifying rounding errors
compounding across 30-year mortgages?&lt;/p&gt;
&lt;p&gt;So I tested it.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Single Loan (30-year mortgage, 360 payments):&lt;/strong&gt;&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot; &gt;&lt;code data-lang=&quot;markdown&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Final balance (Decimal): $-0.0000000000&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Final balance (Float64): $-0.0000000465&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Difference: $0.000000046 (46 nano-cents)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Match when rounded to cents: True&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;After 360 compound calculations, float64 has accumulated an error of 46
billionths of a cent. When you round to pennies (which you have to do anyway,
because that’s what money actually is) they’re identical.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Portfolio interest calculation (1000 loans x 360 payments each):&lt;/strong&gt;&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot; &gt;&lt;code data-lang=&quot;markdown&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Decimal total: $348,905,505.58&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Float64 total: $348,905,505.58&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Difference: $0.00&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Daily interest accrual (30 years = 10,950 compounding periods):&lt;/strong&gt;&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot; &gt;&lt;code data-lang=&quot;markdown&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;$300,000 at 6% compounded daily for 30 years&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Decimal final: $1,814,625.78&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Float64 final: $1,814,625.78&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Difference: $0.00&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Accumulation of small amounts (sum a million pennies):&lt;/strong&gt;&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot; &gt;&lt;code data-lang=&quot;markdown&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Sum of 1,000,000 × $0.01&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Decimal: $10,000.00&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Float64: $10,000.00&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Difference: $0.00&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Even after 360,000 interest calculations across a portfolio, nearly 11,000
daily compounding operations, or a million additions of $0.01, the results
match to the penny.&lt;/p&gt;
&lt;h2 id=&quot;the-performance-reality&quot;&gt;The Performance Reality&lt;a class=&quot;zola-anchor&quot; href=&quot;#the-performance-reality&quot; aria-label=&quot;Anchor link for: the-performance-reality&quot;&gt;
  &lt;span class=&quot;content-icon content-icon-sm&quot; aria-hidden=&quot;true&quot;&gt;
    &lt;svg focusable=&quot;false&quot; class=&quot;social-icon&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.5.5l3-3a5 5 0 0 0-7-7l-1.5 1.5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.5-.5l-3 3a5 5 0 0 0 7 7l1.5-1.5&quot;&gt;&lt;/path&gt;&lt;/svg&gt;

  &lt;/span&gt;
&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;The precision difference is unmeasurable. The performance difference is not.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot; &gt;&lt;code data-lang=&quot;markdown&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;1000 loan amortizations (360 payments each):&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  Decimal: 110ms&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  Float64: 15ms&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  Speedup: 7x&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Pandas aggregation (100k rows):&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  Decimal (object dtype): 891ms&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  Float64 (native dtype): 7ms&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  Speedup: 127x&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;For interactive analysis in Jupyter notebooks and dashboards, this is the
difference between “responsive” and “go get coffee.”&lt;/p&gt;
&lt;h2 id=&quot;what-industry-actually-does&quot;&gt;What Industry Actually Does&lt;a class=&quot;zola-anchor&quot; href=&quot;#what-industry-actually-does&quot; aria-label=&quot;Anchor link for: what-industry-actually-does&quot;&gt;
  &lt;span class=&quot;content-icon content-icon-sm&quot; aria-hidden=&quot;true&quot;&gt;
    &lt;svg focusable=&quot;false&quot; class=&quot;social-icon&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.5.5l3-3a5 5 0 0 0-7-7l-1.5 1.5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.5-.5l-3 3a5 5 0 0 0 7 7l1.5-1.5&quot;&gt;&lt;/path&gt;&lt;/svg&gt;

  &lt;/span&gt;
&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Once I started looking, I noticed that basically &lt;em&gt;everyone&lt;/em&gt; doing financial
analytics uses float64:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;QuantLib&lt;/strong&gt;: The standard open-source quant finance library defines &lt;code&gt;Real&lt;/code&gt; as
&lt;code&gt;double&lt;/code&gt; in its source.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;R&lt;/strong&gt;: R has no Decimal type at all. The language stores all real numbers as
double-precision floats. And R has long been the workhorse for analytical and
computational modeling problems&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Every pandas/NumPy financial analysis ever&lt;/strong&gt;: float64 by default.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The places that use fixed-point decimal arithmetic are accounting systems:
general ledgers, transaction processing, regulatory reporting where everything
must reconcile exactly. But credkit isn’t an accounting system. It’s an
analytics library. NPV calculations, cash flow modeling, IRR, portfolio
metrics. The output is “this loan is worth approximately $287,342” not “account
47291 has a balance of $287,342.18 that must match the ledger.”&lt;/p&gt;
&lt;p&gt;I was demanding accounting precision for analytics work, and making everything
more painful for no real benefit.&lt;/p&gt;
&lt;h2 id=&quot;the-lesson&quot;&gt;The Lesson&lt;a class=&quot;zola-anchor&quot; href=&quot;#the-lesson&quot; aria-label=&quot;Anchor link for: the-lesson&quot;&gt;
  &lt;span class=&quot;content-icon content-icon-sm&quot; aria-hidden=&quot;true&quot;&gt;
    &lt;svg focusable=&quot;false&quot; class=&quot;social-icon&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.5.5l3-3a5 5 0 0 0-7-7l-1.5 1.5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.5-.5l-3 3a5 5 0 0 0 7 7l1.5-1.5&quot;&gt;&lt;/path&gt;&lt;/svg&gt;

  &lt;/span&gt;
&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Best Practices do not absolve you from needing to actually understand the scope
and bounds of your problem, and “never use floats for money” is a heuristic,
not a divine commandment. It’s advice for transaction processing where
everything must reconcile exactly.&lt;/p&gt;
&lt;p&gt;But credkit is not a ledger.&lt;/p&gt;
&lt;p&gt;After testing, the actual error I found was 46 nano-cents on a single
loan. Across a portfolio of 1000 mortgages with 360,000 interest calculations,
the difference was still zero cents.&lt;/p&gt;
&lt;p&gt;Is your loss forecast accurate to the nano-cent? Do you know your prepayment
rate down to the milli-basis-point? If not, you’re measuring ingredients to the
microgram while guessing at the oven temperature.&lt;/p&gt;
&lt;p&gt;The number type doesn’t matter. &lt;a href=&quot;mailto:jth@jt-hill.com&quot;&gt;Getting the model right
does&lt;/a&gt;.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;&lt;em&gt;&lt;a rel=&quot;external&quot; href=&quot;https://gist.github.com/jt-hill/839e1a6c51d28cbcb8fc69e6143193eb&quot;&gt;The benchmark code is
available&lt;/a&gt;.
Credkit is on &lt;a rel=&quot;external&quot; href=&quot;https://pypi.org/project/credkit/&quot;&gt;PyPI&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Introducing Credkit</title>
        <published>2025-10-12T00:00:00+00:00</published>
        <updated>2025-10-12T00:00:00+00:00</updated>
        
        <author>
          <name>Unknown</name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://cristata.tech/writing/introducing-credkit/"/>
        <id>https://cristata.tech/writing/introducing-credkit/</id>
        
        <content type="html" xml:base="https://cristata.tech/writing/introducing-credkit/">&lt;p&gt;I got tired of fighting with QuantLib to model simple mortgages.
So I built something easier.&lt;/p&gt;
&lt;h2 id=&quot;the-problem&quot;&gt;The Problem&lt;a class=&quot;zola-anchor&quot; href=&quot;#the-problem&quot; aria-label=&quot;Anchor link for: the-problem&quot;&gt;
  &lt;span class=&quot;content-icon content-icon-sm&quot; aria-hidden=&quot;true&quot;&gt;
    &lt;svg focusable=&quot;false&quot; class=&quot;social-icon&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.5.5l3-3a5 5 0 0 0-7-7l-1.5 1.5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.5-.5l-3 3a5 5 0 0 0 7 7l1.5-1.5&quot;&gt;&lt;/path&gt;&lt;/svg&gt;

  &lt;/span&gt;
&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;QuantLib is great for complex derivatives. But for simple amortizing consumer
loans it’s complete overkill. You spend more time wrestling with schedule
builders and leg constructors than actually modeling the loan.&lt;/p&gt;
&lt;p&gt;These are relatively simple instruments, so they should be similarly simple to model&lt;/p&gt;
&lt;h2 id=&quot;the-solution&quot;&gt;The Solution&lt;a class=&quot;zola-anchor&quot; href=&quot;#the-solution&quot; aria-label=&quot;Anchor link for: the-solution&quot;&gt;
  &lt;span class=&quot;content-icon content-icon-sm&quot; aria-hidden=&quot;true&quot;&gt;
    &lt;svg focusable=&quot;false&quot; class=&quot;social-icon&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.5.5l3-3a5 5 0 0 0-7-7l-1.5 1.5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.5-.5l-3 3a5 5 0 0 0 7 7l1.5-1.5&quot;&gt;&lt;/path&gt;&lt;/svg&gt;

  &lt;/span&gt;
&lt;/a&gt;
&lt;/h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot; &gt;&lt;code data-lang=&quot;python&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;from&lt;/span&gt;&lt;span&gt; credkit&lt;/span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; import&lt;/span&gt;&lt;span&gt; Loan&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; Money&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; InterestRate&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;loan&lt;/span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; =&lt;/span&gt;&lt;span&gt; Loan&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;mortgage&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#E36209, #FFAB70);&quot;&gt;    principal&lt;/span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;=&lt;/span&gt;&lt;span&gt;Money&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;from_float&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;300000.0&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#E36209, #FFAB70);&quot;&gt;    annual_rate&lt;/span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;=&lt;/span&gt;&lt;span&gt;InterestRate&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;from_percent&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;6.5&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#E36209, #FFAB70);&quot;&gt;    term_years&lt;/span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#005CC5, #79B8FF);&quot;&gt;30&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;payment&lt;/span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; =&lt;/span&gt;&lt;span&gt; loan&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;calculate_payment&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6A737D, #6A737D);&quot;&gt;  #&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6A737D, #6A737D);&quot;&gt; ~$1,896.20/month&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;schedule&lt;/span&gt;&lt;span style=&quot;color: light-dark(#D73A49, #F97583);&quot;&gt; =&lt;/span&gt;&lt;span&gt; loan&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;generate_schedule&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6A737D, #6A737D);&quot;&gt;  #&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6A737D, #6A737D);&quot;&gt; Done.&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;That’s it. No ceremony, no fighting with abstractions designed for exotic swaps.&lt;/p&gt;
&lt;h2 id=&quot;what-you-get&quot;&gt;What You Get&lt;a class=&quot;zola-anchor&quot; href=&quot;#what-you-get&quot; aria-label=&quot;Anchor link for: what-you-get&quot;&gt;
  &lt;span class=&quot;content-icon content-icon-sm&quot; aria-hidden=&quot;true&quot;&gt;
    &lt;svg focusable=&quot;false&quot; class=&quot;social-icon&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.5.5l3-3a5 5 0 0 0-7-7l-1.5 1.5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.5-.5l-3 3a5 5 0 0 0 7 7l1.5-1.5&quot;&gt;&lt;/path&gt;&lt;/svg&gt;

  &lt;/span&gt;
&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Domain-specific primitives:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;Money&lt;/code&gt;, &lt;code&gt;InterestRate&lt;/code&gt;, &lt;code&gt;Spread&lt;/code&gt; types that actually make sense&lt;/li&gt;
&lt;li&gt;Day count conventions, payment frequencies, business day calendars&lt;/li&gt;
&lt;li&gt;Full amortization support (level payment, level principal, interest-only, bullet)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Type-safe and immutable:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Frozen dataclasses with full type hints&lt;/li&gt;
&lt;li&gt;Your IDE will actually help you&lt;/li&gt;
&lt;li&gt;No accidental mutations&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Cash flow modeling:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Generate schedules with principal/interest breakdown&lt;/li&gt;
&lt;li&gt;Discount curves for NPV calculations&lt;/li&gt;
&lt;li&gt;Filter and aggregate however you need&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;status-v0-2-0&quot;&gt;Status (v0.2.0)&lt;a class=&quot;zola-anchor&quot; href=&quot;#status-v0-2-0&quot; aria-label=&quot;Anchor link for: status-v0-2-0&quot;&gt;
  &lt;span class=&quot;content-icon content-icon-sm&quot; aria-hidden=&quot;true&quot;&gt;
    &lt;svg focusable=&quot;false&quot; class=&quot;social-icon&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.5.5l3-3a5 5 0 0 0-7-7l-1.5 1.5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.5-.5l-3 3a5 5 0 0 0 7 7l1.5-1.5&quot;&gt;&lt;/path&gt;&lt;/svg&gt;

  &lt;/span&gt;
&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;148 passing tests. Works end-to-end: create a loan → generate schedule →
calculate NPV.&lt;/p&gt;
&lt;p&gt;Currently USD-only, focused on US consumer lending (mortgages, auto, personal loans).&lt;/p&gt;
&lt;h2 id=&quot;what-s-next&quot;&gt;What’s Next&lt;a class=&quot;zola-anchor&quot; href=&quot;#what-s-next&quot; aria-label=&quot;Anchor link for: what-s-next&quot;&gt;
  &lt;span class=&quot;content-icon content-icon-sm&quot; aria-hidden=&quot;true&quot;&gt;
    &lt;svg focusable=&quot;false&quot; class=&quot;social-icon&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.5.5l3-3a5 5 0 0 0-7-7l-1.5 1.5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.5-.5l-3 3a5 5 0 0 0 7 7l1.5-1.5&quot;&gt;&lt;/path&gt;&lt;/svg&gt;

  &lt;/span&gt;
&lt;/a&gt;
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Credit risk metrics (PD, LGD, ratings)&lt;/li&gt;
&lt;li&gt;pandas integration&lt;/li&gt;
&lt;li&gt;Prepayment modeling&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;try-it&quot;&gt;Try It&lt;a class=&quot;zola-anchor&quot; href=&quot;#try-it&quot; aria-label=&quot;Anchor link for: try-it&quot;&gt;
  &lt;span class=&quot;content-icon content-icon-sm&quot; aria-hidden=&quot;true&quot;&gt;
    &lt;svg focusable=&quot;false&quot; class=&quot;social-icon&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.5.5l3-3a5 5 0 0 0-7-7l-1.5 1.5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.5-.5l-3 3a5 5 0 0 0 7 7l1.5-1.5&quot;&gt;&lt;/path&gt;&lt;/svg&gt;

  &lt;/span&gt;
&lt;/a&gt;
&lt;/h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6F42C1, #B392F0);&quot;&gt;pip&lt;/span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; install&lt;/span&gt;&lt;span style=&quot;color: light-dark(#032F62, #9ECBFF);&quot;&gt; credkit&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;GitHub: &lt;a rel=&quot;external&quot; href=&quot;https://github.com/jt-hill/credkit&quot;&gt;github.com/jt-hill/credkit&lt;/a&gt;&lt;br /&gt;
PyPI: &lt;a rel=&quot;external&quot; href=&quot;https://pypi.org/project/credkit/&quot;&gt;pypi.org/project/credkit&lt;/a&gt;
License: AGPL-3.0 (&lt;a href=&quot;mailto:jth@jt-hill.com&quot;&gt;other commercial options available&lt;/a&gt;)&lt;/p&gt;
&lt;h2 id=&quot;feedback&quot;&gt;Feedback?&lt;a class=&quot;zola-anchor&quot; href=&quot;#feedback&quot; aria-label=&quot;Anchor link for: feedback&quot;&gt;
  &lt;span class=&quot;content-icon content-icon-sm&quot; aria-hidden=&quot;true&quot;&gt;
    &lt;svg focusable=&quot;false&quot; class=&quot;social-icon&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.5.5l3-3a5 5 0 0 0-7-7l-1.5 1.5&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.5-.5l-3 3a5 5 0 0 0 7 7l1.5-1.5&quot;&gt;&lt;/path&gt;&lt;/svg&gt;

  &lt;/span&gt;
&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;This is early. If you work in or near credit and have ideas or pain points,
let me know. What would make your life easier?&lt;/p&gt;
</content>
        
    </entry>
</feed>
