{"slug": "financial-models-as-code", "title": "Financial Models as Code", "summary": "Orcaset has released an experimental Python library for building financial models as code, using type annotations to catch malformed models at write time. The library allows humans and AI agents to build, modify, and audit large financial models with confidence through strong typing, flexible data integration, and transparent, deterministic calculations.", "body_md": "This library is in experimental status and the API is likely to change.\n\nOrcaset is a Python library for building financial models as code. Type annotations catch malformed models at write time, so humans and AI agents can build, modify, and audit large models with confidence.\n\n**Build and update with confidence**— Strong typing promotes correct models and surfaces relationship dependencies, so you can modify models without breaking them.**Flexible integration**— Connect to any data source and embed in existing workflows by leveraging Python's ecosystem.** Transparent and deterministic**— No black boxes. Materialize and inspect query-specific traces to audit every calculation.** Efficient construction**— Reusable components and terse definitions mean faster iteration and less context rot for agents.\n\nInstall from GitHub with `uv`\n\nor `pip`\n\n:\n\n```\nuv add git+https://github.com/orcaset/orcaset-py\npip install git+https://github.com/orcaset/orcaset-py\n```\n\nRequires Python 3.14 or later.\n\nAdd the `orcaset-py`\n\nskill to your coding agent by pasting in the following command:\n\n```\nInstall the skill from https://github.com/Orcaset/orcaset-py/tree/main/skill/orcaset-py\n```\n\nOrcaset models are built by defining and combining line item classes. Values are materialized by querying over dates, with caching and circular references handled by the evaluation context.\n\nThe snippet below defines a simple model with revenue, expenses, and income, then queries quarterly values through 2026.\n\n``` python\nfrom datetime import date\nfrom typing import Iterable\n\nfrom dateutil.relativedelta import relativedelta\n\nfrom orcaset import (\n    Context,\n    Formula,\n    Period,\n    Span,\n    SpanSeries,\n    Stmt,\n    Total,\n    fixed_width_table,\n    span,\n    split_daily,\n    sum_spans,\n)\n\n# Assumptions\nstart_date = date(2025, 12, 31)\ninitial_revenue = 100.0\nrevenue_growth_rate = 0.05\n\n# Model\nclass Revenue(SpanSeries):\n    agg = sum_spans(0.0)\n\n    def spans(self) -> Iterable[Span]:\n        value = initial_revenue\n        for period in Period.seq(start_date, relativedelta(months=1, day=31)):\n            yield Span(period, Formula.pure(value), split_daily)\n            value *= 1 + revenue_growth_rate / 12\n\nExpenses = span.scale(Revenue, -0.7, name=\"Expenses\")\nIncome = span.sum([Revenue, Expenses], agg=sum_spans(0.0), name=\"Income\")\n\n# Build a statement view\nstmt = Stmt(Total(Income, [Revenue, Expenses]))\n\n# Resolve and print formatted values\nctx = Context()\nqtrly_periods = Period.list(start_date, relativedelta(months=3, day=31), date(2026, 12, 31))\nprint(fixed_width_table(stmt.values(ctx, qtrly_periods)))\n\n# Start                   2025-12-31  2026-03-31  2026-06-30  2026-09-30\n# End         2025-12-31  2026-03-31  2026-06-30  2026-09-30  2026-12-31\n#   Revenue                   301.25      305.03      308.86      312.74\n#   Expenses                 -210.88     -213.52     -216.20     -218.92\n# ----------------------------------------------------------------------\n# Income                       90.38       91.51       92.66       93.82\n```\n\nNote that `Revenue`\n\nis defined on a monthly basis but queried quarterly. Orcaset automatically aligns, interpolates, and aggregates over partial periods.\n\nSee the [quickstart example](/Orcaset/orcaset-py/blob/main/examples/quickstart/README.md) for a step-by-step guide covering cells, series, context, and structured output.\n\nOrcaset is licensed under the Server Side Public License. You can freely use it to build internal models for underwriting, valuation, risk, or other analysis. See [LICENSE](/Orcaset/orcaset-py/blob/main/LICENSE) for details.", "url": "https://wpnews.pro/news/financial-models-as-code", "canonical_source": "https://github.com/Orcaset/orcaset-py", "published_at": "2026-05-29 18:56:47+00:00", "updated_at": "2026-05-29 19:17:24.282550+00:00", "lang": "en", "topics": ["ai-tools", "ai-infrastructure", "ai-agents", "mlops"], "entities": ["Orcaset", "Python"], "alternates": {"html": "https://wpnews.pro/news/financial-models-as-code", "markdown": "https://wpnews.pro/news/financial-models-as-code.md", "text": "https://wpnews.pro/news/financial-models-as-code.txt", "jsonld": "https://wpnews.pro/news/financial-models-as-code.jsonld"}}