Exemplo n.º 1
0
def equalsAmortization(pv, i, n):
    """ This method will implement the amortization based on the constant amortization system for PRICE payment """
    
    if i == None or pv == None or n == None or i == 0 or pv == 0 or n == 0:
            raise PyFinancialLibraryException, "Some values for calculating amortization have not been provided."
    realRate = i / Decimal('100.0')
    
    #Getting constant amortization
    amortization = convertToDecimal(pv) / n
    
    #Storing information for first period, containing for each period: pmt, interest, acumulated interest, amortization, acumulated amortization and amount to be payed
    amortizationPlan = AmortizationTable(n)
    amortizationPlan.setTableLine(0, Decimal('0.0'), Decimal('0.0'), Decimal('0.0'), Decimal('0.0'), Decimal('0.0'), pv)
    
    #Calculating information for other periods
    for index in xrange(1, n+1, 1):
        lastLine = index-1
        
        lastAmountToBePayed = amortizationPlan.getNewAmountToBePayed(lastLine)
        acumulatedAmortization = amortizationPlan.getNewAcumulatedAmortization(lastLine)
        acumulatedInterest = amortizationPlan.getNewAcumulatedInterest(lastLine)
        
        interest = (pv * realRate) - (amortization * realRate * (index-1))
        payment = amortization + interest
        
        newAmountToBePayed = lastAmountToBePayed - amortization
        newAcumulatedAmortization = acumulatedAmortization + amortization
        newAcumulatedInterest = acumulatedInterest + interest
        
        if newAmountToBePayed <= TOLERANCE:
            newAmountToBePayed = Decimal('0.0')
            
        amortizationPlan.setTableLine(index, payment, interest, newAcumulatedInterest, amortization, newAcumulatedAmortization,  newAmountToBePayed)   
        
    return amortizationPlan
Exemplo n.º 2
0
def frenchAmortization(pv, i, n):
    """ This method will implement the amortization based on the french system for PRICE payment """
    
    if i == None or pv == None or n == None or i == Decimal("0") or pv == Decimal("0") or n == Decimal("0"):
        raise PyFinancialLibraryException, "Some values for calculating amortization have not been provided." 
    realRate = i / Decimal('100.0')
    
    #Getting pmt
    pmt = calculateFrenchPmt(pv, realRate, n)
    
    #Storing information for first period, containing for each period: pmt, interest, acumulated interest, amortization, acumulated amortization and amount to be payed
    amortizationPlan = AmortizationTable(n)
    amortizationPlan.setTableLine(0, Decimal('0.0'), Decimal('0.0'), Decimal('0.0'), Decimal('0.0'), Decimal('0.0'), pv)
    
    #Calculating information for other periods
    for index in xrange(1, n+1, 1):
        lastLine = index-1
        
        lastAmountToBePayed = amortizationPlan.getNewAmountToBePayed(lastLine)
        acumulatedAmortization = amortizationPlan.getNewAcumulatedAmortization(lastLine)
        acumulatedInterest = amortizationPlan.getNewAcumulatedInterest(lastLine)
        
        amortization = (pmt - (pv* realRate) ) * (realRate+1)**(index-1)
        interest = pmt - amortization
        amountToBePayed = lastAmountToBePayed - amortization
        newAcumulatedAmortization = acumulatedAmortization + amortization
        newAcumulatedInterest = acumulatedInterest + interest
        
        if amountToBePayed <= TOLERANCE:
            amountToBePayed = Decimal('0.0')
        
        amortizationPlan.setTableLine(index, pmt, interest, newAcumulatedInterest, amortization, newAcumulatedAmortization, amountToBePayed)
     
    return amortizationPlan   
Exemplo n.º 3
0
def equalsAmortization(pv, i, n):
    """ This method will implement the amortization based on the constant amortization system for PRICE payment """

    if i == None or pv == None or n == None or i == 0 or pv == 0 or n == 0:
        raise PyFinancialLibraryException, "Some values for calculating amortization have not been provided."
    realRate = i / Decimal('100.0')

    #Getting constant amortization
    amortization = convertToDecimal(pv) / n

    #Storing information for first period, containing for each period: pmt, interest, acumulated interest, amortization, acumulated amortization and amount to be payed
    amortizationPlan = AmortizationTable(n)
    amortizationPlan.setTableLine(0, Decimal('0.0'), Decimal('0.0'),
                                  Decimal('0.0'), Decimal('0.0'),
                                  Decimal('0.0'), pv)

    #Calculating information for other periods
    for index in xrange(1, n + 1, 1):
        lastLine = index - 1

        lastAmountToBePayed = amortizationPlan.getNewAmountToBePayed(lastLine)
        acumulatedAmortization = amortizationPlan.getNewAcumulatedAmortization(
            lastLine)
        acumulatedInterest = amortizationPlan.getNewAcumulatedInterest(
            lastLine)

        interest = (pv * realRate) - (amortization * realRate * (index - 1))
        payment = amortization + interest

        newAmountToBePayed = lastAmountToBePayed - amortization
        newAcumulatedAmortization = acumulatedAmortization + amortization
        newAcumulatedInterest = acumulatedInterest + interest

        if newAmountToBePayed <= TOLERANCE:
            newAmountToBePayed = Decimal('0.0')

        amortizationPlan.setTableLine(index, payment, interest,
                                      newAcumulatedInterest, amortization,
                                      newAcumulatedAmortization,
                                      newAmountToBePayed)

    return amortizationPlan
Exemplo n.º 4
0
def frenchAmortization(pv, i, n):
    """ This method will implement the amortization based on the french system for PRICE payment """

    if i == None or pv == None or n == None or i == Decimal(
            "0") or pv == Decimal("0") or n == Decimal("0"):
        raise PyFinancialLibraryException, "Some values for calculating amortization have not been provided."
    realRate = i / Decimal('100.0')

    #Getting pmt
    pmt = calculateFrenchPmt(pv, realRate, n)

    #Storing information for first period, containing for each period: pmt, interest, acumulated interest, amortization, acumulated amortization and amount to be payed
    amortizationPlan = AmortizationTable(n)
    amortizationPlan.setTableLine(0, Decimal('0.0'), Decimal('0.0'),
                                  Decimal('0.0'), Decimal('0.0'),
                                  Decimal('0.0'), pv)

    #Calculating information for other periods
    for index in xrange(1, n + 1, 1):
        lastLine = index - 1

        lastAmountToBePayed = amortizationPlan.getNewAmountToBePayed(lastLine)
        acumulatedAmortization = amortizationPlan.getNewAcumulatedAmortization(
            lastLine)
        acumulatedInterest = amortizationPlan.getNewAcumulatedInterest(
            lastLine)

        amortization = (pmt - (pv * realRate)) * (realRate + 1)**(index - 1)
        interest = pmt - amortization
        amountToBePayed = lastAmountToBePayed - amortization
        newAcumulatedAmortization = acumulatedAmortization + amortization
        newAcumulatedInterest = acumulatedInterest + interest

        if amountToBePayed <= TOLERANCE:
            amountToBePayed = Decimal('0.0')

        amortizationPlan.setTableLine(index, pmt, interest,
                                      newAcumulatedInterest, amortization,
                                      newAcumulatedAmortization,
                                      amountToBePayed)

    return amortizationPlan