File size: 1,224 Bytes
8069421
a6f8c81
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8069421
a6f8c81
 
8069421
 
 
 
 
a6f8c81
8069421
869f501
 
 
 
 
 
a6f8c81
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import streamlit as st
import numpy as np
import matplotlib.pyplot as plt

def calcular_cashflow(n, A, r, Pi):
    cashflow = []
    saldo = Pi
    for i in range(n):
        interes = saldo * (r/100)
        abono_capital = A - interes
        saldo += abono_capital
        cashflow.append(saldo)
    return cashflow

def graficar_cashflow(cashflow):
    meses = range(1, len(cashflow) + 1)
    plt.plot(meses, cashflow, marker='o', linestyle='-')
    plt.title('Cashflow por Mensualidad')
    plt.xlabel('Mes')
    plt.ylabel('Saldo')
    plt.grid(True)
    st.pyplot()

def main():
    st.title('Calculadora de Cashflow')
    n = st.number_input("Ingrese el número de mensualidades:", min_value=1, step=1, format='%d')
    A = st.number_input("Ingrese el monto de la mensualidad:", min_value=0.0, step=1.0, format='%f')
    r = st.number_input("Ingrese la tasa de interés (%):", min_value=0.0, step=0.01, format='%f')
    Pi = st.number_input("Ingrese el depósito inicial:", min_value=0.0, step=1.0, format='%f')

    if st.button('Calcular y Graficar Cashflow'):
        cashflow = calcular_cashflow(int(n), float(A), float(r), float(Pi))
        graficar_cashflow(cashflow)

if __name__ == "__main__":
    main()