GALOLIT commited on
Commit
72159e1
1 Parent(s): a283b91

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -10
app.py CHANGED
@@ -8,15 +8,17 @@ def calculate_returns(y_initial, A, T, changes_in_interest_rate):
8
  z = np.arange(T+1)
9
  r_c = np.zeros(T+1)
10
  interest_rate = y_initial / (12 * 100)
 
11
  for month in range(T+1):
12
  for change_month, new_interest_rate in changes_in_interest_rate.items():
13
  if month >= change_month:
14
  interest_rate = new_interest_rate / (12 * 100)
 
15
  r_c[month] = A * np.exp(interest_rate * month)
16
- return z, r_c
17
 
18
  def main():
19
- st.title('App de pruebas')
20
 
21
  # Ingresar la tasa de interés nominal inicial
22
  y_initial = st.number_input("Escribe la tasa de interés nominal inicial (%):")
@@ -38,11 +40,11 @@ def main():
38
  new_interest_rate = st.number_input(f"Nueva tasa de interés a partir del mes {change_month} (%):")
39
  changes_in_interest_rate[change_month] = new_interest_rate
40
 
41
- # Calcular los retornos
42
- z, r_c = calculate_returns(y_initial, A, T, changes_in_interest_rate)
43
 
44
  # Crear un DataFrame con los resultados
45
- new_dict = {"Mes": z, "Retorno continuo": r_c}
46
  df = pd.DataFrame(new_dict)
47
 
48
  # Mostrar el DataFrame y el resultado final
@@ -53,8 +55,4 @@ def main():
53
  plt.plot(z, r_c)
54
  plt.xlabel('Mes')
55
  plt.ylabel('Retorno')
56
- plt.title('Comportamiento de la inversión')
57
- st.pyplot()
58
-
59
- if __name__ == "__main__":
60
- main()
 
8
  z = np.arange(T+1)
9
  r_c = np.zeros(T+1)
10
  interest_rate = y_initial / (12 * 100)
11
+ interest_rates = [interest_rate] * (T+1)
12
  for month in range(T+1):
13
  for change_month, new_interest_rate in changes_in_interest_rate.items():
14
  if month >= change_month:
15
  interest_rate = new_interest_rate / (12 * 100)
16
+ interest_rates[month] = interest_rate
17
  r_c[month] = A * np.exp(interest_rate * month)
18
+ return z, r_c, interest_rates
19
 
20
  def main():
21
+ st.title('App de prueba 🏦')
22
 
23
  # Ingresar la tasa de interés nominal inicial
24
  y_initial = st.number_input("Escribe la tasa de interés nominal inicial (%):")
 
40
  new_interest_rate = st.number_input(f"Nueva tasa de interés a partir del mes {change_month} (%):")
41
  changes_in_interest_rate[change_month] = new_interest_rate
42
 
43
+ # Calcular los retornos y las tasas de interés correspondientes
44
+ z, r_c, interest_rates = calculate_returns(y_initial, A, T, changes_in_interest_rate)
45
 
46
  # Crear un DataFrame con los resultados
47
+ new_dict = {"Mes": z, "Tasa de Interés (%)": interest_rates, "Retorno continuo": r_c}
48
  df = pd.DataFrame(new_dict)
49
 
50
  # Mostrar el DataFrame y el resultado final
 
55
  plt.plot(z, r_c)
56
  plt.xlabel('Mes')
57
  plt.ylabel('Retorno')
58
+ plt.