xnav: rename assets to allAssets

This commit is contained in:
c9s 2022-05-04 15:38:28 +08:00
parent ee621e6d4a
commit 0e417f6f71
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54
7 changed files with 43 additions and 23 deletions

View File

@ -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)),
}
}

View File

@ -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

View File

@ -312,6 +312,8 @@ type Account struct {
balances BalanceMap
}
type FuturesAccountInfo struct {
// Futures fields
Assets FuturesAssetMap `json:"assets"`

View 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
}

View File

@ -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),

View File

@ -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,

View File

@ -0,0 +1,2 @@
package util