bpi growth is also just compounding interest but ignore for now
This commit is contained in:
@@ -1,14 +1,16 @@
|
||||
package ledger
|
||||
|
||||
import (
|
||||
"slices"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestRegisterPrediction(t *testing.T) {
|
||||
t.Run("contribution", func(t *testing.T) {
|
||||
input := newTestRegister()
|
||||
|
||||
got, err := RegisterWithContributionPrediction(input, .12)
|
||||
got, err := RegisterWithContributionPrediction(input, time.Hour*24*365)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -26,7 +28,7 @@ func TestRegisterPrediction(t *testing.T) {
|
||||
t.Run("compounding interest", func(t *testing.T) {
|
||||
input := newTestRegister()
|
||||
|
||||
got, err := RegisterWithCompoundingInterestPrediction(input, 1, "X", .04)
|
||||
got, err := RegisterWithCompoundingInterestPrediction(input, time.Hour*24*365, "X", .04)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -35,13 +37,38 @@ func TestRegisterPrediction(t *testing.T) {
|
||||
if len(got) <= len(input) {
|
||||
t.Error(len(got))
|
||||
}
|
||||
t.Error("not impl")
|
||||
|
||||
for _, date := range got.Dates() {
|
||||
for name, balance := range got[date] {
|
||||
t.Logf("%s | %s %s", date, name, balance.Debug())
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestBPIPrediction(t *testing.T) {
|
||||
t.Run("fixed growth", func(t *testing.T) {
|
||||
t.Error("not impl")
|
||||
bpis := BPIs{
|
||||
USD: BPI{
|
||||
"2001-01": -1000,
|
||||
"2001-02": 100,
|
||||
},
|
||||
}
|
||||
|
||||
got, err := BPIsWithFixedGrowthPrediction(bpis, time.Hour*24*365, string(USD), 0.06)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
dates := []string{}
|
||||
for d := range got[USD] {
|
||||
dates = append(dates, d)
|
||||
}
|
||||
slices.Sort(dates)
|
||||
|
||||
for _, d := range dates {
|
||||
t.Logf("%s | %s %.2f", USD, d, got[USD][d])
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user