From 7a5a027a629bd532cf4a71a7d7405d813d81961c Mon Sep 17 00:00:00 2001 From: c9s Date: Tue, 26 Sep 2023 16:45:00 +0800 Subject: [PATCH] bbgo: add logging filledOrder option --- pkg/bbgo/config.go | 7 ++++--- pkg/bbgo/session.go | 8 +++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/pkg/bbgo/config.go b/pkg/bbgo/config.go index d5314283a..6abcff37b 100644 --- a/pkg/bbgo/config.go +++ b/pkg/bbgo/config.go @@ -92,9 +92,10 @@ type NotificationConfig struct { } type LoggingConfig struct { - Trade bool `json:"trade,omitempty"` - Order bool `json:"order,omitempty"` - Fields map[string]interface{} `json:"fields,omitempty"` + Trade bool `json:"trade,omitempty"` + Order bool `json:"order,omitempty"` + FilledOrderOnly bool `json:"filledOrder,omitempty"` + Fields map[string]interface{} `json:"fields,omitempty"` } type Session struct { diff --git a/pkg/bbgo/session.go b/pkg/bbgo/session.go index 046534666..dc3bd54fd 100644 --- a/pkg/bbgo/session.go +++ b/pkg/bbgo/session.go @@ -282,7 +282,13 @@ func (session *ExchangeSession) Init(ctx context.Context, environ *Environment) }) } - if environ.loggingConfig.Order { + if environ.loggingConfig.FilledOrderOnly { + session.UserDataStream.OnOrderUpdate(func(order types.Order) { + if order.Status == types.OrderStatusFilled { + logger.Info(order.String()) + } + }) + } else if environ.loggingConfig.Order { session.UserDataStream.OnOrderUpdate(func(order types.Order) { logger.Info(order.String()) })