ledger-models 1.1.13

A comprehensive model library for financial products (securities, prices, transactions, etc). Protobuf used for serialization, with language-specific implementations
Documentation
{
  "_doc": "applies_to lists the products a measure covers. Each entry is a ProductTypeProto name (e.g. TIPS, TREASURY_FRN) or a node name from ../hierarchy.json (e.g. BOND, STOCK, CASH_INSTRUMENT), which covers every product type under it.",
  "schema_version": "1.0",
  "measures": [
    {
      "name": "UNKNOWN_MEASURE",
      "enum_value": 0,
      "display_name": "Unknown Measure",
      "description": "Placeholder for unset or unrecognized measure values. Should never be requested in a valuation call.",
      "formula": null,
      "units": null,
      "category": "sentinel",
      "applies_to": [],
      "model_assumptions": [],
      "implemented": false
    },
    {
      "name": "DIRECTED_QUANTITY",
      "enum_value": 1,
      "display_name": "Directed Quantity",
      "description": "The signed quantity of a position (e.g. number of shares, or total face value of bonds held). This is an input measure provided on the PositionProto, not a computed output.",
      "formula": null,
      "units": "Units of the security (shares for equity, face-value dollars for bonds)",
      "category": "input",
      "applies_to": ["BOND", "TIPS", "TREASURY_FRN", "STOCK", "CASH_INSTRUMENT"],
      "model_assumptions": [],
      "implemented": true
    },
    {
      "name": "MARKET_VALUE",
      "enum_value": 2,
      "display_name": "Market Value",
      "description": "The current dollar value of a position at the given market price.",
      "formula": "MarketValue = price / 100 * directed_quantity; TIPS: clean_price / 100 * index_ratio * directed_quantity (index_ratio unrounded, unfloored)",
      "units": "Dollars (or settlement currency)",
      "category": "valuation",
      "applies_to": ["BOND", "TIPS", "TREASURY_FRN", "STOCK", "CASH_INSTRUMENT"],
      "model_assumptions": [
        "None — direct mark-to-market calculation"
      ],
      "implemented": true
    },
    {
      "name": "UNADJUSTED_COST_BASIS",
      "enum_value": 3,
      "display_name": "Unadjusted Cost Basis",
      "description": "The original purchase price of the security, before any adjustments for amortization, accretion, or corporate actions.",
      "formula": "Returns the price_input as-is (quoted as % of par for bonds)",
      "units": "Quoted price (% of par for bonds; dollar price for equities)",
      "category": "cost",
      "applies_to": ["BOND", "TIPS", "TREASURY_FRN", "STOCK", "CASH_INSTRUMENT"],
      "model_assumptions": [
        "None — pass-through of the input price"
      ],
      "implemented": true
    },
    {
      "name": "ADJUSTED_COST_BASIS",
      "enum_value": 4,
      "display_name": "Adjusted Cost Basis",
      "description": "Tax amortised cost, per 100 face, quantity-weighted over the open lots. Tax basis only; book (GAAP/IFRS) cost is out of scope. Inputs: cost_basis (CostBasisInput) on BondInput, TipsInput or FrnInput.",
      "formula": "AdjustedCostBasis = sum(open_quantity_i * acb_i) / sum(open_quantity_i) over CostBasisInput.lots, where acb_i is lot i's amortised cost per 100 face at the valuation date. OID: always accreted (mandatory, whatever the elections) at constant yield from the issue price (IssuanceProto.price_for_single_price_auction, MDI-82), reduced by any acquisition premium. Premium (IRC §171): amortised at constant yield if elected. Market discount: accreted only with INCLUDE_CURRENTLY, ratably or at constant yield per market_discount_accrual; otherwise left until disposition. De minimis: OID and market discount below 0.25% × complete years to maturity are treated as zero. TIPS: AdjustedCostBasis = sum(open_quantity_i * real_acb_i) / sum(open_quantity_i) * IndexRatio(valuation date), where real_acb_i is lot i's amortised cost per 100 real face: it starts from the lot's real purchase price (TaxLotProto.price) and accrues at constant yield on real principal; open_quantity_i is the lot's original (unadjusted) face; and IndexRatio(valuation date) is INDEX_RATIO for the UTC date of ValuationRequestProto.asof_datetime. Example: lots of 10000 at real_acb 99.00 and 5000 at 101.50, index ratio 1.2 -> (10000*99.00 + 5000*101.50) / 15000 * 1.2 = 119.80.",
      "units": "Price per 100 face (% of par). TIPS: per 100 original face, in nominal dollars",
      "category": "cost",
      "applies_to": ["TREASURY_NOTE", "TREASURY_BOND", "SOVEREIGN_BOND", "CORP_BOND", "MUNI_BOND", "TIPS", "TREASURY_FRN"],
      "model_assumptions": [
        "Accrual start: from each lot's open_date plus the product's settlement lag (e.g. T+1 for Treasuries)",
        "Elections: CostBasisInput.elections, copied from PortfolioProto.amortisation_elections; unset fields use the defaults (PREMIUM_ELECTED, AT_DISPOSITION, RATABLE)",
        "TIPS: amortise in real terms, then multiply by the index ratio at the valuation date, giving a figure per 100 original face in nominal dollars",
        "TIPS accrual start: from each lot's open_date plus the product's settlement lag, on real principal; valuation-service owns the settlement lag and lots carry no settlement field",
        "TIPS elections: premium and market discount accrue or not per the elections, as in the fixed-rate rules",
        "TIPS CPI: only the m-3 and m-2 readings for the valuation date in TipsInput.cpi; lot dates need no CPI readings",
        "TIPS rounding: none. real_acb_i, the weighted average, the index ratio and the result are all unrounded, as for INDEX_RATIO and MARKET_VALUE",
        "TIPS deflation floor: not applied. It applies only to final principal (INFLATION_ADJUSTED_PRINCIPAL), never to the basis",
        "FRN: use the equivalent fixed rate from the fixing at settlement",
        "Treasury FRN (frn_extension.reference_rate_index T_BILL_13_WEEK, LM-383): inputs are FrnInput.cost_basis (lots and elections) and FrnInput.fixings",
        "Treasury FRN per lot: amortise each lot as the equivalent fixed-rate instrument, using the same constant-yield, elections and de minimis rules as the fixed-rate bonds",
        "Treasury FRN coupon: the lot's equivalent fixed coupon, as a decimal fraction, is coupon_i = MMY(fixing_i) + spread / 10000. fixing_i is the fixing in effect at the lot's accrual start, i.e. the FrnInput.fixings entry with the latest fixing_date on or before it; spread is frn_extension.spread, in basis points",
        "Treasury FRN OID: the fixing in effect on bond_details.issue_date (the latest fixing_date on or before it) sets the issue-date OID schedule",
        "Treasury FRN resets: later coupon resets do not change a lot's schedule",
        "Treasury FRN conversion: fixings.rate is the published high discount rate in percent (see ReferenceRateFixingProto.rate). valuation-service converts it to the money-market yield, on a 360-day basis: MMY = 360 * d / (360 - d * t), where d = rate / 100 and t = bill_maturity_date - bill_issue_date, in days, both from the same fixing. bill_issue_date is the chosen auction's own issue date, so a reopened bill counts from the reopening. Example: rate 4.215, t 91 -> d = 0.04215, MMY = 360 * 0.04215 / (360 - 0.04215 * 91) = 0.042604 (rounded here only)",
        "Treasury FRN missing data: no fixing on or before a needed date (a lot's accrual start, or the issue date) makes the request invalid",
        "Treasury FRN other indices (e.g. SOFR): not defined yet",
        "No lots: the measure is absent, with a \"no open lots\" warning, never 0"
      ],
      "implemented": false
    },
    {
      "name": "CURRENT_YIELD",
      "enum_value": 5,
      "display_name": "Current Yield",
      "description": "Annual coupon income as a percentage of the current market price.",
      "formula": "CurrentYield = (coupon_rate * principal) / (price * face_value / 100). For zero-coupon: (face_value / dollar_price)^(1 / years_to_maturity) - 1",
      "units": "Decimal (0-1 scale; e.g. 0.0526 = 5.26%)",
      "category": "yield",
      "applies_to": ["BOND", "TIPS"],
      "model_assumptions": [
        "Assumes coupon income is constant (no reinvestment assumption)",
        "For TIPS, uses the inflation-adjusted principal for the annual coupon calculation",
        "Day count: Actual/365 for years-to-maturity calculation"
      ],
      "implemented": true
    },
    {
      "name": "YIELD_TO_MATURITY",
      "enum_value": 7,
      "display_name": "Yield to Maturity",
      "description": "The annualized rate of return assuming the bond is held to maturity and all coupons are reinvested at the same rate. This is the internal rate of return that equates the present value of all future cashflows to the current price.",
      "formula": "Solve for r: price * (face / 100) = Sum[C / (1 + r/m)^t] + F / (1 + r/m)^N",
      "units": "Decimal (0-1 scale; e.g. 0.06 = 6.00% annual)",
      "category": "yield",
      "applies_to": ["BOND", "TIPS"],
      "model_assumptions": [
        "Coupon reinvestment at the YTM rate (standard bond math assumption)",
        "For TIPS: returns the same value as REAL_YIELD, with the response summary warning \"YIELD_TO_MATURITY for TIPS is the real yield (same as REAL_YIELD); a nominal yield needs an inflation forecast\"",
        "Settlement on a coupon date (no accrued interest adjustment currently)",
        "Day count: Actual/365 for years-to-maturity",
        "Solver: Newton-Raphson iteration with linear approximation initial guess"
      ],
      "implemented": true
    },
    {
      "name": "MACAULAY_DURATION",
      "enum_value": 8,
      "display_name": "Macaulay Duration",
      "description": "The weighted average time (in years) to receive all cashflows from a bond, where each cashflow's weight is its proportion of the bond's total present value.",
      "formula": "D = Sum[(t / m) * PV_t / TotalPV]",
      "units": "Years (e.g. 4.41 = 4.41 years)",
      "category": "risk",
      "applies_to": ["BOND", "TIPS"],
      "model_assumptions": [
        "Uses the bond's YTM (from Newton-Raphson solver) as the discount rate",
        "Flat yield curve (single rate for all maturities)",
        "Settlement on a coupon date (integer period exponents)"
      ],
      "implemented": true
    },
    {
      "name": "PRESENT_VALUE",
      "enum_value": 9,
      "display_name": "Present Value",
      "description": "The theoretical price of a bond computed as the sum of all future cashflows (coupons + principal) discounted at the bond's yield to maturity.",
      "formula": "PV = Sum[C / (1 + r/m)^t] + F / (1 + r/m)^N, returned as quoted price (% of par)",
      "units": "Quoted price (% of par; e.g. 95.00 = $95 per $100 face)",
      "category": "valuation",
      "applies_to": ["BOND", "TIPS"],
      "model_assumptions": [
        "Same as YIELD_TO_MATURITY (the discount rate is derived from the input price)",
        "For TIPS: inflation-adjusted cash flows discounted at REAL_YIELD, consistent with clean_price × index_ratio",
        "Three-way invariant: price == present_value == sum(cashflow_pvs)"
      ],
      "implemented": true
    },
    {
      "name": "REAL_YIELD",
      "enum_value": 10,
      "display_name": "Real Yield",
      "description": "The yield of a TIPS bond in real (inflation-adjusted) terms. This is the return an investor earns above the rate of inflation.",
      "formula": "Solve for r: clean_price × index_ratio × face / 100 = Sum[PV(inflation-adjusted cash flows at r)]",
      "units": "Decimal (0-1 scale; e.g. 0.02 = 2.00% real annual yield)",
      "category": "yield",
      "applies_to": ["TIPS"],
      "model_assumptions": [
        "Same solver and conventions as YIELD_TO_MATURITY",
        "The quoted real price is scaled by the same index ratio as the cash flows, so the result is the true real yield and does not change with CPI"
      ],
      "implemented": true
    },
    {
      "name": "INFLATION_ADJUSTED_PRINCIPAL",
      "enum_value": 11,
      "display_name": "Inflation-Adjusted Principal",
      "description": "The inflation-adjusted principal of a TIPS bond, reflecting the cumulative change in the Consumer Price Index (CPI) since the bond's issuance.",
      "formula": "adjusted_principal = max(face_value * index_ratio, face_value)",
      "units": "Dollars (e.g. 103.36 for face=100 with 3.36% cumulative inflation)",
      "category": "valuation",
      "applies_to": ["TIPS"],
      "model_assumptions": [
        "Uses base_cpi from the security's tips_extension and the reference CPI from TipsInput.cpi",
        "Deflation floor applies only to the principal at maturity; interim coupons use the raw adjusted principal"
      ],
      "implemented": true
    },
    {
      "name": "PRESENT_VALUE_CASHFLOWS",
      "enum_value": 12,
      "display_name": "Present Value Cashflows",
      "description": "Requests the full schedule of future cashflows for a bond. The ValuationResponseProto will populate the cashflows repeated field with one CashflowProto per payment period.",
      "formula": "Each CashflowProto contains: cashflow_date, fv_amount, pv_amount, coupon_rate. Sum of pv_amounts equals PRESENT_VALUE.",
      "units": "fv_amount and pv_amount in dollars; coupon_rate as percentage",
      "category": "valuation",
      "applies_to": ["BOND", "TIPS", "TREASURY_FRN"],
      "model_assumptions": [
        "Same as PRESENT_VALUE",
        "Three-way invariant: sum(pv_amounts) == present_value == price"
      ],
      "implemented": true
    },
    {
      "name": "DISCOUNT_MARGIN",
      "enum_value": 13,
      "display_name": "Discount Margin",
      "description": "The discount margin of a Floating Rate Note (FRN) — the spread over the reference rate at which the market discounts the FRN's projected cashflows to arrive at its current price. This is the FRN analogue of YTM.",
      "formula": "Solve for DM: price = Sum[(R + QM)/m * FV / (1 + (R + DM)/m)^t] + FV / (1 + (R + DM)/m)^N",
      "units": "Decimal (0-1 scale; e.g. 0.0075 = 75 basis points)",
      "category": "yield",
      "applies_to": ["TREASURY_FRN"],
      "model_assumptions": [
        "Flat forward rates: all future reference rate fixings assumed equal to current observation",
        "When DM = QM, price = par (100) on a reset date",
        "When DM > QM, price < par; when DM < QM, price > par",
        "Solver: Newton-Raphson, same as YTM",
        "T_BILL_13_WEEK fixings: FrnInput.fixings rate is the auction's high discount rate as Treasury publishes it, in percent per annum on a bank-discount basis (4.215 = 4.215%), the same as IssuanceProto.high_discount_rate. valuation-service converts it to the money-market yield the FRN accrues on, using the fixing's bill_maturity_date. SOFR fixings stay decimal fractions (0.0432 = 4.32%)."
      ],
      "implemented": true
    },
    {
      "name": "SPREAD_DURATION",
      "enum_value": 14,
      "display_name": "Spread Duration",
      "description": "The sensitivity of an FRN's price to a 1 basis point change in the discount margin. This is the primary risk measure for FRNs, analogous to modified duration for fixed-rate bonds but measuring spread risk rather than rate risk.",
      "formula": "SpreadDuration = (P_down - P_up) / (2 * 0.0001 * P_base)",
      "units": "Years (e.g. 1.90 = a 1bp spread widening causes ~1.90bp price decline)",
      "category": "risk",
      "applies_to": ["TREASURY_FRN"],
      "model_assumptions": [
        "Same flat-forward assumption as DISCOUNT_MARGIN",
        "Uses a symmetric 1bp bump for numerical differentiation",
        "Interest rate duration of an FRN is near-zero; spread duration captures the economically significant risk"
      ],
      "implemented": true
    },
    {
      "name": "PAR_YIELD",
      "enum_value": 15,
      "display_name": "Par Yield",
      "description": "The par yield at a given maturity point on the yield curve. The par yield is the coupon rate at which a bond would trade at par (price = 100) for a given maturity.",
      "formula": "Solve for c: 100 = Sum[c/m / (1 + r_t)^t] + 100 / (1 + r_N)^N",
      "units": "Decimal (0-1 scale; e.g. 0.045 = 4.50% annual)",
      "category": "curve",
      "applies_to": ["BOND", "TIPS"],
      "model_assumptions": [
        "Coupon frequency matches market convention (semiannual for US Treasuries)",
        "Interpolation between observed maturities uses method specified in CurveRequestProto"
      ],
      "implemented": false
    },
    {
      "name": "SPOT_YIELD",
      "enum_value": 16,
      "display_name": "Spot Yield",
      "description": "The spot (zero-coupon) yield at a given maturity. Represents the pure time value of money with no reinvestment assumption.",
      "formula": "Bootstrapped from par curve: s_N = ((100 + c/m) / (100 - Sum[c/m / (1+s_t)^t]))^(1/N) - 1",
      "units": "Decimal (0-1 scale; e.g. 0.046 = 4.60% annual)",
      "category": "curve",
      "applies_to": ["BOND", "TIPS"],
      "model_assumptions": [
        "Requires a complete par yield curve as input",
        "Bootstrap assumes exact coupon dates"
      ],
      "implemented": false
    },
    {
      "name": "FORWARD_YIELD",
      "enum_value": 17,
      "display_name": "Forward Yield",
      "description": "The forward yield between two future dates, implied by the spot curve. The rate agreed today for borrowing/lending between future times t1 and t2.",
      "formula": "f(t1,t2) = [(1 + s_t2)^t2 / (1 + s_t1)^t1]^(1/(t2-t1)) - 1",
      "units": "Decimal (0-1 scale; e.g. 0.048 = 4.80% annual forward rate)",
      "category": "curve",
      "applies_to": ["BOND", "TIPS"],
      "model_assumptions": [
        "Derived from spot curve (bootstrapped from par)",
        "No-arbitrage between spot and forward rates",
        "Forward period defined by adjacent tenor points"
      ],
      "implemented": false
    },
    {
      "name": "REFERENCE_CPI",
      "enum_value": 28,
      "display_name": "Reference CPI",
      "description": "The reference CPI of a TIPS for the settlement date (UTC date of ValuationRequestProto.asof_datetime), the numerator of the index ratio.",
      "formula": "reference_cpi as given, or RefCPI = CPI(m-3) + (d - 1) / days_in_month * (CPI(m-2) - CPI(m-3)) from monthly readings",
      "units": "Index points (e.g. 310.326)",
      "category": "valuation",
      "applies_to": ["TIPS"],
      "model_assumptions": [
        "Reference CPI from TipsInput.cpi",
        "Unrounded (Treasury publishes 5 decimals)",
        "Request rejected unless readings are exactly months m-3 and m-2 (UTC settlement month)",
        "Absent when no CPI is given"
      ],
      "implemented": false
    },
    {
      "name": "INDEX_RATIO",
      "enum_value": 29,
      "display_name": "Index Ratio",
      "description": "The index ratio of a TIPS for the settlement date: reference CPI over the security's base CPI.",
      "formula": "IndexRatio = reference_cpi / base_cpi (unrounded, unfloored)",
      "units": "Dimensionless",
      "category": "valuation",
      "applies_to": ["TIPS"],
      "model_assumptions": [
        "Reference CPI from TipsInput.cpi",
        "Unrounded (Treasury publishes 5 decimals)",
        "Unfloored: the deflation floor applies to INFLATION_ADJUSTED_PRINCIPAL only"
      ],
      "implemented": false
    }
  ]
}