Skip to main content

Deep Dive: Trading Module (pwrtrade)

Narrative

The Trading module manages the complete lifecycle of mortgage trades -- from creation through designation, settlement, and archival. A trade represents a commitment to deliver loans or securities to an investor at a specified price on a specified date. The module supports six trade type families (MBS, whole loan, best efforts, futures, eurodollar, treasury) plus options on most types.


Trade Lifecycle


Trade Types

TypeFamilyEntity TypesAOTsPair-OffsCash GridContract Size
MBSmbsSecurities or PoolsYesYesNoNo
Whole Loan (Mandatory)wlPoolsYesYesYesNo
Whole Loan (Best Efforts)bePoolsNoNoYesNo
FuturesfcSecuritiesNoYesNoYes
EurodollareuroN/ANoYesNoYes
TreasurytsSecuritiesNoYesNoNo
Options (all types)variesPair-offs onlyNoYesNoVaries

Designation Process

Cascade Designation

For bulk designation across multiple trades:

  1. User sets market price and tail trade option
  2. For each trade: calculate target amount based on tolerance and price comparison
  3. Iterate available entities, designating up to available or remaining need
  4. If tail trade requested: create phantom trade for leftover securities

Settlement Process

Unsettlement reverses: clears actual_settlement_date, moves loans from loan_shipped back to loan, clears pool_settle_override_date.


Business Rules

Designation Rules

  • Securities can be split across trades (partial designated amount)
  • Pools always designate at 100% (full pool amount; cannot split)
  • Pair-offs must be contra-trades: sell ↔ buy of same trade type
  • AOTs allowed only for MBS and mandatory WL
  • An AOT cannot be undesignated if it has its own entities designated
  • Settled trades are read-only (no designation changes)
  • Designation date auto-sets on first entity, auto-clears when last removed

Tolerance Rules

tolerance_amount = ROUND(trade_amount * tolerance / 100, 2)
minimum_allowed = ROUND(trade_amount - tolerance_amount, 2)
maximum_allowed = ROUND(trade_amount + tolerance_amount, 2)
  • Above-tolerance designation is a hard block (cannot save)
  • Below-tolerance designation is a warning (user can proceed)
  • Tolerance auto-computes from instrument or system default
  • variance_override = 'y' skips auto-computation
  • Tolerance capped at 999.999999 to prevent overflow
  • Only applies to MBS, WL, BE sell trades that are unsettled

Settlement Rules

  • Phantom trades cannot be settled
  • Trades with no designated entities cannot be settled
  • Out-of-tolerance trades can settle with user confirmation
  • WL settlement: loans move from loan to loan_shipped
  • Security settlement: only when security is 100% designated to settled trades

Contract Size Rules (Futures/Eurodollar)

trade_amount = num_contracts * contract_size
  • Validated that trade_amount % contract_size == 0

Key Calculations

Designated Amount

total_designated = SUM(security designations) + SUM(pool designations)
+ SUM(pair-off amounts) + SUM(AOT amounts)

Notification Date

notification_date = settlement_date - 2 business days
(skips weekends and holidays)

Cash Grid Pricing (WL Trades)

  • Grid type: note (use note rate) or pass (note rate - servicing fee)
  • Each loan's effective rate is matched to cash grid rate tiers
  • Unmatched loans are priced at the next lowest rate tier

Margin Activity

  • Margin activity is tracked in pscat_margin_activity
  • Margin threshold and minimum transfer amount are per-counterparty
  • Margin calculations compare mark-to-market values against limits

Data Model

TablePurpose
pscat_tradesMaster trade records
pscat_trades_securities_relTrade-to-security designation junction
pscat_trades_pools_relationTrade-to-pool designation junction
pscat_pair_offsPair-off trade designations
pscat_trades_assignmentsAOT trade assignments
pscat_trades_rollover_relRollover relationship tree
pscat_trades_builder_relEurodollar trade builder relationships
pscat_trade_cash_gridTrade-specific cash grid data
pscat_cash_grid_syntaxCash grid syntax definitions
pscat_securitiesSecurity definitions
pscat_poolsPool definitions
pscat_pool_security_relationPool-to-security junction
pscat_instrumentsInstrument configuration
pscat_trade_counterpartiesInvestor/counterparty records
pscat_margin_activityMargin call tracking
pscat_current_valuesSystem defaults (tolerance)
loanActive loans (pre-settlement)
loan_shippedSettled loans (post-settlement)

Key NVOs

NVOPurpose
n_cst_tradesCore trade logic: designation, tolerance, settlement, rollover
n_cst_securitiesSecurity logic: pool balances, designation checks
n_cst_trades_cash_gridsWL cash grid pricing: rate matching, servicing fee calc