Skip to main content

Someone wanted to learn this too, so Grasp built them a personal learning path.

You can keep exploring this one or create your own

Spanish Mortgage Payment Calculation

Hello! Welcome to the second module of our course.

In the last lesson, we successfully built a Python model to calculate Net Operating Income (NOI). This gave us a clear picture of a property's profitability based purely on its operations, before considering any financing. However, since most real estate investments are made with borrowed money, our next step is to incorporate the cost of that debt.

This lesson directly addresses that by focusing on how to calculate monthly mortgage payments (debt service) using loan amount, interest rate, and term specific to Spanish market conditions. This payment, often called debt service, is typically the largest single cash outflow for a leveraged property investor. Understanding how it's calculated is fundamental to analyzing any real estate deal.

1. The French Amortization System: The Standard in Spain

When you get a mortgage in Spain, it's almost certain to use the "sistema de amortización francés" (French amortization system). Its defining characteristic is a constant monthly payment throughout the life of the loan (assuming a fixed interest rate).

While the total payment stays the same, the composition of that payment changes each month:

  • In the early years, a larger portion of your payment goes towards paying interest.
  • In the later years, a larger portion goes towards paying down the principal loan amount.

This front-loading of interest is why you'll often hear that "at first, you’re mostly paying the bank."

The constant monthly payment (PMT or cuota mensual) is calculated using a standard formula.

What is the French amortization system for mortgages and ...

The article 'What is the French amortization system for mortgages and how does it work' provides a concise explanation of this system and presents the core formula we'll be using. It's written by a software developer, so the perspective should resonate with you.

Please read the first two sections, 'What is this?' and the introduction to 'How does it work?'. Focus on the formula provided for the monthly payment (PMT) and the definition of its variables: P, r, and n.

As you saw in the reading, the formula is:

Where:

  • = The total loan amount (the principal).
  • = The periodic interest rate (the annual rate divided by the number of payments per year). For a monthly mortgage, this is the annual interest rate divided by 12.
  • = The total number of payments (loan term in years multiplied by 12).

Given your background, you might appreciate that this formula isn't arbitrary. It's the result of solving a recursive equation that describes the loan balance month after month.

Derivation of Loan/Mortgage Monthly Payment Formula

This video, 'Derivation of Loan/Mortgage Monthly Payment Formula' by Physics Ninja, provides an excellent step-by-step derivation of this exact formula. While you don't need to memorize the derivation, seeing how it's built from first principles can provide a deeper understanding.

Watch from 06:22 to 17:35. The presenter sets up the balance equations month by month, identifies the underlying geometric series, and solves it to arrive at the final formula. Notice the parallel between this mathematical modeling and how you might model complex systems in engineering.

2. The Interest Rate in Spain: TIN vs. TAE

Before we can use the formula, we must clarify a crucial point for the Spanish market: which interest rate to use for . When you look at mortgage offers in Spain, you will always see two rates: TIN and TAE.

  • TIN (Tipo de Interés Nominal): The nominal interest rate. This is the "price" of the money you're borrowing. It's the rate used in the mortgage payment formula.
  • TAE (Tasa Anual Equivalente): The annual equivalent rate. This rate includes the TIN plus most of the other costs associated with the loan, such as opening fees (comisión de apertura), mandatory insurance products, etc.

The TAE is a comparison tool required by Spanish law to help you understand the true total cost of different loan offers. However, for calculating the monthly payment, we always use the TIN.

¿Cuál es la Diferencia entre TIN y TAE? Guía Completa para ...

This article, '¿Cuál es la Diferencia entre TIN y TAE?', explains these two concepts clearly. Understanding this distinction is non-negotiable for making informed financial decisions in Spain.

Read the sections titled '¿Qué es el TIN y cómo se calcula?', 'La TAE explicada - Definición y cálculo', and 'Diferencias principales entre TIN y TAE'. The key takeaway is understanding why TIN is used for the payment calculation, while TAE is used for comparing overall loan costs.

3. Calculating the Monthly Payment: A Worked Example

Let's apply this knowledge. We'll use the example from the estebansastre.com article you read earlier.

  • Loan Principal (): €100,000
  • Annual Fixed TIN: 3.5%
  • Term: 25 years

Step 1: Define the variables

  • Annual TIN = 0.035
  • Monthly interest rate ():
  • Total number of payments ():

Step 2: Apply the formula

Plugging this into a calculator gives:

This is the fixed monthly payment for the next 25 years.

Step 3: Analyze the first payment

  • Interest Portion:
  • Principal Portion:
  • New Balance:

For the second month, the interest would be calculated on the new, slightly lower balance, meaning a tiny bit less interest is paid and a tiny bit more principal is paid down. This process repeats every month, as shown in an amortization schedule.

Mortgage Amortization Schedule with Variable Interest Rate
This image shows a typical amortization schedule. You can see the constant `Cuota` (payment) and how the `Intereses` (interest) portion decreases while the `Amortización` (principal) portion increases with each payment, reducing the `Capital pendiente` (outstanding balance).

4. Fixed vs. Variable Rates in the Spanish Market

The example above uses a fixed TIN (tipo fijo). However, many mortgages in Spain have a variable TIN (tipo variable). These are typically structured as:

Variable TIN = Euribor + Differential (diferencial)

  • Euribor: The Euro Interbank Offered Rate. It's a benchmark rate that fluctuates with the market. The 12-month Euribor is most common for Spanish mortgages.
  • Differential: A fixed percentage added by the bank. This is the bank's margin.

With a variable-rate mortgage, the TIN (and therefore your monthly payment) is recalculated at set intervals, usually every 6 or 12 months, based on the latest Euribor value.

BBVA Spanish Mortgage Payment Calculator
This screenshot from Spanish bank BBVA's website shows a calculator for a variable-rate mortgage. Note the separate inputs for the `Euribor` and the `diferencial` (spread), which are combined to determine the interest rate for the calculation.
Test your understanding!

A Spanish bank offers you a mortgage for a property investment.

  • Loan Amount (P): €220,000
  • Term: 30 years
  • Interest Rate: A fixed annual TIN of 2.8%

What will your fixed monthly mortgage payment be?

Show answer
  1. Identify variables:

    • Annual TIN = 0.028
    • Monthly rate
    • Number of payments
  2. Apply the formula:

    Your monthly mortgage payment will be approximately €904.22.

5. From Formula to Code

As a software engineer, you'll want to automate this. We can translate the formula and the logic for generating an amortization schedule directly into Python.

A professional approach would be to use a dedicated financial library. numpy-financial is a standard choice that has a pre-built pmt function.

What is the French amortization system for mortgages and ...

Let's return to the article on the French amortization system. The author provides two ways to code this: a 'from-scratch' Python function and a more concise version using the numpy-financial library.

Review the 'How about automating this?' and the following section. First, look at the french_amortization_schedule function to see the manual implementation. Then, observe how much cleaner the calculation becomes using numpy_financial.pmt().

Here is a clean implementation using numpy-financial. You'll need to install it first: pip install numpy-financial.

import numpy_financial as npf

# --- Inputs ---
principal = 220000  # Loan amount in Euros
annual_tin = 0.028  # 2.8% annual TIN
years = 30          # 30-year term

# --- Calculations ---
# Convert to monthly rate and number of periods
monthly_rate = annual_tin / 12
n_periods = years * 12

# Calculate the monthly payment
# npf.pmt returns a negative value as it's a cash outflow. We use abs() for a positive number.
monthly_payment = abs(npf.pmt(rate=monthly_rate, nper=n_periods, pv=principal))

# --- Output ---
print(f"--- Mortgage Payment Calculation ---")
print(f"Loan Amount:         €{principal:,.2f}")
print(f"Annual TIN:          {annual_tin:.2%}")
print(f"Term:                {years} years")
print("---------------------------------------")
print(f"Monthly Payment:     €{monthly_payment:,.2f}")

# Example: Calculate interest for the first month
first_month_interest = principal * monthly_rate
print(f"Interest in Month 1:   €{first_month_interest:,.2f}")

# Example: Calculate principal paid in the first month
first_month_principal = monthly_payment - first_month_interest
print(f"Principal in Month 1:  €{first_month_principal:,.2f}")

This code is clean, reliable, and uses industry-standard tools for financial calculations—a perfect addition to the financial models we'll be building.

Conclusion

In this lesson, you have learned the mechanics behind mortgage payments, a critical component of real estate investment analysis.

Key Takeaways:

  • Mortgages in Spain typically follow the French amortization system, characterized by a constant monthly payment.
  • The monthly payment formula requires the principal, the number of periods, and the periodic interest rate, which is derived from the TIN (Tipo de Interés Nominal).
  • The TAE (Tasa Anual Equivalente) is a tool for comparing the total cost of different loans but is not used to calculate the monthly payment itself.
  • We can easily model this calculation in Python, with the numpy-financial library offering a robust and straightforward solution.

Preview of the Next Lesson:
Now that we can calculate our debt service, the next logical question is: how much debt should we take on? In the next lesson, we will explore the Loan-to-Value (LTV) ratio, a key metric used by lenders to determine the maximum loan amount they are willing to offer and by investors to measure their leverage.

Can't find a good explanation? Sign up and we'll make it for you

Sign up