AriaEs39 commited on
Commit
9e291ca
1 Parent(s): e748e8b

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -0
app.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ esent_value = (monthly_payment * 12 / interest_rate) * (1 - (1 / (1 + interest_rate/12)**months))
2
+
3
+ # Display the present value
4
+ st.write(f"The present value is {present_value:,.2f} using the discrete model")
5
+
6
+ # Cashflow DataFrame
7
+ cashflows = [-present_value] + [monthly_payment] * months
8
+ cf_df = pd.DataFrame({"cashflows": cashflows}).astype(float)
9
+ st.dataframe(cf_df.T)
10
+
11
+ # Plot the Cashflow Diagram
12
+ colors = ["green" if cf > 0 else "red" for cf in cf_df.cashflows]
13
+ plt.scatter(range(months + 1), cf_df.cashflows, c=colors)
14
+ plt.title("Cashflow Diagram")
15
+ plt.xlabel("Period")
16
+ plt.ylabel("Cashflow")
17
+ for i, cf in enumerate(cf_df.cashflows):
18
+ plt.annotate(f"{cf:,.2f}", (i, cf), textcoords="offset points", xytext=(0, months), ha="center")
19
+ st.pyplot(plt)