Created
October 4, 2020 21:18
-
-
Save edualzate/49176171236b61c35659ae0b45497398 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Calculando una tabla de amortización de un préstamo | |
import numpy_financial as npf | |
import tabulate as tab | |
capital = 1000000 | |
tasa = 0.01 | |
plazo = 12 | |
cuota = round(npf.pmt(tasa, plazo, -capital, 0), 0) | |
datos = [] | |
saldo = capital | |
for i in range(1, plazo+1): | |
pago_capital = npf.ppmt(tasa, i, plazo, -capital, 0) | |
pago_int = cuota - pago_capital | |
saldo -= pago_capital | |
linea = [i, format(cuota, '0,.0f'), format(pago_capital, '0,.0f'), format(pago_int, '0,.0f'), format(saldo, '0,.0f')] | |
datos.append(linea) | |
print(tab.tabulate(datos, headers=['Periodo', 'Cuota', 'Capital', 'Intereses', 'saldo'], tablefmt='psql')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment