3ck0 commited on
Commit
f70d24a
1 Parent(s): 0372a76

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +54 -0
app.py ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import numpy as np
3
+
4
+ # Function to calculate loan details
5
+ def calculate_loan(loan_amount, loan_term_years, interest_rate):
6
+ monthly_rate = interest_rate / 100 / 12
7
+ loan_term_months = loan_term_years * 12
8
+ monthly_payment = loan_amount * (monthly_rate * (1 + monthly_rate) ** loan_term_months) / ((1 + monthly_rate) ** loan_term_months - 1)
9
+ total_payments = monthly_payment * loan_term_months
10
+ total_interest = total_payments - loan_amount
11
+ return monthly_payment, total_payments, total_interest
12
+
13
+ # Main Streamlit app
14
+ def main():
15
+ st.subheader("Real Estate Loan Calculator")
16
+ st.markdown("---")
17
+ st.subheader("Loan Details")
18
+ col1, col2, col3 = st.columns(3)
19
+
20
+ with col1:
21
+ loan_amount = st.number_input("Loan Amount (€)", value=150000, step=1000)
22
+ loan_term_years = st.number_input("Loan Term (Years)", value=20, step=1)
23
+ interest_rate = st.number_input("Interest Rate (%)", value=3.49, step=0.01)
24
+
25
+ monthly_payment, total_payments, total_interest = calculate_loan(loan_amount, loan_term_years, interest_rate)
26
+
27
+ with col2:
28
+ st.markdown(
29
+ f"""
30
+ <div style="border: 2px solid #ccc; padding: 10px; background-color: #0e1117; border-radius: 5px; text-align: center;">
31
+ <h4 style="font-weight: bold;">Loan Details</h4>
32
+ <p>Monthly:<br> <span style="font-weight: bold; color: orange;">{monthly_payment:.2f} €</span><br>
33
+ Total:<br> <span style="font-weight: bold; color: teal;">{total_payments:.2f} €</span><br>
34
+ Total Interest:<br> <span style="font-weight: bold; color: green;">{total_interest:.2f} €</span></p>
35
+ </div>
36
+ """,
37
+ unsafe_allow_html=True
38
+ )
39
+ with col3:
40
+ st.markdown(
41
+ f"""
42
+ <div style="padding: 10px; ">
43
+ <h5 style="font-style: italic;">Project Costs</h5>
44
+ <p style="font-style: italic;"><span style="font-weight: bold;">Costs closing: 10,000 €</span></p>
45
+ <p style="font-style: italic;">Notary fees and others: 5,000 €</p>
46
+ <p style="font-style: italic;">Notary fees and others: 5,000 €</p>
47
+ </div>
48
+ """,
49
+ unsafe_allow_html=True
50
+ )
51
+
52
+ if __name__ == "__main__":
53
+ main()
54
+