org.apache.poi.ss.formula.functions

## Class FinanceLib

• java.lang.Object
• org.apache.poi.ss.formula.functions.FinanceLib

• ```public final class FinanceLib
extends java.lang.Object```
Author:
Amol S. Deshmukh < amolweb at ya hoo dot com > This class is a functon library for common fiscal functions. Glossary of terms/abbreviations:
• FV: Future Value
• PV: Present Value
• NPV: Net Present Value
• PMT: (Periodic) Payment
Online References:
1. GNU Emacs Calc 2.02 Manual: http://theory.uwinnipeg.ca/gnu/calc/calc_203.html
2. Yahoo Financial Glossary: http://biz.yahoo.com/f/g/nn.html#y
3. MS Excel function reference: http://office.microsoft.com/en-us/assistance/CH062528251033.aspx

### Implementation Notes:

Symbols used in the formulae that follow:
• p: present value
• f: future value
• n: number of periods
• y: payment (in each period)
• r: rate
• ^: the power operator (NOT the java bitwise XOR operator!)
[From MS Excel function reference] Following are some of the key formulas that are used in this implementation:
``` p(1+r)^n + y(1+rt)((1+r)^n-1)/r + f=0   ...{when r!=0}
ny + p + f=0                            ...{when r=0}
```
• ### Method Summary

All Methods
Modifier and Type Method and Description
`static double` ```fv(double r, double n, double y, double p, boolean t)```
Future value of an amount given the number of payments, rate, amount of individual payment, present value and boolean value indicating whether payments are due at the beginning of period (false => payments are due at end of period)
`static double` ```nper(double r, double y, double p, double f, boolean t)```
`static double` ```npv(double r, double[] cfs)```
calculates the Net Present Value of a principal amount given the discount rate and a sequence of cash flows (supplied as an array).
`static double` ```pmt(double r, double n, double p, double f, boolean t)```
`static double` ```pv(double r, double n, double y, double f, boolean t)```
Present value of an amount given the number of future payments, rate, amount of individual payment, future value and boolean value indicating whether payments are due at the beginning of period (false => payments are due at end of period)
• ### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
• ### Method Detail

• #### fv

```public static double fv(double r,
double n,
double y,
double p,
boolean t)```
Future value of an amount given the number of payments, rate, amount of individual payment, present value and boolean value indicating whether payments are due at the beginning of period (false => payments are due at end of period)
Parameters:
`r` - rate
`n` - num of periods
`y` - pmt per period
`p` - present value
`t` - type (true=pmt at beginning of period, false=pmt at end of period)
• #### pv

```public static double pv(double r,
double n,
double y,
double f,
boolean t)```
Present value of an amount given the number of future payments, rate, amount of individual payment, future value and boolean value indicating whether payments are due at the beginning of period (false => payments are due at end of period)
Parameters:
`r` - rate
`n` - num of periods
`y` - pmt per period
`f` - future value
`t` - type (true=pmt at beginning of period, false=pmt at end of period)
• #### npv

```public static double npv(double r,
double[] cfs)```
calculates the Net Present Value of a principal amount given the discount rate and a sequence of cash flows (supplied as an array). If the amounts are income the value should be positive, else if they are payments and not income, the value should be negative.
Parameters:
`r` - rate
`cfs` - cashflow amounts
• #### pmt

```public static double pmt(double r,
double n,
double p,
double f,
boolean t)```
Parameters:
`r` - rate
`n` - num of periods
`p` - present value
`f` - future value
`t` - type (true=pmt at beginning of period, false=pmt at end of period)
• #### nper

```public static double nper(double r,
double y,
double p,
double f,
boolean t)```
Parameters:
`r` - rate
`y` - pmt per period
`p` - present value
`f` - future value
`t` - type (true=pmt at beginning of period, false=pmt at end of period)

Copyright 2020 The Apache Software Foundation or its licensors, as applicable.