add range detection methods

This commit is contained in:
c9s 2021-10-30 18:42:34 +08:00 committed by c9s
parent 47fbe3a3ed
commit e1a882bbad
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -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{}{}