UNPKG

@prestamype/financial-functions

Version:
40 lines (32 loc) • 1.08 kB
const { cronograma, tasa } = require('../') async function main() { // // Prestamype data // const amount = 50000, // i_rate = 0.012, // commission_rate = 0.255, // nper = 12 * 4 // // Adela data // const amount = 500, // i_rate = 0.035, // commission_rate = 0.15*1.18, // nper = 2 const amount = 100000, i_rate = 0.0142, commission_rate = 0.146, nper = 30 const schedule = cronograma.flexible(amount, nper, i_rate, commission_rate) // const schedule = cronograma.fija(amount, nper, i_rate, commission_rate) // const schedule = cronograma.puente(amount, nper, i_rate, commission_rate) // const flow = [ - schedule.total_amount, ...schedule.payments.map(a => a.fee) ] const flow = [ - amount, ...schedule.payments.map(a => a.fee) ] // console.log(flow) console.table(schedule.payments) // console.log(schedule.total_amount) // const tir = TIR_biscetion(schedule.flow) // const tir = TIR_newton(flow) const tir = await tasa.main(flow) console.log(tir) } main() .catch(err => console.log(err)) .finally(() => process.exit())