Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
1836b6bcf9
|
|||
|
83edcc7c62
|
|||
|
bd6c0a4d25
|
|||
|
f10c652292
|
7
.github/workflows/go.yml
vendored
7
.github/workflows/go.yml
vendored
@@ -22,11 +22,8 @@ jobs:
|
||||
dep ensure
|
||||
fi
|
||||
|
||||
- name: Install golangci-lint
|
||||
run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.22.2
|
||||
|
||||
- name: Lint
|
||||
run: /home/runner/go/bin/golangci-lint run
|
||||
- name: GolangCI-Lint
|
||||
uses: Mushus/golangci-linter@v1.1.2
|
||||
|
||||
- name: Test
|
||||
run: go test -v .
|
||||
|
||||
@@ -3,6 +3,10 @@
|
||||
|
||||
Goxirr is a simple implementation of a function for calculating the Internal Rate of Return for irregular cash flow (XIRR).
|
||||
|
||||
## Links
|
||||
- [Wikipedia](https://en.wikipedia.org/wiki/Internal_rate_of_return)
|
||||
- [Excel support](https://support.office.com/en-us/article/XIRR-function-DE1242EC-6477-445B-B11B-A303AD9ADC9D)
|
||||
|
||||
## Example
|
||||
|
||||
```go
|
||||
|
||||
6
xirr.go
6
xirr.go
@@ -9,16 +9,16 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
//A Transaction represents a single transaction from a series of irregular payments.
|
||||
//A Transaction represent a single transaction from a series of irregular payments.
|
||||
type Transaction struct {
|
||||
Date time.Time
|
||||
Cash float64
|
||||
}
|
||||
|
||||
//Transactions represents a cash flow consisting of individual transactions
|
||||
//Transactions represent a cash flow consisting of individual transactions
|
||||
type Transactions []Transaction
|
||||
|
||||
//Xirr return the Internal Rate of Return (IRR) for an irregular series of cash flows (XIRR)
|
||||
//Xirr returns the Internal Rate of Return (IRR) for an irregular series of cash flows (XIRR)
|
||||
func Xirr(transactions Transactions) float64 {
|
||||
var years []float64
|
||||
for _, t := range transactions {
|
||||
|
||||
Reference in New Issue
Block a user