{
 "description": "Verified Soma programs. Every entry passed `soma check` (and `soma test` / `soma verify` where applicable) on the soma version below, re-run when this index was generated. Fetch `url` for the source. Filter by `domain` or `features` to find a working example of what you are about to write.",
 "soma_version": "3.2.4",
 "count": 17,
 "domains": {
  "finance": 17
 },
 "features": [
  "agent",
  "cost",
  "fail",
  "guard",
  "http",
  "invariant",
  "lambda",
  "match",
  "multi_cell",
  "native",
  "pipeline",
  "service",
  "skeleton",
  "state_machine",
  "sum_type",
  "think",
  "tools",
  "try"
 ],
 "programs": [
  {
   "id": "finance/bond_pricer",
   "domain": "finance",
   "title": "Fixed-coupon bond pricing: present value of coupons plus redemption, current yield, and a par/premium/discount classifier",
   "summary": "Fixed-coupon bond pricing: present value of coupons plus redemption, current yield, and a par/premium/discount classifier. Discounts each coupon over a range, sum() of the discounted stream.",
   "url": "https://soma-lang.dev/corpus/finance/bond_pricer.cell",
   "repo_path": "examples/corpus/finance/bond_pricer.cell",
   "lines": 49,
   "features": [],
   "cells": [
    "BondPricer",
    "BondTests"
   ]
  },
  {
   "id": "finance/budget_tracker",
   "domain": "finance",
   "title": "Monthly budget tracker with a spend cap invariant",
   "summary": "Monthly budget tracker with a spend cap invariant. Total spend per category must never exceed its allotted budget; an over-budget write is rejected by memory. Shows group accounting and a remaining-budget query.",
   "url": "https://soma-lang.dev/corpus/finance/budget_tracker.cell",
   "repo_path": "examples/corpus/finance/budget_tracker.cell",
   "lines": 54,
   "features": [
    "invariant",
    "try"
   ],
   "cells": [
    "BudgetTracker",
    "BudgetTests"
   ]
  },
  {
   "id": "finance/chip_ledger",
   "domain": "finance",
   "title": "Chip/cash ledger with a non-negative balance invariant",
   "summary": "Chip/cash ledger with a non-negative balance invariant. The memory itself rejects any write that would overdraw an account — the bad .set() never commits, so the slot keeps its previous value. Demonstrates: memory invariant, try around a guarded write, assert_fails.",
   "url": "https://soma-lang.dev/corpus/finance/chip_ledger.cell",
   "repo_path": "examples/corpus/finance/chip_ledger.cell",
   "lines": 54,
   "features": [
    "invariant",
    "try"
   ],
   "cells": [
    "ChipLedger",
    "ChipLedgerTests"
   ]
  },
  {
   "id": "finance/compound_interest",
   "domain": "finance",
   "title": "Compound interest: future value, with periodic compounding and a continuous-compounding variant",
   "summary": "Compound interest: future value, with periodic compounding and a continuous-compounding variant. Pure numeric handlers, tolerance-based float assertions (never == on floats).",
   "url": "https://soma-lang.dev/corpus/finance/compound_interest.cell",
   "repo_path": "examples/corpus/finance/compound_interest.cell",
   "lines": 46,
   "features": [],
   "cells": [
    "CompoundInterest",
    "CompoundTests"
   ]
  },
  {
   "id": "finance/currency_converter",
   "domain": "finance",
   "title": "FX converter with a rate table in memory and a non-negative rate invariant",
   "summary": "FX converter with a rate table in memory and a non-negative rate invariant. Cross rates are derived via a USD base. Demonstrates a Map<String,Float> slot, an invariant on stored values, and triangular cross-rate arithmetic.",
   "url": "https://soma-lang.dev/corpus/finance/currency_converter.cell",
   "repo_path": "examples/corpus/finance/currency_converter.cell",
   "lines": 60,
   "features": [
    "invariant",
    "try"
   ],
   "cells": [
    "FxConverter",
    "FxTests"
   ]
  },
  {
   "id": "finance/dividend_yield",
   "domain": "finance",
   "title": "Equity income metrics: dividend yield, payout ratio, dividend-discount",
   "summary": "Equity income metrics: dividend yield, payout ratio, dividend-discount (Gordon growth) fair value, and yield-on-cost. Straightforward ratios with guards against division by zero.",
   "url": "https://soma-lang.dev/corpus/finance/dividend_yield.cell",
   "repo_path": "examples/corpus/finance/dividend_yield.cell",
   "lines": 49,
   "features": [],
   "cells": [
    "DividendMetrics",
    "DividendTests"
   ]
  },
  {
   "id": "finance/fee_calculator",
   "domain": "finance",
   "title": "Brokerage fee calculator: tiered commission, bps fee with a floor, and a maker/taker exchange fee",
   "summary": "Brokerage fee calculator: tiered commission, bps fee with a floor, and a maker/taker exchange fee. Shows clamp/max for floors and caps, and match on a tier bucket.",
   "url": "https://soma-lang.dev/corpus/finance/fee_calculator.cell",
   "repo_path": "examples/corpus/finance/fee_calculator.cell",
   "lines": 57,
   "features": [
    "match"
   ],
   "cells": [
    "FeeCalculator",
    "FeeTests"
   ]
  },
  {
   "id": "finance/loan_amortization",
   "domain": "finance",
   "title": "Fixed-rate loan amortization: monthly payment, remaining balance after k payments, and total interest paid",
   "summary": "Fixed-rate loan amortization: monthly payment, remaining balance after k payments, and total interest paid. Standard annuity formula with periodic compounding.",
   "url": "https://soma-lang.dev/corpus/finance/loan_amortization.cell",
   "repo_path": "examples/corpus/finance/loan_amortization.cell",
   "lines": 48,
   "features": [],
   "cells": [
    "LoanAmortization",
    "LoanTests"
   ]
  },
  {
   "id": "finance/moving_average",
   "domain": "finance",
   "title": "Moving averages over a price series: simple MA window, full-series mean, and a momentum signal from an SMA crossover",
   "summary": "Moving averages over a price series: simple MA window, full-series mean, and a momentum signal from an SMA crossover. Uses range(), avg(), slicing by index, sum() reductions.",
   "url": "https://soma-lang.dev/corpus/finance/moving_average.cell",
   "repo_path": "examples/corpus/finance/moving_average.cell",
   "lines": 64,
   "features": [],
   "cells": [
    "MovingAverage",
    "MovingAverageTests"
   ]
  },
  {
   "id": "finance/npv",
   "domain": "finance",
   "title": "Discounted cash flow: present value of a single flow, net present value of a cash-flow stream, and a simple payback-period count",
   "summary": "Discounted cash flow: present value of a single flow, net present value of a cash-flow stream, and a simple payback-period count. Discounting over an index range, sum() of derived discounted flows.",
   "url": "https://soma-lang.dev/corpus/finance/npv.cell",
   "repo_path": "examples/corpus/finance/npv.cell",
   "lines": 57,
   "features": [],
   "cells": [
    "DCF",
    "DCFTests"
   ]
  },
  {
   "id": "finance/option_payoff",
   "domain": "finance",
   "title": "European option payoffs at expiry, plus a long straddle",
   "summary": "European option payoffs at expiry, plus a long straddle. max()/min() of two numbers, records for the trade leg, tolerance asserts.",
   "url": "https://soma-lang.dev/corpus/finance/option_payoff.cell",
   "repo_path": "examples/corpus/finance/option_payoff.cell",
   "lines": 56,
   "features": [],
   "cells": [
    "OptionPayoff",
    "OptionTests"
   ]
  },
  {
   "id": "finance/order_lifecycle",
   "domain": "finance",
   "title": "Order lifecycle as a verified state machine: an order flows from new to filled or rejected, and a fill settles",
   "summary": "Order lifecycle as a verified state machine: an order flows from new to filled or rejected, and a fill settles. Every state can reach a terminal (settled / rejected / cancelled). Pairs with order_lifecycle.toml so `soma verify` proves deadlock-freedom and eventual settlement.",
   "url": "https://soma-lang.dev/corpus/finance/order_lifecycle.cell",
   "repo_path": "examples/corpus/finance/order_lifecycle.cell",
   "lines": 63,
   "features": [
    "state_machine",
    "guard"
   ],
   "cells": [
    "OrderLifecycle",
    "OrderLifecycleTests"
   ]
  },
  {
   "id": "finance/portfolio_pnl",
   "domain": "finance",
   "title": "Portfolio P&L tracker over a list of position records",
   "summary": "Portfolio P&L tracker over a list of position records. Each position: {symbol, qty, cost, mark}. Computes per-position and total unrealized P&L, market value, and the best/worst performer. Shows records, pipe map/filter, sum_by-style reductions over derived fields.",
   "url": "https://soma-lang.dev/corpus/finance/portfolio_pnl.cell",
   "repo_path": "examples/corpus/finance/portfolio_pnl.cell",
   "lines": 63,
   "features": [
    "pipeline",
    "lambda"
   ],
   "cells": [
    "PortfolioPnL",
    "PortfolioTests"
   ]
  },
  {
   "id": "finance/position_limit",
   "domain": "finance",
   "title": "Position-limit risk gate. Each symbol's net position must stay within",
   "summary": "Position-limit risk gate. Each symbol's net position must stay within [-MAX, +MAX]. The memory invariant enforces it on every write, so an order that would breach the limit is refused and the book is unchanged.",
   "url": "https://soma-lang.dev/corpus/finance/position_limit.cell",
   "repo_path": "examples/corpus/finance/position_limit.cell",
   "lines": 59,
   "features": [
    "invariant",
    "try"
   ],
   "cells": [
    "PositionBook",
    "PositionTests"
   ]
  },
  {
   "id": "finance/returns_stats",
   "domain": "finance",
   "title": "Return-series statistics: arithmetic mean return, volatility (sample stdev), annualized Sharpe ratio, and max drawdown of an equity curve",
   "summary": "Return-series statistics: arithmetic mean return, volatility (sample stdev), annualized Sharpe ratio, and max drawdown of an equity curve. sqrt/pow, sum() reductions, running peak tracking.",
   "url": "https://soma-lang.dev/corpus/finance/returns_stats.cell",
   "repo_path": "examples/corpus/finance/returns_stats.cell",
   "lines": 62,
   "features": [],
   "cells": [
    "ReturnStats",
    "ReturnStatsTests"
   ]
  },
  {
   "id": "finance/tax_brackets",
   "domain": "finance",
   "title": "Progressive income tax over marginal brackets, plus effective rate and marginal rate lookup",
   "summary": "Progressive income tax over marginal brackets, plus effective rate and marginal rate lookup. Iterates a list of {upto, rate} bracket records, taxing each slice. Records, min(), accumulation.",
   "url": "https://soma-lang.dev/corpus/finance/tax_brackets.cell",
   "repo_path": "examples/corpus/finance/tax_brackets.cell",
   "lines": 70,
   "features": [],
   "cells": [
    "TaxBrackets",
    "TaxTests"
   ]
  },
  {
   "id": "finance/trade_settlement",
   "domain": "finance",
   "title": "Trade settlement as a sum type",
   "summary": "Trade settlement as a sum type. A settlement attempt yields one of three tagged variants; `match` over them is exhaustive (drop an arm and `soma check` refuses). Demonstrates struct / tuple / unit variants and exhaustive matching for money outcomes.",
   "url": "https://soma-lang.dev/corpus/finance/trade_settlement.cell",
   "repo_path": "examples/corpus/finance/trade_settlement.cell",
   "lines": 58,
   "features": [
    "sum_type",
    "match"
   ],
   "cells": [
    "Settlement",
    "TradeSettlement",
    "SettlementTests"
   ]
  }
 ]
}