This is a Flask-based web API for real estate calculations. It provides endpoints for calculating mortgage payments and performing a month-by-month comparison of costs.
.
├── .gitignore
├── app.py
├── calculations
│ ├── init.py
│ ├── comparison.py
│ └── mortgage_calculations.py
├── main.py
└── realEstimate.py
- Clone the repository:
git clone <repository-url>
-
Navigate to the project directory:
cd <project-directory>
-
Create a virtual environment:
python3 -m venv venv
-
Activate the virtual environment: On Windows:
venv\Scripts\activate
On Unix or MacOS:
source venv/bin/activate
- Install the required packages:
pip install -r requirements.txt
To run the application, use the following command:
python app.py
This will start a development server on http://localhost:5000.
Calculate Mortgage Payments
URL: /calculate_mortgage_payments
Method: POST
Data Params:
{
"property_price": <property_price>,
"down_payment_percentage": <down_payment_percentage>,
"interest_rate_first_period": <interest_rate_first_period>,
"interest_rate_subsequent_min": <interest_rate_subsequent_min>,
"interest_rate_subsequent_max": <interest_rate_subsequent_max>,
"mortgage_term_years": <mortgage_term_years>,
"fixed_interest_duration_years": <fixed_interest_duration_years>
}
Month by Month Comparison
URL: /month_by_month_comparison
Method: POST
Data Params:
{
"monthly_payment_first_period": <monthly_payment_first_period>,
"monthly_payment_subsequent_min": <monthly_payment_subsequent_min>,
"monthly_payment_subsequent_max": <monthly_payment_subsequent_max>,
"monthly_rent": <monthly_rent>,
"mortgage_term_years": <mortgage_term_years>,
"loan_amount": <loan_amount>,
"interest_rate_first_period": <interest_rate_first_period>,
"interest_rate_subsequent_min": <interest_rate_subsequent_min>,
"interest_rate_subsequent_max": <interest_rate_subsequent_max>,
"fixed_interest_duration_years": <fixed_interest_duration_years>
}
This API uses the loan amortization formula to calculate monthly mortgage payments. The formula is as follows:
M = P[r(1+r)^n]/[(1+r)^n – 1]
Where:
- M is your monthly payment.
- P is the principal loan amount.
- r is your monthly interest rate, calculated by dividing your annual interest rate by 12.
- n is your number of payments (the number of months you will be paying the loan).
Inspired by: https://www.rumah123.com/kpr/simulasi-kpr/