Crate financial

source ·
Expand description

Financial

Financial is a collection of finance calculations mimicking some of Excel Financial Functions interface.

What makes this crate different

It supports both periodic and scheduled computation for IRR and NPV.

IRR and NPV functions are faster since powers are pre-computed iteratively instead of using power function multiple times. Take this with a grain of salt since no benches tests are offered at the moment.

Supported Functions

  • FV(Rate, Nper, Pmt, Pv, Pmt_is_due)
  • PV(Rate, Nper, Pmt, Fv, Pmt_is_due)
  • NPV(Rate, values)
  • XNPV(Rate), values, dates)
  • IRR(values)
  • XIRR(values, dates)
  • MIRR(values, finance_rate, reinvest_rate)

Future Work

  • Add More Functions (NPER, PMT, Rate, effect)

Testing

  • This crate has over 180 test case, most of them are compared to Excel outputs.
  • XIRR is not compared against Excel, since Excel XIRR doesn’t always converge to the correct answer and often produce the wrong answer of 0.000000002980. Instead XIRR are tested by using the XIRR to produce a zero XNPV value.
  • Note that the precision used for equality of floating points is 1e-7

Contribution

  • Using the crate and providing feedback or pointing out any issues.
  • Adding more test cases is encouraged.
  • Any contribution that serves the crate is welcome.

Github

Buy Me A Coffee

Modules

Functions

Calculates the future value of an investment based on a constant interest rate. You can use FV with either periodic, constant payments, or a single lump sum payment.
Calculates the internal rate of return for a series of cash flows occurring at regular interval represented by the numbers in values.
Returns the modified internal rate of return for a series of periodic cash flows. MIRR considers both the cost of the investment and the interest received on reinvestment of cash.
Calculates the net present value of an investment by using a discount rate and a series of future payments (negative values) and income (positive values).
Calculates the present value of a loan or an investment, based on a constant interest rate. You can use PV with either periodic, constant payments (such as a mortgage or other loan), or a future value that’s your investment goal.
Returns the internal rate of return for a schedule of cash flows that is not necessarily periodic
Returns the net present value for a schedule of cash flows that is not necessarily periodic.