types: improve order string format

This commit is contained in:
c9s 2023-09-17 18:03:23 +08:00
parent 5f8a5e47d5
commit 8314a7e750
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -320,9 +320,8 @@ func (o Order) String() string {
orderID = strconv.FormatUint(o.OrderID, 10)
}
desc := fmt.Sprintf("ORDER %s | %s | %s | %s | %s %-4s | %s/%s @ %s",
desc := fmt.Sprintf("ORDER %s | %s | %s | %s %-4s | %s/%s @ %s",
o.Exchange.String(),
o.CreationTime.Time().Local().Format(time.StampMilli),
orderID,
o.Symbol,
o.Type,
@ -335,7 +334,15 @@ func (o Order) String() string {
desc += " Stop @ " + o.StopPrice.String()
}
return desc + " | " + string(o.Status)
desc += " | " + string(o.Status) + " | "
if time.Time(o.UpdateTime).IsZero() {
desc += "0/" + time.Time(o.CreationTime).UTC().Format(time.StampMilli)
} else {
desc += time.Time(o.UpdateTime).UTC().Format(time.StampMilli) + "/" + time.Time(o.CreationTime).UTC().Format(time.StampMilli)
}
return desc
}
// PlainText is used for telegram-styled messages