fannie_mae_quicktest script and data

Input files

Payments

Current Actual UPBUPB at IssuanceOriginal Interest RateLoan IdentifierSeller NameMonthly Reporting PeriodRemaining Months To MaturityOrigination DateDeal NameBorrower Credit Score at OriginationZero Balance Effective DateScheduled Principal CurrentRemaining Months to Legal MaturityOriginal UPBOriginal Loan Term
485775.65485775.656.875136610574Flagstar Bank, National Association2023082035020221020CAS 2023 R08 G173500351490000360
248112.85248112.856.375136610575Planet Home Lending, LLC2023082035220221020CAS 2023 R08 G170900352250000360
468571.34468571.346.5136610576Rocket Mortgage, LLC2023082035120221020CAS 2023 R08 G178700351473000360
307534.77307534.775.25136610577Rocket Mortgage, LLC2023082035120220920CAS 2023 R08 G173200351311000360
348025.67348025.675.5136610578U.S. Bank N.A.2023082035020221020CAS 2023 R08 G176300351352000360
139258.92139258.926136610579Other2023082033920220920CAS 2023 R08 G172000351142000360
202982.62202982.625.875136610580U.S. Bank N.A.2023082035120221020CAS 2023 R08 G179900351205000360
172686.14172686.146.575136610581Planet Home Lending, LLC2023082035220221020CAS 2023 R08 G169000352174000360
110751.32110751.325.375136610582Other2023082032320221020CAS 2023 R08 G176200351116000360
231756.02231756.025.5136610583JPMorgan Chase Bank, National Association2023082035020220920CAS 2023 R08 G179500350234000360

Total 30200 rows

01_read_payments

Script node 01_read_payments:

{
  "01_read_payments": {
    "type": "file_table",
    "desc": "Read source files to a table",
    "start_policy": "manual",
    "r": {
      "urls": "{file_urls|stringlist}",
      "columns": {
        "col_loan_id": {
          "col_type": "int",
          "parquet": {
            "col_name": "Loan Identifier"
          }
        },
        "col_deal_name": {
          "col_type": "string",
          "parquet": {
            "col_name": "Deal Name"
          }
        },
        "col_seller_name": {
          "col_type": "string",
          "parquet": {
            "col_name": "Seller Name"
          }
        },
        "col_origination_date": {
          "col_type": "int",
          "parquet": {
            "col_name": "Origination Date"
          }
        },
        "col_original_interest_rate": {
          "col_type": "float",
          "parquet": {
            "col_name": "Original Interest Rate"
          }
        },
        "col_borrower_credit_score_at_origination": {
          "col_type": "int",
          "parquet": {
            "col_name": "Borrower Credit Score at Origination"
          }
        },
        "col_original_upb": {
          "col_type": "decimal2",
          "parquet": {
            "col_name": "Original UPB"
          }
        },
        "col_upb_at_issuance": {
          "col_type": "decimal2",
          "parquet": {
            "col_name": "UPB at Issuance"
          }
        },
        "col_original_loan_term": {
          "col_type": "int",
          "parquet": {
            "col_name": "Original Loan Term"
          }
        },
        "col_monthly_reporting_period": {
          "col_type": "int",
          "parquet": {
            "col_name": "Monthly Reporting Period"
          }
        },
        "col_current_actual_upb": {
          "col_type": "decimal2",
          "parquet": {
            "col_name": "Current Actual UPB"
          }
        },
        "col_remaining_months_to_legal_maturity": {
          "col_type": "int",
          "parquet": {
            "col_name": "Remaining Months to Legal Maturity"
          }
        },
        "col_remaining_months_to_maturity": {
          "col_type": "int",
          "parquet": {
            "col_name": "Remaining Months To Maturity"
          }
        },
        "col_zero_balance_effective_date": {
          "col_type": "int",
          "parquet": {
            "col_name": "Zero Balance Effective Date"
          }
        }
      }
    },
    "w": {
      "name": "payments",
      "having_tmp": "(w.zero_balance_effective_date == 0 || w.scheduled_principal_current > 0) && w.original_income > 0",
      "fields": {
        "loan_id": {
          "expression": "r.col_loan_id",
          "type": "int"
        },
        "deal_name": {
          "expression": "r.col_deal_name",
          "type": "string"
        },
        "origination_date": {
          "expression": "r.col_origination_date",
          "type": "int"
        },
        "seller_name": {
          "expression": "r.col_seller_name",
          "type": "string"
        },
        "original_interest_rate": {
          "expression": "r.col_original_interest_rate",
          "type": "float"
        },
        "borrower_credit_score_at_origination": {
          "expression": "r.col_borrower_credit_score_at_origination",
          "type": "int"
        },
        "original_upb": {
          "expression": "r.col_original_upb",
          "type": "decimal2"
        },
        "upb_at_issuance": {
          "expression": "r.col_upb_at_issuance",
          "type": "decimal2"
        },
        "original_loan_term": {
          "expression": "r.col_original_loan_term",
          "type": "int"
        },
        "payment_json": {
          "expression": "strings.ReplaceAll(fmt.Sprintf(`{'monthly_reporting_period':%d,'current_actual_upb':%s,'remaining_months_to_legal_maturity':%d,'remaining_months_to_maturity':%d,'zero_balance_effective_date':%d}`,r.col_monthly_reporting_period, r.col_current_actual_upb, r.col_remaining_months_to_legal_maturity, r.col_remaining_months_to_maturity,r.col_zero_balance_effective_date), `'`,`\"`)",
          "type": "string"
        }
      },
      "indexes": {
        "idx_payments_by_loan_id": "non_unique(loan_id)"
      }
    }
  }
}

Script node 01_read_payments produces Cassandra table payments:

rowidbatch_idxborrower_credit_score_at_originationdeal_nameloan_idoriginal_interest_rateoriginal_loan_termoriginal_upborigination_datepayment_jsonseller_nameupb_at_issuance
8001587024082731130795CAS 2023 R08 G11366297184.99360263000.0020221120{"monthly_reporting_period":20230820,"current_actual_upb":259946.84,"remaining_months_to_legal_matur ... total length 176DHI Mortgage Company, Ltd.259946.84
50363054672909689290812CAS 2023 R08 G11366302147.375360240000.0020221220{"monthly_reporting_period":20230820,"current_actual_upb":236445.01,"remaining_months_to_legal_matur ... total length 176Other236445.01
54932066932458345980773CAS 2023 R08 G11366297165.5360440000.0020221120{"monthly_reporting_period":20230820,"current_actual_upb":436040.01,"remaining_months_to_legal_matur ... total length 176Wells Fargo Bank, N.A.436040.01
53368533183725986241770CAS 2023 R08 G11366612435.5360347000.0020220920{"monthly_reporting_period":20230820,"current_actual_upb":342944.54,"remaining_months_to_legal_matur ... total length 176Other342944.54
51746166567691659641786CAS 2023 R08 G11366667337.12536092000.0020220920{"monthly_reporting_period":20230820,"current_actual_upb":91244.32,"remaining_months_to_legal_maturi ... total length 175Other91244.32
9444074275309615720779CAS 2023 R08 G11366200734.625360499000.0020221020{"monthly_reporting_period":20230820,"current_actual_upb":490550.87,"remaining_months_to_legal_matur ... total length 176PennyMac Loan Services, LLC490550.87
85302734579172764610767CAS 2023 R08 G11366159526.5360333000.0020221020{"monthly_reporting_period":20230820,"current_actual_upb":330330.37,"remaining_months_to_legal_matur ... total length 176PHH Mortgage Corporation330330.37
73857198061242784261722CAS 2023 R08 G11366472165.375360610000.0020220920{"monthly_reporting_period":20230820,"current_actual_upb":602309.89,"remaining_months_to_legal_matur ... total length 176Other602309.89
17999015512532163550765CAS 2023 R08 G11366243276.875360272000.0020221120{"monthly_reporting_period":20230820,"current_actual_upb":270134.77,"remaining_months_to_legal_matur ... total length 176Other270134.77
19807615316582108370753CAS 2023 R08 G11366303256.625360336000.0020221120{"monthly_reporting_period":20230820,"current_actual_upb":333582.14,"remaining_months_to_legal_matur ... total length 176Other333582.14

Total 60345 rows

02_loan_ids

Script node 02_loan_ids:

{
  "02_loan_ids": {
    "type": "distinct_table",
    "desc": "Select distinct loan ids",
    "rerun_policy": "fail",
    "r": {
      "table": "payments",
      "rowset_size": 10000,
      "expected_batches_total": "{expected_batches|number}"
    },
    "w": {
      "name": "loan_ids",
      "fields": {
        "loan_id": {
          "expression": "r.loan_id",
          "type": "int"
        },
        "deal_name": {
          "expression": "r.deal_name",
          "type": "string"
        },
        "origination_date": {
          "expression": "r.origination_date",
          "type": "int"
        },
        "seller_name": {
          "expression": "r.seller_name",
          "type": "string"
        },
        "original_interest_rate": {
          "expression": "r.original_interest_rate",
          "type": "float"
        },
        "borrower_credit_score_at_origination": {
          "expression": "r.borrower_credit_score_at_origination",
          "type": "int"
        },
        "original_upb": {
          "expression": "r.original_upb",
          "type": "decimal2"
        },
        "upb_at_issuance": {
          "expression": "r.upb_at_issuance",
          "type": "decimal2"
        },
        "original_loan_term": {
          "expression": "r.original_loan_term",
          "type": "int"
        }
      },
      "indexes": {
        "idx_loan_ids_loan_id": "unique(loan_id)",
        "idx_loan_ids_deal_name": "non_unique(deal_name)"
      }
    }
  }
}

Script node 02_loan_ids produces Cassandra table loan_ids:

rowidbatch_idxborrower_credit_score_at_originationdeal_nameloan_idoriginal_interest_rateoriginal_loan_termoriginal_upborigination_dateseller_nameupb_at_issuance
67526081782728062487701CAS 2023 R08 G11366665545.875360320000.0020220820Other316322.06
52664307004458567024704CAS 2023 R08 G11366447347.625360169000.0020221120Other167048.07
69054763349424240284743CAS 2023 R08 G11366467225.875360244000.0020220920Other241195.58
29449900950036513528787CAS 2023 R08 G11366535704.375360499000.0020221020Other442394.00
10939474160604667225760CAS 2023 R08 G11366560806.875360400000.0020220920United Wholesale Mortgage, LLC34389.66
11960917181146977437745CAS 2023 R08 G11366482436.1360511000.0020221020Other506455.79
25340387761612504315784CAS 2023 R08 G11366145926.625360200000.0020221020Other198376.39
21220965880389577326704CAS 2023 R08 G11366210986.125360420000.0020221020Other416250.12
15615825204042909308671CAS 2023 R08 G11366605905.375360273000.0020220820Lakeview Loan Servicing, LLC269310.18
78682653203657139091715CAS 2023 R08 G11366360157.5360400000.0020221220Guild Mortgage Company LLC396977.70

Total 60345 rows

02_deal_names

Script node 02_deal_names:

{
  "02_deal_names": {
    "type": "distinct_table",
    "desc": "Select distinct deal names",
    "rerun_policy": "fail",
    "r": {
      "table": "loan_ids",
      "rowset_size": 10000,
      "expected_batches_total": "{expected_batches|number}"
    },
    "w": {
      "name": "deal_names",
      "fields": {
        "deal_name": {
          "expression": "r.deal_name",
          "type": "string"
        }
      },
      "indexes": {
        "idx_deal_names_deal_name": "unique(deal_name)"
      }
    }
  }
}

Script node 02_deal_names produces Cassandra table deal_names:

rowidbatch_idxdeal_name
8771943470102064018CAS 2023 R08 G1

Total 1 rows

03_deal_total_upbs

Script node 03_deal_total_upbs:

{
  "03_deal_total_upbs": {
    "type": "table_lookup_table",
    "desc": "For each deal, calculate total UPBs",
    "r": {
      "table": "deal_names",
      "expected_batches_total": "{expected_batches|number}"
    },
    "l": {
      "index_name": "idx_loan_ids_deal_name",
      "join_on": "r.deal_name",
      "idx_read_batch_size": 10000,
      "right_lookup_read_batch_size": 10000,
      "group": true,
      "join_type": "left"
    },
    "w": {
      "name": "deal_total_upbs",
      "fields": {
        "deal_name": {
          "expression": "r.deal_name",
          "type": "string"
        },
        "total_original_upb": {
          "expression": "sum(l.original_upb)",
          "type": "decimal2"
        },
        "total_upb_at_issuance": {
          "expression": "sum(l.upb_at_issuance)",
          "type": "decimal2"
        },
        "total_original_upb_for_nonzero_rates": {
          "expression": "sum_if(l.original_upb, l.original_interest_rate > 0)",
          "type": "decimal2"
        },
        "total_original_upb_for_nonzero_credit_scores": {
          "expression": "sum_if(l.original_upb, l.borrower_credit_score_at_origination > 0)",
          "type": "decimal2"
        }
      }
    }
  }
}

Script node 03_deal_total_upbs produces Cassandra table deal_total_upbs:

rowidbatch_idxdeal_nametotal_original_upbtotal_original_upb_for_nonzero_credit_scorestotal_original_upb_for_nonzero_ratestotal_upb_at_issuance
3136075748262539830CAS 2023 R08 G119356281000.0019339292000.0019356281000.0018880190518.06

Total 1 rows

04_loan_payment_summaries

Script node 04_loan_payment_summaries:

{
  "04_loan_payment_summaries": {
    "type": "table_lookup_table",
    "desc": "For each loan, merge all payments into single json string",
    "r": {
      "table": "loan_ids",
      "expected_batches_total": "{expected_batches|number}"
    },
    "l": {
      "index_name": "idx_payments_by_loan_id",
      "join_on": "r.loan_id",
      "group": true,
      "join_type": "left"
    },
    "w": {
      "name": "loan_payment_summaries",
      "fields": {
        "loan_id": {
          "expression": "r.loan_id",
          "type": "int"
        },
        "deal_name": {
          "expression": "r.deal_name",
          "type": "string"
        },
        "origination_date": {
          "expression": "r.origination_date",
          "type": "int"
        },
        "seller_name": {
          "expression": "r.seller_name",
          "type": "string"
        },
        "original_interest_rate": {
          "expression": "r.original_interest_rate",
          "type": "float"
        },
        "borrower_credit_score_at_origination": {
          "expression": "r.borrower_credit_score_at_origination",
          "type": "int"
        },
        "original_upb": {
          "expression": "r.original_upb",
          "type": "decimal2"
        },
        "upb_at_issuance": {
          "expression": "r.upb_at_issuance",
          "type": "decimal2"
        },
        "original_loan_term": {
          "expression": "r.original_loan_term",
          "type": "int"
        },
        "payments_json": {
          "expression": "string_agg(l.payment_json,\",\")",
          "type": "string"
        }
      }
    }
  }
}

Script node 04_loan_payment_summaries produces Cassandra table loan_payment_summaries:

rowidbatch_idxborrower_credit_score_at_originationdeal_nameloan_idoriginal_interest_rateoriginal_loan_termoriginal_upborigination_datepayments_jsonseller_nameupb_at_issuance
56156013563991176620791CAS 2023 R08 G11366553555.625360232000.0020220920{"monthly_reporting_period":20230820,"current_actual_upb":227886.47,"remaining_months_to_legal_matur ... total length 176Rocket Mortgage, LLC227886.47
85651531930460437951773CAS 2023 R08 G11366314227.125360252000.0020221120{"monthly_reporting_period":20230820,"current_actual_upb":250353.93,"remaining_months_to_legal_matur ... total length 176Movement Mortgage, LLC250353.93
20911260075048799373789CAS 2023 R08 G11366233446.875360393000.0020221120{"monthly_reporting_period":20230820,"current_actual_upb":389808.48,"remaining_months_to_legal_matur ... total length 176Other389808.48
25302954106982613726787CAS 2023 R08 G11366528585.125360217000.0020220920{"monthly_reporting_period":20230820,"current_actual_upb":214402.77,"remaining_months_to_legal_matur ... total length 176Other214402.77
65654635570894768308747CAS 2023 R08 G11366388566.625360200000.0020221120{"monthly_reporting_period":20230820,"current_actual_upb":198560.79,"remaining_months_to_legal_matur ... total length 176Other198560.79
43270406152842992674770CAS 2023 R08 G11366452625.75360325000.0020221020{"monthly_reporting_period":20230820,"current_actual_upb":320745.38,"remaining_months_to_legal_matur ... total length 176PennyMac Loan Services, LLC320745.38
78774954306324557730709CAS 2023 R08 G11366683435.125360392000.0020220820{"monthly_reporting_period":20230820,"current_actual_upb":384018.56,"remaining_months_to_legal_matur ... total length 176Rocket Mortgage, LLC384018.56
76807396006166711079801CAS 2023 R08 G11366182034.75360241000.0020221120{"monthly_reporting_period":20230820,"current_actual_upb":235714.16,"remaining_months_to_legal_matur ... total length 176DHI Mortgage Company, Ltd.235714.16
64997199068594849055785CAS 2023 R08 G11366438394.875360375000.0020220820{"monthly_reporting_period":20230820,"current_actual_upb":369823.69,"remaining_months_to_legal_matur ... total length 176CitiMortgage, Inc.369823.69
41662761692745253415796CAS 2023 R08 G11366424395.875360203000.0020221020{"monthly_reporting_period":20230820,"current_actual_upb":201513.99,"remaining_months_to_legal_matur ... total length 176Other201513.99

Total 60345 rows

04_loan_summaries_calculated

Script node 04_loan_summaries_calculated:

{
  "04_loan_summaries_calculated": {
    "type": "table_custom_tfm_table",
    "custom_proc_type": "py_calc",
    "desc": "Apply Python calculations to loan summaries",
    "r": {
      "table": "loan_payment_summaries",
      "rowset_size": 1000,
      "expected_batches_total": "{expected_batches|number}"
    },
    "p": {
      "python_code_urls": [
        "{dir_cfg}/py/payment_calc.py"
      ],
      "calculated_fields": {
        "sorted_payments_json": {
          "expression": "sorted_payments_json(r.payments_json)",
          "type": "string"
        },
        "payments_behind_ratio": {
          "expression": "payments_behind_ratio(r.payments_json)",
          "type": "float"
        },
        "paid_off_amount": {
          "expression": "paid_off_amount(r.original_upb,r.upb_at_issuance,r.payments_json)",
          "type": "decimal2"
        },
        "paid_off_ratio": {
          "expression": "paid_off_ratio(r.original_upb,r.upb_at_issuance,r.payments_json)",
          "type": "float"
        }
      }
    },
    "w": {
      "name": "loan_summaries_calculated",
      "fields": {
        "loan_id": {
          "expression": "r.loan_id",
          "type": "int"
        },
        "deal_name": {
          "expression": "r.deal_name",
          "type": "string"
        },
        "origination_date": {
          "expression": "r.origination_date",
          "type": "int"
        },
        "seller_name": {
          "expression": "r.seller_name",
          "type": "string"
        },
        "original_interest_rate": {
          "expression": "r.original_interest_rate",
          "type": "float"
        },
        "borrower_credit_score_at_origination": {
          "expression": "r.borrower_credit_score_at_origination",
          "type": "int"
        },
        "original_upb": {
          "expression": "r.original_upb",
          "type": "decimal2"
        },
        "upb_at_issuance": {
          "expression": "r.upb_at_issuance",
          "type": "decimal2"
        },
        "original_loan_term": {
          "expression": "r.original_loan_term",
          "type": "int"
        },
        "is_original_loan_term_30y": {
          "expression": "int.iif(r.original_loan_term == 360, 1, 0)",
          "type": "int"
        },
        "payments_json": {
          "expression": "p.sorted_payments_json",
          "type": "string"
        },
        "payments_behind_ratio": {
          "expression": "p.payments_behind_ratio",
          "type": "float"
        },
        "paid_off_amount": {
          "expression": "decimal2(p.paid_off_amount)",
          "type": "decimal2"
        },
        "paid_off_ratio": {
          "expression": "p.paid_off_ratio",
          "type": "float"
        }
      },
      "indexes": {
        "idx_loan_summaries_calculated_deal_name": "non_unique(deal_name)",
        "idx_loan_summaries_calculated_deal_name_seller_name": "non_unique(deal_name,seller_name)"
      }
    }
  }
}

Script node 04_loan_summaries_calculated produces Cassandra table loan_summaries_calculated:

rowidbatch_idxborrower_credit_score_at_originationdeal_nameis_original_loan_term_30yloan_idoriginal_interest_rateoriginal_loan_termoriginal_upborigination_datepaid_off_amountpaid_off_ratiopayments_behind_ratiopayments_jsonseller_nameupb_at_issuance
19020799269413588702777CAS 2023 R08 G111366481595.5360196000.00202208203435.630.01752872448980[{"monthly_reporting_period": 20230820, "current_actual_upb": 192564.37, "remaining_months_to_legal_ ... total length 187Other192564.37
74531380068060997918772CAS 2023 R08 G111366513047.125360187000.00202209201535.970.00821374331550[{"monthly_reporting_period": 20230820, "current_actual_upb": 185464.03, "remaining_months_to_legal_ ... total length 187Other185464.03
24725123650201530619681CAS 2023 R08 G111366525725.375360184000.00202204208644.630.04698168478260[{"monthly_reporting_period": 20230820, "current_actual_upb": 175355.37, "remaining_months_to_legal_ ... total length 187Wells Fargo Bank, N.A.175355.37
8136019694467104585691CAS 2023 R08 G111366497284.99360200000.00202208202956.020.01478010[{"monthly_reporting_period": 20230820, "current_actual_upb": 197043.98, "remaining_months_to_legal_ ... total length 187Other197043.98
32479197538349137414801CAS 2023 R08 G111366553216.5360100000.0020220920949.330.00949330[{"monthly_reporting_period": 20230820, "current_actual_upb": 99050.67, "remaining_months_to_legal_m ... total length 186Rocket Mortgage, LLC99050.67
12045900445831794961777CAS 2023 R08 G111366232875.5360290000.00202206206220.400.02144965517240[{"monthly_reporting_period": 20230820, "current_actual_upb": 283779.6, "remaining_months_to_legal_m ... total length 186Other283779.60
42757186436983857072776CAS 2023 R08 G111366382297.125360205000.00202211201537.780.00750136585370[{"monthly_reporting_period": 20230820, "current_actual_upb": 203462.22, "remaining_months_to_legal_ ... total length 187Other203462.22
67083659406652193855787CAS 2023 R08 G111366357636.625360376000.00202211202785.190.00740742021280[{"monthly_reporting_period": 20230820, "current_actual_upb": 373214.81, "remaining_months_to_legal_ ... total length 187PennyMac Corp.373214.81
2780998720615704000799CAS 2023 R08 G111366568466.75360381000.00202208203711.600.00974173228350[{"monthly_reporting_period": 20230820, "current_actual_upb": 377288.4, "remaining_months_to_legal_m ... total length 186Rocket Mortgage, LLC377288.40
69796451069134233817713CAS 2023 R08 G111366393915.99360258000.00202210202430.820.00942178294570[{"monthly_reporting_period": 20230820, "current_actual_upb": 255569.18, "remaining_months_to_legal_ ... total length 187Rocket Mortgage, LLC255569.18

Total 60345 rows

05_deal_seller_summaries

Script node 05_deal_seller_summaries:

{
  "05_deal_seller_summaries": {
    "type": "table_lookup_table",
    "desc": "For each deal/seller, calculate aggregates from calculated loan summaries",
    "rerun_policy": "fail",
    "r": {
      "table": "deal_sellers",
      "expected_batches_total": "{expected_batches|number}"
    },
    "l": {
      "index_name": "idx_loan_summaries_calculated_deal_name_seller_name",
      "join_on": "r.deal_name,r.seller_name",
      "group": true,
      "join_type": "left"
    },
    "w": {
      "name": "deal_seller_summaries",
      "fields": {
        "deal_name": {
          "expression": "r.deal_name",
          "type": "string"
        },
        "seller_name": {
          "expression": "r.seller_name",
          "type": "string"
        },
        "avg_original_interest_rate": {
          "expression": "avg(l.original_interest_rate)",
          "type": "float"
        },
        "min_original_interest_rate": {
          "expression": "min(l.original_interest_rate)",
          "type": "float"
        },
        "max_original_interest_rate": {
          "expression": "max(l.original_interest_rate)",
          "type": "float"
        },
        "avg_borrower_credit_score_at_origination": {
          "expression": "avg(float(l.borrower_credit_score_at_origination))",
          "type": "float"
        },
        "min_borrower_credit_score_at_origination": {
          "expression": "min(l.borrower_credit_score_at_origination)",
          "type": "int"
        },
        "max_borrower_credit_score_at_origination": {
          "expression": "max(l.borrower_credit_score_at_origination)",
          "type": "int"
        },
        "total_original_upb": {
          "expression": "sum(l.original_upb)",
          "type": "decimal2"
        },
        "total_upb_at_issuance": {
          "expression": "sum(l.upb_at_issuance)",
          "type": "decimal2"
        },
        "total_loans": {
          "expression": "count()",
          "type": "int"
        },
        "total_original_loan_term_30y": {
          "expression": "sum(l.is_original_loan_term_30y)",
          "type": "int"
        },
        "avg_payments_behind_ratio": {
          "expression": "avg(l.payments_behind_ratio)",
          "type": "float"
        },
        "total_paid_off_amount": {
          "expression": "sum(l.paid_off_amount)",
          "type": "decimal2"
        },
        "avg_paid_off_ratio": {
          "expression": "avg(l.paid_off_ratio)",
          "type": "float"
        }
      }
    }
  }
}

Script node 05_deal_seller_summaries produces Cassandra table deal_seller_summaries:

rowidavg_borrower_credit_score_at_originationavg_original_interest_rateavg_paid_off_ratioavg_payments_behind_ratiobatch_idxdeal_namemax_borrower_credit_score_at_originationmax_original_interest_ratemin_borrower_credit_score_at_originationmin_original_interest_rateseller_nametotal_loanstotal_original_loan_term_30ytotal_original_upbtotal_paid_off_amounttotal_upb_at_issuance
2893991749081546317757.3529845246876.3441009579960.025252138743306CAS 2023 R08 G18297.62503.75Fairway Independent Mortgage Corporation13571355457905000.0012699866.91445205133.09
5357438395202032473750.769834350486.5526904969490.017151939936705CAS 2023 R08 G18258.12503NewRez LLC11471144379065000.006383953.49372681046.51
7235310274837037295753.5878260869576.5344765217390.01936502094906CAS 2023 R08 G18248.1256233.75Flagstar Bank, National Association575575194992000.004062149.92190929850.08
3573471684421377849765.1394101876685.5524504021450.02411371633607CAS 2023 R08 G18207.1256243.25CitiMortgage, Inc.746745276412000.007097228.84269314771.16
9033258309346024608758.6476079346564.8849474912480.022891179631402CAS 2023 R08 G18277.37503.25DHI Mortgage Company, Ltd.857857268469000.006135452.44262333547.56
2046922479759246362749.1761024596136.0957262407220.019021074003106CAS 2023 R08 G18298.1256013.875Rocket Mortgage, LLC687168372205904000.0043306960.592162597039.41
6066198704004736390761.103000811035.9382400648820.025362034669604CAS 2023 R08 G18237.62502.99Guaranteed Rate, Inc.12331233443720000.0012278921.05431441078.95
3112795190318877763753.408756.693318750.021668004548200CAS 2023 R08 G18198.12503.5CrossCountry Mortgage, LLC800798237075000.005715230.05231359769.95
6171034476166660796754.7327162279436.510392826150.01857825000306CAS 2023 R08 G18298.1256204.125United Wholesale Mortgage, LLC345734521148073000.0022176379.261125896620.74
7697567447654914531764.2248394004285.689897930050.026102790433807CAS 2023 R08 G18247.503.05Truist Bank14011399428974000.0011747338.03417226661.97

Total 25 rows

05_deal_summaries

Script node 05_deal_summaries:

{
  "05_deal_summaries": {
    "type": "table_lookup_table",
    "desc": "For each deal, calculate aggregates from calculated loan summaries",
    "r": {
      "table": "deal_total_upbs",
      "expected_batches_total": "{expected_batches|number}"
    },
    "l": {
      "index_name": "idx_loan_summaries_calculated_deal_name",
      "join_on": "r.deal_name",
      "group": true,
      "join_type": "left"
    },
    "w": {
      "name": "deal_summaries",
      "fields": {
        "deal_name": {
          "expression": "r.deal_name",
          "type": "string"
        },
        "wa_original_interest_rate_by_original_upb": {
          "expression": "sum(l.original_interest_rate * float(l.original_upb))",
          "type": "float"
        },
        "min_original_interest_rate": {
          "expression": "min_if(l.original_interest_rate, l.original_interest_rate > 0)",
          "type": "float"
        },
        "max_original_interest_rate": {
          "expression": "max(l.original_interest_rate)",
          "type": "float"
        },
        "wa_borrower_credit_score_at_origination_by_original_upb": {
          "expression": "sum(float(l.borrower_credit_score_at_origination) * float(l.original_upb))",
          "type": "float"
        },
        "min_borrower_credit_score_at_origination": {
          "expression": "min_if(l.borrower_credit_score_at_origination, l.borrower_credit_score_at_origination > 0)",
          "type": "int"
        },
        "max_borrower_credit_score_at_origination": {
          "expression": "max(l.borrower_credit_score_at_origination)",
          "type": "int"
        },
        "total_original_upb": {
          "expression": "r.total_original_upb",
          "type": "decimal2"
        },
        "total_upb_at_issuance": {
          "expression": "r.total_upb_at_issuance",
          "type": "decimal2"
        },
        "total_original_upb_for_nonzero_rates": {
          "expression": "r.total_original_upb_for_nonzero_rates",
          "type": "decimal2"
        },
        "total_original_upb_for_nonzero_credit_scores": {
          "expression": "r.total_original_upb_for_nonzero_credit_scores",
          "type": "decimal2"
        },
        "total_loans": {
          "expression": "count()",
          "type": "int"
        },
        "total_original_loan_term_30y": {
          "expression": "sum(l.is_original_loan_term_30y)",
          "type": "int"
        },
        "avg_payments_behind_ratio": {
          "expression": "avg(l.payments_behind_ratio)",
          "type": "float"
        },
        "total_paid_off_amount": {
          "expression": "sum(l.paid_off_amount)",
          "type": "decimal2"
        },
        "avg_paid_off_ratio": {
          "expression": "avg(l.paid_off_ratio)",
          "type": "float"
        }
      }
    }
  }
}

Script node 05_deal_summaries produces Cassandra table deal_summaries:

rowidavg_paid_off_ratioavg_payments_behind_ratiobatch_idxdeal_namemax_borrower_credit_score_at_originationmax_original_interest_ratemin_borrower_credit_score_at_originationmin_original_interest_ratetotal_loanstotal_original_loan_term_30ytotal_original_upbtotal_original_upb_for_nonzero_credit_scorestotal_original_upb_for_nonzero_ratestotal_paid_off_amounttotal_upb_at_issuancewa_borrower_credit_score_at_origination_by_original_upbwa_original_interest_rate_by_original_upb
56974161220934592900.023111203774806CAS 2023 R08 G18328.1256002.5603456011419356281000.0019339292000.0019356281000.00476091393.3718880190518.061.4670429761e+13118134224964

Total 1 rows

04_write_file_loan_summaries_calculated

Script node 04_write_file_loan_summaries_calculated:

{
  "04_write_file_loan_summaries_calculated": {
    "type": "table_file",
    "desc": "Write from table to file loan_summaries.parquet",
    "r": {
      "table": "loan_summaries_calculated"
    },
    "w": {
      "top": {
        "order": "loan_id(asc)"
      },
      "url_template": "{dir_out}/loan_summaries_calculated.parquet",
      "columns": [
        {
          "parquet": {
            "column_name": "loan_id"
          },
          "name": "loan_id",
          "expression": "r.loan_id",
          "type": "int"
        },
        {
          "parquet": {
            "column_name": "deal_name"
          },
          "name": "deal_name",
          "expression": "r.deal_name",
          "type": "string"
        },
        {
          "parquet": {
            "column_name": "seller_name"
          },
          "name": "seller_name",
          "expression": "r.seller_name",
          "type": "string"
        },
        {
          "parquet": {
            "column_name": "original_interest_rate"
          },
          "name": "original_interest_rate",
          "expression": "r.original_interest_rate",
          "type": "float"
        },
        {
          "parquet": {
            "column_name": "borrower_credit_score_at_origination"
          },
          "name": "borrower_credit_score_at_origination",
          "expression": "r.borrower_credit_score_at_origination",
          "type": "int"
        },
        {
          "parquet": {
            "column_name": "origination_date"
          },
          "name": "origination_date",
          "expression": "r.origination_date",
          "type": "int"
        },
        {
          "parquet": {
            "column_name": "original_upb"
          },
          "name": "original_upb",
          "expression": "r.original_upb",
          "type": "decimal2"
        },
        {
          "parquet": {
            "column_name": "upb_at_issuance"
          },
          "name": "upb_at_issuance",
          "expression": "r.upb_at_issuance",
          "type": "decimal2"
        },
        {
          "parquet": {
            "column_name": "original_loan_term"
          },
          "name": "original_loan_term",
          "expression": "r.original_loan_term",
          "type": "int"
        },
        {
          "parquet": {
            "column_name": "payments_json"
          },
          "name": "payments_json",
          "expression": "r.payments_json",
          "type": "string"
        },
        {
          "parquet": {
            "column_name": "payments_behind_ratio"
          },
          "name": "payments_behind_ratio",
          "expression": "math.Round(r.payments_behind_ratio*100000)/100000",
          "type": "float"
        },
        {
          "parquet": {
            "column_name": "paid_off_amount"
          },
          "name": "paid_off_amount",
          "expression": "r.paid_off_amount",
          "type": "decimal2"
        },
        {
          "parquet": {
            "column_name": "paid_off_ratio"
          },
          "name": "paid_off_ratio",
          "expression": "math.Round(r.paid_off_ratio*100000)/100000",
          "type": "float"
        }
      ]
    }
  }
}

Script node 04_write_file_loan_summaries_calculated produces data file:

loan_iddeal_nameseller_nameoriginal_interest_rateborrower_credit_score_at_originationorigination_dateoriginal_upbupb_at_issuanceoriginal_loan_termpayments_jsonpayments_behind_ratiopaid_off_amountpaid_off_ratio
136610574CAS 2023 R08 G1Flagstar Bank, National Association6.87573520221020490000485775.65360[{monthly_reporting_period": 20230820 "current_actual_upb": 485775.65 "remaining_months_to_legal_maturity": 351 "remaining_months_to_maturity": 350 "zero_balance_effective_date": 0}]"04224.350.00862
136610575CAS 2023 R08 G1Planet Home Lending, LLC6.37570920221020250000248112.85360[{monthly_reporting_period": 20230820 "current_actual_upb": 248112.85 "remaining_months_to_legal_maturity": 352 "remaining_months_to_maturity": 352 "zero_balance_effective_date": 0}]"01887.150.00755
136610576CAS 2023 R08 G1Rocket Mortgage, LLC6.578720221020473000468571.34360[{monthly_reporting_period": 20230820 "current_actual_upb": 468571.34 "remaining_months_to_legal_maturity": 351 "remaining_months_to_maturity": 351 "zero_balance_effective_date": 0}]"04428.660.00936
136610577CAS 2023 R08 G1Rocket Mortgage, LLC5.2573220220920311000307534.77360[{monthly_reporting_period": 20230820 "current_actual_upb": 307534.77 "remaining_months_to_legal_maturity": 351 "remaining_months_to_maturity": 351 "zero_balance_effective_date": 0}]"03465.230.01114
136610578CAS 2023 R08 G1U.S. Bank N.A.5.576320221020352000348025.67360[{monthly_reporting_period": 20230820 "current_actual_upb": 348025.67 "remaining_months_to_legal_maturity": 351 "remaining_months_to_maturity": 350 "zero_balance_effective_date": 0}]"03974.330.01129
136610579CAS 2023 R08 G1Other672020220920142000139258.92360[{monthly_reporting_period": 20230820 "current_actual_upb": 139258.92 "remaining_months_to_legal_maturity": 351 "remaining_months_to_maturity": 339 "zero_balance_effective_date": 0}]"02741.080.0193
136610580CAS 2023 R08 G1U.S. Bank N.A.5.87579920221020205000202982.62360[{monthly_reporting_period": 20230820 "current_actual_upb": 202982.62 "remaining_months_to_legal_maturity": 351 "remaining_months_to_maturity": 351 "zero_balance_effective_date": 0}]"02017.380.00984
136610581CAS 2023 R08 G1Planet Home Lending, LLC6.57569020221020174000172686.14360[{monthly_reporting_period": 20230820 "current_actual_upb": 172686.14 "remaining_months_to_legal_maturity": 352 "remaining_months_to_maturity": 352 "zero_balance_effective_date": 0}]"01313.860.00755
136610582CAS 2023 R08 G1Other5.37576220221020116000110751.32360[{monthly_reporting_period": 20230820 "current_actual_upb": 110751.32 "remaining_months_to_legal_maturity": 351 "remaining_months_to_maturity": 323 "zero_balance_effective_date": 0}]"05248.680.04525
136610583CAS 2023 R08 G1JPMorgan Chase Bank, National Association5.579520220920234000231756.02360[{monthly_reporting_period": 20230820 "current_actual_upb": 231756.02 "remaining_months_to_legal_maturity": 350 "remaining_months_to_maturity": 350 "zero_balance_effective_date": 0}]"02243.980.00959

Total 60345 rows

05_write_file_deal_seller_summaries

Script node 05_write_file_deal_seller_summaries:

{
  "05_write_file_deal_seller_summaries": {
    "type": "table_file",
    "desc": "Write from table to file deal_seller_summaries.parquet",
    "r": {
      "table": "deal_seller_summaries"
    },
    "w": {
      "top": {
        "order": "deal_name(asc),seller_name(asc)"
      },
      "url_template": "{dir_out}/deal_seller_summaries.parquet",
      "columns": [
        {
          "parquet": {
            "column_name": "deal_name"
          },
          "name": "deal_name",
          "expression": "r.deal_name",
          "type": "string"
        },
        {
          "parquet": {
            "column_name": "seller_name"
          },
          "name": "seller_name",
          "expression": "r.seller_name",
          "type": "string"
        },
        {
          "parquet": {
            "column_name": "avg_original_interest_rate"
          },
          "name": "avg_original_interest_rate",
          "expression": "math.Round(r.avg_original_interest_rate*1000)/1000",
          "type": "float"
        },
        {
          "parquet": {
            "column_name": "min_original_interest_rate"
          },
          "name": "min_original_interest_rate",
          "expression": "r.min_original_interest_rate",
          "type": "float"
        },
        {
          "parquet": {
            "column_name": "max_original_interest_rate"
          },
          "name": "max_original_interest_rate",
          "expression": "r.max_original_interest_rate",
          "type": "float"
        },
        {
          "parquet": {
            "column_name": "avg_borrower_credit_score_at_origination"
          },
          "name": "avg_borrower_credit_score_at_origination",
          "expression": "math.Round(r.avg_borrower_credit_score_at_origination*100)/100",
          "type": "float"
        },
        {
          "parquet": {
            "column_name": "min_borrower_credit_score_at_origination"
          },
          "name": "min_borrower_credit_score_at_origination",
          "expression": "r.min_borrower_credit_score_at_origination",
          "type": "int"
        },
        {
          "parquet": {
            "column_name": "max_borrower_credit_score_at_origination"
          },
          "name": "max_borrower_credit_score_at_origination",
          "expression": "r.max_borrower_credit_score_at_origination",
          "type": "int"
        },
        {
          "parquet": {
            "column_name": "total_original_upb"
          },
          "name": "total_original_upb",
          "expression": "r.total_original_upb",
          "type": "decimal2"
        },
        {
          "parquet": {
            "column_name": "total_original_upb_paid_off_ratio"
          },
          "name": "total_original_upb_paid_off_ratio",
          "expression": "math.Round(float(r.total_paid_off_amount)/float(r.total_original_upb)*100000)/100000",
          "type": "float"
        },
        {
          "parquet": {
            "column_name": "total_upb_at_issuance"
          },
          "name": "total_upb_at_issuance",
          "expression": "r.total_upb_at_issuance",
          "type": "decimal2"
        },
        {
          "parquet": {
            "column_name": "total_loans"
          },
          "name": "total_loans",
          "expression": "r.total_loans",
          "type": "int"
        },
        {
          "parquet": {
            "column_name": "total_original_loan_term_30y"
          },
          "name": "total_original_loan_term_30y",
          "expression": "r.total_original_loan_term_30y",
          "type": "int"
        },
        {
          "parquet": {
            "column_name": "avg_payments_behind_ratio"
          },
          "name": "avg_payments_behind_ratio",
          "expression": "math.Round(r.avg_payments_behind_ratio*100000)/100000",
          "type": "float"
        },
        {
          "parquet": {
            "column_name": "total_paid_off_amount"
          },
          "name": "total_paid_off_amount",
          "expression": "r.total_paid_off_amount",
          "type": "decimal2"
        },
        {
          "parquet": {
            "column_name": "avg_paid_off_ratio"
          },
          "name": "avg_paid_off_ratio",
          "expression": "math.Round(r.avg_paid_off_ratio*100000)/100000",
          "type": "float"
        }
      ]
    }
  }
}

Script node 05_write_file_deal_seller_summaries produces data file:

deal_nameseller_nameavg_original_interest_ratemin_original_interest_ratemax_original_interest_rateavg_borrower_credit_score_at_originationmin_borrower_credit_score_at_originationmax_borrower_credit_score_at_originationtotal_original_upbtotal_original_upb_paid_off_ratiototal_upb_at_issuancetotal_loanstotal_original_loan_term_30yavg_payments_behind_ratiototal_paid_off_amountavg_paid_off_ratio
CAS 2023 R08 G1CitiMortgage, Inc.5.5523.257.125765.146248202764120000.02568269314771.1674674507097228.840.02411
CAS 2023 R08 G1CrossCountry Mortgage, LLC6.6933.58.125753.4108192370750000.02411231359769.9580079805715230.050.02167
CAS 2023 R08 G1DHI Mortgage Company, Ltd.4.8853.257.375758.6508272684690000.02285262333547.5685785706135452.440.02289
CAS 2023 R08 G1Fairway Independent Mortgage Corporation6.3443.757.625757.3508294579050000.02773445205133.0913571355012699866.910.02525
CAS 2023 R08 G1Fifth Third Bank, National Association5.723.997.625756.4908232855780000.03003277002271.9794294108575728.030.02764
CAS 2023 R08 G1Flagstar Bank, National Association6.5343.758.125753.596238241949920000.02083190929850.0857557504062149.920.01937
CAS 2023 R08 G1Guaranteed Rate, Inc.5.9382.997.625761.108234437200000.02767431441078.9512331233012278921.050.02536
CAS 2023 R08 G1Guild Mortgage Company LLC6.624.258760.8208212339250000.02983226947065.5368568506977934.470.02757
CAS 2023 R08 G1JPMorgan Chase Bank, National Association6.2173.58.125759.276208232535240000.0362244345711.6689488409178398.20.03168
CAS 2023 R08 G1Lakeview Loan Servicing, LLC6.0084.257.625749.666208212315740000.01804227396791.3461961204177208.660.01805

Total 25 rows

05_write_file_deal_summaries

Script node 05_write_file_deal_summaries:

{
  "05_write_file_deal_summaries": {
    "type": "table_file",
    "desc": "Write from table to file deal_summaries.parquet",
    "r": {
      "table": "deal_summaries"
    },
    "w": {
      "top": {
        "order": "deal_name(asc)"
      },
      "url_template": "{dir_out}/deal_summaries.parquet",
      "columns": [
        {
          "parquet": {
            "column_name": "deal_name"
          },
          "name": "deal_name",
          "expression": "r.deal_name",
          "type": "string"
        },
        {
          "parquet": {
            "column_name": "wa_original_interest_rate_by_original_upb"
          },
          "name": "wa_original_interest_rate_by_original_upb",
          "expression": "math.Round(r.wa_original_interest_rate_by_original_upb/r.total_original_upb_for_nonzero_rates*1000)/1000",
          "type": "float"
        },
        {
          "parquet": {
            "column_name": "min_original_interest_rate"
          },
          "name": "min_original_interest_rate",
          "expression": "r.min_original_interest_rate",
          "type": "float"
        },
        {
          "parquet": {
            "column_name": "max_original_interest_rate"
          },
          "name": "max_original_interest_rate",
          "expression": "r.max_original_interest_rate",
          "type": "float"
        },
        {
          "parquet": {
            "column_name": "wa_borrower_credit_score_at_origination_by_original_upb"
          },
          "name": "wa_borrower_credit_score_at_origination_by_original_upb",
          "expression": "math.Round(r.wa_borrower_credit_score_at_origination_by_original_upb/r.total_original_upb_for_nonzero_credit_scores*100)/100",
          "type": "float"
        },
        {
          "parquet": {
            "column_name": "min_borrower_credit_score_at_origination"
          },
          "name": "min_borrower_credit_score_at_origination",
          "expression": "r.min_borrower_credit_score_at_origination",
          "type": "int"
        },
        {
          "parquet": {
            "column_name": "max_borrower_credit_score_at_origination"
          },
          "name": "max_borrower_credit_score_at_origination",
          "expression": "r.max_borrower_credit_score_at_origination",
          "type": "int"
        },
        {
          "parquet": {
            "column_name": "total_original_upb"
          },
          "name": "total_original_upb",
          "expression": "r.total_original_upb",
          "type": "decimal2"
        },
        {
          "parquet": {
            "column_name": "total_original_upb_paid_off_ratio"
          },
          "name": "total_original_upb_paid_off_ratio",
          "expression": "math.Round(float(r.total_paid_off_amount)/float(r.total_original_upb)*100000)/100000",
          "type": "float"
        },
        {
          "parquet": {
            "column_name": "total_upb_at_issuance"
          },
          "name": "total_upb_at_issuance",
          "expression": "r.total_upb_at_issuance",
          "type": "decimal2"
        },
        {
          "parquet": {
            "column_name": "total_loans"
          },
          "name": "total_loans",
          "expression": "r.total_loans",
          "type": "int"
        },
        {
          "parquet": {
            "column_name": "total_original_loan_term_30y"
          },
          "name": "total_original_loan_term_30y",
          "expression": "r.total_original_loan_term_30y",
          "type": "int"
        },
        {
          "parquet": {
            "column_name": "avg_payments_behind_ratio"
          },
          "name": "avg_payments_behind_ratio",
          "expression": "math.Round(r.avg_payments_behind_ratio*100000)/100000",
          "type": "float"
        },
        {
          "parquet": {
            "column_name": "total_paid_off_amount"
          },
          "name": "total_paid_off_amount",
          "expression": "r.total_paid_off_amount",
          "type": "decimal2"
        },
        {
          "parquet": {
            "column_name": "avg_paid_off_ratio"
          },
          "name": "avg_paid_off_ratio",
          "expression": "math.Round(r.avg_paid_off_ratio*100000)/100000",
          "type": "float"
        }
      ]
    }
  }
}

Script node 05_write_file_deal_summaries produces data file:

deal_namewa_original_interest_rate_by_original_upbmin_original_interest_ratemax_original_interest_ratewa_borrower_credit_score_at_origination_by_original_upbmin_borrower_credit_score_at_originationmax_borrower_credit_score_at_originationtotal_original_upbtotal_original_upb_paid_off_ratiototal_upb_at_issuancetotal_loanstotal_original_loan_term_30yavg_payments_behind_ratiototal_paid_off_amountavg_paid_off_ratio
CAS 2023 R08 G16.1032.58.125758.58600832193562810000.024618880190518.0660345601140476091393.370.02311

Total 1 rows