mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-25 08:15:15 +00:00
fix trade slack formatting
This commit is contained in:
parent
8f5491d818
commit
c40982164a
|
@ -15,6 +15,7 @@ type AverageCostPnlReport struct {
|
|||
CurrentPrice float64
|
||||
StartTime time.Time
|
||||
Symbol string
|
||||
Market types.Market
|
||||
|
||||
NumTrades int
|
||||
Profit float64
|
||||
|
@ -51,11 +52,6 @@ func (report AverageCostPnlReport) SlackAttachment() slack.Attachment {
|
|||
color = slackstyle.Green
|
||||
}
|
||||
|
||||
market, ok := types.FindMarket(report.Symbol)
|
||||
if !ok {
|
||||
return slack.Attachment{}
|
||||
}
|
||||
|
||||
return slack.Attachment{
|
||||
Title: report.Symbol + " Profit and Loss report",
|
||||
Text: "Profit " + types.USD.FormatMoney(report.Profit),
|
||||
|
@ -65,8 +61,8 @@ func (report AverageCostPnlReport) SlackAttachment() slack.Attachment {
|
|||
Fields: []slack.AttachmentField{
|
||||
{Title: "Profit", Value: types.USD.FormatMoney(report.Profit)},
|
||||
{Title: "Unrealized Profit", Value: types.USD.FormatMoney(report.UnrealizedProfit)},
|
||||
{Title: "Current Price", Value: market.FormatPrice(report.CurrentPrice), Short: true},
|
||||
{Title: "Average Cost", Value: market.FormatPrice(report.AverageBidCost), Short: true},
|
||||
{Title: "Current Price", Value: report.Market.FormatPrice(report.CurrentPrice), Short: true},
|
||||
{Title: "Average Cost", Value: report.Market.FormatPrice(report.AverageBidCost), Short: true},
|
||||
{Title: "Fee (USD)", Value: types.USD.FormatMoney(report.FeeInUSD), Short: true},
|
||||
{Title: "Stock", Value: strconv.FormatFloat(report.Stock, 'f', 8, 64), Short: true},
|
||||
{Title: "Number of Trades", Value: strconv.Itoa(report.NumTrades), Short: true},
|
||||
|
|
|
@ -170,9 +170,9 @@ func convertWebSocketTrade(t max.TradeUpdate) (*types.Trade, error) {
|
|||
return &types.Trade{
|
||||
ID: int64(t.ID),
|
||||
OrderID: t.OrderID,
|
||||
Price: price,
|
||||
Symbol: toGlobalSymbol(t.Market),
|
||||
Exchange: "max",
|
||||
Price: price,
|
||||
Quantity: quantity,
|
||||
Side: side,
|
||||
IsBuyer: side == "bid",
|
||||
|
|
|
@ -37,23 +37,15 @@ func (trade Trade) SlackAttachment() slack.Attachment {
|
|||
color = "#228B22"
|
||||
}
|
||||
|
||||
market, ok := FindMarket(trade.Symbol)
|
||||
if !ok {
|
||||
return slack.Attachment{
|
||||
Text: fmt.Sprintf("*%s* Trade %s", trade.Symbol, trade.Side),
|
||||
Color: color,
|
||||
}
|
||||
}
|
||||
|
||||
return slack.Attachment{
|
||||
Text: fmt.Sprintf("*%s* Trade %s", trade.Symbol, trade.Side),
|
||||
Color: color,
|
||||
// Pretext: "",
|
||||
// Text: "",
|
||||
Fields: []slack.AttachmentField{
|
||||
{Title: "Price", Value: market.FormatPrice(trade.Price), Short: true},
|
||||
{Title: "Volume", Value: market.FormatVolume(trade.Quantity), Short: true},
|
||||
{Title: "Amount", Value: market.FormatPrice(trade.QuoteQuantity)},
|
||||
{Title: "Price", Value: util.FormatFloat(trade.Price, 2), Short: true},
|
||||
{Title: "Volume", Value: util.FormatFloat(trade.Quantity, 4), Short: true},
|
||||
{Title: "Amount", Value: util.FormatFloat(trade.QuoteQuantity, 1)},
|
||||
{Title: "Fee", Value: util.FormatFloat(trade.Fee, 4), Short: true},
|
||||
{Title: "FeeCurrency", Value: trade.FeeCurrency, Short: true},
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue
Block a user