mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-25 16:25:16 +00:00
improve SubmitOrder formating
This commit is contained in:
parent
6002a958d2
commit
13577fc2b4
|
@ -8,3 +8,12 @@ var BNB = accounting.Accounting{Symbol: "BNB ", Precision: 4}
|
|||
|
||||
var FiatCurrencies = []string{"USDC", "USDT", "USD", "TWD", "EUR", "GBP", "BUSD"}
|
||||
|
||||
func IsFiatCurrency(currency string) bool {
|
||||
for _, c := range FiatCurrencies {
|
||||
if c == currency {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
|
|
|
@ -131,10 +131,35 @@ func (o *SubmitOrder) SlackAttachment() slack.Attachment {
|
|||
{Title: "Quantity", Value: o.QuantityString, Short: true},
|
||||
}
|
||||
|
||||
|
||||
if len(o.PriceString) > 0 {
|
||||
fields = append(fields, slack.AttachmentField{Title: "Price", Value: o.PriceString, Short: true})
|
||||
}
|
||||
|
||||
if o.Price > 0 && o.Quantity > 0 && len(o.Market.QuoteCurrency) > 0 {
|
||||
if IsFiatCurrency(o.Market.QuoteCurrency) {
|
||||
fields = append(fields, slack.AttachmentField{
|
||||
Title: "Amount",
|
||||
Value: USD.FormatMoneyFloat64(o.Price * o.Quantity),
|
||||
Short: true,
|
||||
})
|
||||
} else {
|
||||
fields = append(fields, slack.AttachmentField{
|
||||
Title: "Amount",
|
||||
Value: fmt.Sprintf("%f %s", o.Price * o.Quantity, o.Market.QuoteCurrency),
|
||||
Short: true,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if len(o.ClientOrderID) > 0 {
|
||||
fields = append(fields, slack.AttachmentField{Title: "ClientOrderID", Value: o.ClientOrderID, Short: true})
|
||||
}
|
||||
|
||||
if len(o.MarginSideEffect) > 0 {
|
||||
fields = append(fields, slack.AttachmentField{Title: "MarginSideEffect", Value: string(o.MarginSideEffect), Short: true})
|
||||
}
|
||||
|
||||
return slack.Attachment{
|
||||
Color: SideToColorName(o.Side),
|
||||
Title: string(o.Type) + " Order " + string(o.Side),
|
||||
|
|
Loading…
Reference in New Issue
Block a user