From ea733f560c83c9db56ce3ce733acc4e42edf4326 Mon Sep 17 00:00:00 2001 From: bel Date: Fri, 27 Oct 2023 08:00:14 -0600 Subject: [PATCH] maybe --- cmd/clitest/main.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/cmd/clitest/main.go b/cmd/clitest/main.go index 046b5c9..cb3661b 100644 --- a/cmd/clitest/main.go +++ b/cmd/clitest/main.go @@ -86,6 +86,26 @@ func main() { window := time.Hour * 24.0 * 365.0 / 12.0 * time.Duration(predictionMonths) // TODO whatif // TODO ana.Prediction + prediction := make(ana.Prediction, 0) + for _, spec := range r.URL.Query()["prediction"] { + idx := strings.Index(spec, "=") + k := spec[:idx] + fields := strings.Fields(spec[idx+1:]) + switch k { + case "interest": + apy, err := strconv.ParseFloat(fields[2], 64) + if err != nil { + panic(err) + } + prediction = append(prediction, ana.NewInterestPredictor(fields[0], fields[1], apy)) + case "contributions": + prediction = append(prediction, ana.NewContributionPredictor(register)) + default: + panic(k) + } + } + predicted := prediction.Predict(register, window) + register.PushAll(predicted) // TODO draw line separately for _, currencyRate := range r.URL.Query()["predictFixedGrowth"] { currency := strings.Split(currencyRate, "=")[0] rate, err := strconv.ParseFloat(strings.Split(currencyRate, "=")[1], 64)