fix notification arguments

This commit is contained in:
c9s 2021-05-15 09:59:17 +08:00
parent 236df245a2
commit 638cc40516
2 changed files with 8 additions and 8 deletions

View File

@ -31,27 +31,27 @@ func (n *Notifier) Notify(obj interface{}, args ...interface{}) {
}
func filterPlaintextMessages(args []interface{}) (texts []string, pureArgs []interface{}) {
var textArgsOffset = -1
var firstObjectOffset = -1
for idx, arg := range args {
switch a := arg.(type) {
case types.PlainText:
texts = append(texts, a.PlainText())
if textArgsOffset == -1 {
textArgsOffset = idx
if firstObjectOffset == -1 {
firstObjectOffset = idx
}
case types.Stringer:
texts = append(texts, a.String())
if textArgsOffset == -1 {
textArgsOffset = idx
if firstObjectOffset == -1 {
firstObjectOffset = idx
}
}
}
pureArgs = args
if textArgsOffset > -1 {
pureArgs = args[:textArgsOffset]
if firstObjectOffset > -1 {
pureArgs = args[:firstObjectOffset]
}
return texts, pureArgs

View File

@ -432,7 +432,7 @@ func (s *Strategy) Hedge(ctx context.Context, pos fixedpoint.Value) {
}
s.Notifiability.Notify("Submitting hedge order: %s %s %f", s.Symbol, side, quantity.Float64())
s.Notifiability.Notify("Submitting hedge order: %s %s %f", s.Symbol, side.String(), quantity.Float64())
orderExecutor := &bbgo.ExchangeOrderExecutor{Session: s.sourceSession}
returnOrders, err := orderExecutor.SubmitOrders(ctx, types.SubmitOrder{
Symbol: s.Symbol,