mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-21 22:43:52 +00:00
bitget: add more debug logs for orderEvent and tradeEvent
This commit is contained in:
parent
92aa7652d5
commit
841229518a
19
pkg/exchange/bitget/debug.go
Normal file
19
pkg/exchange/bitget/debug.go
Normal file
|
@ -0,0 +1,19 @@
|
|||
package bitget
|
||||
|
||||
import "github.com/c9s/bbgo/pkg/util"
|
||||
|
||||
type LogFunction func(msg string, args ...interface{})
|
||||
|
||||
var debugf LogFunction
|
||||
|
||||
func getDebugFunction() LogFunction {
|
||||
if v, ok := util.GetEnvVarBool("DEBUG_BITGET"); ok && v {
|
||||
return log.Infof
|
||||
}
|
||||
|
||||
return func(msg string, args ...interface{}) {}
|
||||
}
|
||||
|
||||
func init() {
|
||||
debugf = getDebugFunction()
|
||||
}
|
|
@ -14,7 +14,6 @@ import (
|
|||
"github.com/c9s/bbgo/pkg/exchange/bitget/bitgetapi"
|
||||
v2 "github.com/c9s/bbgo/pkg/exchange/bitget/bitgetapi/v2"
|
||||
"github.com/c9s/bbgo/pkg/types"
|
||||
"github.com/c9s/bbgo/pkg/util"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -64,22 +63,6 @@ var (
|
|||
kLineRateLimiter = rate.NewLimiter(rate.Every(time.Second/10), 5)
|
||||
)
|
||||
|
||||
type LogFunction func(msg string, args ...interface{})
|
||||
|
||||
var debugf LogFunction
|
||||
|
||||
func getDebugFunction() LogFunction {
|
||||
if v, ok := util.GetEnvVarBool("DEBUG_BITGET"); ok && v {
|
||||
return log.Infof
|
||||
}
|
||||
|
||||
return func(msg string, args ...interface{}) {}
|
||||
}
|
||||
|
||||
func init() {
|
||||
debugf = getDebugFunction()
|
||||
}
|
||||
|
||||
type Exchange struct {
|
||||
key, secret, passphrase string
|
||||
|
||||
|
|
|
@ -424,7 +424,11 @@ func (s *Stream) handleOrderTradeEvent(m OrderTradeEvent) {
|
|||
return
|
||||
}
|
||||
|
||||
debugf("received OrderTradeEvent: %+v", m)
|
||||
|
||||
for _, order := range m.Orders {
|
||||
debugf("received Order: %+v", order)
|
||||
|
||||
globalOrder, err := order.toGlobalOrder()
|
||||
if err != nil {
|
||||
if orderLogLimiter.Allow() {
|
||||
|
@ -437,12 +441,15 @@ func (s *Stream) handleOrderTradeEvent(m OrderTradeEvent) {
|
|||
if m.actionType != ActionTypeSnapshot {
|
||||
continue
|
||||
}
|
||||
|
||||
s.StandardStream.EmitOrderUpdate(globalOrder)
|
||||
|
||||
if order.TradeId == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
debugf("received Trade: %+v", order.Trade)
|
||||
|
||||
switch globalOrder.Status {
|
||||
case types.OrderStatusPartiallyFilled, types.OrderStatusFilled:
|
||||
trade, err := order.toGlobalTrade()
|
||||
|
|
Loading…
Reference in New Issue
Block a user