From e1a882bbad42ba033a144ed2ec202e608163df70 Mon Sep 17 00:00:00 2001 From: c9s Date: Sat, 30 Oct 2021 18:42:34 +0800 Subject: [PATCH] add range detection methods --- pkg/strategy/shakegrid/grid.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pkg/strategy/shakegrid/grid.go b/pkg/strategy/shakegrid/grid.go index 4daa1c77b..1f968313f 100644 --- a/pkg/strategy/shakegrid/grid.go +++ b/pkg/strategy/shakegrid/grid.go @@ -41,6 +41,18 @@ func NewGrid(lower, upper, density fixedpoint.Value) *Grid { return grid } +func (g *Grid) Above(price fixedpoint.Value) bool { + return price > g.UpperPrice +} + +func (g *Grid) Below(price fixedpoint.Value) bool { + return price < g.LowerPrice +} + +func (g *Grid) OutOfRange(price fixedpoint.Value) bool { + return price < g.LowerPrice || price > g.UpperPrice +} + func (g *Grid) updatePinsCache() { for _, pin := range g.Pins { g.pinsCache[pin] = struct{}{}