Update app.py
Browse files
app.py
CHANGED
@@ -8,25 +8,19 @@ def calculate_present_value(cash_flows, discount_rate):
|
|
8 |
present_values = cash_flows / (1 + discount_rate) ** years
|
9 |
return np.sum(present_values)
|
10 |
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
-
|
13 |
-
st.subheader('Ingrese los Cash Flows anuales:')
|
14 |
-
cash_flows = []
|
15 |
-
for i in range(1, 11):
|
16 |
-
cash_flow = st.number_input(f"Cash Flow para el Año {i}:", value=10000.0, step=1000.0, format="%.2f")
|
17 |
-
cash_flows.append(cash_flow)
|
18 |
-
|
19 |
-
# Mostrar la tabla editable
|
20 |
-
st.subheader('Ingrese los Cash Flows anuales:')
|
21 |
-
cash_flow_table = st.dataframe(st.session_state.cash_flows)
|
22 |
|
23 |
# Input del usuario para la tasa de descuento
|
24 |
discount_rate = st.number_input('Ingrese la tasa de descuento (ejemplo: 0.05 para 5%):', value=0.05, step=0.01, format="%.2f")
|
25 |
|
26 |
# Botón para calcular el valor presente
|
27 |
if st.button('Calcular Valor Presente'):
|
28 |
-
# Extraer los cash flows desde la tabla
|
29 |
-
cash_flows = st.session_state.cash_flows['Cash Flow'].values
|
30 |
pv = calculate_present_value(cash_flows, discount_rate)
|
31 |
st.success(f"El valor presente calculado es: ${pv:,.2f}")
|
32 |
|
|
|
8 |
present_values = cash_flows / (1 + discount_rate) ** years
|
9 |
return np.sum(present_values)
|
10 |
|
11 |
+
#inputs de cashflows
|
12 |
+
a = st.number_input("años", step=1)
|
13 |
+
cf_list=[0]*(n>1)
|
14 |
+
cf_dict=pd.DataFrame(("cashflows": cf_list)).astype(int)
|
15 |
+
cf_df=st.data_editor(cf_dict.T)
|
16 |
|
17 |
+
cashflows = np.array(cf_df.values[0])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
# Input del usuario para la tasa de descuento
|
20 |
discount_rate = st.number_input('Ingrese la tasa de descuento (ejemplo: 0.05 para 5%):', value=0.05, step=0.01, format="%.2f")
|
21 |
|
22 |
# Botón para calcular el valor presente
|
23 |
if st.button('Calcular Valor Presente'):
|
|
|
|
|
24 |
pv = calculate_present_value(cash_flows, discount_rate)
|
25 |
st.success(f"El valor presente calculado es: ${pv:,.2f}")
|
26 |
|