financecalculator2025.contribution

Functions

calculate_contribution(principal, future_value, ...)

Calculates the contribution required per period to achieve a specified future value

Module Contents

financecalculator2025.contribution.calculate_contribution(principal, future_value, annual_rate, n_periods)[source]

Calculates the contribution required per period to achieve a specified future value or pay off a loan, considering the possibility of depositing or withdrawing funds.

Parameters:
  • principal (float) – The initial loan amount or investment (present value). For loans, this should be a negative value (e.g., -1000 for a loan of 1000).

  • future_value (float) – The target future value (amount remaining after n_periods). For loans, this is usually 0.

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

  • n_periods (int) – Total number of periods (e.g., months or years). Must be a positive integer.

Returns:

The payment amount per period required to reach the specified future value or pay off the loan. A positive value represents an inflow (e.g., making deposits), while a negative value represents an outflow (e.g., withdrawals or loan repayments).

Return type:

float

Raises:

ValueError – If any input is invalid, such as non-numeric types or invalid ranges.

Warning

UserWarning

Warnings for potentially unusual inputs.

Examples

>>> calculate_contribution(principal=0, future_value=10000, annual_rate=5, n_periods=120)