import streamlit as st import numpy as np # Function to calculate loan details def calculate_loan(loan_amount, loan_term_years, interest_rate): monthly_rate = interest_rate / 100 / 12 loan_term_months = loan_term_years * 12 monthly_payment = loan_amount * (monthly_rate * (1 + monthly_rate) ** loan_term_months) / ((1 + monthly_rate) ** loan_term_months - 1) total_payments = monthly_payment * loan_term_months total_interest = total_payments - loan_amount return monthly_payment, total_payments, total_interest # Main Streamlit app def main(): st.subheader("Real Estate Loan Calculator") st.markdown("---") st.subheader("Loan Details") col1, col2, col3 = st.columns(3) with col1: loan_amount = st.number_input("Loan Amount (€)", value=150000, step=1000) loan_term_years = st.number_input("Loan Term (Years)", value=20, step=1) interest_rate = st.number_input("Interest Rate (%)", value=3.49, step=0.01) monthly_payment, total_payments, total_interest = calculate_loan(loan_amount, loan_term_years, interest_rate) with col2: st.markdown( f"""
Monthly:
{monthly_payment:.2f} €
Total:
{total_payments:.2f} €
Total Interest:
{total_interest:.2f} €
Costs closing: 10,000 €
Notary fees and others: 5,000 €
Notary fees and others: 5,000 €