financecalculator2025.present_value

Functions

present_value(principal, annual_rate, n_periods[, ...])

Calculates the present value of an investment or loan, accounting for optional contributions.

Module Contents

financecalculator2025.present_value.present_value(principal, annual_rate, n_periods, contribution=0)[source]

Calculates the present value of an investment or loan, accounting for optional contributions.

Parameters:
  • principal (float) – The initial investment or loan amount.

  • annual_rate (float) – Annual interest rate (as a percentage, e.g., 5 for 5%).

  • n_periods (int) – Total number of periods (in months), a non-zero positive integer.

  • contribution (float, optional) – Payment made per period (monthly contributions). Defaults to 0 if not provided.

Returns:

A DataFrame containing the following columns:
  • ’Present Value’: The present value of the investment or loan.

  • ’Principal’: The initial investment or loan amount.

  • ’Contributions’: Total amount contributed over the investment period.

  • ’Interest Saved’: The amount of interest avoided by paying a lump sum today instead

    of spreading payments over time.

Return type:

pandas.DataFrame

Raises:
  • TypeError – If any of principal, annual_rate, n_periods, or contribution is not a float or int.

  • ValueError – If n_periods is not positive. If annual_rate is negative.

Warning

UserWarning

If annual_rate is 0, the present value will not include any interest effects. If annual_rate is unusually low (<1), indicating the user may have entered a percentage instead of a decimal. If n_periods is unusually low (<6), suggesting the user may have entered years instead of months.

Examples

>>> present_value(principal=1000, annual_rate=5, n_periods=120, contribution=100)