4 Commits

Author SHA1 Message Date
1836b6bcf9 Add linter actions 2020-01-22 15:43:54 +03:00
83edcc7c62 Add linter actions 2020-01-22 15:42:10 +03:00
bd6c0a4d25 Fix typo 2020-01-21 12:50:47 +03:00
f10c652292 Add links to README 2020-01-17 14:29:13 +03:00
3 changed files with 9 additions and 8 deletions

View File

@@ -22,11 +22,8 @@ jobs:
dep ensure dep ensure
fi fi
- name: Install golangci-lint - name: 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 uses: Mushus/golangci-linter@v1.1.2
- name: Lint
run: /home/runner/go/bin/golangci-lint run
- name: Test - name: Test
run: go test -v . run: go test -v .

View File

@@ -3,6 +3,10 @@
Goxirr is a simple implementation of a function for calculating the Internal Rate of Return for irregular cash flow (XIRR). 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 ## Example
```go ```go

View File

@@ -9,16 +9,16 @@ import (
"time" "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 { type Transaction struct {
Date time.Time Date time.Time
Cash float64 Cash float64
} }
//Transactions represents a cash flow consisting of individual transactions //Transactions represent a cash flow consisting of individual transactions
type Transactions []Transaction 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 { func Xirr(transactions Transactions) float64 {
var years []float64 var years []float64
for _, t := range transactions { for _, t := range transactions {