You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cointop/cointop/marketbar.go

42 lines
962 B
Go

package cointop
import (
"fmt"
"github.com/miguelmota/cointop/pkg/color"
"github.com/miguelmota/cointop/pkg/humanize"
"github.com/miguelmota/cointop/pkg/pad"
)
func (ct *Cointop) updateMarketbar() error {
maxX := ct.Width()
market, err := ct.api.GetGlobalMarketData()
if err != nil {
return err
}
timeframe := "7 Day"
ct.Update(func() {
ct.marketview.Clear()
fmt.Fprintln(
ct.marketview,
color.White(
pad.Right(
fmt.Sprintf(
"%s Chart: %s • Total Market Cap: %s • 24H Volume: %s • BTC Dominance: %.2f%% • Active Currencies: %s • Active Markets: %s",
color.Cyan("cointop"),
timeframe,
humanize.Commaf(market.TotalMarketCapUSD),
humanize.Commaf(market.Total24HVolumeUSD),
market.BitcoinPercentageOfMarketCap,
humanize.Commaf(float64(market.ActiveCurrencies)),
humanize.Commaf(float64(market.ActiveMarkets)),
),
maxX,
" ",
),
),
)
})
return nil
}