Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FV ¶
FV gets the present value, the interest rate (compounded annually if needed) and the number of periods and returns the future value.
Example ¶
presentValue := 100.0 interestRate := 0.07 periods := 10.0 compoundedAnnually := false fv := FV(presentValue, interestRate, compoundedAnnually, periods) fmt.Printf("FV is: %f", fv)
Output: FV is: 170.000000
func IRR ¶
IRR returns the Internal Rate of Return (IRR).
Example ¶
initialInvestment := 100.0 cashFlowYear1 := 39.0 cashFlowYear2 := 59.0 cashFlowYear3 := 55.0 cashFlowYear4 := 20.0 irr, err := IRR([]float64{-initialInvestment, cashFlowYear1, cashFlowYear2, cashFlowYear3, cashFlowYear4}) if err != nil { fmt.Println(err.Error()) return } fmt.Printf("IRR is: %f", irr)
Output: IRR is: 0.280948
func NPV ¶
NPV returns the NPV (Net Present Value) of a cash flow series given an interest rate r, or an error.
Example ¶
initialInvestment := 100.0 cashFlowYear1 := 39.0 cashFlowYear2 := 59.0 cashFlowYear3 := 55.0 cashFlowYear4 := 20.0 discountRate := 0.281 npv, err := NPV(discountRate, []float64{-initialInvestment, cashFlowYear1, cashFlowYear2, cashFlowYear3, cashFlowYear4}) if err != nil { fmt.Println(err.Error()) return } fmt.Printf("NPV is: %f", npv)
Output: NPV is: -0.008479
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.