compoundInterest

package module
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 13, 2021 License: MIT Imports: 2 Imported by: 0

README

compound-interest

Install
go get "github.com/evgeny-klyopov/compound-interest"
Usage
import (
    "fmt"
    "github.com/evgeny-klyopov/compound-interest"
    "time"
)
func main() {
    date, _ := time.Parse("2006-01-02", "2020-12-12")
    
    for monthNumber, row := range compoundInterest.New(compoundInterest.Params{
    	DateStart:                                date,
    	InvestmentTermInYears:                    2,
    	PercentRate:                              10,
    	InitialPayment:                           50000,
    	MonthlyPayment:                           30000,
    	AnnualPercentageIncreaseInMonthlyPayment: 15,
    	AvgPercentDividend:                       4,
        AnnualPercentageIncreaseDividend:         5,
    }).Calculate() {
        fmt.Printf(
            "monthNumber = %v, " +
                "date = %s, " +
                "monthlyPayment = %f, " +
                "AvgPercentDividend = %f, " +
                "Amount = %f, " +
                "Dividend = %f\n",
            monthNumber + 1,
            row.Date.Format("2006 Jan"),
            row.MonthlyPayment,
            row.AvgPercentDividend,
            row.Amount,
            row.MonthlyDividend,
        )
    }       
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Params

type Params struct {
	DateStart                                time.Time `json:"date_start"`
	InvestmentTermInYears                    float64   `json:"investment_term_in_years"`
	PercentRate                              float64   `json:"percent_rate"`
	InitialPayment                           float64   `json:"initial_payment"`
	MonthlyPayment                           float64   `json:"monthly_payment"`
	AnnualPercentageIncreaseInMonthlyPayment float64   `json:"annual_percentage_increase_in_monthly_payment"`
	AvgPercentDividend                       float64   `json:"avg_percent_dividend"`
	AnnualPercentageIncreaseDividend         float64   `json:"annual_percentage_increase_dividend"`
}

type Prediction

type Prediction struct {
	Date               time.Time
	Amount             float64
	MonthlyDividend    float64
	MonthlyPayment     float64
	AvgPercentDividend float64
}

type Predictor

type Predictor interface {
	Calculate() []Prediction
	// contains filtered or unexported methods
}

func New

func New(params Params) Predictor

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL