|pv => Present Value|
|fv => Future Value|
|ir => Yearly Interest Rate (in percent)|
|pmt => Payment Amount|
|np => Number of Payments/Loan Term|
|tpy => Terms Per Year (defaults to 12)|
|pd => Payments made so far (used only for loan/annuity balances)|
Calculations are based <B>eitherB> on the attributes set with the new or set methods, <B>orB> with arguments fed directly to the methods. This seemed like the least confusing way to make the interface flexible for people who are using the module in different ways.
Also, performing a calculation does <B>notB> update the attribute of the solution. In other words, if you solve an equation that returns fv, the solution is returned but the internal fv field is unaffected.
Any attempted calculation which cannot be completed due to either missing or invalid attributes will return undef.
I am interested to hear from people using this module let me know what you think about the interface and how it can be improved.
$calc = new Math::Financial();
$calc = new Math::Financial(pv => 10000, ir => 5, np = 12)>
There are no default values for any of the attributes except TPY (Terms Per Year), which is 12 by default, and PD which defaults to zero.
If you dont want to use the object-oriented interface, see the EXPORTS section below.
$calc->set(fv => 100000, pmt => 500)
$calc->get(field = ir)>
$calc->get([qw(ir pmt pv)])
You can get one or several attributes using this method. In the multiple attribute formats, it accepts either a list or a list reference as input.
In single attribute context, returns a scalar. In multiple attribute context, it returns a list or a reference to a list, depending on the calling context.
$calc->compound_interest->(find => fv)
Calculates compund interest for an annuity. With any 3 of pv, fv, np, and ir, you can always solve the fourth.
Without arguments, the method will attempt to figure out what youd like to solve based on what attributes of the object are defined. Usually, youll probably want to explicitly request what attribute youd like returned, which you can do using the second or third method.
$calc->funding_annuity->(pmt => 2000, ir => 6.50, np => 40, tpy = 4)>
funding_annuity calculates how much money ( fv ) you will have at the end of np periods if you deposit pmt into the account each period and the account earns ir interest per year.
You may want to set the tpy attribute here to something other than 12, since, while loans usually compound monthly, annuities rarely do.
$calc->loan_balance->(pmt => 2000, ir => 6.50, np => 360, pd => 12)
loan_balance calculates the balance on a loan that is being made in np equal payments, given that pd payments have already been made. You can also use this method to determine the amount of money left in an annuity that you are drawing down.
Return the payment amount, per period, of a loan. This is also known as amortizing. The ir, np, and pv fields must be set.
$calc->loan_size->(pmt => 2000, ir => 6.50, np => 360)
loan_size calculates the size of loan you can get based on the monthly payment you can afford.
Return the number of payments (term) of a loan given the interest rate ir, payment amount pmt and loan amount pv. The ir, pmt, and pv fields must be set.
$calc->simple_interest->(find => ir)
This works just like compound interest, but there is no consideration of np. With any 2 of pv, fv, and ir, you can always solve for the third.
Without arguments, the method will attempt to figure out what youd like to solve based on what attributes of the object have been defined. Usually, youll probably want to explicitly request what attribute youd like returned, which you can do using the second or third method.
POSIX c_type functions
(c_types might work under Windows. I really dont know. Id appreciate it if someome would let me know. If they dont, in a future release, Ill provide a runtime replacement for the POSIX functions so itll work on Win releases. )
By default, nothing.
If youd like to use a procedural interface, you can use Math::Financial qw(:standard).
Then you can call the methods as function, without an object reference, like
$term = loan_term(ir => 6.5, pmt => 1000, pv => 200000);
All of the methods are exported in this fashion, except for set and get; this just seemed too confusing.
You can still use the facility of set and get with the procedural interface (i.e., you can set the attributes and them use them for many different calculations), but you must call them as Math::Financial::set and Math::Financial::get.
Eric Fixler <email@example.com>, 1999
Add more equations! Send me equations and Ill put them in.
Larry Freeman, whose Financial Formulas Page http://ourworld.compuserve.com/homepages/Larry_Freeman/finance.htm was essential for this project.
Hey! <B>The above document had some coding errors, which are explained below:B>
Around line 33: Unknown directive: =over4 Around line 35: =item outside of any =over Around line 104: Unterminated C<...> sequence
|perl v5.20.3||FINANCIAL (3)||1999-09-15|