Skip to main content

luna.financial.annuity_calculator

ComparisonType Objects

@enum.unique
class ComparisonType(enum.Enum)

Enum for specifying comparison types in loan calculations.

Values:

  • RELATIVE_VALUE: Represents a relative value comparison.
  • ACTUAL_VALUE: Represents an actual value comparison.
  • ABSOLUTE_VALUE: Represents an absolute value comparison.

LastPaymentTreatment Objects

class LastPaymentTreatment(LunaModel)

Model defining how the last payment in a loan is treated.

Attributes:

  • treatment_type (str): Type of the last payment treatment.
  • threshold (Decimal): Threshold for determining the treatment type.
  • writedown_amount (Decimal): Amount for writedown.

RepaymentDetails Objects

class RepaymentDetails(LunaModel)

Model capturing details of loan repayments.

Attributes:

  • processing_date (date): The date when the repayment was processed.
  • repayment_due_date (date): The due date for the repayment.
  • repayment_amount (Decimal): The total repayment amount.
  • interest_payment (Decimal): The interest payment portion of the repayment.
  • capital_payment (Decimal): The capital payment portion of the repayment.
  • opening_balance (Decimal): The opening balance before the repayment.
  • closing_balance (Decimal): The closing balance after the repayment.
  • previous_closing_balance (Decimal): The previous closing balance before this repayment.

calc_annuity

def calc_annuity(term: int, payment_period_rate: Decimal,
balance: Decimal) -> SixteenDecimal

Calculates the annuity payment for a loan based on term, rate, and balance.

Arguments:

  • term (int): The term length of the loan.
  • payment_period_rate (Decimal): The payment period interest rate.
  • balance (Decimal): The initial loan balance.

Returns:

  • SixteenDecimal: The calculated annuity payment.

solve_for_term

def solve_for_term(target_annuity: Decimal, balance: Decimal,
payment_period_rate: Decimal) -> int | None

Determines the term length for a loan given target annuity, balance, and rate.

Arguments:

  • target_annuity (Decimal): The target annuity payment.
  • balance (Decimal): The initial loan balance.
  • payment_period_rate (Decimal): The payment period interest rate.

Returns:

  • int | None: The calculated term length or None if it cannot be determined.