mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
grid2: use string builder for debugGrid
This commit is contained in:
parent
67d84b9716
commit
9d218d93ac
|
@ -2,6 +2,7 @@ package grid2
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/c9s/bbgo/pkg/bbgo"
|
||||
"github.com/c9s/bbgo/pkg/fixedpoint"
|
||||
|
@ -9,7 +10,9 @@ import (
|
|||
)
|
||||
|
||||
func debugGrid(grid *Grid, book *bbgo.ActiveOrderBook) {
|
||||
fmt.Println("================== GRID ORDERS ==================")
|
||||
var sb strings.Builder
|
||||
|
||||
sb.WriteString("================== GRID ORDERS ==================\n")
|
||||
|
||||
pins := grid.Pins
|
||||
missingPins := scanMissingPinPrices(book, pins)
|
||||
|
@ -19,30 +22,33 @@ func debugGrid(grid *Grid, book *bbgo.ActiveOrderBook) {
|
|||
pin := pins[i]
|
||||
price := fixedpoint.Value(pin)
|
||||
|
||||
fmt.Printf("%s -> ", price.String())
|
||||
sb.WriteString(fmt.Sprintf("%s -> ", price.String()))
|
||||
|
||||
existingOrder := book.Lookup(func(o types.Order) bool {
|
||||
return o.Price.Eq(price)
|
||||
})
|
||||
|
||||
if existingOrder != nil {
|
||||
fmt.Printf("%s", existingOrder.String())
|
||||
sb.WriteString(fmt.Sprintf("%s", existingOrder.String()))
|
||||
|
||||
switch existingOrder.Status {
|
||||
case types.OrderStatusFilled:
|
||||
fmt.Printf(" | 🔧")
|
||||
sb.WriteString(" | 🔧")
|
||||
case types.OrderStatusCanceled:
|
||||
fmt.Printf(" | 🔄")
|
||||
sb.WriteString(" | 🔄")
|
||||
default:
|
||||
fmt.Printf(" | ✅")
|
||||
sb.WriteString(" | ✅")
|
||||
}
|
||||
} else {
|
||||
fmt.Printf("ORDER MISSING ⚠️ ")
|
||||
sb.WriteString("ORDER MISSING ⚠️ ")
|
||||
if missing == 1 {
|
||||
fmt.Printf(" COULD BE EMPTY SLOT")
|
||||
sb.WriteString(" COULD BE EMPTY SLOT")
|
||||
}
|
||||
}
|
||||
fmt.Printf("\n")
|
||||
sb.WriteString("\n")
|
||||
}
|
||||
fmt.Println("================== END OF GRID ORDERS ===================")
|
||||
|
||||
sb.WriteString("================== END OF GRID ORDERS ===================")
|
||||
|
||||
fmt.Println(sb.String())
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user