mirror of
https://github.com/c9s/bbgo.git
synced 2024-09-20 08:11:08 +00:00
improve message formatting
This commit is contained in:
parent
8eb8a3de72
commit
942eaac659
|
@ -55,7 +55,12 @@ func (p *Position) SlackAttachment() slack.Attachment {
|
|||
}
|
||||
|
||||
func (p *Position) PlainText() string {
|
||||
return p.String()
|
||||
return fmt.Sprintf("Position %s: average cost = %f, base = %f, quote = %f",
|
||||
p.Symbol,
|
||||
p.AverageCost.Float64(),
|
||||
p.Base.Float64(),
|
||||
p.Quote.Float64(),
|
||||
)
|
||||
}
|
||||
|
||||
func (p *Position) String() string {
|
||||
|
|
|
@ -75,7 +75,12 @@ func (r *WithdrawalRequest) String() string {
|
|||
}
|
||||
|
||||
func (r *WithdrawalRequest) PlainText() string {
|
||||
return r.String()
|
||||
return fmt.Sprintf("Withdrawal request: sending %s %s from %s -> %s",
|
||||
util.FormatFloat(r.Amount.Float64(), 4),
|
||||
r.Asset,
|
||||
r.FromSession,
|
||||
r.ToSession,
|
||||
)
|
||||
}
|
||||
|
||||
func (r *WithdrawalRequest) SlackAttachment() slack.Attachment {
|
||||
|
@ -140,7 +145,7 @@ func (s *Strategy) checkBalance(ctx context.Context, sessions map[string]*bbgo.E
|
|||
return
|
||||
}
|
||||
|
||||
s.Notifiability.Notify("Found low level %s balance %s", s.Asset, lowLevelBalance.String())
|
||||
s.Notifiability.Notify("Found low level %s balance from session %s: %s", s.Asset, lowLevelSession.Name, lowLevelBalance.String())
|
||||
|
||||
requiredAmount := s.Middle - lowLevelBalance.Available
|
||||
|
||||
|
@ -273,7 +278,7 @@ func (s *Strategy) LoadState() error {
|
|||
s.state = &state
|
||||
|
||||
log.Infof("%s %s state is restored: %+v", ID, s.Asset, s.state)
|
||||
s.Notifiability.Notify("%s %s state is restored => %f", ID, s.Asset, s.state)
|
||||
s.Notifiability.Notify("%s %s state is restored => ", ID, s.Asset, s.state)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
@ -172,13 +172,15 @@ func (o Order) String() string {
|
|||
return fmt.Sprintf("ORDER %s %s %s %f/%f @ %f -> %s", o.Exchange, o.Symbol, o.Side, o.ExecutedQuantity, o.Quantity, o.Price, o.Status)
|
||||
}
|
||||
|
||||
// PlainText is used for telegram-styled messages
|
||||
func (o Order) PlainText() string {
|
||||
return fmt.Sprintf("%s %s Order %s %s price %s, quantity %s/%s status %s",
|
||||
return fmt.Sprintf("Order %s %s %s %s @ %s %s/%s -> %s",
|
||||
o.Exchange,
|
||||
o.Type,
|
||||
o.Symbol,
|
||||
o.Type,
|
||||
o.Side,
|
||||
util.FormatFloat(o.Price, 2),
|
||||
util.FormatFloat(o.ExecutedQuantity, 2),
|
||||
util.FormatFloat(o.Quantity, 4), o.Status)
|
||||
util.FormatFloat(o.Quantity, 4),
|
||||
o.Status)
|
||||
}
|
||||
|
|
|
@ -81,8 +81,15 @@ func (trade Trade) String() string {
|
|||
util.FormatFloat(trade.QuoteQuantity, 2))
|
||||
}
|
||||
|
||||
// PlainText is used for telegram-styled messages
|
||||
func (trade Trade) PlainText() string {
|
||||
return trade.String()
|
||||
return fmt.Sprintf("Trade %s %s %s %s @ %s, amount %s",
|
||||
trade.Exchange,
|
||||
trade.Symbol,
|
||||
trade.Side,
|
||||
util.FormatFloat(trade.Quantity, 4),
|
||||
util.FormatFloat(trade.Price, 3),
|
||||
util.FormatFloat(trade.QuoteQuantity, 2))
|
||||
}
|
||||
|
||||
var slackTradeTextTemplate = ":handshake: {{ .Symbol }} {{ .Side }} Trade Execution @ {{ .Price }}"
|
||||
|
|
Loading…
Reference in New Issue
Block a user