NAME

App::FinanceUtils - Calculate present value (PV) from future value (FV), rate of return (r), and number of periods (n)

VERSION

This document describes version 0.001 of App::FinanceUtils (from Perl distribution App-FinanceUtils), released on 2017-03-13.

DESCRIPTION

This distribution contains some CLI's to do financial calculations:

# INSERT_EXECS_LIST

FUNCTIONS

calc_fv_future_value

Usage:

calc_fv_future_value(%args) -> any

Calculate future value (FV) from present value (PV), rate of return (r), and number of periods (n).

Examples:

  • Invest $100 at 6% annual return rate for 5 years:

    calc_fv_future_value(pv => 100, r => 6, n => 5); # -> 133.82255776
  • Invest $100 at 6% annual return rate for 5 years, simple interest:

    calc_fv_future_value(pv => 100, r => 6, n => 5, simple => 1); # -> 130

The formula is:

FV = PV*(1+r)^n

But if you use simple interest (--simple) where the interest is not compounded, the formula is:

FV = PV*(1+r*n)

This function is not exported.

Arguments ('*' denotes required arguments):

  • n* => float

    Number of periods.

  • pv* => float

    Present value.

  • r* => float

    Rate of return, in percent.

  • simple => bool

    Use simple interest (interest not compounded).

Return value: (any)

calc_fv_periods

Usage:

calc_fv_periods(%args) -> any

Calculate number of periods (n) from present value (FV), present value (PV), and return rate (r).

Examples:

  • Want to get $120 using $100 investment with annual 6% return rate, how many years must we wait?:

    calc_fv_periods(fv => 120, pv => 100, r => 6); # -> 3.12896813521953

The formula is:

n = ln(FV/PV) / ln(1+r)

This function is not exported.

Arguments ('*' denotes required arguments):

  • fv* => float

    Future value.

  • pv* => float

    Present value.

  • r* => float

    Return rate, in percentage.

Return value: (any)

calc_fv_present_value

Usage:

calc_fv_present_value(%args) -> any

Calculate present value (PV) from future value (FV), rate of return (r), and number of periods (n).

Examples:

  • Want to get $100 after 5 years at 6% annual return rate, how much to invest?:

    calc_fv_present_value(fv => 100, r => 6, n => 5); # -> 74.7258172866057
  • Want to get $100 after 5 years at 6% annual return rate, with simple interest, how much to invest?:

    calc_fv_present_value(fv => 100, r => 6, n => 5, simple => 1); # -> 76.9230769230769

The formula is:

PV = FV/(1+r)^n

But if you use simple interest (--simple) where the interest is not compounded, the formula is:

PV = FV/(1+r*n)

This function is not exported.

Arguments ('*' denotes required arguments):

  • fv* => float

    Future value.

  • n* => float

    Number of periods.

  • r* => float

    Rate of return, in percent.

  • simple => bool

    Use simple interest (interest not compounded).

Return value: (any)

calc_fv_return_rate

Usage:

calc_fv_return_rate(%args) -> any

Calculate return rate (r) from future value (FV), present value (PV), and number of periods (n).

Examples:

  • Want to get $120 in 5 years using $100 investment, what is the required return rate (in percentage)?:

    calc_fv_return_rate(fv => 120, pv => 100, n => 5); # -> 3.71372893366482

The formula is:

r = (FV/PV)^(1/n) - 1

This function is not exported.

Arguments ('*' denotes required arguments):

  • fv* => float

    Future value.

  • n* => float

    Number of periods.

  • pv* => float

    Present value.

Return value: (any)

HOMEPAGE

Please visit the project's homepage at https://metacpan.org/release/App-FinanceUtils.

SOURCE

Source repository is at https://github.com/perlancar/perl-App-FinanceUtils.

BUGS

Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=App-FinanceUtils

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.

AUTHOR

perlancar <perlancar@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2017 by perlancar@cpan.org.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.