10.02
Mortgage
Background (Non-Technical Explanation)
- A mortgage is a loan used to buy a property (house or apartment).
- The borrower repays the loan over time with interest.
Key Concepts
1. Interest Rate
- This is the cost of borrowing money, expressed as a percentage per year.
- Example: 5% means you pay 5% of the loan amount per year as interest
2. Fixed vs Variable Mortgages
Fixed Rate Mortgage
- The interest rate is locked (fixed) for a set period
Common fixed periods:
- 2 years
- 3 years
- 5 years
- 10 years
Example:
“5-year fixed at 4.5%”
→ Rate stays 4.5% for 5 years, then changes
Variable Rate Mortgage
- The rate moves over time (can go up or down)
- Often linked to central bank rates or market rates
3. Fees, Cashback, Legal/Valuation Frees/Other terms
Mortgages often include upfront costs:
- Fixed fee (e.g. £999)
- Or % of loan (e.g. 1%)
- Cashback (essentially a negative fee)
- Maximum Loan-to-Value (LTV)
These must be included when comparing deals.
4. Why Compare Mortgages?
The goal is to find the cheapest total cost, not just the lowest rate.
======================================================================
2. “Swap Rates?” (Important Context)
- Swap rates are market interest rates used by banks.
- They represent the true cost of fixed-rate lending in financial markets.
Why They Matter
Banks price mortgages based on swap rates
If:
5-year swap = 3%
Mortgage = 5%
👉 Bank margin ≈ 2%
This allows us to:
- Compare banks
- Identify overpriced or cheap mortgages
3. System Objective
Build a system that:
- Collects mortgage offers from aggregators (e.g. MoneySuperMarket)
- Stores them in a structured format
- Collects daily swap rates
- Enables mathematical comparison of mortgage deals vs market rates
CODING TO DO
4. Mortgage Rates Scraper
See: http://localhost:8000/mortgage/rates/
This page contains buttons:
- 2-year
- 3-year
- 5-year
- 10-year
Each button leads to a page showing mortgage offers for that maturity term
What to Scrape (Per Mortgage Product)
For each mortgage on the page, extract:
- Link on moneysupermarket
- Bank Name
- Term (ie fixed period in years (eg 2yr, 3yr, 5yr or 10yr)
- Interest Rate (%)
- Rate Type
- Fees
- Fixed amount (£)
- Percentage (%) if available
- Cashback
- Maximum LTV
- Free Legals
- Free Valuation
Storage
Create a new record via: http://localhost:8000/mortgage/rates/new
Scraper Logic
For each term (2, 3, 5, 10):
- Open the page (2yr, 3yr, 5yr, 10yr)
- Loop through all mortgage deals available
- Extract required fields
- Save one record per mortgage deal available
Maintaining a record over time… (let's tackle handling versioning over time after we have the scrape working)
- If the Mortgage Deal already exists in the database (same Lender, same maturity term, same rate, same fees, status=Active) then don't create a new one record
- If it is a Mortgage Deal, set “DateLaunched” as today and set status as Active
- If a mortgage record (Active) is no longer present, mark the date "DateWithdrawn" as today
5. Swap Rate Scraper Specification
See: http://localhost:8000/swap/rates/
What to Extract
For each tenor:
- 2-year
- 3-year
- 5-year
- 10-year
Extract:
- Rate (%)
- Tenor
- Date (today’s date)
Execution
Run once per day (cron job)
6. End Goal (Why This Matters)
This system allows comparison of mortgage deals on a like-for-like basis. I can explain why to you, but not important for the coding exercise