bbgo: add logging filledOrder option

This commit is contained in:
c9s 2023-09-26 16:45:00 +08:00
parent 9fffa4a47f
commit 7a5a027a62
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54
2 changed files with 11 additions and 4 deletions

View File

@ -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 {

View File

@ -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())
})