types: remove trade trailing zero digits

This commit is contained in:
c9s 2021-12-27 17:36:58 +08:00
parent 8d02f0b03e
commit 5fca633495

View File

@ -4,6 +4,7 @@ import (
"database/sql"
"fmt"
"strconv"
"strings"
"sync"
"time"
@ -90,12 +91,12 @@ func (trade Trade) PositionChange() fixedpoint.Value {
}
func (trade Trade) String() string {
return fmt.Sprintf("TRADE %s %s %4s %f @ %f orderID %d %s amount %f",
return fmt.Sprintf("TRADE %s %s %4s %s @ %s orderID %d %s amount %f",
trade.Exchange.String(),
trade.Symbol,
trade.Side,
trade.Quantity,
trade.Price,
strings.TrimRight(fmt.Sprintf("%f", trade.Quantity), "0"),
strings.TrimRight(fmt.Sprintf("%f", trade.Price), "0"),
trade.OrderID,
trade.Time.Time().Format(time.StampMilli),
trade.QuoteQuantity)
@ -103,12 +104,12 @@ func (trade Trade) String() string {
// PlainText is used for telegram-styled messages
func (trade Trade) PlainText() string {
return fmt.Sprintf("Trade %s %s %s %f @ %f, amount %f, fee %f %s",
return fmt.Sprintf("Trade %s %s %s %s @ %s, amount %f, fee %f %s",
trade.Exchange.String(),
trade.Symbol,
trade.Side,
trade.Quantity,
trade.Price,
strings.TrimRight(fmt.Sprintf("%f", trade.Quantity), "0"),
strings.TrimRight(fmt.Sprintf("%f", trade.Price), "0"),
trade.QuoteQuantity,
trade.Fee,
trade.FeeCurrency)