bpis predictFixedGrowth fixed
All checks were successful
cicd / ci (push) Successful in 1m15s

This commit is contained in:
Bel LaPointe
2025-06-16 18:12:11 -06:00
parent fe7c3a9682
commit 6aa549cb02

View File

@@ -297,6 +297,11 @@ func (router Router) APIReg(w http.ResponseWriter, r *http.Request) {
register := deltas.Register()
predicted := make(ledger.Register)
bpis, err := router.bpis()
if err != nil {
panic(err)
}
if predictionMonths, err := strconv.ParseInt(r.URL.Query().Get("predictionMonths"), 10, 16); err == nil && predictionMonths > 0 {
window := time.Hour * 24.0 * 365.0 / 12.0 * time.Duration(predictionMonths)
// TODO whatif
@@ -334,10 +339,6 @@ func (router Router) APIReg(w http.ResponseWriter, r *http.Request) {
if err != nil {
panic(err)
}
bpis, err := router.bpis()
if err != nil {
panic(err)
}
bpis, err = ana.BPIsWithFixedGrowthPrediction(bpis, window, currency, rate)
if err != nil {
panic(err)
@@ -346,10 +347,6 @@ func (router Router) APIReg(w http.ResponseWriter, r *http.Request) {
}
if r.URL.Query().Get("bpi") == "true" {
bpis, err := router.bpis()
if err != nil {
panic(err)
}
register = register.WithBPIs(bpis)
predicted = predicted.WithBPIs(bpis)
}