## finance 0.1.0

The fundamental package for financial computing with Dart.

This package provides a set of high-level functions and classes that make it easy to compute financial ratios, patterned after spreadsheet computations. It's platform-independent, supports iOS and Android.

# Using #

The easiest way to use this library is via the top-level functions. They allow you to make financial calculations with minimal hassle:

## Future Value calculation #

What is the future value after 30 years of saving \$1000 now, with an additional monthly savings of \$100. Assume the interest rate is 7% (annually) compounded monthly?

``````  print(Finance.fv(rate: 0.07 / 12, nper: 30 * 12, pmt: -100, pv: -1000));
``````

Thus, saving \$1000 today and then \$100 a month at 7% annual interest leads to \$130,113.59 available to spend in 30 years from now.

## Payments calculation #

What is the monthly payment needed to pay off a \$100,000 loan in 10 years at an annual interest rate of 2.5%?

``````  print(Finance.pmt(rate: 0.025 / 12, nper: 10 * 12, pv: 100000));
``````

Thus, in order to pay-off (i.e., have a future-value of 0) the \$100,000 obtained today, a monthly payment of \$942.69 would be required. Note that this example illustrates usage of future value having a default value of 0.

## Number of period calculation #

If we only had \$500/month to pay towards the loan, how long would it take to pay-off a loan of \$100,000 at 3% annual interest?

``````   print(Finance.nper(rate: 0.03 / 12, pmt: -500, pv: 10000));
``````

So, over 20 months would be required to pay off the loan.

## Principal and Interest payment calculation #

What is the amortization schedule for a 1 year loan of \$5000 at 10% interest per year compounded monthly? And the total interest payments?

``````  final Iterable<Map<String, num>> payments =
List<int>.generate(12, (int index) => index + 1).map((int per) =>
<String, num>{
'per': per,
'pmt': Finance.pmt(rate: 0.1 / 12, nper: 1 * 12, pv: 5000),
'ppmt':
Finance.ppmt(rate: 0.1 / 12, per: per, nper: 1 * 12, pv: 5000),
'ipmt':
Finance.ipmt(rate: 0.1 / 12, per: per, nper: 1 * 12, pv: 5000),
});

payments.forEach(print);

final num interestPaid =
payments.fold(0, (num p, Map<String, num> c) => p + c['ipmt']);
print(interestPaid);
``````

Thus, the total interest paid are close to \$275.

## Present Value calculation #

What is the present value (e.g., the initial investment) of an investment that needs to total \$20,000 after 10 years of saving \$100 every month? Assume the interest rate is 7% (annually) compounded monthly.

``````  print(Finance.pv(rate: 0.05 / 12, nper: 10 * 12, pmt: -100, fv: 15692.93));
``````

So, to end up with \$20,000 in 10 years saving \$100 a month at 7% annual interest, one's initial deposit should be \$1,339.28.

## Interest rate calculation #

What is the interest rate for a \$8,000 loan if the loan term is 5 years and and payments are \$152.50 monthly?

``````  print(Finance.rate(nper: 60, pmt: -152.5, pv: 8000, fv: 0));
``````

The calculated interest rate is 0.45% monthly, or 5.42% annually.

## Net present value calculation #

What is the Net Present Value of an investment that requires \$15000 deposit now and then makes the following withdrawals at regular (fixed) intervals: 1500, 2500, 3500, 4500, 6000?. Assuming the ending value is 0 and a discount rate of 5%.

``````  print(Finance.npv(rate: 0.05, values: <num>[-15000, 1500, 2500, 3500, 4500, 6000]));
``````

So, this investment is worth \$122.894 today.

## Internal Rate of Return calculation #

What is the Internal Rate of return of an investment that requires \$15000 deposit now and then makes the following withdrawals at regular (fixed) intervals: 1500, 2500, 3500, 4500, 6000?. Assuming the ending value is 0.

``````  print(Finance.irr(rate: 0.05, values: <num>[-15000, 1500, 2500, 3500, 4500, 6000]));
``````

So, the IRR of this investment is 5.24%.

## [0.1.0] - 3/9/19 #

• Added nper, ppmt, ipmt, pv, rate, npv and irr. Stibilize interfaces

## [0.0.5] - 2/9/19 #

• Extracted quote retrieval to finance_quote package. Added fv and pmt functions.

## [0.0.4] - 1/9/19 #

• Documentation fixes.

## [0.0.3] - 1/9/19 #

• Documentation fixes.

## [0.0.2] - 1/9/19 #

• Documentation fixes.

## [0.0.1] - 1/9/19 #

• Initial implementation of finance plugin.

example/main.dart

``````import 'package:finance/finance.dart';

void main(List<String> arguments) {
// What is the future value after 30 years of saving \$1000 now, with
// an additional monthly savings of \$100.  Assume the interest rate is
// 7% (annually) compounded monthly?
print(Finance.fv(rate: 0.07 / 12, nper: 30 * 12, pmt: -100, pv: -1000));

// What is the monthly payment needed to pay off a \$100,000 loan in 10
// years at an annual interest rate of 2.5%?
print(Finance.pmt(rate: 0.025 / 12, nper: 10 * 12, pv: 100000));

// If you only had \$500/month to pay towards the loan, how long would it take
// to pay-off a loan of \$10,000 at 3% annual interest?
print(Finance.nper(rate: 0.03 / 12, pmt: -500, pv: 10000));

// What is the amortization schedule for a 1 year loan of \$5000 at 10%
// interest per year compounded monthly?
final Iterable<Map<String, num>> payments =
List<int>.generate(12, (int index) => index + 1).map((int per) =>
<String, num>{
'per': per,
'pmt': Finance.pmt(rate: 0.1 / 12, nper: 1 * 12, pv: 5000),
'ppmt':
Finance.ppmt(rate: 0.1 / 12, per: per, nper: 1 * 12, pv: 5000),
'ipmt':
Finance.ipmt(rate: 0.1 / 12, per: per, nper: 1 * 12, pv: 5000),
});

payments.forEach(print);
final num interestPaid =
payments.fold(0, (num p, Map<String, num> c) => p + c['ipmt']);
print(interestPaid);

//  What is the present value (e.g., the initial investment) of an investment that
//  needs to total \$20000 after 10 years of saving \$100 every month?  Assume the
//  interest rate is 7% (annually) compounded monthly.
print(Finance.pv(rate: 0.07 / 12, nper: 10 * 12, pmt: -100, fv: 20000));

//  What is the interest rate for a \$8,000 loan if the loan term is 5 years and
//  and payments are \$152.50 monthly?
print(Finance.rate(nper: 60, pmt: -152.5, pv: 8000, fv: 0));

//  What is the Internal Rate of return of an investment that requires \$15000 deposit now
//  and then makes the following withdrawals at regular (fixed)
//  intervals:  1500, 2500, 3500, 4500, 6000?.  Assuming the ending value is 0.
print(Finance.irr(values: <num>[-15000, 1500, 2500, 3500, 4500, 6000]));

//  What is the Net Present Value of an investment that requires \$15000 deposit now
//  and then makes the following withdrawals at regular (fixed)
//  intervals:  1500, 2500, 3500, 4500, 6000?.  Assuming the ending value is 0
//  and a discount rate of 5%.

print(Finance.npv(
rate: 0.05, values: <num>[-15000, 1500, 2500, 3500, 4500, 6000]));
}
``````

## Use this package as a library

### 1. Depend on it

``````
dependencies:
finance: ^0.1.0

``````

### 2. Install it

You can install packages from the command line:

with pub:

``````
\$ pub get

``````

with Flutter:

``````
\$ flutter pub get

``````

Alternatively, your editor might support `pub get` or `flutter pub get`. Check the docs for your editor to learn more.

### 3. Import it

Now in your Dart code, you can use:

``````
import 'package:finance/finance.dart';
``````
 Popularity: Describes how popular the package is relative to other packages. [more] 76 Health: Code health derived from static analysis. [more] 100 Maintenance: Reflects how tidy and up-to-date the package is. [more] 98 Overall: Weighted score of the above. [more] 87

We analyzed this package on Apr 8, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

• Dart: 2.7.1
• pana: 0.13.6

#### Maintenance suggestions

The package description is too short. (-2 points)

Add more detail to the `description` field of `pubspec.yaml`. Use 60 to 180 characters to describe the package, what it does, and its target use case.

#### Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
meta ^1.1.7 1.1.8
Dev dependencies
mockito ^4.1.0
pedantic ^1.8.0+1
test >=1.3.0 <1.6.8