mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-25 16:25:16 +00:00
xnav: rename assets to allAssets
This commit is contained in:
parent
ee621e6d4a
commit
0e417f6f71
|
@ -7,6 +7,8 @@ import (
|
|||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/slack-go/slack"
|
||||
|
||||
"github.com/c9s/bbgo/pkg/cache"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
|
@ -921,3 +923,16 @@ func (session *ExchangeSession) bindConnectionStatusNotification(stream types.St
|
|||
session.Notifiability.Notify("session %s %s stream connected", session.Name, streamName)
|
||||
})
|
||||
}
|
||||
|
||||
func (session *ExchangeSession) SlackAttachment() slack.Attachment {
|
||||
var fields []slack.AttachmentField
|
||||
var footerIcon = types.ExchangeFooterIcon(session.ExchangeName)
|
||||
return slack.Attachment{
|
||||
// Pretext: "",
|
||||
// Text: text,
|
||||
Title: session.Name,
|
||||
Fields: fields,
|
||||
FooterIcon: footerIcon,
|
||||
Footer: util.Render("update time {{ . }}", time.Now().Format(time.RFC822)),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -113,8 +113,8 @@ func (s *Strategy) recordNetAssetValue(ctx context.Context, sessions map[string]
|
|||
s.Environment.RecordAsset(priceTime, session, assets)
|
||||
}
|
||||
|
||||
assets := totalBalances.Assets(allPrices, priceTime)
|
||||
for currency, asset := range assets {
|
||||
allAssets := totalBalances.Assets(allPrices, priceTime)
|
||||
for currency, asset := range allAssets {
|
||||
// calculated if it's dust only when InUSD (usd value) is defined.
|
||||
if s.IgnoreDusts && !asset.InUSD.IsZero() && asset.InUSD.Compare(Ten) < 0 {
|
||||
continue
|
||||
|
|
|
@ -312,6 +312,8 @@ type Account struct {
|
|||
balances BalanceMap
|
||||
}
|
||||
|
||||
|
||||
|
||||
type FuturesAccountInfo struct {
|
||||
// Futures fields
|
||||
Assets FuturesAssetMap `json:"assets"`
|
||||
|
|
20
pkg/types/exchange_icon.go
Normal file
20
pkg/types/exchange_icon.go
Normal file
|
@ -0,0 +1,20 @@
|
|||
package types
|
||||
|
||||
func ExchangeFooterIcon(exName ExchangeName) string {
|
||||
footerIcon := ""
|
||||
|
||||
switch exName {
|
||||
case ExchangeBinance:
|
||||
footerIcon = "https://bin.bnbstatic.com/static/images/common/favicon.ico"
|
||||
case ExchangeMax:
|
||||
footerIcon = "https://max.maicoin.com/favicon-16x16.png"
|
||||
case ExchangeFTX:
|
||||
footerIcon = "https://ftx.com/favicon.ico?v=2"
|
||||
case ExchangeOKEx:
|
||||
footerIcon = "https://static.okex.com/cdn/assets/imgs/MjAxODg/D91A7323087D31A588E0D2A379DD7747.png"
|
||||
case ExchangeKucoin:
|
||||
footerIcon = "https://assets.staticimg.com/cms/media/7AV75b9jzr9S8H3eNuOuoqj8PwdUjaDQGKGczGqTS.png"
|
||||
}
|
||||
|
||||
return footerIcon
|
||||
}
|
|
@ -300,7 +300,7 @@ func (o Order) SlackAttachment() slack.Attachment {
|
|||
Short: true,
|
||||
})
|
||||
|
||||
footerIcon := exchangeFooterIcon(o.Exchange)
|
||||
footerIcon := ExchangeFooterIcon(o.Exchange)
|
||||
|
||||
return slack.Attachment{
|
||||
Color: SideToColorName(o.Side),
|
||||
|
|
|
@ -151,25 +151,6 @@ func (trade Trade) PlainText() string {
|
|||
|
||||
var slackTradeTextTemplate = ":handshake: Trade {{ .Symbol }} {{ .Side }} {{ .Quantity }} @ {{ .Price }}"
|
||||
|
||||
func exchangeFooterIcon(exName ExchangeName) string {
|
||||
footerIcon := ""
|
||||
|
||||
switch exName {
|
||||
case ExchangeBinance:
|
||||
footerIcon = "https://bin.bnbstatic.com/static/images/common/favicon.ico"
|
||||
case ExchangeMax:
|
||||
footerIcon = "https://max.maicoin.com/favicon-16x16.png"
|
||||
case ExchangeFTX:
|
||||
footerIcon = "https://ftx.com/favicon.ico?v=2"
|
||||
case ExchangeOKEx:
|
||||
footerIcon = "https://static.okex.com/cdn/assets/imgs/MjAxODg/D91A7323087D31A588E0D2A379DD7747.png"
|
||||
case ExchangeKucoin:
|
||||
footerIcon = "https://assets.staticimg.com/cms/media/7AV75b9jzr9S8H3eNuOuoqj8PwdUjaDQGKGczGqTS.png"
|
||||
}
|
||||
|
||||
return footerIcon
|
||||
}
|
||||
|
||||
func (trade Trade) SlackAttachment() slack.Attachment {
|
||||
var color = "#DC143C"
|
||||
|
||||
|
@ -179,7 +160,7 @@ func (trade Trade) SlackAttachment() slack.Attachment {
|
|||
|
||||
liquidity := trade.Liquidity()
|
||||
text := util.Render(slackTradeTextTemplate, trade)
|
||||
footerIcon := exchangeFooterIcon(trade.Exchange)
|
||||
footerIcon := ExchangeFooterIcon(trade.Exchange)
|
||||
|
||||
return slack.Attachment{
|
||||
Text: text,
|
||||
|
|
2
pkg/util/exchange_icon.go
Normal file
2
pkg/util/exchange_icon.go
Normal file
|
@ -0,0 +1,2 @@
|
|||
package util
|
||||
|
Loading…
Reference in New Issue
Block a user