main
bel 2023-10-27 08:00:14 -06:00
parent bbe4b468ef
commit ea733f560c
1 changed files with 20 additions and 0 deletions

View File

@ -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)