Skip to content

Financial functions

The luego.finance package contains basic financial functions.

luego.finance

cumulativeRateBands

cumulativeRateBands(ratebands: NEList[(Number,Number)]) => (Number) => Number

Given a list of rate bands, this function returns a function: Number => Number, that given a monetary amount applies the cumulative rates.

futureValueAtEnd

futureValueAtEnd(r: Number, nper: Integer, c: Number, pv: Number) => Number

Returns the future value of an investment, given the periodic interest rate r, the number of periods nper, the payment made each period c (a negative number) and the present value of future payments pv (a negative number)

mortgageMonthlyPayment

mortgageMonthlyPayment(p: Number, r: Number, t: Integer) => Number

Calculates the monthly payment of a mortgage as a Number given a principal p, a yearly rate r and a term in years t

mortgageMonthlyPaymentBD

mortgageMonthlyPaymentBD(p: BigDecimal, r: BigDecimal, t: Integer) => BigDecimal

Calculates the monthly payment of a mortgage as a BigDecimal given a principal p, a yearly rate r and a term in years t

npv

npv(r: Number, cashflows: List[Number]) => Number

Calculates the Net Present Value of a principal amount given a discount rate r and a sequence of cash flows. If the amounts represent an income then the value should be positive, else if they are payments, the value should be negative.

positivePiecewiseConstant

positivePiecewiseConstant(tiers: NEList[(Number,Number)]) => (Number) => Number

Given a list of intervals with an associated constant value (represented as a list of pair of numbers), this function returns a function: Number => Number, that given a numeric amount returns the constant value for the corresponding interval.

projectFixedRateGrowth

projectFixedRateGrowth(v0: Number, r: Number, n: Integer) => NEList[Number]

Project initial value v0 at a fixed growth rate r during n periods

projectVarRateGrowth

projectVarRateGrowth(v0: Number, rates: List[Number]) => NEList[Number]

Projects initial value v0 at a variable growth rate represented by the list of numbers rates