Skip to content
RateStack
Capability · Pricing engine

A pricing engine that explains itself.

Stateless rule engine with a three-tier cache, multi-mode pricing (BEST_EX, BY_RATE, BY_PRICE), two-stage eligibility, full per-rule trace, drill-down, and historical replay. Loan-level pricing across every active investor — in milliseconds.

Overview

What it is, in one paragraph

The pricing engine is stateless. Each request loads the active ratesheet (Caffeine 60s → Redis → MySQL), runs the eligible programs against the loan, and applies AND/OR-composed adjustment rules in deterministic combine strategies (SUM, MAX, MIN, OVERRIDE, REPLACE_DIMENSION). Every rule is data-driven — no investor-specific code. Every quote returns a per-rule trace describing exactly which rule fired, the condition matched, the value contributed, and the running cumulative price.

  • Three pricing modes

    BEST_EX returns the best execution across every eligible investor; BY_RATE returns the price ladder at a pinned rate; BY_PRICE returns the rate ladder at a pinned price.

  • Two-stage eligibility

    Stage 1 runs cheap program-eligibility checks; only survivors run the full pricing ladder. Saves both latency and rule-engine work.

  • Per-rule trace

    Every quote ships with the ordered list of rules that fired, the condition each matched, and the value each contributed — readable straight to compliance.

  • Drill-down on any quote

    Open a quote and re-pin its rate to see the full ladder around it, or expand any adjustment line to its source rule and source ratesheet version.

  • Historical replay

    Reprice as of any prior moment using the ratesheet that was active at that timestamp — useful for disputes, audits, or recreating a lock-day price.

  • Three-tier cache

    Caffeine local cache (60s) → Redis cluster cache → MySQL source of truth, invalidated on the NATS ratesheets.activated event so every node reflects activations within milliseconds.

How it works

The pipeline, end to end.

Numbered steps from input to output. Each step maps to a specific subsystem you can inspect via OpenTelemetry.

  1. 1

    Submit a LoanInput

    Borrower, loan, property, transaction, and execution facets. Every facet is documented in the OpenAPI spec, every required field is enforced before any rule runs.

  2. 2

    Stage 1 — eligibility

    Programs are filtered against the loan profile (occupancy, doc type, LTV, FICO, state, etc.). Survivors progress to Stage 2.

  3. 3

    Stage 2 — pricing ladder

    For each survivor, the engine loads the active ratesheet, computes the base price at the requested rate (or scans the rate ladder), then layers AND/OR-composed adjustment rules using the configured combine strategy.

  4. 4

    Margin & overlay

    Branch / loan-officer / org-level margin rules apply on top of the base price; MI, buydown, and cap layers fire next, each with their own trace lines.

  5. 5

    Mode filter

    BEST_EX picks the highest final price across all eligible investors; BY_RATE returns the ladder pinned at a rate; BY_PRICE returns the ladder pinned at a price.

  6. 6

    Trace + correlationId emit

    The response includes the per-rule trace; the engine emits pricing.computed on NATS with the same correlationId, so webhooks and downstream consumers can join on it.

Hands on

Request a priced ladder with full trace

Live cURL sample — copy, paste, ship.

curl -X POST https://api.ratestack.com/v1/pricing/explain \
  -H "X-API-Key: $RATESTACK_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "borrower":   { "fico": 752 },
    "loan":       { "loanAmount": 425000, "loanType": "CONFORMING", "amortizationType": "FIXED" },
    "property":   { "attachmentType": "DETACHED", "constructionMethod": "SITE_BUILT", "projectLegalStructureType": "NONE", "projectClassificationIdentifier": "NA", "pudIndicator": false, "financedNumberOfUnits": 1, "propertyEstateType": "FEE_SIMPLE", "occupancy": "PRIMARY", "state": "CA", "appraisedValue": 532000 },
    "transaction":{ "type": "PURCHASE" },
    "execution":  { "lockPeriodDays": 30 },
    "pricingMode":"BEST_EX"
  }'

Why this matters

The pain it removes.

No surprises at lock

Eligibility runs as a cheap first pass. If the borrower or property is borderline on a 1% LTV change, you see it before you lock — not after.

Compliance reads the trace

Per-rule trace converts a number into a defensible answer. Auditors stop asking 'why' because the answer is in the response payload.

Same engine, every channel

Retail, broker, correspondent, and sell-side all run the same engine. The per-channel comp/margin layer is the only thing that changes.

Frequently asked

Direct answers, no marketing spin.

Is the rule engine general purpose?

It is purpose-built for residential mortgage pricing — but the operators and combine strategies are general enough that we have not had to add a hardcoded special case in production. Every adjustment is a row in MySQL, not code.

How do you avoid investor lock-in?

There is no investor-specific code. Investors are rows in MySQL; their ratesheets are versioned blobs; their adjustments are rules. You can disable an investor with a config change — no deploy required.

Can I run a what-if without saving anything?

Yes. Every pricing endpoint is read-only with respect to investor state; only your own scenarios are persisted, and only when you explicitly save them.

What's the worst-case latency?

Cold cache + cold ratesheet + 50 active investors lands around 800 ms p99. Warm-path p95 is sub-200 ms. The three-tier cache is invalidated by NATS, not TTL drift, so cold paths are rare in steady state.

How do I reprice an old loan?

Pass an as-of timestamp. The engine uses the ratesheet that was active at that time. Useful for replaying lock-day pricing, regulator requests, or post-mortem on any prior decision.

Ready to see it on your data?

Wire a pricing engine that explains itself. up to your real workflow.

We'll spin you a sandbox, load your actual ratesheets, and walk you through this capability against your top scenarios.

Pricing engine — multi-mode pricing with full rule trace | RateStack