From 04a7c7a2cc3c70813fd3f522784d7ca7fbea1bd5 Mon Sep 17 00:00:00 2001 From: c9s Date: Tue, 10 Nov 2020 16:55:35 +0800 Subject: [PATCH] add stddev accessor --- pkg/indicator/boll.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/indicator/boll.go b/pkg/indicator/boll.go index b0692ddd1..3fa5719c8 100644 --- a/pkg/indicator/boll.go +++ b/pkg/indicator/boll.go @@ -54,6 +54,14 @@ func (inc *BOLL) LastDownBand() float64 { return inc.DownBand[len(inc.DownBand)-1] } +func (inc *BOLL) LastStdDev() float64 { + if len(inc.StdDev) == 0 { + return 0.0 + } + + return inc.StdDev[len(inc.StdDev)-1] +} + func (inc *BOLL) LastSMA() float64 { return inc.SMA[len(inc.SMA)-1] }