forked from c9s/bbgo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
debug.go
56 lines (43 loc) · 1.21 KB
/
debug.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package grid2
import (
"fmt"
"strings"
"github.com/sirupsen/logrus"
"github.com/c9s/bbgo/pkg/bbgo"
"github.com/c9s/bbgo/pkg/fixedpoint"
"github.com/c9s/bbgo/pkg/types"
)
func debugGrid(logger logrus.FieldLogger, grid *Grid, book *bbgo.ActiveOrderBook) {
var sb strings.Builder
sb.WriteString("================== GRID ORDERS ==================\n")
pins := grid.Pins
missingPins := scanMissingPinPrices(book, pins)
missing := len(missingPins)
for i := len(pins) - 1; i >= 0; i-- {
pin := pins[i]
price := fixedpoint.Value(pin)
sb.WriteString(fmt.Sprintf("%s -> ", price.String()))
existingOrder := book.Lookup(func(o types.Order) bool {
return o.Price.Eq(price)
})
if existingOrder != nil {
sb.WriteString(existingOrder.String())
switch existingOrder.Status {
case types.OrderStatusFilled:
sb.WriteString(" | 🔧")
case types.OrderStatusCanceled:
sb.WriteString(" | 🔄")
default:
sb.WriteString(" | ✅")
}
} else {
sb.WriteString("ORDER MISSING ⚠️ ")
if missing == 1 {
sb.WriteString(" COULD BE EMPTY SLOT")
}
}
sb.WriteString("\n")
}
sb.WriteString("================== END OF GRID ORDERS ===================")
logger.Infoln(sb.String())
}