xirr

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2021 License: ISC Imports: 4 Imported by: 0

README

PkgGoDev

Implementation of the XIRR function found in spreadsheet applications like LibreOffice Calc, for Go. Read the documentation for further details.

Install xirr with,

go get github.com/cskr/go-xirr

Use of this module is governed by the license that can be found in the LICENSE file.

Documentation

Overview

Package xirr implements the XIRR function found in spreadsheet applications like LibreOffice Calc.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidPayments = errors.New("negative and positive payments are required")

ErrInvalidPayments is returned by Compute calls when both positive and negative payments are not provided.

Functions

func Compute

func Compute(payments []Payment) (xirr float64, err error)

Compute calculates the internal rate of return of a series of irregular payments.

It tries to identify the rate of return using Newton's method with an initial guess of 0.1. If that does not provide a solution, it attempts with guesses from -0.99 to 0.99 in increments of 0.01 and returns NaN if that fails too.

Types

type Payment

type Payment struct {
	Date   time.Time
	Amount float64
}

A Payment represents a payment made or received on a particular date.

Jump to

Keyboard shortcuts

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