mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 08:45:16 +00:00
grid2: fix upper price error
This commit is contained in:
parent
2fed98ea55
commit
34ab53303a
|
@ -40,13 +40,16 @@ func calculateArithmeticPins(lower, upper, spread, tickSize fixedpoint.Value) []
|
|||
var ts = tickSize.Float64()
|
||||
var prec = int(math.Round(math.Log10(ts) * -1.0))
|
||||
var pow10 = math.Pow10(prec)
|
||||
for p := lower; p.Compare(upper) <= 0; p = p.Add(spread) {
|
||||
for p := lower; p.Compare(upper.Sub(spread)) <= 0; p = p.Add(spread) {
|
||||
pp := math.Round(p.Float64()*pow10*10.0) / 10.0
|
||||
pp = math.Trunc(pp) / pow10
|
||||
pin := Pin(fixedpoint.NewFromFloat(pp))
|
||||
pins = append(pins, pin)
|
||||
}
|
||||
|
||||
// this makes sure there is no error at the upper price
|
||||
pins = append(pins, Pin(upper))
|
||||
|
||||
return pins
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user