Skip to main content

Devlog: 2026-03-17 — PricingCalculator Tests and Pipeline Fill-In

What Happened

Two tasks completed back-to-back:

PricingCalculator Unit Tests

Added 31 unit tests covering every method in PricingCalculator.cs:

  • Par rate interpolation (spec rule 9): standard case, price-at-par, divide-by-zero, multiple inputs via Theory
  • Daily price change and price interpolation (rule 10)
  • DPC calculations (rules 13-14): lower and higher rate DPCs, divide-by-zero guards
  • Total price formula (rules 28-31): all components, max-price cap, below-cap, warehouse + finance
  • Unit gain (rules 32-34): profit price, loss case, profit amount with rounding, zero profit
  • Price validation (rules 1-6): monotonic ascending, non-monotonic, equal prices, unsorted input, valid series, too-few pairs, negative price, zero price, non-monotonic series, empty list

All 32 tests pass in 52ms. Pure functions, no database dependency.

Pipeline TODO Fill-In

Implemented 7 of 12 simplified pipeline steps with real business logic:

StepChange
Guarantee fee25bps default (was 0)
Servicing typeReads ProfileStrategy buyup/buydown/excess flags (was always "sell")
Junk feesReads flat_fee + point_fee from Instrument entity (was always 0)
Warehouse incomewarehouseRate / 360 * daysToHold in price points (was 0)
Finance costfinanceRate / 360 * daysToHold in price points (was 0)
Cost basisUses loan.BuyPrice with par (100) fallback (was hardcoded 100)
Fee adjustment normalizationDollar-to-price-point conversion (was pass-through)

Added flat_fee, point_fee, excess_servicing_limit, servicing_sell, servicing_retain, servicing_retain_xs to Instrument entity. Added buy_price, srp_paid to Loan entity. Updated seed schema.

Remaining TODOs (8)

  • SQL WHERE syntax filter for loan import (needs parser)
  • Pool eligibility verification (needs pool capacity data)
  • Early delivery credits (needs coupon price differential logic)
  • Report tables population (needs report schema)
  • Archive results (needs archive schema)
  • Warehouse/finance rates configurable (hardcoded defaults for now)
  • Enhanced syntax evaluator for AND/OR/IN (in FeatureAdjustmentService)

Verification

  • Build: 0 warnings, 0 errors
  • Tests: 32 passed, 0 failed